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

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. public partial class AddDepartmentForm : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.     Model.Department MD = new Model.Department();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     BLL.Department BD = new BLL.Department();
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.         LoginLogic.MatchLoad("", "AddDepartmentForm");
  24.         if (!IsPostBack)
  25.         {
  26.             Department_DropDownList.DataTextField = "DeptName";
  27.             Department_DropDownList.DataValueField = "ID";
  28.             Department_DropDownList.DataSource = EnumGet.DepartmentGetEnum();
  29.             Department_DropDownList.DataBind();
  30.             ListItem linone = new ListItem();
  31.             linone.Text = "无";
  32.             linone.Value = "0";
  33.             Department_DropDownList.Items.Add(linone);
  34.             Department_DropDownList.SelectedIndex = Department_DropDownList.Items.Count - 1;
  35.         }
  36.     }
  37.     protected void Button5_Click(object sender, EventArgs e)
  38.     {
  39.         try
  40.         {
  41.             int Num_TextBox_int = 0;
  42.             if (!int.TryParse(Num_TextBox.Text, out Num_TextBox_int))
  43.             {
  44.                 throw new Exception("序号必须为数字");
  45.             }
  46.        
  47.             MD.DeptName = DepartMent_TextBox.Text;
  48.             MD.DeptNo = Num_TextBox_int;
  49.             MD.DeptFunc = DeptFunc_TextBox.Text;
  50.             MD.Leader1 = Leader1_TextBox.Text;
  51.             MD.Leader2 = Leader2_TextBox.Text;
  52.             MD.Manager = DepartmentMain_TextBox.Text;
  53.             MD.ParentDept =int.Parse(Department_DropDownList.SelectedValue);
  54.             MD.FaxNo = Fax_TextBox.Text;
  55.             MD.TelNo = Tel_TextBox.Text;
  56.             BD.Add(MD);
  57.             MessageBox.Show("新建成功!");
  58.         }
  59.         catch(Exception exp)
  60.         {
  61.             MessageBox.Show(exp.Message);
  62.         }
  63.     }
  64. }