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

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. using System.Text;
  12. public partial class General_MeetingApply : System.Web.UI.Page
  13. {
  14.     /// <summary>
  15.     /// 会议室名称
  16.     /// </summary>
  17.     public string StrHtmlMC = "";
  18.     /// <summary>
  19.     /// 预定情况
  20.     /// </summary>
  21.     public string StrHtmlYDQK = "";
  22.     /// <summary>
  23.     /// 当前状态
  24.     /// </summary>
  25.     public string StrHtmlDQZT = "";
  26.     //模板
  27.     Model.MeetingRun MM = new Model.MeetingRun();
  28.     //业务
  29.     BLL.MeetingRun BM = new BLL.MeetingRun();
  30.     protected void Page_Load(object sender, EventArgs e)
  31.     {
  32.         LoginLogic.MatchLoad("../", "General_MeetingApply");
  33.         if (!IsPostBack)
  34.         {
  35.             DropLoadSet();
  36.         }
  37.     }
  38.     /// <summary>
  39.     /// 数据绑定
  40.     /// </summary>
  41.     public void DropLoadSet()
  42.     {
  43.         #region 会议室
  44.         KeyValue_HYS.DataTextField = "MC";
  45.         KeyValue_HYS.DataValueField = "ID";
  46.         KeyValue_HYS.DataSource = EnumGet.MeetingRoomsGetEnum();
  47.         KeyValue_HYS.DataBind();
  48.         ListItem linone = new ListItem();
  49.         linone.Text = "--请选择--";
  50.         linone.Value = "0";
  51.         KeyValue_HYS.Items.Add(linone);
  52.         KeyValue_HYS.SelectedIndex = KeyValue_HYS.Items.Count - 1;
  53.         #endregion
  54.         #region 会议室管理员
  55.         KeyValue_HYGLY.DataTextField = "GLY";
  56.         KeyValue_HYGLY.DataValueField = "ID";
  57.         KeyValue_HYGLY.DataSource = EnumGet.MeetingManagersGetEnum();
  58.         KeyValue_HYGLY.DataBind();
  59.         ListItem linone2 = new ListItem();
  60.         linone2.Text = "--请选择--";
  61.         linone2.Value = "0";
  62.         KeyValue_HYGLY.Items.Add(linone2);
  63.         KeyValue_HYGLY.SelectedIndex = KeyValue_HYGLY.Items.Count - 1;
  64.         #endregion
  65.         #region 申请人
  66.         KeyValue_SQR.Text = SessionInclude.SessionId;
  67.         #endregion
  68.     }
  69.     public void DropLoadSet(int Id)
  70.     {
  71.         if (Id > 0)
  72.         {
  73.             MM = BM.GetModel(Id);
  74.             #region 会议室名称
  75.             StrHtmlMC = EnumGet.GetMeetingRoomsName(Id);
  76.             #endregion
  77.             #region 预定情况
  78.             StrHtmlYDQK = YDXX(Id);
  79.             #endregion
  80.             #region 当前状态
  81.             //string condition = "HYS = 'lvs' and PZZT = '已准' and convert(varchar(10),KSSJ,120) = '今天' and (KSSJ < '现在时间' and JSSJ > '现在时间')";
  82.             string condition = "HYS = '" + Id.ToString() + "' and PZZT = '" + States.SupplyState_Agree + "' and convert(varchar(10),KSSJ,120) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (KSSJ < '" + DateTime.Now.ToString() + "' and JSSJ > '" + DateTime.Now.ToString() + "')";
  83.             if (BM.GetCount(condition) > 0)
  84.             {
  85.                 StrHtmlDQZT = States.UseState_Busy;
  86.             }
  87.             else
  88.             {
  89.                 StrHtmlDQZT = States.UseState_Free;
  90.             }
  91.             #endregion
  92.         }
  93.     }
  94.     /// <summary>
  95.     /// 预定情况
  96.     /// </summary>
  97.     /// <param name="Id">会议室ID</param>
  98.     /// <returns></returns>
  99.     public string YDXX(int Id)
  100.     {
  101.         StringBuilder sb = new StringBuilder();
  102.         if (Id > 0)
  103.         {
  104.             //string condtion = "MC = 'lvs' and PZZT = '待批' and convert(varchar(10),KSSJ,120) = '今天'";
  105.             string condition = "HYS = '" + Id.ToString() + "' and PZZT = '" + States.SupplyState_Wait + "' and convert(varchar(10),KSSJ,120) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
  106.             string Rtstr = "当前共 " + BM.GetCount(condition).ToString() + " 条预定信息";
  107.             //sb.Append("<a href='VehicleWait.aspx?TiaoJian=" + condition + "' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
  108.             if (BM.GetCount(condition) > 0)
  109.             {
  110.                 sb.Append("<a href='" + "MeetingWait.aspx?id=" + Id.ToString() + "' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
  111.             }
  112.             else
  113.             {
  114.                 sb.Append("<a href='#' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
  115.             }
  116.         }
  117.         else
  118.         {
  119.             sb.Append("");
  120.         }
  121.         return sb.ToString();
  122.     }
  123.     protected void KeyValue_HYS_SelectedIndexChanged(object sender, EventArgs e)
  124.     {
  125.         DropLoadSet(int.Parse(KeyValue_HYS.SelectedValue));
  126.     }
  127.     protected void Button1_Click(object sender, EventArgs e)
  128.     {
  129.         try
  130.         {
  131.             if (KeyValue_HYS.SelectedValue == "0")
  132.             {
  133.                 throw new Exception("请选择会议室!");
  134.             }
  135.             if (String.IsNullOrEmpty(KeyValue_MC.Text.Trim()))
  136.             {
  137.                 throw new Exception("名称不能为空!");
  138.             }
  139.             if (String.IsNullOrEmpty(KeyValue_ZT.Text.Trim()))
  140.             {
  141.                 throw new Exception("主题不能为空!");
  142.             }
  143.             if (String.IsNullOrEmpty(KeyValue_SQR.Text.Trim()))
  144.             {
  145.                 throw new Exception("申请人不能为空!");
  146.             }
  147.             if (String.IsNullOrEmpty(KeyValue_CXRYNB.Text.Trim()))
  148.             {
  149.                 throw new Exception("出席人员(内部)不能为空!");
  150.             }
  151.             #region 开始时间
  152.             if (String.IsNullOrEmpty(KeyValue_KSSJ.Text.Trim()))
  153.             {
  154.                 throw new Exception("开始时间不能为空!");
  155.             }
  156.             if (DateTime.Compare(Convert.ToDateTime(KeyValue_KSSJ.Text), DateTime.Now) <= 0)
  157.             {
  158.                 throw new Exception("开始时间必须大于当前时间!");
  159.             }
  160.             #endregion
  161.             #region 结束时间
  162.             if (String.IsNullOrEmpty(KeyValue_JSSJ.Text.Trim()))
  163.             {
  164.                 throw new Exception("结束时间不能为空!");
  165.             }
  166.             if (DateTime.Compare(Convert.ToDateTime(KeyValue_JSSJ.Text), Convert.ToDateTime(KeyValue_KSSJ.Text)) <= 0)
  167.             {
  168.                 throw new Exception("结束时间必须大于开始时间!");
  169.             }
  170.             #endregion
  171.             if (KeyValue_HYGLY.SelectedValue == "0")
  172.             {
  173.                 throw new Exception("请选择会议管理员!");
  174.             }
  175.             if (String.IsNullOrEmpty(KeyValue_SQSJ.Text.Trim()))
  176.             {
  177.                 throw new Exception("申请时间不能为空!");
  178.             }
  179.             if (DateTime.Now.ToString("yyyy-MM-dd HH:mm") != Convert.ToDateTime(KeyValue_SQSJ.Text).ToString("yyyy-MM-dd HH:mm"))
  180.             {
  181.                 throw new Exception("申请时间必须为当前时间(精确到分钟)!");
  182.             }
  183.             MM.HYS = int.Parse(KeyValue_HYS.SelectedValue);
  184.             MM.MC = KeyValue_MC.Text;
  185.             MM.ZT = KeyValue_ZT.Text;
  186.             MM.MS = KeyValue_MS.Text;
  187.             MM.SQR = KeyValue_SQR.Text;           
  188.             MM.CXRYNB = KeyValue_CXRYNB.Text;
  189.             MM.CXRYWB = KeyValue_CXRYWB.Text;
  190.             MM.KSSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_KSSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
  191.             MM.JSSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_JSSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
  192.             MM.HYGLY = KeyValue_HYGLY.SelectedValue;
  193.             MM.SQSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_SQSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
  194.             MM.PZZT = States.SupplyState_Wait;
  195.             BM.Add(MM);
  196.             MessageBox.Show("添加成功!");
  197.             DropLoadSet();
  198.             KeyValue_MC.Text = "";
  199.             KeyValue_ZT.Text = "";
  200.             KeyValue_MS.Text = "";
  201.             KeyValue_CXRYNB.Text = "";
  202.             KeyValue_CXRYWB.Text = "";
  203.             KeyValue_KSSJ.Text = "";
  204.             KeyValue_JSSJ.Text = "";
  205.             KeyValue_SQSJ.Text = "";
  206.         }
  207.         catch (Exception exp)
  208.         {
  209.             MessageBox.Show(exp.Message);
  210.             DropLoadSet(int.Parse(KeyValue_HYS.SelectedValue));
  211.         }
  212.     }
  213. }