AddDepartmentForm.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:2k
- 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;
- public partial class AddDepartmentForm : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- Model.Department MD = new Model.Department();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.Department BD = new BLL.Department();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("", "AddDepartmentForm");
- if (!IsPostBack)
- {
- Department_DropDownList.DataTextField = "DeptName";
- Department_DropDownList.DataValueField = "ID";
- Department_DropDownList.DataSource = EnumGet.DepartmentGetEnum();
- Department_DropDownList.DataBind();
- ListItem linone = new ListItem();
- linone.Text = "无";
- linone.Value = "0";
- Department_DropDownList.Items.Add(linone);
- Department_DropDownList.SelectedIndex = Department_DropDownList.Items.Count - 1;
- }
- }
- protected void Button5_Click(object sender, EventArgs e)
- {
- try
- {
- int Num_TextBox_int = 0;
- if (!int.TryParse(Num_TextBox.Text, out Num_TextBox_int))
- {
- throw new Exception("序号必须为数字");
- }
-
- MD.DeptName = DepartMent_TextBox.Text;
- MD.DeptNo = Num_TextBox_int;
- MD.DeptFunc = DeptFunc_TextBox.Text;
- MD.Leader1 = Leader1_TextBox.Text;
- MD.Leader2 = Leader2_TextBox.Text;
- MD.Manager = DepartmentMain_TextBox.Text;
- MD.ParentDept =int.Parse(Department_DropDownList.SelectedValue);
- MD.FaxNo = Fax_TextBox.Text;
- MD.TelNo = Tel_TextBox.Text;
- BD.Add(MD);
- MessageBox.Show("新建成功!");
- }
- catch(Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }