protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { txtBeginDate.Text = DateTime.Now.AddDays(-7).Date.ToString("yyyy-MM-dd"); txtEndDate.Text = DateTime.Now.Date.ToString("yyyy-MM-dd"); //程序模块权限验证 Authorization clsRighter = new Authorization("0504"); if (clsRighter.Read) { //创建操作员记录数据表类实例 SMSOperate clsRecord = new SMSOperate(); //获取记录数据 //DataTable dt1 = clsRecord.ShowName(); //DataRow df = dt1.NewRow(); //df["DirNum"] = "---请选择---"; //dt1.Rows.InsertAt(df, 0); //ddlDirNum.DataSource = dt1; //ddlDirNum.DataTextField = "DirNum"; //ddlDirNum.DataValueField = "DirNum"; //ddlDirNum.DataBind(); BindDataGrid(); } else { Common.ShowMsg("权限不足!"); } } }
protected void btnSend_Click(object sender, EventArgs e) { string strCardId = ""; string strCardLast = ""; string strNowDate = DateTime.Now.Date.ToString("yyyy-MM-dd"); string strNowTime = DateTime.Now.Date.ToString("hh:MM:ss"); string strMemName = ""; string strMoney = ""; string levelid = this.ddlLevelID.Items.Count > 0 ? ddlLevelID.SelectedItem.Value : ""; string strContent = this.txtContent.Text; if (strContent == "") { Common.ShowMsg("发送内容不能为空!"); return; } string strSql = @"select a.MemName,a.Mobile,b.Account,c.LevelName,b.Pwd,b.cardid from Mem a,Mem_Card b,Mem_Card_Level c where a.CardId = b.CardId and b.CardLevel = c.LevelId and c.LevelId = '" + levelid + "'"; DataTable dt = new DataTable(); DBManager db = DBManager.Instance(); dt = db.GetDataTable(strSql); string strTel = ""; for (int i = 0; i < dt.Rows.Count; i++) { strTel = dt.Rows[i]["mobile"].ToString().Trim(); if (strTel.Length != 11) { continue; } else { strCardId = dt.Rows[i]["cardid"].ToString(); strMemName = dt.Rows[i]["MemName"].ToString(); strMoney = dt.Rows[i]["account"].ToString(); strCardLast = strCardId.Substring(strCardId.Length - 4); string strTemp = strContent; strTemp.Replace("#CardID#", strCardId); strTemp.Replace("#LCardID#", strCardLast); strTemp.Replace("#Date#", strNowDate); strTemp.Replace("#Time#", strNowTime); strTemp.Replace("##Name#", strMemName); strTemp.Replace("#Money#", strMoney); sms.Send(strTel, strContent); SMSOperate.SaveRecord(strTel, strContent); } } Common.ShowMsg("短信发送操作已完成!"); //RecordOperate.SaveRecord(Session["UserID"].ToString(), "短信平台", "使用系统数据发送短信;用户组ID:" + groupid + ";发送内容:" + strContent); //RecordOperate.SaveRecord(Session["UserID"].ToString(), "短信平台", "使用系统数据发送短信;会员级别:" + levelid + ";"); }
private void DataGridBind() { SMSOperateDB smsdb; SMSOperate sms = new SMSOperate(); smsdb = sms.ShowMsg(Request.QueryString["MsgId"]); this.txtNum.Text = smsdb.DirNum.ToString(); this.txtMsg.Text = smsdb.Msg; this.txtTime.Text = smsdb.SendTime.ToString(); }
protected void MyDataGrid_ItemCommand(object source, DataGridCommandEventArgs e) { SMSOperateDB smsdb; SMSOperate sms = new SMSOperate(); smsdb = sms.ShowMsg(((Label)e.Item.Cells[1].Controls[1]).Text); string num = smsdb.DirNum; string msg = smsdb.Msg; string sendtime = smsdb.SendTime.ToString(); Common.ShowMsgs(num, msg, sendtime); }
/// <summary> /// 绑定数据到DataGrid控件MyDataGrid上 /// </summary> private void BindDataGrid() { //创建操作员记录数据表类实例 SMSOperate clsRecord = new SMSOperate(); //获取记录数据 DataTable dt = clsRecord.Bind(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToString()); DataView dv = new DataView(); dt.TableName = "SMS_Log"; if (dt != null) { dv.Table = dt; dv.Sort = " sendtime DESC"; if (ViewState["Condition"] != null && ViewState["Condition"].ToString() != "") { dv.RowFilter = ViewState["Condition"].ToString(); } else { dv = dt.DefaultView; } //新增ID自增值列绑定 dt.Columns.Add(new DataColumn("idno", Type.GetType("System.Int32"))); int intCountRecNum = dv.Count; //获取数据表记录数 for (int i = 0; i < intCountRecNum; i++) { dv[i]["idno"] = i + 1; } MyDataGrid.DataSource = dv; int PageCount = 0; if (intCountRecNum % MyDataGrid.PageSize == 0) { PageCount = intCountRecNum / MyDataGrid.PageSize; } else { PageCount = intCountRecNum / MyDataGrid.PageSize + 1; } if (PageCount != 0 && MyDataGrid.CurrentPageIndex >= PageCount) { MyDataGrid.CurrentPageIndex = PageCount - 1; } MyDataGrid.DataBind(); lblRecNum.Text = intCountRecNum.ToString(); //显示总记录数 ShowStats(); //显示页数信息 } }
protected void btnSend_Click(object sender, EventArgs e) { string strNumTemp = this.txtNumber.Text.Trim(); string strContent = this.txtContent.Text; string[] strNums = strNumTemp.Split(';'); string strCardId = ""; string strCardLast = ""; string strNowDate = DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss"); string strNowTime = DateTime.Now.Date.ToString("hh:MM:ss"); string strMemName = ""; string strMoney = ""; if (strContent.Contains("#")) { DBManager db = DBManager.Instance(); DataTable dt = db.GetDataTable(@"select a.mobile, a.MemName,a.cardid,b.account from mem a,mem_card b where a.CardId = b.CardId "); foreach (string num in strNums) { if (num.Length != 11) { continue; } DataRow[] dr = dt.Select("mobile ='" + num + "'"); if (dr.Length > 0) { strCardId = dr[0]["cardid"].ToString(); strMemName = dr[0]["MemName"].ToString(); strMoney = dr[0]["account"].ToString(); strCardLast = strCardId.Substring(strCardId.Length - 4); string strTemp = strContent; strTemp.Replace("#CardID#", strCardId); strTemp.Replace("#LCardID#", strCardLast); strTemp.Replace("#Date#", strNowDate); strTemp.Replace("#Time#", strNowTime); strTemp.Replace("##Name#", strMemName); strTemp.Replace("#Money#", strMoney); res = sms.Send(num, strTemp); SMSOperate.SaveRecord(num, strTemp); } } } else { foreach (string num in strNums) { if (num.Length != 11) { continue; } res = sms.Send(num, strContent); SMSOperate.SaveRecord(num, strContent); } } //res = sms.Send(strNumTemp, strContent); Common.ShowMsg("短信发送操作已完成!"); //RecordOperate.SaveRecord(Session["UserID"].ToString(), "短信平台", "使用系统数据发送短信;对象号码:" + strNumTemp + ";发送内容:" + strContent); //RecordOperate.SaveRecord(Session["UserID"].ToString(), "短信平台", "使用系统数据发送短信;对象号码:" + strNumTemp + ";"); //SMSOperate.SaveRecord(strNumTemp,strContent); }