110,896
社区成员
发帖
与我相关
我的任务
分享
private void timer1_Tick(object sender, EventArgs e)
{
Random rand = new Random();
int i = rand.Next(1, 10);
foreach(DataRow row in DataSet_Distri_Status.Tables[0].Rows)
{
Update_Distri_List(row, i);
DBGrid_Distri_Status.Update();
}
}
private void Update_Distri_List(DataRow row, int count)
{
string updatecommand = "UPDATE m_Customer SET '當前MAC' = '?', '已分派數量' = '?', '可用數量' = '?' WHERE '起始地址' = '?' AND '結束地址' = '?' AND '客戶名稱' = '?'";
OleDbCommand update = new OleDbCommand(updatecommand, MyConnect_DataBase);
update.Parameters.Add("當前MAC",OleDbType.Char);
update.Parameters.Add("已分派數量",OleDbType.Char);
update.Parameters.Add("可用數量",OleDbType.Char);
update.Parameters.Add("起始地址",OleDbType.Char);
update.Parameters.Add("結束地址",OleDbType.Char);
update.Parameters.Add("客戶名稱",OleDbType.Char);
update.Parameters["客戶名稱"].Value = row["客戶名稱"].ToString();
update.Parameters["起始地址"].Value = row["起始地址"].ToString();
update.Parameters["結束地址"].Value = row["結束地址"].ToString();
update.Parameters["當前MAC"].Value = (Convert.ToInt64(row["當前MAC"].ToString().Trim(),16) + count).ToString("X12");
update.Parameters["已分派數量"].Value = (Convert.ToInt64(row["已分派數量"].ToString().Trim(), 10) + count).ToString();
update.Parameters["可用數量"].Value = (Convert.ToInt64(row["可用數量"].ToString().Trim(), 10) - count).ToString();
Adapter_Distri_Status.Update(DataSet_Distri_Status);
}