📄 branchinf.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using qminoa.BLL;
using qminoa.Common;
using qminoa.Common.Data;
namespace qminoa.Webs.MR
{
public class BranchSet : qminoa.Webs.PageBase
{
protected System.Web.UI.WebControls.Label lblBranchID;
protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
protected System.Web.UI.WebControls.Label lblErr;
protected System.Web.UI.WebControls.DataGrid dgdBranch;
protected System.Web.UI.WebControls.LinkButton cmdAdd;
protected System.Web.UI.WebControls.RequiredFieldValidator valSimCode;
protected System.Web.UI.WebControls.TextBox txtSimCode;
protected System.Web.UI.WebControls.RequiredFieldValidator valName;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.ImageButton ImageButton1;
private void Page_Load(object sender, System.EventArgs e)
{
this.PageBegin("机构管理",true);
if(!Page.IsPostBack)
{
DataBind();
}
}
public DataTable BraTB
{
get
{
return (new DepSystem()).GetBraTB();
}
}
#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.cmdAdd.Click += new System.EventHandler(this.cmdAdd_Click);
this.dgdBranch.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdBranch_CancelCommand);
this.dgdBranch.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdBranch_EditCommand);
this.dgdBranch.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdBranch_UpdateCommand);
this.dgdBranch.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgdBranch_DeleteCommand);
this.dgdBranch.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgdBranch_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dgdBranch_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(this.EmpRightCode >= 3)
{
int index = e.Item.ItemIndex;
dgdBranch.EditItemIndex = index;
dgdBranch.DataBind();
}
else
JScript.Alert("您没有权限进行此操作!");
}
private void dgdBranch_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(this.EmpRightCode == 4)
{
lblErr.Visible = false;
int index = e.Item.ItemIndex;
int braID = Convert.ToInt16(dgdBranch.DataKeys[index].ToString(),10);
try
{
bool result = (new DepSystem()).DeleteMrBranch(braID);
this.WriteOptLog("删除机构"+braID.ToString()+"信息");
}
catch
{
lblErr.Visible = true;
lblErr.Text = "存在和该机构相关联的信息,不能删除!";
}
dgdBranch.DataBind();
}
else
JScript.Alert("您没有权限进行此操作!");
}
private void dgdBranch_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int index = e.Item.ItemIndex;
dgdBranch.EditItemIndex = -1;
dgdBranch.DataBind();
}
private void dgdBranch_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(this.EmpRightCode >= 3)
{
int index = e.Item.ItemIndex;
int braID = Convert.ToInt16(dgdBranch.DataKeys[index].ToString(),10);
string s1 = ((TextBox)e.Item.Cells[0].Controls[0]).Text;
string s2 = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
if(!ValidateUtil.isBlank(s1))
{
bool result = (new DepSystem()).UpdateMrBranch(braID,s1,s2);
this.WriteOptLog("修改机构"+s1+"信息");
dgdBranch.EditItemIndex = -1;
dgdBranch.DataBind();
}
else
JScript.Alert ("机构名称不能为空!");
}
else
JScript.Alert("您没有权限进行此操作!");
}
private void cmdAdd_Click(object sender, System.EventArgs e)
{
if(this.EmpRightCode >= 2)
{
bool result = (new DepSystem()).InsertMrBranch(txtName.Text,txtSimCode.Text);
this.WriteOptLog("添加机构"+txtName.Text.ToString()+"信息");
dgdBranch.DataBind();
}
else
JScript.Alert("您没有权限进行此操作!");
}
private void dgdBranch_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
if (itemType == ListItemType.Item )
{
e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
}
else if( itemType == ListItemType.AlternatingItem)
{
e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
}
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
ImageButton button = (ImageButton) e.Item.FindControl("Imagebutton2");
button.Attributes.Add ("onclick",
"return confirm (\"确定要删除此项记录吗?\");");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -