ClientLink.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:5k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  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. using System.Data.SqlClient;
  12. public partial class Module_Employee_Relation_ClientLink : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (Session["UserName"] != null)
  17.         {
  18.             if (Session["Popedom"].ToString() == "0")
  19.             {
  20.                 this.lnkbtnAdd.Visible = true;
  21.             }
  22.         }
  23.         else
  24.         {
  25.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  26.         }
  27.         SqlData da = new SqlData();
  28.         string cmdtxt1 = "select * from tb_ClientLink";
  29.         this.GridView1.DataSource = da.ExceDS(cmdtxt1, "tb_ClientLink");
  30.         this.GridView1.DataKeyNames = new string[] { "ID" };
  31.         this.GridView1.DataBind();
  32.         if (!IsPostBack)
  33.         {
  34.             string cmdtxt2 = "select Distinct Name from tb_User";
  35.             SqlDataReader dr = da.ExceDr(cmdtxt2);
  36.             while (dr.Read())
  37.             {
  38.                 this.dropName.Items.Add(dr["Name"].ToString());
  39.             }
  40.             dr.Close();
  41.         }  
  42.     }
  43.     protected void btnFind_Click(object sender, EventArgs e)
  44.     {
  45.         if (this.txtKeyWord.Text == "")
  46.         {
  47.             Response.Write("<script language=javascript>alert('关键字不能为空!');location='ClientLink.aspx'</script>");
  48.             return;
  49.         }
  50.         SqlData da = new SqlData();
  51.         string search = this.dropClass.SelectedValue;
  52.         switch (search)
  53.         {
  54.             case "客户ID":
  55.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  56.                 break;
  57.             case "客户名称":
  58.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ClientName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  59.                 break;
  60.             case "客户类型":
  61.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ClientClass  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  62.                 break;
  63.             default:
  64.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  65.                 break;
  66.         }
  67.     }
  68.     protected void lnkbtnAdd_Click1(object sender, EventArgs e)
  69.     {
  70.         this.Panel1.Visible = false;
  71.         this.Panel2.Visible = true;
  72.     }
  73.     protected void btnOK_Click(object sender, EventArgs e)
  74.     {
  75.         SqlData da = new SqlData();
  76.         string cmdtxt = "INSERT INTO tb_ClientLink(ClientName,ClientClass,ClientProperty,ClientPhone,Email,Country,Province,City,PostCode,WriteInMan,Fax,WriteInTime,ClientRelation)";
  77.         cmdtxt += "VALUES('"+this.txtName.Text+"','"+this.dropClass1.SelectedValue+"','"+this.dropProperty.SelectedValue+"','"+this.txtClientPhone.Text+"'";
  78.         cmdtxt += ",'"+this.txtEmail.Text+"','"+this.txtCounty.Text+"','"+this.txtProvince.Text+"','"+this.txtCity.Text+"','"+this.txtPostCode.Text+"'";
  79.         cmdtxt += ",'"+this.dropName.SelectedValue+"','"+this.txtFax.Text+"','"+DateTime.Now+"','"+this.dropRelation.SelectedValue+"')";
  80.         if (da.ExceSQL(cmdtxt))
  81.         {
  82.             Response.Write("<script language=javascript>alert('操作成功!');location='ClientLink.aspx'</script>");
  83.             CommonClass.WriteNote(this.txtName.Text, 0, Session["UserName"].ToString());
  84.         }
  85.         else
  86.         {
  87.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  88.         }
  89.     }
  90.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  91.     {
  92.         this.GridView1.PageIndex = e.NewPageIndex;
  93.         SqlData da = new SqlData();
  94.         string search = this.dropClass.SelectedValue;
  95.         switch (search)
  96.         {
  97.             case "客户ID":
  98.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  99.                 break;
  100.             case "客户名称":
  101.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ClientName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  102.                 break;
  103.             case "客户类型":
  104.                 da.BindData(this.GridView1, "Select * From tb_ClientLink Where ClientClass  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ClientLink");
  105.                 break;
  106.             default:
  107.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  108.                 break;
  109.         }
  110.     }
  111.     protected void btnBack_Click(object sender, EventArgs e)
  112.     {
  113.         Response.Write("<script>this.parent.rightFrame.location='ClientLink.aspx'</script>");
  114.     }
  115. }