CRMManager.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:5k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class CRMManager : System.Web.UI.Page
  12. {
  13. /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.     Model.CRM MR = new Model.CRM();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     BLL.CRM BR = new BLL.CRM();
  21.     /// <summary>
  22.     /// 查询条件
  23.     /// </summary>
  24.     public string TiaoJian
  25.     {
  26.         get
  27.         {
  28.             if (ViewState["CRMTiaoJian"] == null)
  29.             {
  30.                 return "";
  31.             }
  32.             else
  33.             {
  34.                 return ViewState["CRMTiaoJian"].ToString();
  35.             }
  36.         }
  37.         set { ViewState["CRMTiaoJian"] = value; }
  38.     }
  39.     protected void Page_Load(object sender, EventArgs e)
  40.     {
  41.         LoginLogic.MatchLoad("../", "CRMManager");
  42.         if (!IsPostBack)
  43.         {
  44.             TiaoJian = "KFID='"+SessionInclude.SessionId+"'";
  45.             if (Request.QueryString["TiaoJian"] != null)
  46.             {
  47.                 TiaoJian = Server.UrlDecode(Request.QueryString["TiaoJian"].ToString());
  48.             }
  49.             MyDataBind(1);
  50.         }
  51.       
  52.     }
  53.     /// <summary>
  54.     /// 获取信息
  55.     /// </summary>
  56.     /// <param name="pidx">页号</param>
  57.     public void MyDataBind(int pidx)
  58.     {
  59.         AspNetPager1.RecordCount = BR.GetCount(TiaoJian);
  60.         List<Model.CRM> LRData = BR.GetPageList(20, pidx, "ID", false, TiaoJian);
  61.         if (LRData.Count == 0)
  62.         {
  63.             Model.CRM MR = new Model.CRM();
  64.    
  65.             LRData.Add(MR);
  66.         }
  67.         GridView1.DataSource = LRData;
  68.         GridView1.DataBind();
  69.     }
  70.  
  71.     
  72.     /// <summary>
  73.     /// 操作
  74.     /// </summary>
  75.     /// <returns></returns>
  76.     public string CaoZuo()
  77.     {
  78.         string Id = Eval("Id").ToString();
  79.         //编辑 清空密码 删除
  80.         string Rtstr = "<a href='CRMAdd.aspx'>添加客户</a>&nbsp;&nbsp;";
  81.         if (BR.GetCount(TiaoJian) > 0)
  82.         {
  83.             Rtstr += "<a href='CRMEdit.aspx?id=" + Id + "'>修改客户信息</a>&nbsp;&nbsp;";
  84.         }
  85.         
  86.         return Rtstr;
  87.     }
  88.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  89.     {
  90.         MyDataBind(e.NewPageIndex);
  91.     }
  92.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  93.     {
  94.         for (int i = 0; i < GridView1.Rows.Count; i++)
  95.         {
  96.             //首先判断是否是数据行
  97.             if (e.Row.RowType == DataControlRowType.DataRow)
  98.             {
  99.                 //当鼠标停留时更改背景色
  100.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  101.                 //当鼠标移开时还原背景色
  102.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  103.             }
  104.         }
  105.     }
  106.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  107.     {
  108.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  109.         {
  110.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  111.             if (CheckBox1.Checked)
  112.             {
  113.                 cbox.Checked = true;
  114.             }
  115.             else
  116.             {
  117.                 cbox.Checked = false;
  118.             }
  119.         }
  120.     }
  121.     protected void DelButton1_Click(object sender, EventArgs e)
  122.     {
  123.         try
  124.         {
  125.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  126.             {
  127.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  128.                 if (cbox.Checked)
  129.                 {
  130.                     // Response.Write(GridView1.Rows[i].Cells[1].Text.ToString() + ":True");
  131.                     int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
  132.                     if (Id == 0)
  133.                     {
  134.                         throw new Exception("该记录不能删除!");
  135.                     }
  136.                     BR.Delete(Id);
  137.                 }
  138.                 else
  139.                 {
  140.                     //  Response.Write((GridView1.Rows[i].Cells[1]).Text.ToString() + ":False");
  141.                 }
  142.             }
  143.             MessageBox.Show("删除完成!");
  144.         }
  145.         catch (Exception exp)
  146.         { MessageBox.Show(exp.Message); }
  147.         MyDataBind(AspNetPager1.CurrentPageIndex);
  148.     }
  149. }