📄 depup.aspx.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using qminoa.BLL;
using qminoa.Common;
using qminoa.Common.Data;
namespace qminoa.Webs.MR
{
public class DepAddUp : qminoa.Webs.PageBase
{
protected System.Web.UI.WebControls.Label lblDepID;
protected System.Web.UI.WebControls.Label lblErr;
protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
protected System.Web.UI.WebControls.ImageButton cmdExi;
protected System.Web.UI.WebControls.ImageButton cmdSaveExi;
protected System.Web.UI.WebControls.DropDownList lstBranch;
protected System.Web.UI.WebControls.RequiredFieldValidator valName;
protected System.Web.UI.WebControls.TextBox txtPostCode;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.TextBox txtStreet;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.TextBox txtDistrict;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox txtCity;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.TextBox txtProvince;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.TextBox txtTel2;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.TextBox txtTel1;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox txtFax;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.TextBox txtManager;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.Label Label1;
private string PARAM_KEY_DEPID = "DepID";
private void Page_Load(object sender, System.EventArgs e)
{
this.PageBegin("部门管理",true);
if(!Page.IsPostBack)
{
DataBind();
FillPage();
}
}
private void FillPage()
{
int depID = Convert.ToInt32(Request.Params[PARAM_KEY_DEPID],10);
DataTable depTB = (new DepSystem()).GetDepTB_By_DepID(depID);
DataRow row = depTB.Rows[0];
lblDepID.Text = row[DepData.DEPID_FIELD].ToString();
txtName.Text = row[DepData.DEPNAME_FIELD].ToString();
txtManager.Text = row[DepData.MANAGER_FIELD].ToString();
txtTel1.Text = row[DepData.TEL1_FIELD].ToString();
txtTel2.Text = row[DepData.TEL2_FIELD].ToString();
txtFax.Text = row[DepData.FAX_FIELD].ToString();
txtPostCode.Text = row[DepData.POSTCODE_FIELD].ToString();
txtProvince.Text = row[DepData.PROVINCE_FIELD].ToString();
txtCity.Text = row[DepData.CITY_FIELD].ToString();
txtDistrict.Text = row[DepData.DISTRICT_FIELD].ToString();
txtStreet.Text = row[DepData.STREET_FIELD].ToString();
int branchID = (int)row[DepData.BRANCHID_FIELD];
foreach(ListItem item in lstBranch.Items)
{
if(Convert.ToInt32(item.Value,10) == branchID)
item.Selected = true;
}
}
public void UpdateDep()
{
DepData depData = new DepData();
DataTable depTB = depData.Tables[DepData.DEP_TABLE_NAME];
DataRow row = depTB.NewRow();
depTB.Rows.Add(row);
depTB.AcceptChanges();
row[DepData.DEPID_FIELD] = Convert.ToInt32(lblDepID.Text,10);
row[DepData.BRANCHID_FIELD] = Convert.ToInt32(lstBranch.SelectedItem.Value,10);
row[DepData.DEPNAME_FIELD] = txtName.Text;
row[DepData.MANAGER_FIELD] = txtManager.Text;
row[DepData.TEL1_FIELD] = txtTel1.Text;
row[DepData.TEL2_FIELD] = txtTel2.Text;
row[DepData.FAX_FIELD] = txtFax.Text;
row[DepData.POSTCODE_FIELD] = txtPostCode.Text;
row[DepData.PROVINCE_FIELD] = txtProvince.Text;
row[DepData.CITY_FIELD] = txtCity.Text;
row[DepData.DISTRICT_FIELD] = txtDistrict.Text;
row[DepData.STREET_FIELD] = txtStreet.Text;
bool result = (new DepSystem()).UpdateDep(depData);
}
public DataTable BraTB
{
get
{
DataTable braTB = (new DepSystem()).GetBraTB();
return braTB;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.cmdSaveExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdSaveExi_Click);
this.cmdExi.Click += new System.Web.UI.ImageClickEventHandler(this.cmdExi_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void cmdSaveExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(this.EmpRightCode >= 3)
{
UpdateDep();
Response.Redirect("./DepInf.aspx",false);
}
else
JScript.Alert("您没有权限进行此操作!");
}
private void cmdExi_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("./DepInf.aspx",false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -