SendNote.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_SendNote : 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.         if (!IsPostBack)
  29.         {
  30.             string cmdtxt1 = "select * from tb_SendMan";
  31.             this.GridView1.DataSource = da.ExceDS(cmdtxt1, "tb_SendMan");
  32.             this.GridView1.DataKeyNames = new string[] { "ID" };
  33.             this.GridView1.DataBind();
  34.             string cmdtxt2 = "select Distinct Name from tb_User";
  35.             SqlDataReader dr = da.ExceDr(cmdtxt2);
  36.             while (dr.Read())
  37.             {
  38.                 this.dropDepEmployee.Items.Add(dr["Name"].ToString());
  39.             }
  40.             dr.Close();
  41.             string cmdtxt3 = "select Distinct DepName from tb_Department";
  42.             SqlCommand Com = new SqlCommand(cmdtxt3, da.ExceCon());
  43.             SqlDataReader dr1 = Com.ExecuteReader();
  44.             while (dr1.Read())
  45.             {
  46.                 this.dropDepAbout.Items.Add(dr1["DepName"].ToString());
  47.             }
  48.             dr.Close();
  49.         }  
  50.     }
  51.     protected void btnFind_Click(object sender, EventArgs e)
  52.     {
  53.         if (this.txtKeyWord.Text == "")
  54.         {
  55.             Response.Write("<script language=javascript>alert('关键字不能为空!');location='SendNote.aspx'</script>");
  56.             return;
  57.         }
  58.         SqlData da = new SqlData();
  59.         string search = this.dropClass.SelectedValue;
  60.         switch (search)
  61.         {
  62.             case "记录ID":
  63.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  64.                 break;
  65.             case "客户名称":
  66.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ClientName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  67.                 break;
  68.             case "服务员工":
  69.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ServicePerson  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  70.                 break;
  71.             default:
  72.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  73.                 break;
  74.         }
  75.     }
  76.     protected void lnkbtnAdd_Click1(object sender, EventArgs e)
  77.     {
  78.         this.Panel1.Visible = false;
  79.         this.Panel2.Visible = true;
  80.     }
  81.     protected void btnOK_Click(object sender, EventArgs e)
  82.     {
  83.         SqlData da = new SqlData();
  84.         string cmdtxt = "INSERT INTO tb_SendMan(ClientName,ClientAddress,ServicePerson,PlanTime,StartTime,EndTime,PhoneAbout";
  85.         cmdtxt += ",PostCode,ClientEmail,NoticeContent,DepName) VALUES('"+this.txtClientName.Text+"','"+this.txtClientAddress.Text+"'";
  86.         cmdtxt += ",'" + this.dropDepEmployee.SelectedValue + "','" + this.txtPlanTime.Text +"天','"+this.txtStartTime.Text+"'";
  87.         cmdtxt += ",'"+this.txtEndTime.Text+"','"+this.txtPhoneAbout.Text+"','"+this.txtPostCode.Text+"','"+this.txtClientEmail.Text+"'";
  88.         cmdtxt += ",'"+this.txtComContent.Text+"','"+this.dropDepAbout.SelectedValue+"')";
  89.         if (da.ExceSQL(cmdtxt))
  90.         {
  91.             Response.Write("<script language=javascript>alert('操作成功!');location='SendNote.aspx'</script>");
  92.             CommonClass.WriteNote(this.txtClientName.Text, 0, Session["UserName"].ToString());
  93.         }
  94.         else
  95.         {
  96.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  97.         }
  98.     }
  99.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  100.     {
  101.         this.GridView1.PageIndex = e.NewPageIndex;
  102.         SqlData da = new SqlData();
  103.         string search = this.dropClass.SelectedValue;
  104.         switch (search)
  105.         {
  106.             case "记录ID":
  107.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  108.                 break;
  109.             case "客户名称":
  110.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ClientName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  111.                 break;
  112.             case "服务员工":
  113.                 da.BindData(this.GridView1, "Select * From tb_SendMan Where ServicePerson  Like  '%" + this.txtKeyWord.Text + "%'", "tb_SendMan");
  114.                 break;
  115.             default:
  116.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  117.                 break;
  118.         }
  119.     }
  120.     protected void btnBack_Click(object sender, EventArgs e)
  121.     {
  122.         Response.Write("<script>this.parent.rightFrame.location='SendNote.aspx'</script>");
  123.     }
  124. }