NewMeeting.aspx.cs
资源名称:OA_at.rar [点击查看]
上传用户:tree100901
上传日期:2007-06-03
资源大小:2295k
文件大小:5k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace OA
- {
- /// <summary>
- /// NewMeeting 的摘要说明。
- /// </summary>
- public class NewMeeting : System.Web.UI.Page
- {
- protected System.Data.SqlClient.SqlConnection MyConnection;
- protected System.Data.SqlClient.SqlCommand MyCommand;
- protected System.Web.UI.WebControls.TextBox Accepter;
- protected System.Web.UI.WebControls.Button Send;
- protected System.Web.UI.WebControls.TextBox Title;
- protected System.Web.UI.WebControls.TextBox Attends;
- protected System.Web.UI.WebControls.TextBox MeetingDate;
- protected System.Web.UI.WebControls.TextBox Caller;
- protected System.Web.UI.WebControls.DropDownList Address;
- protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
- protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
- protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
- protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
- protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator5;
- protected System.Web.UI.HtmlControls.HtmlInputHidden AccepterID;
- protected System.Web.UI.HtmlControls.HtmlInputHidden CallerID;
- public string PID;
- private void Page_Load(object sender, System.EventArgs e)
- {
- CheckUser CHU = new CheckUser();
- CHU.UserName = User.Identity.Name;
- PID = CHU.UserID.ToString();
- if(CHU.Is_FileManager() == false)
- Response.Write("<script>alert('对不起,你没有查看此页面的权限!');history.back(2)</" + "script>");
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Send.Click += new System.EventHandler(this.Send_Click);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void Reset_Click(object sender, System.EventArgs e)
- {
- Accepter.Text="";
- Title.Text="";
- Attends.Text="";
- Caller.Text="";
- MeetingDate.Text="";
- }
- private void Send_Click(object sender, System.EventArgs e)
- {
- MyConnection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
- if(AccepterID.Value.Trim()!=""&&CallerID.Value.Trim()!="")
- {
- MyCommand=new SqlCommand("InsertMeeting",MyConnection);
- MyCommand.CommandType = CommandType.StoredProcedure;
- MyCommand.Parameters.Add(new SqlParameter("@Title",SqlDbType.NVarChar, 50));
- MyCommand.Parameters["@Title"].Value = Title.Text;
- MyCommand.Parameters.Add(new SqlParameter("@PersonID",SqlDbType.Int, 4));
- MyCommand.Parameters["@PersonID"].Value = PID;
- MyCommand.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.NVarChar, 500));
- MyCommand.Parameters["@AccepterID"].Value = AccepterID.Value.Trim();
- MyCommand.Parameters.Add(new SqlParameter("@Caller", SqlDbType.NVarChar, 120));
- MyCommand.Parameters["@Caller"].Value = CallerID.Value.Trim();
- MyCommand.Parameters.Add(new SqlParameter("@MeetingDate",SqlDbType.DateTime, 8));
- MyCommand.Parameters["@MeetingDate"].Value = DateTime.Parse(MeetingDate.Text);
- MyCommand.Parameters.Add(new SqlParameter("@State",SqlDbType.NVarChar, 500));
- MyCommand.Parameters["@State"].Value = "0";
- MyCommand.Parameters.Add(new SqlParameter("@Attends",SqlDbType.NVarChar, 500));
- MyCommand.Parameters["@Attends"].Value = Attends.Text;
- MyCommand.Parameters.Add(new SqlParameter("@Address",SqlDbType.NVarChar, 50));
- MyCommand.Parameters["@Address"].Value = Address.SelectedValue;
- if(MyConnection.State.ToString()=="Closed")
- MyConnection.Open();
- try
- {
- MyCommand.ExecuteNonQuery();
- RegisterStartupScript("alert","<script>alert('会议通知发送完毕!')</script>");
- }
- catch
- {
- }
- MyConnection.Close();
- Accepter.Text="";
- AccepterID.Value = "";
- Title.Text="";
- Attends.Text="";
- Caller.Text="";
- CallerID.Value = "";
- MeetingDate.Text="";
- }
- }
- public static string[] RemoveDup(string[] myData)
- {
- if (myData.Length > 0)
- {
- Array.Sort(myData);
- int size = 1;
- for (int i=1; i<myData.Length; i++)
- if (myData[i] != myData[i-1])
- size++;
- string[] myTempData = new string[size];
- int j=0;
- myTempData[j++] = myData[0];
- for (int i=1; i<myData.Length; i++)
- if (myData[i] != myData[i-1])
- myTempData[j++] = myData[i];
- return myTempData;
- }
- return myData;
- }
- }
- }