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

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_ChanceItem : 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_ChanceItem";
  29.         this.GridView1.DataSource = da.ExceDS(cmdtxt1, "tb_ChanceItem");
  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.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='ChanceItem.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_ChanceItem Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  64.                 break;
  65.             case "项目名称":
  66.                 da.BindData(this.GridView1, "Select * From tb_ChanceItem Where ItemName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  67.                 break;
  68.             case "订单编号":
  69.                 da.BindData(this.GridView1, "Select * From tb_ChanceItem Where OrderCode  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  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 GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  82.     {
  83.         this.GridView1.PageIndex = e.NewPageIndex;
  84.         SqlData da = new SqlData();
  85.         string search = this.dropClass.SelectedValue;
  86.         switch (search)
  87.         {
  88.             case "项目ID":
  89.                 da.BindData(this.GridView1, "Select * From tb_ChanceItem Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  90.                 break;
  91.             case "项目名称":
  92.                 da.BindData(this.GridView1, "Select * From tb_ChanceItem Where ItemName  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  93.                 break;
  94.             case "项目编号":
  95.                 da.BindData(this.GridView1, "Select * From tb_ChanceItem Where OrderCode  Like  '%" + this.txtKeyWord.Text + "%'", "tb_ChanceItem");
  96.                 break;
  97.             default:
  98.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  99.                 break;
  100.         }
  101.     }
  102.     protected void btnOK_Click(object sender, EventArgs e)
  103.     {
  104.         SqlData da = new SqlData();
  105.         string cmdtxt1 = "SELECT * FROM tb_ChanceItem WHERE OrderCode='"+this.txtOrderCode.Text+"'";
  106.         SqlCommand Com = new SqlCommand(cmdtxt1, da.ExceCon());
  107.         SqlDataReader dr = Com.ExecuteReader();
  108.         dr.Read();
  109.         if (dr.HasRows)
  110.         {
  111.             Response.Write("<script language=javascript>alert('该产品编号已经使用,请选择其他编号!')</script>");
  112.             return;
  113.         }
  114.         string cmdtxt = "INSERT INTO tb_ChanceItem(ItemName,ClientName,ItemPrincipal,OrderCode,ItemMoney";
  115.         cmdtxt += ",StartTime,EndTime,PhoneAbout,ClientAddress,PostCode,ClientEmail,CommunionContent,DepName)";
  116.         cmdtxt += " VALUES('"+this.txtItemName.Text+"','"+this.txtClientName.Text+"','"+this.dropDepEmployee.SelectedValue+"'";
  117.         cmdtxt += ",'"+this.txtOrderCode.Text+"','"+this.txtItemMoney.Text+"','"+this.txtStartTime.Text+"','"+this.txtEndTime.Text+"'";
  118.         cmdtxt += ",'"+this.txtPhoneAbout.Text+"','"+this.txtClientAddress.Text+"','"+this.txtPostCode.Text+"'";
  119.         cmdtxt += ",'"+this.txtClientEmail.Text+"','"+this.txtComContent.Text+"','"+this.dropDepAbout.SelectedValue+"')";
  120.         if (da.ExceSQL(cmdtxt))
  121.         {
  122.             Response.Write("<script language=javascript>alert('操作成功!');location='ChanceItem.aspx'</script>");
  123.             CommonClass.WriteNote(this.txtItemName.Text, 0, Session["UserName"].ToString());
  124.         }
  125.         else
  126.         {
  127.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  128.         }
  129.     }
  130.     protected void btnBack_Click(object sender, EventArgs e)
  131.     {
  132.         Response.Write("<script>this.parent.rightFrame.location='ChanceItem.aspx'</script>");
  133.     }
  134. }