using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Mobile_MobileSms : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ZWL.Common.PublicMethod.CheckSession(); DataBindToGridview(); //设定按钮权限 ImageButton1.Visible = ZWL.Common.PublicMethod.StrIFIn("|097A|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton5.Visible = ZWL.Common.PublicMethod.StrIFIn("|097M|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton3.Visible = ZWL.Common.PublicMethod.StrIFIn("|097D|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton2.Visible = ZWL.Common.PublicMethod.StrIFIn("|097E|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); } } public void DataBindToGridview() { ZWL.BLL.ERPMobile MyLanEmail = new ZWL.BLL.ERPMobile(); GVData.DataSource = MyLanEmail.GetList("ContentStr like '%" + this.TextBox1.Text.Trim() + "%' and FaSongUser='" + ZWL.Common.PublicMethod.GetSessionValue("UserName") + "' order by ID desc"); GVData.DataBind(); LabPageSum.Text = Convert.ToString(GVData.PageCount); LabCurrentPage.Text = Convert.ToString(((int)GVData.PageIndex + 1)); this.GoPage.Text = LabCurrentPage.Text.ToString(); } #region 分页方法 protected void ButtonGo_Click(object sender, ImageClickEventArgs e) { try { if (GoPage.Text.Trim().ToString() == "") { Response.Write(""); } else if (GoPage.Text.Trim().ToString() == "0" || Convert.ToInt32(GoPage.Text.Trim().ToString()) > GVData.PageCount) { Response.Write(""); } else if (GoPage.Text.Trim() != "") { int PageI = Int32.Parse(GoPage.Text.Trim()) - 1; if (PageI >= 0 && PageI < (GVData.PageCount)) { GVData.PageIndex = PageI; } } if (TxtPageSize.Text.Trim().ToString() == "") { Response.Write(""); } else if (TxtPageSize.Text.Trim().ToString() == "0") { Response.Write(""); } else if (TxtPageSize.Text.Trim() != "") { try { int MyPageSize = int.Parse(TxtPageSize.Text.ToString().Trim()); this.GVData.PageSize = MyPageSize; } catch { Response.Write(""); } } DataBindToGridview(); } catch { DataBindToGridview(); Response.Write(""); } } protected void PagerButtonClick(object sender, ImageClickEventArgs e) { //获得Button的参数值 string arg = ((ImageButton)sender).CommandName.ToString(); switch (arg) { case ("Next"): if (this.GVData.PageIndex < (GVData.PageCount - 1)) GVData.PageIndex++; break; case ("Pre"): if (GVData.PageIndex > 0) GVData.PageIndex--; break; case ("Last"): try { GVData.PageIndex = (GVData.PageCount - 1); } catch { GVData.PageIndex = 0; } break; default: //本页值 GVData.PageIndex = 0; break; } DataBindToGridview(); } #endregion protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e) { ZWL.Common.PublicMethod.GridViewRowDataBound(e); } protected void ImageButton4_Click(object sender, ImageClickEventArgs e) { DataBindToGridview(); } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Response.Redirect("MobileSmsAdd.aspx"); } protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible"); if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("delete from ERPMobile where ID in (" + IDlist + ")") == -1) { Response.Write(""); } else { DataBindToGridview(); //写系统日志 ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi(); MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName"); MyRiZhi.DoSomething = "用户删除手机短信中的已发送信息"; MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString(); MyRiZhi.Add(); } } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { string IDList = "0"; for (int i = 0; i < GVData.Rows.Count; i++) { Label LabVis = (Label)GVData.Rows[i].FindControl("LabVisible"); IDList = IDList + "," + LabVis.Text.ToString(); } Hashtable MyTable = new Hashtable(); MyTable.Add("FaSongUser", "发送人"); MyTable.Add("ToUserList", "接收人"); MyTable.Add("TimeStr", "发送时间"); MyTable.Add("ContentStr", "信息内容"); ZWL.Common.DataToExcel.GridViewToExcel(ZWL.DBUtility.DbHelperSQL.GetDataSet("select FaSongUser,ToUserList,TimeStr,ContentStr from ERPMobile where ID in (" + IDList + ") order by ID desc"), MyTable, "Excel报表"); } protected void ImageButton5_Click(object sender, ImageClickEventArgs e) { string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible"); string[] IDArray = IDlist.Split(','); for (int jk = 0; jk < IDArray.Length; jk++) { if (IDArray[jk].Trim().Length > 0 && IDArray[jk].Trim() != "0") { ZWL.BLL.ERPMobile MyModel = new ZWL.BLL.ERPMobile(); MyModel.GetModel(int.Parse(IDArray[jk].Trim())); if (ZWL.Common.PublicMethod.StrIFIn("内部人员:", MyModel.ToUserList) == true) { //内部 //Mobile.SendSMS(MyModel.FaSongUser, MyModel.ToUserList.Replace("内部人员:", ""), MyModel.ContentStr); string WrongUser = Mobile.UserToTel(MyModel.ToUserList.Replace("内部人员:", ""), MyModel.ContentStr); } else { //外部 //Mobile.SendSMS2(MyModel.FaSongUser, MyModel.ToUserList.Replace("外部人员:", ""), MyModel.ContentStr); string WrongUser = Mobile.send(MyModel.ToUserList.Replace("外部人员:", ""), MyModel.ContentStr); //发送人和发送内容 } } } DataBindToGridview(); //写系统日志 ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi(); MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName"); MyRiZhi.DoSomething = "用户发送已发送手机短信中的信息"; MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString(); MyRiZhi.Add(); Response.Write(""); } }