void BindDgv(string commandtext)//重新根据传入的SQL语句绑定数据 { GoldenLadyWS.Service service = new GoldenLadyWS.Service(); string keywords = txtKey.Text.Trim(); commandtext += " and (customername like '%" + keywords + "%' or smsphone like '%" + keywords + "%' or smscontent like '%" + keywords + "%' or name like '%" + keywords + "%' or employeeno like '%" + keywords + "%' or customerno like '" + keywords + "')"; //dtStart = dtpStart.Value.ToString("yyyy-MM-dd") + " 00:00:00"; //dtEnd = dtpEnd.Value.ToString("yyyy-MM-dd")+" 23:59:59"; dtStart = dtpStart.Value.Date.ToString(); dtEnd = dtpStart.Value.Date.ToString(); if (ckbAllTime.Checked) { sqlByTime = ""; } else { //sqlByTime = " and CAST(smstime as datetime) between '" + dtStart + "' and '" + dtEnd + "'"; sqlByTime = " and datediff(dd,SmsTime,'" + dtStart + "')<=0 and datediff(dd,SmsTime,'" + dtEnd + "')>=0"; } commandtext += sqlByTime; if (ckbAllTime.Checked)//所有时间段 { DataSet ds = service.GetDataSet(commandtext); dgvSearchResult.DataSource = ds.Tables[0]; } else { string test = commandtext + sqlByTime; DataSet ds = service.GetDataSet(commandtext); dgvSearchResult.DataSource = ds.Tables[0]; } }
void Delete(int id) { GoldenLadyWS.Service service = new GoldenLadyWS.Service(); if (ckbNotSent.Checked) { if (service.ExecuteCommandText(sqlUpdateStatus + 0 + " where smsid=" + id) > 0) //更改状态为取消发送 { if (service.ExecuteCommandText(sqlDeletePlatform + id) <= 0) //删除未发送的短信 { MessageBox.Show("删除失败!"); return; } } else { MessageBox.Show("更新状态失败!"); return; } } else { if (service.ExecuteCommandText(sqlDeleteOld + id) <= 0)//删除短信历史记录 { MessageBox.Show("删除失败!"); return; } } }
private void frmSendSms_Load(object sender, EventArgs e) { GoldenLadyWS.Service service = new GoldenLadyWS.Service(); string sql = "select sa.id as id,name,content1 as content from SMSUsefulExpressions su,SMSAi sa where su.id=sa.id"; DataSet ds = service.GetDataSet(sql); if (ds != null) { cmbAi.ValueMember = "content"; cmbAi.DisplayMember = "name"; cmbAi.DataSource = ds.Tables[0]; cmbAi.SelectedIndex = -1; foreach (DataRow i in ds.Tables[0].Rows) { listAiID.Add(Convert.ToInt32(i["id"].ToString())); } } }
void StartSend() { try { string[] phones = txtPhone.Text.Split(','); //验证短信内容不能为空 GoldenLadyWS.Service service = new GoldenLadyWS.Service(); ClientSide.Sms.GetApp(Application.StartupPath); string result = ""; string sql = ""; int sendsucceed = 0; int sendfailed = 0; int savesucceed = 0; int savefailed = 0; dlgChangeSendState myDlg = new dlgChangeSendState(ChangeSendState); if (!ckbTiming.Checked) { try { for (int i = 0; i < phones.Length; i++) { if (phones[i].Trim() == "") //add by wujianbo 20110808,如果手机号为空则不发送 { continue; } string tempContent = txtSendContent.Text; if (sendType == 1) { tempContent = txtSendContent.Text.Replace("[姓名]", customername[i]); } result = ClientSide.Sms.app.fSendSMS(tempContent, phones[i], "5", Information.CurrentUser.EmployeeNO, "无"); //update by wujianbo 20120728 if (result == "发送成功") { if (sendType == 1) { sql = "insert into SMSOld (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('" + customername[i] + "','" + customerno[i] + "','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text.Replace("[姓名]", customername[i]) + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',5,1,0) "; } else { sql = "insert into SMSOld (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('无','无','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',5,1,0) "; } if (service.ExecuteCommandText(sql) <= 0) { sendsucceed++; savefailed++; } else { sendsucceed++; savesucceed++; } } else { if (sendType == 1) { sql = "insert into SMSOld (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('" + customername[i] + "','" + customerno[i] + "','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text.Replace("[姓名]", customername[i]) + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',5,2,0)"; } else { sql = "insert into SMSOld (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('无','无','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',5,2,0)"; } if (service.ExecuteCommandText(sql) > 0) { sendfailed++; savesucceed++; } else { sendfailed++; savefailed++; } } this.Invoke(myDlg, phones.Length, i + 1); } } catch (Exception ex) { MessageBox.Show(ex.Message, @"出错啦!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { for (int i = 0; i < phones.Length; i++) { string sqlTiming = "insert into SMSPlatform (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('无','无','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text + "','" + dtpYMD.Value.ToString("yyyy-MM-dd") + " " + dtpHMS.Text + "',5,3," + listAiID[cmbAi.SelectedIndex] + ")"; if (sendType == 1) { sqlTiming = "insert into SMSPlatform (customername,customerno,employeeno,smsphone,smscontent,smstime,smspriority,smsstatus,smsaistatus) " + "values ('" + customername[i] + "','" + customerno[i] + "','" + Information.CurrentUser.EmployeeNO + "','" + phones[i] + "','" + txtSendContent.Text.Replace("[姓名]", customername[i]) + "','" + dtpYMD.Value.ToString("yyyy-MM-dd") + " " + dtpHMS.Text + "',5,3," + listAiID[cmbAi.SelectedIndex] + ")"; } if (service.ExecuteCommandText(sqlTiming) > 0) { sendsucceed++; savesucceed++; } else { sendfailed++; savefailed++; } this.Invoke(myDlg, phones.Length, i + 1); } } if (MessageBox.Show( @"发送任务执行完毕!发送成功" + sendsucceed + @"条,失败" + sendfailed + @"条;保存记录成功" + savesucceed + @"条,失败" + savefailed + @"条!", @"提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.OK) { txtPhone.Clear(); txtSendContent.Clear(); sendsucceed = 0; sendfailed = 0; savesucceed = 0; savefailed = 0; #region 操作日志 qiuqianquan 20120518 string DepartmentNO = Information.CurrentUser.EmployeeDepartmentNO; string CreateEmployee = Information.CurrentUser.EmployeeNO; string CreateDate = DateTime.Now.ToString(); ErpWs.InsertOrderLogoZON("", "O7_011", DepartmentNO, CreateEmployee, CreateDate, "0", "操作日志", "发送短信:" + txtPhone.Text.ToString()); #endregion this.Close(); } else { this.Close(); } //foreach (Control cnt in this.Controls) //{ // cnt.Name = "ucLoading"; // cnt.Dispose(); // break; //} } catch { return; } }