private void LoadData() { MessageUserClass dao = new MessageUserClass(); DataTable dt = dao.Search("").Tables[0]; dgvMessageUser.AutoGenerateColumns = false; dgvMessageUser.DataSource = dt; }
private void Time_Day_Tick(object sender, EventArgs e) { if (tag_Day != DateTime.Now.ToString("yyyyMMdd")) { tag_Day = DateTime.Now.ToString("yyyyMMdd"); } else { return; } if (!WeekTest()) { return; } EmergFileClass dao_emerg_day = new EmergFileClass(); MessageUserClass dao_user = new MessageUserClass(); MessageUserEntity ety_user = new MessageUserEntity(); DataTable dt = dao_emerg_day.SearchAllGetDept().Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { ety_user.Deptname = dt.Rows[0][0].ToString(); DataTable dt_user = dao_user.Search(ety_user, null).Tables[0]; if (dt_user.Rows.Count > 0) { string[] username = dt_user.Rows[0]["UserName"].ToString().Split(','); string[] phonenum = dt_user.Rows[0]["PhoneNum"].ToString().Split(','); if (username.Length > 1) { int index = dgvSendSms.Rows.Add(); dgvSendSms.Rows[index].Cells[0].Value = dt.Rows[0]["DeptName"].ToString(); dgvSendSms.Rows[index].Cells[1].Value = username[1]; dgvSendSms.Rows[index].Cells[2].Value = phonenum[1]; dgvSendSms.Rows[index].Cells[3].Value = "你有文件待取!"; dgvSendSms.Rows[index].Cells[5].Value = "未发送"; dgvSendSms.Rows[index].Cells[6].Value = "每日文件提醒"; } else { int index = dgvSendSms.Rows.Add(); dgvSendSms.Rows[index].Cells[0].Value = dt.Rows[0]["DeptName"].ToString(); dgvSendSms.Rows[index].Cells[1].Value = username[0]; dgvSendSms.Rows[index].Cells[2].Value = phonenum[0]; dgvSendSms.Rows[index].Cells[3].Value = "你有文件待取!"; dgvSendSms.Rows[index].Cells[5].Value = "未发送"; dgvSendSms.Rows[index].Cells[6].Value = "每日文件提醒"; } } } }
public void CreateNewRow(string boxname, int recount, string fileid, string fileboxid) { if (dgvSendSms.InvokeRequired) { SetDgvCallback setdgvCallbak = new SetDgvCallback(CreateNewRow); dgvSendSms.Invoke(setdgvCallbak, boxname, recount, fileid, fileboxid); } else { txtMessage.Text = boxname; MessageUserClass dao = new MessageUserClass(); MessageUserEntity ety = new MessageUserEntity(); ety.Deptname = boxname; DataTable dt = dao.Search(ety, null).Tables[0]; if (dt.Rows.Count > 0) { string[] username = dt.Rows[0]["UserName"].ToString().Split(','); string[] phonenum = dt.Rows[0]["PhoneNum"].ToString().Split(','); if (recount > 0) { //重复发送 for (int i = 0; i < username.Length; i++) { int index = dgvSendSms.Rows.Add(); dgvSendSms.Rows[index].Cells[0].Value = dt.Rows[0]["DeptName"].ToString(); dgvSendSms.Rows[index].Cells[1].Value = username[i]; dgvSendSms.Rows[index].Cells[2].Value = phonenum[i]; dgvSendSms.Rows[index].Cells[3].Value = GlobalFunction.ConfigueGet("ProgrameSet.xml", "appSettings", "defMessage"); dgvSendSms.Rows[index].Cells[5].Value = "未发送"; dgvSendSms.Rows[index].Cells[6].Value = "已重复发送" + recount + "次"; } } else { //首次发送 if (username.Length > 1) { int index = dgvSendSms.Rows.Add(); dgvSendSms.Rows[index].Cells[0].Value = dt.Rows[0]["DeptName"].ToString(); dgvSendSms.Rows[index].Cells[1].Value = username[1]; dgvSendSms.Rows[index].Cells[2].Value = phonenum[1]; dgvSendSms.Rows[index].Cells[3].Value = GlobalFunction.ConfigueGet("ProgrameSet.xml", "appSettings", "defMessage"); dgvSendSms.Rows[index].Cells[5].Value = "未发送"; } else { int index = dgvSendSms.Rows.Add(); dgvSendSms.Rows[index].Cells[0].Value = dt.Rows[0]["DeptName"].ToString(); dgvSendSms.Rows[index].Cells[1].Value = username[0]; dgvSendSms.Rows[index].Cells[2].Value = phonenum[0]; dgvSendSms.Rows[index].Cells[3].Value = GlobalFunction.ConfigueGet("ProgrameSet.xml", "appSettings", "defMessage"); dgvSendSms.Rows[index].Cells[5].Value = "未发送"; } EmergFileEntity ety_emerg = new EmergFileEntity(); EmergFileClass dao_emerg = new EmergFileClass(); ety_emerg.FileBoxId = fileboxid; ety_emerg.Fileid = fileid; ety_emerg.State = "1"; DataTable dt_emerg = dao_emerg.Search(ety_emerg, null).Tables[0]; if (dt_emerg.Rows.Count < 1) { ety_emerg.Recount = "1"; dao_emerg.Insert(ety_emerg, null); } } } } }