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

OA系统

开发平台:

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. public partial class Entertain_EntertainAdd : System.Web.UI.Page
  12. {
  13.     //模板
  14.     Model.Receives MR = new Model.Receives();
  15.     //业务
  16.     BLL.Receives BR = new BLL.Receives();
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         LoginLogic.MatchLoad("../", "Entertain_EntertainAdd");
  20.         if (!IsPostBack)
  21.         {
  22.             DropLoadSet();
  23.         }
  24.     }
  25.     /// <summary>
  26.     /// 绑定接待类别
  27.     /// </summary>
  28.     public void DropLoadSet()
  29.     {
  30.         //接待类别
  31.         KeyValue_JDLB.DataTextField = "Text";
  32.         KeyValue_JDLB.DataValueField = "Value";
  33.         KeyValue_JDLB.DataSource = EnumGet.JieDaiGetEnum();
  34.         KeyValue_JDLB.DataBind();
  35.         ListItem linone = new ListItem();
  36.         linone.Text = "--请选择--";
  37.         linone.Value = "0";
  38.         KeyValue_JDLB.Items.Add(linone);
  39.         KeyValue_JDLB.SelectedIndex = KeyValue_JDLB.Items.Count - 1;
  40.     }
  41.     public void DropLoadSet(string i)
  42.     {
  43.         string name = EnumGet.GetJieDaiName(i);
  44.         switch (name)
  45.         { 
  46.             case "用餐":
  47.                 KeyValue_XXLB.Enabled = true;
  48.                 KeyValue_XXLB.DataTextField = "YCLBMC";
  49.                 KeyValue_XXLB.DataValueField = "ID";
  50.                 KeyValue_XXLB.DataSource = EnumGet.YongCanGetEnum();
  51.                 KeyValue_XXLB.DataBind();
  52.                 ListItem linone = new ListItem();
  53.                 linone.Text = "--请选择--";
  54.                 linone.Value = "0";
  55.                 KeyValue_XXLB.Items.Add(linone);
  56.                 KeyValue_XXLB.SelectedIndex = KeyValue_XXLB.Items.Count - 1;
  57.                 break;
  58.             case "住宿":
  59.                 KeyValue_XXLB.Enabled = true;
  60.                 KeyValue_XXLB.DataTextField = "ZSLBM";
  61.                 KeyValue_XXLB.DataValueField = "ID";
  62.                 KeyValue_XXLB.DataSource = EnumGet.ZhuSuGetEnum();
  63.                 KeyValue_XXLB.DataBind();
  64.                 ListItem linone2 = new ListItem();
  65.                 linone2.Text = "--请选择--";
  66.                 linone2.Value = "0";
  67.                 KeyValue_XXLB.Items.Add(linone2);
  68.                 KeyValue_XXLB.SelectedIndex = KeyValue_XXLB.Items.Count - 1;
  69.                 break;
  70.             default:
  71.                 KeyValue_XXLB.Items.Clear();
  72.                 KeyValue_XXLB.Enabled = false;
  73.                 break;
  74.         }
  75.     }
  76.     protected void KeyValue_JDLB_SelectedIndexChanged(object sender, EventArgs e)
  77.     {
  78.         string i = KeyValue_JDLB.SelectedValue;
  79.         DropLoadSet(i);
  80.     }
  81.     protected void Button1_Click(object sender, EventArgs e)
  82.     {
  83.         try
  84.         {
  85.             if (KeyValue_JDLB.SelectedValue == "0")
  86.             {
  87.                 throw new Exception("请选择接待类别!");
  88.             }
  89.             else
  90.             {
  91.                 if (KeyValue_XXLB.Items.Count > 1 && KeyValue_XXLB.SelectedValue == "0")
  92.                 {
  93.                     throw new Exception("请选择详细类别!");
  94.                 }
  95.             }
  96.             if (String.IsNullOrEmpty(KeyValue_BJDZXM.Text.Trim()))
  97.             {
  98.                 throw new Exception("被接待者姓名不能为空!");
  99.             }
  100.             if (String.IsNullOrEmpty(KeyValue_FSRQ.Text))
  101.             {
  102.                 throw new Exception("发生时间不能为空!");
  103.             }
  104.             MR.JDLB = KeyValue_JDLB.SelectedValue;
  105.             if (KeyValue_XXLB.Enabled == false)
  106.             {
  107.                 MR.XXLB = KeyValue_JDLB.SelectedValue;
  108.             }
  109.             else
  110.             {
  111.                 MR.XXLB = KeyValue_XXLB.SelectedValue;
  112.             }
  113.             MR.BJDZXM = KeyValue_BJDZXM.Text;
  114.             MR.FSRQ = Convert.ToDateTime(KeyValue_FSRQ.Text);
  115.             MR.BZ = KeyValue_BZ.Text;
  116.             BR.Add(MR);
  117.             MessageBox.Show("添加成功!");
  118.             DropLoadSet();
  119.             string i = KeyValue_JDLB.SelectedValue;
  120.             DropLoadSet(i);
  121.             KeyValue_BJDZXM.Text = "";
  122.             KeyValue_FSRQ.Text = "";
  123.             KeyValue_BZ.Text = "";
  124.         }
  125.         catch (Exception exp)
  126.         {
  127.             MessageBox.Show(exp.Message);
  128.         }
  129.     }
  130. }