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 SystemManage_BuMenInfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//判断是否是列表显示参数
try
{
if (Request.QueryString["View"].ToString() == "List")
{
this.RadioButtonList1.SelectedValue = "列表显示";
this.Panel1.Visible = true;
this.Panel2.Visible = false;
}
}
catch { }
ZWL.Common.PublicMethod.CheckSession();
DataBindToGridview();
GetDaoHang(int.Parse(Request.QueryString["DirID"].ToString()));
//绑定部门树
BindBuMenTree(this.ListTreeView.Nodes, 0);
}
if (this.RadioButtonList1.SelectedItem.Text == "列表显示")
{
//设定按钮权限
ImageButton1.Visible = ZWL.Common.PublicMethod.StrIFIn("|085A|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
ImageButton5.Visible = ZWL.Common.PublicMethod.StrIFIn("|085M|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
ImageButton3.Visible = ZWL.Common.PublicMethod.StrIFIn("|085D|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
ImageButton2.Visible = ZWL.Common.PublicMethod.StrIFIn("|085E|", ZWL.Common.PublicMethod.GetSessionValue("QuanXian"));
}
else
{
this.ImageButton1.Visible = false;
this.ImageButton2.Visible = false;
this.ImageButton3.Visible = false;
this.ImageButton5.Visible = false;
}
//判断是否属于查询模块
try
{
string SerchTypeStr = Request.QueryString["Type"].ToString();
if (SerchTypeStr.Trim().Length > 0)
{
this.ImageButton1.Visible = false;
this.ImageButton2.Visible = false;
this.ImageButton3.Visible = false;
this.ImageButton5.Visible = false;
}
}
catch
{ }
}
///
/// 有权限就显示对应按钮
///
///
///
///
public string IFView(string ViewStr,string QuanXianStr)
{
if (ZWL.Common.PublicMethod.StrIFIn(QuanXianStr, ZWL.Common.PublicMethod.GetSessionValue("QuanXian")) == true)
{
return ViewStr;
}
else
{
return "";
}
}
public void BindBuMenTree(TreeNodeCollection Nds, int IDStr)
{
DataSet MYDT=ZWL.DBUtility.DbHelperSQL.GetDataSet("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc");
for(int i=0;i[未设置负责人]";
}
else
{
CharManStr = MYDT.Tables[0].Rows[i]["ChargeMan"].ToString().Trim();
}
//OrganizationNode.Text = MYDT.Tables[0].Rows[i]["BuMenName"].ToString() + " 部门主管:" + CharManStr + IFView(" [添加同级部门]", "|085A|") + IFView(" [添加下级部门]", "|085A|") + IFView(" [修改]", "|085M|") + IFView(" [删除]", "|085D|");
//OrganizationNode.ToolTip = "部门主管:" + MYDT.Tables[0].Rows[i]["ChargeMan"].ToString() + "\n电话:" + MYDT.Tables[0].Rows[i]["TelStr"].ToString() + "\n传真:" + MYDT.Tables[0].Rows[i]["ChuanZhen"].ToString() + "\n备注:" + MYDT.Tables[0].Rows[i]["BackInfo"].ToString();
OrganizationNode.Text = MYDT.Tables[0].Rows[i]["BuMenName"].ToString() + " 部门主管:" + CharManStr + IFView(" [添加同级部门]", "|085A|") + IFView(" [添加下级部门]", "|085A|") + IFView(" [修改]", "|085M|") + IFView(" [维护公章]", "|085A|") + IFView(" [删除]", "|085D|");
OrganizationNode.ToolTip = "部门主管:" + MYDT.Tables[0].Rows[i]["ChargeMan"].ToString() + "\n电话:" + MYDT.Tables[0].Rows[i]["TelStr"].ToString() + "\n传真:" + MYDT.Tables[0].Rows[i]["ChuanZhen"].ToString() + "\n备注:" + MYDT.Tables[0].Rows[i]["BackInfo"].ToString();
OrganizationNode.Value = MYDT.Tables[0].Rows[i]["ID"].ToString();
int strId = int.Parse(MYDT.Tables[0].Rows[i]["ID"].ToString());
OrganizationNode.ImageUrl = "~/images/user_group.gif";
OrganizationNode.SelectAction = TreeNodeSelectAction.Expand;
OrganizationNode.Expand();
Nds.Add(OrganizationNode);
//递归循环
BindBuMenTree(Nds[Nds.Count - 1].ChildNodes, strId);
}
}
public void GetDaoHang(int DirID)
{
if (DirID == 0)
{
if (this.Label1.Text.Trim() == "")
{
this.Label1.Text = "部门信息管理";
}
else
{
this.Label1.Text = "部门信息管理" + "\\" + this.Label1.Text;
}
}
else
{
if (this.Label1.Text.Trim() == "")
{
this.Label1.Text = "" + ZWL.DBUtility.DbHelperSQL.GetSHSL("select BuMenName from ERPBuMen where ID=" + DirID.ToString()) + "";
}
else
{
this.Label1.Text = "" + ZWL.DBUtility.DbHelperSQL.GetSHSL("select BuMenName from ERPBuMen where ID=" + DirID.ToString()) + "" + "\\" + this.Label1.Text;
}
int FatherID = int.Parse(ZWL.DBUtility.DbHelperSQL.GetSHSLInt("select DirID from ERPBuMen where ID=" + DirID.ToString()));
if (FatherID == 0)
{
this.Label1.Text = this.Label1.Text = "部门信息管理" + "\\" + this.Label1.Text;
}
else
{
GetDaoHang(FatherID);
}
}
}
public void DataBindToGridview()
{
ZWL.BLL.ERPBuMen MyERPBuMen = new ZWL.BLL.ERPBuMen();
string DirID = "0";
try
{
DirID = Request.QueryString["DirID"].ToString();
}
catch { }
GVData.DataSource = MyERPBuMen.GetList("DirID=" + DirID + " and BuMenName Like '%"+this.TextBox1.Text+"%' order by ID desc");
GVData.DataBind();
LabPageSum.Text = Convert.ToString(GVData.PageCount);
LabCurrentPage.Text = Convert.ToString(((int)GVData.PageIndex + 1));
this.GoPage.Text = LabCurrentPage.Text.ToString();
}
#region 分页方法
protected void ButtonGo_Click(object sender, ImageClickEventArgs e)
{
try
{
if (GoPage.Text.Trim().ToString() == "")
{
Response.Write("");
}
else if (GoPage.Text.Trim().ToString() == "0" || Convert.ToInt32(GoPage.Text.Trim().ToString()) > GVData.PageCount)
{
Response.Write("");
}
else if (GoPage.Text.Trim() != "")
{
int PageI = Int32.Parse(GoPage.Text.Trim()) - 1;
if (PageI >= 0 && PageI < (GVData.PageCount))
{
GVData.PageIndex = PageI;
}
}
if (TxtPageSize.Text.Trim().ToString() == "")
{
Response.Write("");
}
else if (TxtPageSize.Text.Trim().ToString() == "0")
{
Response.Write("");
}
else if (TxtPageSize.Text.Trim() != "")
{
try
{
int MyPageSize = int.Parse(TxtPageSize.Text.ToString().Trim());
this.GVData.PageSize = MyPageSize;
}
catch
{
Response.Write("");
}
}
DataBindToGridview();
}
catch
{
DataBindToGridview();
Response.Write("");
}
}
protected void PagerButtonClick(object sender, ImageClickEventArgs e)
{
//获得Button的参数值
string arg = ((ImageButton)sender).CommandName.ToString();
switch (arg)
{
case ("Next"):
if (this.GVData.PageIndex < (GVData.PageCount - 1))
GVData.PageIndex++;
break;
case ("Pre"):
if (GVData.PageIndex > 0)
GVData.PageIndex--;
break;
case ("Last"):
try
{
GVData.PageIndex = (GVData.PageCount - 1);
}
catch
{
GVData.PageIndex = 0;
}
break;
default:
//本页值
GVData.PageIndex = 0;
break;
}
DataBindToGridview();
}
#endregion
protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e)
{
ZWL.Common.PublicMethod.GridViewRowDataBound(e);
}
protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
{
DataBindToGridview();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("BuMenInfoAdd.aspx?View=List&Type=" + Request.QueryString["Type"].ToString() + "&DirID=" + Request.QueryString["DirID"].ToString());
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
string IDlist = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("delete from ERPBuMen where ID in (" + IDlist + ")") == -1)
{
Response.Write("");
}
else
{
DataBindToGridview();
//写系统日志
ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
MyRiZhi.DoSomething = "用户删除部门信息";
MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
MyRiZhi.Add();
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
string IDList = "0";
for (int i = 0; i < GVData.Rows.Count; i++)
{
Label LabVis = (Label)GVData.Rows[i].FindControl("LabVisible");
IDList = IDList + "," + LabVis.Text.ToString();
}
Hashtable MyTable = new Hashtable();
MyTable.Add("BuMenName", "部门名称");
MyTable.Add("ChargeMan", "部门主管");
MyTable.Add("TelStr", "联系电话");
MyTable.Add("ChuanZhen", "传真号码");
MyTable.Add("BackInfo", "备注信息");
ZWL.Common.DataToExcel.GridViewToExcel(ZWL.DBUtility.DbHelperSQL.GetDataSet("select BuMenName,ChargeMan,TelStr,ChuanZhen,BackInfo from ERPBuMen where ID in (" + IDList + ") order by ID desc"), MyTable, "Excel报表");
}
protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
{
string CheckStr = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
string[] CheckStrArray = CheckStr.Split(',');
if (CheckStrArray[0].ToString().Trim().Length>0)
{
Response.Redirect("BuMenInfoModify.aspx?View=List&Type=" + Request.QueryString["Type"].ToString() + "&DirID=" + Request.QueryString["DirID"].ToString() + "&ID=" + CheckStrArray[0].ToString());
}
else
{
ZWL.Common.MessageBox.Show(this, "当前未选择任何待修改项,不可以进行修改!");
}
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedItem.Text == "树形显示")
{
this.Panel2.Visible = true;
this.Panel1.Visible = false;
this.ImageButton1.Visible = false;
this.ImageButton2.Visible = false;
this.ImageButton3.Visible = false;
this.ImageButton5.Visible = false;
}
else
{
this.Panel1.Visible = true;
this.Panel2.Visible = false;
}
}
}