MeetingApply.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:8k
- 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;
- using System.Text;
- public partial class General_MeetingApply : System.Web.UI.Page
- {
- /// <summary>
- /// 会议室名称
- /// </summary>
- public string StrHtmlMC = "";
- /// <summary>
- /// 预定情况
- /// </summary>
- public string StrHtmlYDQK = "";
- /// <summary>
- /// 当前状态
- /// </summary>
- public string StrHtmlDQZT = "";
- //模板
- Model.MeetingRun MM = new Model.MeetingRun();
- //业务
- BLL.MeetingRun BM = new BLL.MeetingRun();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "General_MeetingApply");
- if (!IsPostBack)
- {
- DropLoadSet();
- }
- }
- /// <summary>
- /// 数据绑定
- /// </summary>
- public void DropLoadSet()
- {
- #region 会议室
- KeyValue_HYS.DataTextField = "MC";
- KeyValue_HYS.DataValueField = "ID";
- KeyValue_HYS.DataSource = EnumGet.MeetingRoomsGetEnum();
- KeyValue_HYS.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "--请选择--";
- linone.Value = "0";
- KeyValue_HYS.Items.Add(linone);
- KeyValue_HYS.SelectedIndex = KeyValue_HYS.Items.Count - 1;
- #endregion
- #region 会议室管理员
- KeyValue_HYGLY.DataTextField = "GLY";
- KeyValue_HYGLY.DataValueField = "ID";
- KeyValue_HYGLY.DataSource = EnumGet.MeetingManagersGetEnum();
- KeyValue_HYGLY.DataBind();
- ListItem linone2 = new ListItem();
- linone2.Text = "--请选择--";
- linone2.Value = "0";
- KeyValue_HYGLY.Items.Add(linone2);
- KeyValue_HYGLY.SelectedIndex = KeyValue_HYGLY.Items.Count - 1;
- #endregion
- #region 申请人
- KeyValue_SQR.Text = SessionInclude.SessionId;
- #endregion
- }
- public void DropLoadSet(int Id)
- {
- if (Id > 0)
- {
- MM = BM.GetModel(Id);
- #region 会议室名称
- StrHtmlMC = EnumGet.GetMeetingRoomsName(Id);
- #endregion
- #region 预定情况
- StrHtmlYDQK = YDXX(Id);
- #endregion
- #region 当前状态
- //string condition = "HYS = 'lvs' and PZZT = '已准' and convert(varchar(10),KSSJ,120) = '今天' and (KSSJ < '现在时间' and JSSJ > '现在时间')";
- 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() + "')";
- if (BM.GetCount(condition) > 0)
- {
- StrHtmlDQZT = States.UseState_Busy;
- }
- else
- {
- StrHtmlDQZT = States.UseState_Free;
- }
- #endregion
- }
- }
- /// <summary>
- /// 预定情况
- /// </summary>
- /// <param name="Id">会议室ID</param>
- /// <returns></returns>
- public string YDXX(int Id)
- {
- StringBuilder sb = new StringBuilder();
- if (Id > 0)
- {
- //string condtion = "MC = 'lvs' and PZZT = '待批' and convert(varchar(10),KSSJ,120) = '今天'";
- string condition = "HYS = '" + Id.ToString() + "' and PZZT = '" + States.SupplyState_Wait + "' and convert(varchar(10),KSSJ,120) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
- string Rtstr = "当前共 " + BM.GetCount(condition).ToString() + " 条预定信息";
- //sb.Append("<a href='VehicleWait.aspx?TiaoJian=" + condition + "' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
- if (BM.GetCount(condition) > 0)
- {
- sb.Append("<a href='" + "MeetingWait.aspx?id=" + Id.ToString() + "' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
- }
- else
- {
- sb.Append("<a href='#' title='点击查看详情'><span style='color: #0000ff; text-decoration: underline'>" + Rtstr + "</span></a>");
- }
- }
- else
- {
- sb.Append("");
- }
- return sb.ToString();
- }
- protected void KeyValue_HYS_SelectedIndexChanged(object sender, EventArgs e)
- {
- DropLoadSet(int.Parse(KeyValue_HYS.SelectedValue));
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (KeyValue_HYS.SelectedValue == "0")
- {
- throw new Exception("请选择会议室!");
- }
- if (String.IsNullOrEmpty(KeyValue_MC.Text.Trim()))
- {
- throw new Exception("名称不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_ZT.Text.Trim()))
- {
- throw new Exception("主题不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_SQR.Text.Trim()))
- {
- throw new Exception("申请人不能为空!");
- }
- if (String.IsNullOrEmpty(KeyValue_CXRYNB.Text.Trim()))
- {
- throw new Exception("出席人员(内部)不能为空!");
- }
- #region 开始时间
- if (String.IsNullOrEmpty(KeyValue_KSSJ.Text.Trim()))
- {
- throw new Exception("开始时间不能为空!");
- }
- if (DateTime.Compare(Convert.ToDateTime(KeyValue_KSSJ.Text), DateTime.Now) <= 0)
- {
- throw new Exception("开始时间必须大于当前时间!");
- }
- #endregion
- #region 结束时间
- if (String.IsNullOrEmpty(KeyValue_JSSJ.Text.Trim()))
- {
- throw new Exception("结束时间不能为空!");
- }
- if (DateTime.Compare(Convert.ToDateTime(KeyValue_JSSJ.Text), Convert.ToDateTime(KeyValue_KSSJ.Text)) <= 0)
- {
- throw new Exception("结束时间必须大于开始时间!");
- }
- #endregion
- if (KeyValue_HYGLY.SelectedValue == "0")
- {
- throw new Exception("请选择会议管理员!");
- }
- if (String.IsNullOrEmpty(KeyValue_SQSJ.Text.Trim()))
- {
- throw new Exception("申请时间不能为空!");
- }
- if (DateTime.Now.ToString("yyyy-MM-dd HH:mm") != Convert.ToDateTime(KeyValue_SQSJ.Text).ToString("yyyy-MM-dd HH:mm"))
- {
- throw new Exception("申请时间必须为当前时间(精确到分钟)!");
- }
- MM.HYS = int.Parse(KeyValue_HYS.SelectedValue);
- MM.MC = KeyValue_MC.Text;
- MM.ZT = KeyValue_ZT.Text;
- MM.MS = KeyValue_MS.Text;
- MM.SQR = KeyValue_SQR.Text;
- MM.CXRYNB = KeyValue_CXRYNB.Text;
- MM.CXRYWB = KeyValue_CXRYWB.Text;
- MM.KSSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_KSSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
- MM.JSSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_JSSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
- MM.HYGLY = KeyValue_HYGLY.SelectedValue;
- MM.SQSJ = Convert.ToDateTime(Convert.ToDateTime(KeyValue_SQSJ.Text).ToString("yyyy-MM-dd HH:mm:ss"));
- MM.PZZT = States.SupplyState_Wait;
- BM.Add(MM);
- MessageBox.Show("添加成功!");
- DropLoadSet();
- KeyValue_MC.Text = "";
- KeyValue_ZT.Text = "";
- KeyValue_MS.Text = "";
- KeyValue_CXRYNB.Text = "";
- KeyValue_CXRYWB.Text = "";
- KeyValue_KSSJ.Text = "";
- KeyValue_JSSJ.Text = "";
- KeyValue_SQSJ.Text = "";
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- DropLoadSet(int.Parse(KeyValue_HYS.SelectedValue));
- }
- }
- }