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 CRM_MyCustom : 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("|C001A|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton5.Visible = ZWL.Common.PublicMethod.StrIFIn("|C001M|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton3.Visible = ZWL.Common.PublicMethod.StrIFIn("|C001D|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); ImageButton2.Visible = ZWL.Common.PublicMethod.StrIFIn("|C001E|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian")); } } public string GetTimeCondition() { string ConditionStr = ""; DateTime MyDate, MyDateSec; if (DateTime.TryParse(this.TextBox2.Text.Trim(), out MyDate) == true) { ConditionStr = ConditionStr + " and TimeStr>='" + this.TextBox2.Text.Trim() + " 00:00:00' "; } if (DateTime.TryParse(this.TextBox3.Text.Trim(), out MyDateSec) == true) { ConditionStr = ConditionStr + " and TimeStr<='" + this.TextBox3.Text.Trim() + " 23:59:59' "; } return ConditionStr; } public void DataBindToGridview() { ZWL.BLL.ERPCustomInfo MyModel = new ZWL.BLL.ERPCustomInfo(); GVData.DataSource = MyModel.GetList(" " + this.DropDownList1.SelectedItem.Value.ToString() + " Like '%" + this.TextBox1.Text + "%' " + GetTimeCondition()+ " and UserName='" + 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("CustomAdd.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 ERPCustomInfo 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("CustomName", "客户名称"); MyTable.Add("CustomSerils", "客户编号"); MyTable.Add("Address", "单位地址"); MyTable.Add("UrlLink", "客户单位网站"); MyTable.Add("FaRenDaiMa", "法人"); MyTable.Add("ChargeMan", "负责人"); MyTable.Add("TelStr", "联系电话"); MyTable.Add("XingZhi", "客户性质"); MyTable.Add("LaiYuan", "客户来源"); MyTable.Add("QuYu", "所在区域"); MyTable.Add("ZhuangTai", "客户状态"); MyTable.Add("LeiBie", "客户类别"); MyTable.Add("JiBie", "客户级别"); MyTable.Add("HangYe", "客户行业"); MyTable.Add("TimeStr", "创建时间"); ZWL.Common.DataToExcel.GridViewToExcel(ZWL.DBUtility.DbHelperSQL.GetDataSet("select CustomName,CustomSerils,Address,UrlLink,FaRenDaiMa,ChargeMan,TelStr,XingZhi,LaiYuan,QuYu,ZhuangTai,LeiBie,JiBie,HangYe,TimeStr from ERPCustomInfo where ID in (" + IDList + ") order by ID desc"), MyTable, "Excel报表"); } protected void ImageButton5_Click(object sender, ImageClickEventArgs e) { string CheckStr = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible"); string[] CheckStrArray = CheckStr.Split(','); Response.Redirect("CustomModify.aspx?ID=" + CheckStrArray[0].ToString()); } }