350 lines
11 KiB
C#
350 lines
11 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using DeiNiu.wms.Logical;
|
|||
|
using DeiNiu.Utils;
|
|||
|
|
|||
|
namespace ajax.Dict
|
|||
|
{
|
|||
|
public partial class AuthorityMain :PageBase
|
|||
|
{
|
|||
|
private LAuthority _logic;
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
_logic = new LAuthority();
|
|||
|
Databound();
|
|||
|
}
|
|||
|
SessionSeting();
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** private methods ******************************************/
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// bound the query list.
|
|||
|
/// </summary>
|
|||
|
private void Databound()
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
//װ<><D7B0>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>Žڵ<C5BD><DAB5>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
DataView dv = new DataView(_logic.getAllActiveData().Tables[0]);
|
|||
|
|
|||
|
if (TreeAuth.SelectedNode != null)
|
|||
|
{
|
|||
|
TreeAuth.SelectedNode.ChildNodes.Clear();
|
|||
|
BindTree(TreeAuth.SelectedNode.Value, TreeAuth.SelectedNode, dv);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>ѡ<EFBFBD>еIJ<D0B5><C4B2><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
|||
|
}
|
|||
|
GridView1.DataSource = dv;
|
|||
|
GridView1.DataBind();
|
|||
|
UpdateSession();
|
|||
|
ClearDetail();
|
|||
|
}
|
|||
|
|
|||
|
private void SessionSeting()
|
|||
|
{
|
|||
|
if (IsPostBack)
|
|||
|
{
|
|||
|
_logic = (LAuthority)Session[appScope.PagelevelObj];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void UpdateSession()
|
|||
|
{
|
|||
|
Session[appScope.PagelevelObj] = _logic;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// set data from shift object to page
|
|||
|
/// </summary>
|
|||
|
private void DetailDataBind()
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url<72><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊpublic
|
|||
|
LAuthority ltmp = new LAuthority();
|
|||
|
ltmp.Initialize(Convert.ToInt32(TreeAuth.SelectedValue));
|
|||
|
chkPublic.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
|||
|
chkPublicInfo.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
|||
|
chkAlert.Enabled =!chkPublicInfo.Enabled; //<2F><><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
if (chkPublicInfo.Checked)
|
|||
|
{
|
|||
|
txtLink.Enabled = false;
|
|||
|
txtFormClass.Enabled = false;
|
|||
|
}
|
|||
|
DataDetail.Visible = true;
|
|||
|
txtName.Text = _logic.GetAuthority.auth_name;
|
|||
|
txtDesc.Text = _logic.GetAuthority.auth_desc;
|
|||
|
txtLink.Text = _logic.GetAuthority.auth_link;
|
|||
|
txtFormClass.Text = _logic.GetAuthority.auth_class;
|
|||
|
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
|||
|
chkPublicInfo.Checked = _logic.GetAuthority.auth_publicInfomation;
|
|||
|
chkSpecial.Checked = _logic.GetAuthority.auth_special;
|
|||
|
txtOrder.Text = _logic.GetAuthority.auth_order + "";
|
|||
|
//<2F>ϼ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if(ltmp.GetAuthority.auth_publicInfomation)
|
|||
|
chkPublicInfo.Checked = ltmp.GetAuthority.auth_publicInfomation;
|
|||
|
if (ltmp.GetAuthority.auth_public)
|
|||
|
chkPublic.Checked = ltmp.GetAuthority.auth_public;
|
|||
|
chkAlert.Checked = _logic.GetAuthority.auth_marqueen;
|
|||
|
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
|||
|
chkEnable.Checked = _logic.GetAuthority.dr;
|
|||
|
ltmp = null;
|
|||
|
|
|||
|
// chkStatus.Checked = _logic.GetRole.dr;
|
|||
|
}
|
|||
|
|
|||
|
/************************************** protected methods (event listeners) ********************************/
|
|||
|
|
|||
|
protected void btnAddnew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(true);
|
|||
|
_logic.Initialize();
|
|||
|
GridView1.SelectedIndex = -1;
|
|||
|
Databound();
|
|||
|
DetailDataBind();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(false);
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
Databound();
|
|||
|
DetailDataBind();
|
|||
|
}
|
|||
|
|
|||
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
SetDataBack();
|
|||
|
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
|||
|
|
|||
|
int oper = 0;
|
|||
|
oper = _logic.GetAuthority.ID > 0 ? _logic.GetAuthority.Update() : _logic.GetAuthority.Add();
|
|||
|
ClearDetail();
|
|||
|
Databound();
|
|||
|
lbEdit.Text = "";
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (GridView1 != null)
|
|||
|
{
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
}
|
|||
|
/*
|
|||
|
_logic.GetRole.dr = false;
|
|||
|
_logic.GetRole.Update();
|
|||
|
|
|||
|
*/
|
|||
|
_logic.GetAuthority.Delete();
|
|||
|
ClearDetail();
|
|||
|
Databound();
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
|||
|
{
|
|||
|
GridView1.PageIndex = e.NewPageIndex;
|
|||
|
Databound();
|
|||
|
|
|||
|
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
|||
|
// GridView1.DataBind();
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_DataBinding(object sender, EventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
//reset the page
|
|||
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
_logic.Initialize();
|
|||
|
Page_Load(this, e);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** internal methods ********************************************/
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// set data from page to shift object
|
|||
|
/// </summary>
|
|||
|
private void SetDataBack()
|
|||
|
{
|
|||
|
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
|||
|
|
|||
|
if (!(_logic.GetAuthority.ID > 0))
|
|||
|
{
|
|||
|
// _logic.GetAuthority.lastmodified = DateTime.Now.ToString();
|
|||
|
_logic.GetAuthority.auth_uplevel = Convert.ToInt32(TreeAuth.SelectedValue);
|
|||
|
}
|
|||
|
|
|||
|
_logic.GetAuthority.auth_name = txtName.Text;
|
|||
|
_logic.GetAuthority.auth_desc = txtDesc.Text;
|
|||
|
_logic.GetAuthority.auth_link = txtLink.Text;
|
|||
|
_logic.GetAuthority.auth_class = txtFormClass.Text;
|
|||
|
_logic.GetAuthority.auth_public = chkPublic.Checked;
|
|||
|
_logic.GetAuthority.auth_publicInfomation =chkPublicInfo.Checked ;
|
|||
|
_logic.GetAuthority.auth_marqueen = chkAlert.Checked;
|
|||
|
_logic.GetAuthority.auth_special = chkSpecial.Checked;
|
|||
|
_logic.GetAuthority.auth_order = Convert.ToInt16( txtOrder.Text.Trim());
|
|||
|
_logic.GetAuthority.dr = chkEnable.Checked;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void chgOperTxt(bool addNew)
|
|||
|
{
|
|||
|
DataDetail.Visible = true;
|
|||
|
lbEdit.Text = addNew ? "<22><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>¼" : "<22><EFBFBD><DEB8><EFBFBD><EFBFBD>м<EFBFBD>¼";
|
|||
|
btnSubmit.Enabled = true;
|
|||
|
}
|
|||
|
|
|||
|
private void ClearDetail()
|
|||
|
{
|
|||
|
txtName.Text = "";
|
|||
|
txtDesc.Text = "";
|
|||
|
txtLink.Text ="";
|
|||
|
txtLink.Text = "";
|
|||
|
chkPublic.Checked = false;
|
|||
|
chkPublicInfo.Checked = false;
|
|||
|
DataDetail.Visible = false;
|
|||
|
chkSpecial.Checked = false;
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(false);
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
Databound();
|
|||
|
DetailDataBind();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void BindTree(string id, TreeNode pNode, DataView dv)
|
|||
|
{
|
|||
|
|
|||
|
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
|||
|
foreach (DataRowView row in dv)
|
|||
|
{
|
|||
|
TreeNode node = new TreeNode();
|
|||
|
node.Text = row["auth_name"].ToString();
|
|||
|
node.Value = row["ID"].ToString();
|
|||
|
if (pNode == null)
|
|||
|
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
TreeAuth.Nodes.Add(node);
|
|||
|
node.Expanded = false;
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
pNode.ChildNodes.Add(node);
|
|||
|
node.Expanded = false;
|
|||
|
|
|||
|
}
|
|||
|
BindTree(node.Value, node, new DataView(dv.Table));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void TreeAuth_SelectedNodeChanged1(object sender, EventArgs e)
|
|||
|
{
|
|||
|
GridView1.SelectedIndex = -1;
|
|||
|
DataView dv = new DataView(_logic.getAllActiveData().Tables[0]);
|
|||
|
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
|||
|
GridView1.DataSource = dv;
|
|||
|
GridView1.DataBind();
|
|||
|
ClearDetail();
|
|||
|
if(TreeAuth.SelectedNode.ChildNodes.Count>0)TreeAuth.SelectedNode.Expand();
|
|||
|
}
|
|||
|
|
|||
|
protected void chkPublicInfo_CheckedChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
switch (chkPublicInfo.Checked)
|
|||
|
{
|
|||
|
case true:
|
|||
|
txtLink.Text = string.Empty;
|
|||
|
txtLink.Enabled = false;
|
|||
|
txtFormClass.Text = string.Empty;
|
|||
|
txtFormClass.Enabled = false;
|
|||
|
chkPublic.Checked = true;
|
|||
|
chkPublic.Enabled = false;
|
|||
|
break;
|
|||
|
|
|||
|
case false:
|
|||
|
txtLink.Text = _logic.GetAuthority.auth_link;
|
|||
|
txtFormClass.Text = _logic.GetAuthority.auth_class;
|
|||
|
txtFormClass.Enabled = true;
|
|||
|
txtLink.Enabled = true ;
|
|||
|
chkPublic.Checked = false;
|
|||
|
chkPublic.Enabled = true;
|
|||
|
break;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void chkSpecial_CheckedChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
|
|||
|
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
CheckBox chk;
|
|||
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|||
|
{
|
|||
|
chk = new CheckBox();
|
|||
|
chk.Text = "";
|
|||
|
chk.Enabled = false;
|
|||
|
chk.Checked = e.Row.Cells[4].Text.Trim().Equals("True");
|
|||
|
e.Row.Cells[4].Controls.Add(chk);
|
|||
|
|
|||
|
|
|||
|
chk = new CheckBox();
|
|||
|
chk.Text = "";
|
|||
|
chk.Enabled = false;
|
|||
|
chk.Checked = e.Row.Cells[5].Text.Trim().Equals("True");
|
|||
|
e.Row.Cells[5].Controls.Add(chk);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|