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; } } }
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; } }