using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication1
{
    public partial class MeetCharge : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = DateTime.Now.Year.ToString();
            Label2.Text = DateTime.Now.Year.ToString();
            DropDownList5.SelectedIndex = int.Parse(DateTime.Now.Month.ToString());
            DropDownList6.SelectedIndex = int.Parse(DateTime.Now.Day.ToString());
            DropDownList10.SelectedIndex = int.Parse(DateTime.Now.Month.ToString());
            DropDownList11.SelectedIndex = int.Parse(DateTime.Now.Day.ToString());
            DropDownList12.SelectedIndex = int.Parse(DateTime.Now.Hour.ToString());
            DropDownList13.SelectedIndex = int.Parse(DateTime.Now.Minute.ToString());
            DropDownList14.SelectedIndex = int.Parse(DateTime.Now.Hour.ToString());
            DropDownList15.SelectedIndex = int.Parse(DateTime.Now.Minute.ToString());
        }

        protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Models.T_Meeting meeting = new Models.T_Meeting();
            BLL.T_Meeting mee = new BLL.T_Meeting();
            meeting.m_meetingroom = DropDownList1.SelectedItem.Text;
            meeting.m_chargedept = DropDownList2.SelectedItem.Text;
            meeting.m_naturemeeting = DropDownList3.SelectedItem.Text;
            meeting.m_topicmeeting = TextBox1.Text;
            meeting.m_hostmeeting = TextBox2.Text;
            meeting.m_main = TextBox3.Text;
            string starttime = Label2.Text +"年"+ DropDownList5.SelectedItem.Text +"月"+ DropDownList6.SelectedItem.Text +"日"+ DropDownList12.SelectedItem.Text +"时"+ DropDownList13.SelectedItem.Text+"分";
            string endtime = Label1.Text +"年"+ DropDownList10.SelectedItem.Text +"月"+ DropDownList11.SelectedItem.Text +"日"+ DropDownList14.SelectedItem.Text +"时"+ DropDownList15.SelectedItem.Text+"分";
            DateTime st = DateTime.Parse(starttime);
            DateTime et = DateTime.Parse(endtime);
            meeting.m_starttime = st;
            meeting.m_endtime = et;
            meeting.m_statemeeting = false;
            meeting.m_isdel = false;
            if (mee.insert(meeting))
            {
                clearall();
                Response.Write("<script>alert('会议发布成功！')</script>");
            }
            else
            {
                Response.Write("<script>alert('会议发布失败！')</script>");
            }
        }
        public void clearall()
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            DropDownList1.SelectedIndex = 0;
            DropDownList2.SelectedIndex = 0;
            DropDownList3.SelectedIndex = 0;
            DropDownList5.SelectedIndex = int.Parse(DateTime.Now.Month.ToString());
            DropDownList6.SelectedIndex = int.Parse(DateTime.Now.Day.ToString());
            DropDownList10.SelectedIndex = int.Parse(DateTime.Now.Month.ToString());
            DropDownList11.SelectedIndex = int.Parse(DateTime.Now.Day.ToString());
            DropDownList12.SelectedIndex = int.Parse(DateTime.Now.Hour.ToString());
            DropDownList13.SelectedIndex = int.Parse(DateTime.Now.Minute.ToString());
            DropDownList14.SelectedIndex = int.Parse(DateTime.Now.Hour.ToString());
            DropDownList15.SelectedIndex = int.Parse(DateTime.Now.Minute.ToString());
        }
    }
}
