protected void btn_submit_Click1(object sender, EventArgs e) { try { string msg_url = this.txtUrl.Text.Trim(); string msg_passPort = this.txtPassPort.Text.Trim(); string msg_passWord = this.txtPwd.Text.Trim(); string priceStr = BLL.CommonClass.ValidData.InputText(this.txtSMSUnitPrice.Text); msg_url = BLL.CommonClass.ValidData.InputText(msg_url); msg_passWord = BLL.CommonClass.ValidData.InputText(msg_passWord); double dPrice = 0.1; if (msg_url == "") { BLL.CommonClass.Transforms.JSAlert("网关不能为空!"); return; } if (msg_passPort == "") { BLL.CommonClass.Transforms.JSAlert("网关帐号不能为空!"); return; } if (msg_passWord == "") { BLL.CommonClass.Transforms.JSAlert("网关密码不能为空!"); return; } try { dPrice = double.Parse(priceStr); } catch { BLL.CommonClass.Transforms.JSAlert("短信单价格式错误!"); return; } bool flag = new BLL.FileOperateBLL.ForXML().SaveSMSConfig(msg_url, msg_passPort, msg_passWord, 1); bool flag2 = new BLL.MobileSMS().SetSMSUnitPrice(dPrice); if (flag && flag2) {//设置成功 BLL.CommonClass.Transforms.JSAlert("设置成功!"); } else {//设置失败 BLL.CommonClass.Transforms.JSAlert("设置失败!"); } } catch (Exception ex) { BLL.CommonClass.Transforms.JSAlert("设置出错:" + ex.Message); } }
protected void Button2_Click(object sender, EventArgs e) { int TrueCount = 0; string info = ""; for (int i = 0; i < this.GridView1.Rows.Count; i++) { if ((this.GridView1.Rows[i].FindControl("CheckBox1") as CheckBox).Checked) { string ss = ((HiddenField)GridView1.Rows[i].FindControl("HiddenField1")).Value; using (SqlConnection con = new SqlConnection(DAL.DBHelper.connString)) { con.Open(); SqlTransaction tran = con.BeginTransaction(); try { BLL.MobileSMS sms = new BLL.MobileSMS(); DataTable dt = sms.GetSMS(tran, ss); BLL.MobileSMS.SendMsgTo(tran, dt.Rows[0]["CustomerID"].ToString(), dt.Rows[0]["CustomerID"].ToString(), dt.Rows[0]["mobile"].ToString(), dt.Rows[0]["sendMsg"].ToString(), out info, (Model.SMSCategory)Convert.ToInt32(dt.Rows[0]["Category"].ToString())); sms.DelSMS(tran, ss); if (info.IndexOf("发送成功") != -1) { TrueCount++; } tran.Commit(); } catch { tran.Rollback(); } finally { con.Close(); } } } } ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + GetTran("007902", "共成功发送") + TrueCount + GetTran("006978", "条") + "!')", true); }
protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < this.GridView1.Rows.Count; i++) { if ((this.GridView1.Rows[i].FindControl("CheckBox1") as CheckBox).Checked) { string ss = ((HiddenField)GridView1.Rows[i].FindControl("HiddenField1")).Value; using (SqlConnection con = new SqlConnection(DAL.DBHelper.connString)) { con.Open(); SqlTransaction tran = con.BeginTransaction(); try { BLL.MobileSMS sms = new BLL.MobileSMS(); BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("h_mobileMsg", "ltrim(rtrim(str(id)))"); cl.AddRecordtran(tran, ss); sms.DelSMS(tran, ss); cl.AddRecordtran(tran, ss); cl.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company65, Session["Company"].ToString(), BLL.CommonClass.ENUM_USERTYPE.objecttype10); tran.Commit(); } catch { tran.Rollback(); } finally { con.Close(); } } } } btnSearch_Click(null, null); }
/// <summary> /// [带事务,7参数]发送短信并记录历史记录 /// </summary> /// <param name="tran"></param> /// <param name="recipientNo">接收人在系统中的编号[可为空]</param> /// <param name="primaryKey">关联主键[可为空]</param> /// <param name="mobile">接收人手机号码</param> /// <param name="msg">发送内容</param> /// <param name="info">返回信息[out参数]</param> /// <param name="category">短信类型</param> /// <returns></returns> public static bool SendMsgTo(SqlTransaction tran, string recipientNo, string primaryKey, string mobile, string msg, out string info, Model.SMSCategory category) { info = ""; bool flag = false; bool flag2 = false; string mRtv = ""; if (mobile != "") { if (msg.Length <= 256) { MobileSMS sm = new MobileSMS(); string tempMsg = msg; string temp = ""; ArrayList msgAr = new ArrayList(); while (tempMsg.Length > 65) { temp = tempMsg.Substring(0, 65).Trim(); //前65个字符 tempMsg = tempMsg.Substring(65); //65以后的字符 msgAr.Add(temp); } if (tempMsg.Length > 0) { msgAr.Add(tempMsg); } int maxID = int.Parse(DAL.DBHelper.ExecuteScalar(tran, "select isnull(max(id),0) from h_mobilemsg", new SqlParameter[0], CommandType.Text).ToString()); string SendNo = maxID.ToString().PadLeft(8, '0'); int SendSmallNo = 1; //分条序号 foreach (string str in msgAr) { //短信分条发送 flag = sm.SendMobile(tran, new string[] { mobile }, str, out mRtv); string smallNo = SendSmallNo.ToString() + "/" + msgAr.Count.ToString(); flag2 = sm.SaveSendMsgRecord(tran, recipientNo, primaryKey, mobile, flag, mRtv, str, SendNo, smallNo, (int)category); if (flag && flag2) { SendSmallNo++; } else { break; } } } else { info = BLL.Translation.Translate("007140", "短信内容过长"); return(false); } } if (flag && flag2) { info = BLL.Translation.Translate("005615", "发送成功!"); return(true); } else { if (!flag) { info = BLL.Translation.Translate("007141", "短信发送失败,返回信息:") + mRtv.Replace("'", ""); } if (!flag2) { info = BLL.Translation.Translate("007142", "短信发送记录失败,请与管理员联系!"); } return(false); } }
/// <summary> /// 默认数据绑定 /// </summary> private void DefaultBind() { string Ystr = GetTran("000233", "是"); string Nstr = GetTran("000235", "否"); DataTable dt = new BLL.MobileSMS().GetDefaultConfig(); //注册通知 DataRow[] dr = dt.Select("configCode=1"); string TempOpenFlag = string.Empty; if (dr.Length > 0) { this.txtDefaultSMSReg.Text = dr[0]["DefaultContent"].ToString(); this.lblRegContent.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblIsOpenReg.Text = Ystr; } else { this.lblIsOpenReg.Text = Nstr; } foreach (ListItem li in rbtnReg.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } //发货通知 dr = dt.Select("configCode=2"); if (dr.Length > 0) { this.txtDefaultSmsSend.Text = dr[0]["DefaultContent"].ToString(); this.lblSendContent.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblIsOpenSend.Text = Ystr; } else { this.lblIsOpenSend.Text = Nstr; } foreach (ListItem li in rbtnSend.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } //汇款审核通知 dr = dt.Select("configCode=3"); if (dr.Length > 0) { this.txtDefaultSmsRemittance.Text = dr[0]["DefaultContent"].ToString(); this.lblRemitContent.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblIsOpenRemit.Text = Ystr; } else { this.lblIsOpenRemit.Text = Nstr; } foreach (ListItem li in rbtnRemittance.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } //应收帐款通知 dr = dt.Select("configCode=4"); if (dr.Length > 0) { this.txtDefaultSMSReceivables.Text = dr[0]["DefaultContent"].ToString(); this.lblRevContent.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblIsOpenRev.Text = Ystr; } else { this.lblIsOpenRev.Text = Nstr; } foreach (ListItem li in this.rbtnReceivables.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } //会员找回密码 dr = dt.Select("configCode=8"); if (dr.Length > 0) { this.txtDefaultSMSFind.Text = dr[0]["DefaultContent"].ToString(); this.lblMemberFind.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblMemberOpen.Text = Ystr; } else { this.lblMemberOpen.Text = Nstr; } foreach (ListItem li in this.rbtLoginPassFind.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } //店铺找回密码 dr = dt.Select("configCode=9"); if (dr.Length > 0) { this.txtStorePassFind.Text = dr[0]["DefaultContent"].ToString(); this.lblStoreFind.Text = dr[0]["DefaultContent"].ToString(); TempOpenFlag = "0"; TempOpenFlag = dr[0]["IsOpen"].ToString(); if (TempOpenFlag == "1") { this.lblStoreOpen.Text = Ystr; } else { this.lblStoreOpen.Text = Nstr; } foreach (ListItem li in this.rbtStorePassFind.Items) { if (li.Value.Trim() == TempOpenFlag) { li.Selected = true; } } } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { string id = e.CommandArgument.ToString(); if (e.CommandName == "Del") { using (SqlConnection con = new SqlConnection(DAL.DBHelper.connString)) { con.Open(); SqlTransaction tran = con.BeginTransaction(); try { BLL.MobileSMS sms = new BLL.MobileSMS(); BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("h_mobileMsg", "ltrim(rtrim(str(id)))"); cl.AddRecordtran(tran, id); sms.DelSMS(tran, id); cl.AddRecordtran(tran, id.ToString()); cl.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company65, Session["Company"].ToString(), BLL.CommonClass.ENUM_USERTYPE.objecttype10); tran.Commit(); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + BLL.Translation.Translate("000008", "删除成功") + "')", true); btnSearch_Click(null, null); } catch { tran.Rollback(); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + BLL.Translation.Translate("000009", "删除失败") + "')", true); } finally { con.Close(); } } } if (e.CommandName == "AgainSend") { string info = ""; string[] AllValue = e.CommandArgument.ToString().Split(','); string CommName = e.CommandArgument.ToString(); using (SqlConnection con = new SqlConnection(DAL.DBHelper.connString)) { con.Open(); SqlTransaction tran = con.BeginTransaction(); try { BLL.MobileSMS sms = new BLL.MobileSMS(); BLL.MobileSMS.SendMsgTo(tran, AllValue[2], AllValue[2], AllValue[1], AllValue[3], out info, (Model.SMSCategory)Convert.ToInt32(AllValue[4])); sms.DelSMS(tran, AllValue[0]); tran.Commit(); //BLL.MobileSMS.SendMsgTo(tran, bianhao, bianhao, mobile, msg, out info, Model.SMSCategory.sms_ManualSent); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + info + "');", true); btnSearch_Click(null, null); } catch { tran.Rollback(); ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + info + "');", true); } finally { con.Close(); } } } }