- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class Entertain_EntertainAdd : System.Web.UI.Page
- {
- //模板
- Model.Receives MR = new Model.Receives();
- //业务
- BLL.Receives BR = new BLL.Receives();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "Entertain_EntertainAdd");
- if (!IsPostBack)
- {
- DropLoadSet();
- }
- }
- /// <summary>
- /// 绑定接待类别
- /// </summary>
- public void DropLoadSet()
- {
- //接待类别
- KeyValue_JDLB.DataTextField = "Text";
- KeyValue_JDLB.DataValueField = "Value";
- KeyValue_JDLB.DataSource = EnumGet.JieDaiGetEnum();
- KeyValue_JDLB.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "--请选择--";
- linone.Value = "0";
- KeyValue_JDLB.Items.Add(linone);
- KeyValue_JDLB.SelectedIndex = KeyValue_JDLB.Items.Count - 1;
- }
- public void DropLoadSet(string i)
- {
- string name = EnumGet.GetJieDaiName(i);
- switch (name)
- {
- case "用餐":
- KeyValue_XXLB.Enabled = true;
- KeyValue_XXLB.DataTextField = "YCLBMC";
- KeyValue_XXLB.DataValueField = "ID";
- KeyValue_XXLB.DataSource = EnumGet.YongCanGetEnum();
- KeyValue_XXLB.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "--请选择--";
- linone.Value = "0";
- KeyValue_XXLB.Items.Add(linone);
- KeyValue_XXLB.SelectedIndex = KeyValue_XXLB.Items.Count - 1;
- break;
- case "住宿":
- KeyValue_XXLB.Enabled = true;
- KeyValue_XXLB.DataTextField = "ZSLBM";
- KeyValue_XXLB.DataValueField = "ID";
- KeyValue_XXLB.DataSource = EnumGet.ZhuSuGetEnum();
- KeyValue_XXLB.DataBind();
- ListItem linone2 = new ListItem();
- linone2.Text = "--请选择--";
- linone2.Value = "0";
- KeyValue_XXLB.Items.Add(linone2);
- KeyValue_XXLB.SelectedIndex = KeyValue_XXLB.Items.Count - 1;
- break;
- default:
- KeyValue_XXLB.Items.Clear();
- KeyValue_XXLB.Enabled = false;
- break;
- }
- }
- protected void KeyValue_JDLB_SelectedIndexChanged(object sender, EventArgs e)
- {
- string i = KeyValue_JDLB.SelectedValue;
- DropLoadSet(i);
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (KeyValue_JDLB.SelectedValue == "0")
- {
- throw new Exception("请选择接待类别!");
- }
- else
- {
- if (KeyValue_XXLB.Items.Count > 1 && KeyValue_XXLB.SelectedValue == "0")
- {
- throw new Exception("请选择详细类别!");
- }
- }
- if (String.IsNullOrEmpty(KeyValue_BJDZXM.Text.Trim()))
- {
- throw new Exception("被接待者姓名不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_FSRQ.Text))
- {
- throw new Exception("发生时间不能为空!");
- }
- MR.JDLB = KeyValue_JDLB.SelectedValue;
- if (KeyValue_XXLB.Enabled == false)
- {
- MR.XXLB = KeyValue_JDLB.SelectedValue;
- }
- else
- {
- MR.XXLB = KeyValue_XXLB.SelectedValue;
- }
- MR.BJDZXM = KeyValue_BJDZXM.Text;
- MR.FSRQ = Convert.ToDateTime(KeyValue_FSRQ.Text);
- MR.BZ = KeyValue_BZ.Text;
- BR.Add(MR);
- MessageBox.Show("添加成功!");
- DropLoadSet();
- string i = KeyValue_JDLB.SelectedValue;
- DropLoadSet(i);
- KeyValue_BJDZXM.Text = "";
- KeyValue_FSRQ.Text = "";
- KeyValue_BZ.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }