tijian_tieying/web/Web/Main/SelectLink.aspx.cs
2025-02-20 12:14:39 +08:00

115 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Main_SelectLink : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ZWL.Common.PublicMethod.CheckSession();
DataBindToGridview("");
}
}
protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e)
{
ZWL.Common.PublicMethod.GridViewRowDataBound(e);
}
protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
{
//保存上一次查询结果
string JJ = "0";
for (int i = 0; i < this.GVData.Rows.Count; i++)
{
Label LabV = (Label)GVData.Rows[i].FindControl("LabVisible");
JJ = JJ + "," + LabV.Text.Trim();
}
DataBindToGridview(JJ);
}
protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
{
DataBindToGridview("");
}
public void DataBindToGridview(string IDList)
{
string sql = "SELECT * FROM ERPLink where show like '%" + TextBox1.Text.Trim() + "%' ORDER BY Id asc";
GVData.DataSource = ZWL.DBUtility.DbHelperSQL.GetDataSet(sql).Tables[0];
GVData.DataBind();
//选中赋值
string userid = ZWL.Common.PublicMethod.GetSessionValue("UserID");
string sql2 = "SELECT linkids FROM ERPLinkUser where userid =" + userid;
object linkids = ZWL.DBUtility.DbHelperSQL.GetSingle(sql2);
if (linkids == null)
return;
string[] linkids2 = linkids.ToString().Split(',');
for (int i = 0; i < GVData.Rows.Count; i++)
{
GridViewRow row = GVData.Rows[i];
CheckBox Chk = (CheckBox)row.FindControl("CheckSelect");
Label LabVis = (Label)row.FindControl("LabVisible");
if (linkids2.Contains(LabVis.Text.ToString()))
{
Chk.Checked = true;
}
}
}
protected void ImageButton100_Click(object sender, ImageClickEventArgs e)
{
string CheckStr = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
if (string.IsNullOrEmpty(CheckStr))
{
Response.Write("<script>alert('请先选择');</script>");
return;
}
string userid = ZWL.Common.PublicMethod.GetSessionValue("UserID");
string sql = "SELECT * FROM ERPLinkUser where userid =" + userid;
string sql2 = "update ERPLinkUser set linkids='" + CheckStr + "' where userid=" + userid;
if (ZWL.DBUtility.DbHelperSQL.GetDataSet(sql).Tables[0].Rows.Count == 0)
{
sql2 = "insert into ERPLinkUser (userid,linkids) values ('" + userid + "','" + CheckStr + "')";
}
int result = ZWL.DBUtility.DbHelperSQL.ExecuteSql(sql2);
if (result == 1)
Response.Write("<script>alert('提交成功');</script>");
else
Response.Write("<script>alert('提交失败');</script>");
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("TreeListAdd.aspx");
}
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 ERPTreeList where ID in (" + IDlist + ")") == -1)
{
Response.Write("<script>alert('删除选中记录时发生错误!请重新登陆后重试!');</script>");
}
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 ImageButton5_Click(object sender, ImageClickEventArgs e)
{
string CheckStr = ZWL.Common.PublicMethod.CheckCbx(this.GVData, "CheckSelect", "LabVisible");
string[] CheckStrArray = CheckStr.Split(',');
Response.Redirect("TreeListModify.aspx?ID=" + CheckStrArray[0].ToString());
}
}