📄 dictmanage.aspx.cs
字号:
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;
using Itsv.BLL.SystemManage;
using Itsv.Model;
public partial class SystemManage_DictManage : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.CheckUserState();
//操作 0 向下 1向上 2返回/刷新
string action = "0";
if (Request.QueryString["parentcode"] != null)
{
this.lblParentcode.Text = Request.QueryString["parentcode"];
this.lblLaycode.Text = Server.UrlDecode(Request.QueryString["layer"]);
action = Request.QueryString["action"];
//if (action == "0")
// this.lblLaycode.Text = Convert.ToString(int.Parse(this.lblLaycode.Text) + 1);
//else if (action == "1")
//{
// if (int.Parse(this.lblLaycode.Text) > 0)
// this.lblLaycode.Text = Convert.ToString(int.Parse(this.lblLaycode.Text) - 1);
//}
//else
//{
//}
}
if (action == "0" || this.lblParentcode.Text == "0" || action == "2")
this.BindGridView(this.GetChildDict(this.lblParentcode.Text), this.gvUser, "dict_id");
else
{
this.BindGridView(this.GetParentDict(this.lblParentcode.Text), this.gvUser,"dict_id");
}
}
}
/// <summary>
/// 得到子字典项
/// </summary>
/// <param name="prarentid"></param>
/// <returns></returns>
private DataSet GetChildDict(string prarentid)
{
dictionaryBLL dictbll=new dictionaryBLL();
DataSet ds = dictbll.GetList(" parent_id = " + prarentid,ref msg);
if (ds == null)
{
this.ShowMessage(msg);
}
return ds;
}
/// <summary>
/// 得到父列表
/// </summary>
/// <param name="childid"></param>
/// <returns></returns>
private DataSet GetParentDict(string childid)
{
dictionaryBLL dictbll = new dictionaryBLL();
DataSet ds = dictbll.GetParentList(int.Parse(childid), ref msg);
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
this.lblParentcode.Text = ds.Tables[0].Rows[0]["parent_id"].ToString();
if (lblParentcode.Text == "0")
{
this.lblLaycode.Text = "字典根目录";
}
else
{
dictionary d = dictbll.GetModel(int.Parse(lblParentcode.Text), ref msg);
if (d != null)
{
this.lblLaycode.Text = d.dict_name;
}
d = null;
}
}
}
return ds;
}
/// <summary>
/// 增加新字典
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click(object sender, EventArgs e)
{
Response.Redirect("DictAdd.aspx?parentcode=" + lblParentcode.Text + "&layer=" + Server.UrlEncode(lblLaycode.Text) + "&action=1");
}
/// <summary>
/// 返回上级
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnReturn_Click(object sender, EventArgs e)
{
Response.Redirect("Dictmanage.aspx?parentcode=" + lblParentcode.Text + "&layer=" + Server.UrlEncode(lblLaycode.Text) + "&action=1");
}
/// <summary>
/// 返回根目录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnParent_Click(object sender, EventArgs e)
{
Response.Redirect("Dictmanage.aspx");
}
protected void btnDelete_Click(object sender, EventArgs e)
{
string ids = string.Empty;
string dictNames = string.Empty;
for (int i = 0; i < this.gvUser.Rows.Count; i++)
{
CheckBox cb = (CheckBox)gvUser.Rows[i].FindControl("ckb");
if (cb.Checked)
{
ids += gvUser.DataKeys[i].Value.ToString() + "|";
dictNames += gvUser.Rows[i].Cells[2].Text + "|";
}
}
if (ids == string.Empty)
{
this.ShowMessage("尚未选择需要删除的字典项");
return;
}
string[] ss = ids.Split('|');
string[] dictName = dictNames.Split('|');
dictionaryBLL bll = new dictionaryBLL();
for (int i = 0; i < ss.Length; i++)
{
if (ss[i].Trim().Length > 0)
{
if (!bll.Delete(int.Parse(ss[i]), ref msg))
{
this.ShowMessage(msg);
return;
}
else
{
this.WriteUserAction("删除字典:" + dictName[i]);
}
}
}
Response.Redirect("Dictmanage.aspx?parentcode=" + lblParentcode.Text + "&layer=" + Server.UrlEncode(lblLaycode.Text) + "&action=2");
}
protected void gvUser_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (this.lblParentcode.Text == "0" && !GetSystemRole(CurrentUser.account))
{
string dictId = e.Row.Cells[1].Text.Trim();
if (dictId != "103")
{
e.Row.Visible = false;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -