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