這是 利用 Excel 欄位 來做顏色區別,同時也可以提醒自己 是否到期
主要是利用 下次送校日 與 本日 做判斷 來計算出 日期
#這是完成後的效果
#完整的設定 如下圖 請參考
當然,如果使用 VBA 是比較簡潔,且變化性更好,只是VBA 對於某些人
比較難理解 及 靈活的運用。
2010年12月14日 星期二
2010年12月10日 星期五
[C#] UNC 網路芳鄰連接 含帳號密碼
using IWshRuntimeLibrary; //在COM 元件內
private WshNetwork _networkShell = new WshNetwork();
private void MapDrive(string driveLetter, string UNC, bool isPersistent, string userName, string password)
{
if (driveLetter != "")
{
DisconnectDrive(driveLetter, true, true);
}
else
{
DisconnectDrive(UNC, true, true);
}
object persistent = isPersistent;
object user = userName;
object pwd = password;
_networkShell.MapNetworkDrive(driveLetter, UNC, ref persistent, ref user, ref pwd);
}
private void DisconnectDrive(string UNC_or_DriveName, bool willForce, bool isPersistent)
{
try
{
object force = willForce;
object updateProfile = isPersistent;
_networkShell.RemoveNetworkDrive(UNC_or_DriveName, ref force, ref updateProfile);
}
catch
{
//
}
}
//使用方式 Mount
private void MAP_DRIVER_Y()
{
string sour_path = @"file://123.456.789.123/qq";
MapDrive("Y:", sour_path, false, "user_id", "password");
}
// Umount
private void DIS_MAP_DRIVER_Y()
{
DisconnectDrive("Y:", true, true);
}
不想使用 命令模式 ,這是另一個選擇
private WshNetwork _networkShell = new WshNetwork();
private void MapDrive(string driveLetter, string UNC, bool isPersistent, string userName, string password)
{
if (driveLetter != "")
{
DisconnectDrive(driveLetter, true, true);
}
else
{
DisconnectDrive(UNC, true, true);
}
object persistent = isPersistent;
object user = userName;
object pwd = password;
_networkShell.MapNetworkDrive(driveLetter, UNC, ref persistent, ref user, ref pwd);
}
private void DisconnectDrive(string UNC_or_DriveName, bool willForce, bool isPersistent)
{
try
{
object force = willForce;
object updateProfile = isPersistent;
_networkShell.RemoveNetworkDrive(UNC_or_DriveName, ref force, ref updateProfile);
}
catch
{
//
}
}
//使用方式 Mount
private void MAP_DRIVER_Y()
{
string sour_path = @"file://123.456.789.123/qq";
MapDrive("Y:", sour_path, false, "user_id", "password");
}
// Umount
private void DIS_MAP_DRIVER_Y()
{
DisconnectDrive("Y:", true, true);
}
不想使用 命令模式 ,這是另一個選擇
標籤:
C#
2010年10月7日 星期四
[Firefox] 除了擋廣告,還可以擋網址
之前一直為了 廣告網頁煩惱,這次找到好東西了。
可以直接把 Site 網址 直接擋掉。
先看一下套件 Adblock Plus 是主套件 ,一定要安裝
再來就是這次推薦的 Adblock Plus Pop-up Addon
裝完了之後,進入 Ablock plus pop-up addon 的選項裡面。
將 Always show context menu item 打勾。
使用方法很簡單,只要針對要檔的網頁 按滑鼠右鍵
選擇 Block This Window ,下次這個網址就不會被開啟。
可以直接把 Site 網址 直接擋掉。
先看一下套件 Adblock Plus 是主套件 ,一定要安裝
再來就是這次推薦的 Adblock Plus Pop-up Addon
裝完了之後,進入 Ablock plus pop-up addon 的選項裡面。
將 Always show context menu item 打勾。
使用方法很簡單,只要針對要檔的網頁 按滑鼠右鍵
選擇 Block This Window ,下次這個網址就不會被開啟。
標籤:
Firefox
2010年10月6日 星期三
[WCF] 解決 DataTable 的使用
一般來說,在 WCF 裡面 只能操作 DataSet 而不能 操作 DataTable 。
竟然只要指定 DataTable Name 就可以使用 DataTable 了。
真是太好了。
竟然只要指定 DataTable Name 就可以使用 DataTable 了。
真是太好了。
標籤:
WCF
2010年9月29日 星期三
[C#] 監控USB插拔
// 常數宣告
//USB
public const int WM_DEVICECHANGE = 0x219;
public const int DBT_DEVICEARRIVAL = 0x8000;
public const int DBT_CONFIGCHANGECANCELED = 0x0019;
public const int DBT_CONFIGCHANGED = 0x0018;
public const int DBT_CUSTOMEVENT = 0x8006;
public const int DBT_DEVICEQUERYREMOVE = 0x8001;
public const int DBT_DEVICEQUERYREMOVEFAILED = 0x8002;
public const int DBT_DEVICEREMOVECOMPLETE = 0x8004;
public const int DBT_DEVICEREMOVEPENDING = 0x8003;
public const int DBT_DEVICETYPESPECIFIC = 0x8005;
public const int DBT_DEVNODES_CHANGED = 0x0007;
public const int DBT_QUERYCHANGECONFIG = 0x0017;
public const int DBT_USERDEFINED = 0xFFFF;
//雙擊滑鼠左鍵
public const int WM_MOUSE_DOUBLE_CHICK = 0x0203;
//USB 監控
protected override void WndProc(ref System.Windows.Forms.Message m)
{
try
{
if (m.Msg == WM_DEVICECHANGE)
{
switch (m.WParam.ToInt32())
{
case WM_DEVICECHANGE:
break;
case DBT_DEVICEARRIVAL://USB IN
DriveInfo[] s = DriveInfo.GetDrives();
foreach (DriveInfo drive in s)
{
if (drive.DriveType == DriveType.Removable)
{
MessageBox.Show("U盤已插入,盤符為:" + drive.Name.ToString());
break;
}
}
break;
case DBT_CONFIGCHANGECANCELED:
break;
case DBT_CONFIGCHANGED:
break;
case DBT_CUSTOMEVENT:
break;
case DBT_DEVICEQUERYREMOVE:
break;
case DBT_DEVICEQUERYREMOVEFAILED:
break;
case DBT_DEVICEREMOVECOMPLETE: //USB OUT
MessageBox.Show("You Flash ....Bye");
break;
case DBT_DEVICEREMOVEPENDING:
break;
case DBT_DEVICETYPESPECIFIC:
break;
case DBT_DEVNODES_CHANGED:
break;
case DBT_QUERYCHANGECONFIG:
break;
case DBT_USERDEFINED:
break;
default:
break;
}
}
//Mouse
if (m.Msg == WM_MOUSE_DOUBLE_CHICK)
{
MessageBox.Show("別在雙擊滑鼠左鍵了!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
base.WndProc(ref m);
}
標籤:
C#
訂閱:
文章 (Atom)




