customergroup.aspx.cs
来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 253 行
CS
253 行
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 Customermanangement_Addgroup : System.Web.UI.Page
{
private DataAccess.TableAccessor.UserConporation userCorporation;
private Security.RulesManagement rulesManagement;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
#region security
rulesManagement = new Security.RulesManagement();
HttpCookie rolesCookie = Request.Cookies["RolesID"];
int rolesID = 0;
int areaID = 0;
try
{
//rolesID = int.Parse(rolesCookie.Value);
rolesID = int.Parse(Session["RolesID"].ToString());
areaID = int.Parse(Request.QueryString["areaID"].ToString());
string uaID = Request.QueryString[0].ToString();
}
catch
{
areaID = 0;
// this.cbArea.SelectedValue = areaID.ToString();
//string areaName = Request.QueryString["areaName"].ToString();
// Response.Close();
}
if (rulesManagement.ValidUserRules(rolesID, 5))
{
btnAdd.Visible = rulesManagement.ValidUserRules(rolesID, 6);
btnUpdate.Visible = rulesManagement.ValidUserRules(rolesID, 8);
btnDel.Visible = rulesManagement.ValidUserRules(rolesID, 7);
//FillGrid(areaID);
this.Panel1.Visible = false;
if (areaID != 0)
{
FillGrid(areaID);
}
FillComBox();
if (areaID == 0 ||areaID ==1)
{
this.btnAdd.Visible = false;
this.btnUpdate.Visible = false;
this.btnDel.Visible = false;
}
this.cbArea.SelectedValue = areaID.ToString();
}
else
{
Response.Redirect("../None.aspx");
}
#endregion
}
}
private void FillComBox()
{
DataAccess.TableAccessor.CountyVillage countyVillage = new DataAccess.TableAccessor.CountyVillage();
cbArea.DataSource = countyVillage.GetcoustomertypeInfo();
cbArea.DataTextField = "TypeName";
cbArea.DataValueField = "TypeID";
cbArea.DataBind();
cbArea.Items.Insert(0, "");
cbArea.Items.Insert(1, "全部");
}
private void FillGrid(int areaID)
{
this.Panel1.Visible = true;
gridView.Columns[2].Visible = true;
gridView.Columns[3].Visible = true;
if (areaID == 0 ||areaID ==1)
{
this.btnAdd.Visible = false;
this.btnUpdate.Visible = false;
this.btnDel.Visible = false;
}
else
{
this.btnUpdate.Visible = true;
this.btnAdd.Visible = true;
this.btnDel.Visible = true;
}
//this.Label1.Visible = false;
userCorporation = new DataAccess.TableAccessor.UserConporation();
DataTable dt = userCorporation.GetMostGroupByTypeID(areaID);
dt.Columns.Add("UserDefineID", typeof(int));
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["UserDefineID"] = i + 1;
}
if (dt.Rows.Count == 0)
{
this.Panel1.Visible = false;
}
else
this.Panel1.Visible = true;
gridView.DataSource = dt;
gridView.DataBind();
gridView.Columns[2].Visible = false;
gridView.Columns[3].Visible = false;
//security
rulesManagement = new Security.RulesManagement();
HttpCookie rolesCookie = Request.Cookies["RolesID"];
int rolesID = int.Parse(rolesCookie.Value);
btnAdd.Visible = rulesManagement.ValidUserRules(rolesID, 6);
btnUpdate.Visible = rulesManagement.ValidUserRules(rolesID, 8);
btnDel.Visible = rulesManagement.ValidUserRules(rolesID, 7);
}
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
this.FillGrid(1);
//btnAdd.Visible = false;
//btnUpdate.Visible = false;
//btnDel.Visible = false;
}
private string CheckUserChoose(GridView grid)
{
grid.Columns[2].Visible = true;
string checkValue = "";
int checkCount = 0;
for (int i = 0; i < grid.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)grid.Rows[i].FindControl("chk");
if (ckb.Checked)
{
checkValue = grid.Rows[i].Cells[2].Text;
checkCount++;
}
}
if (checkCount > 1)
{
//grid.Columns[2].Visible = false;
return "00";
}
else if (checkCount == 0)
{
//grid.Columns[2].Visible = false;
return "00";
}
else
{
//grid.Columns[2].Visible = false;
return checkValue;
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
string Name = cbArea.SelectedItem.Text;
string areaName = HttpUtility.UrlEncode(Name);
string gorUrl = string.Format("<script>window.location.href='Addcustomergroup.aspx?uaID=0&areaID={0}&N={1}'</script>", cbArea.SelectedValue, areaName);
Response.Write(gorUrl);
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
string userChooseValue = "";
userChooseValue = CheckUserChoose(gridView);
if (userChooseValue != "00")
{
string goUrl = string.Format("<script>window.location.href = 'UpdateGroup.aspx?Corporation=1&uaID={0}&areaID={1}'</script>", userChooseValue, cbArea.SelectedValue);
Response.Write(goUrl);
}
else
{
Response.Write("<script language='javascript'>alert('更新操作只能选择一行数据!');</script>");
string goUrl = string.Format("<script>window.location.href = 'Customergroup.aspx?areaID={0}'</script>", cbArea.SelectedValue);
Response.Write(goUrl);
}
}
protected void btnDel_Click(object sender, EventArgs e)
{
int i = int.Parse(this.gridView.Rows.Count.ToString());
string[] userChooseValue = new string[i];
int a = 0;
for (int j = 0; j < i; j++)
{
CheckBox ckb = (CheckBox)this.gridView.Rows[j].FindControl("chk");
if (ckb.Checked)
{
userChooseValue[a] = this.gridView.Rows[j].Cells[02].Text;
a++;
}
}
string str = "";
for (int b = 0; b < a; b++)
{
str += "&SystemID" + b + "=" + userChooseValue[b];
}
//i = +a + int.Parse(str);
i = a;// +Int32.Parse(str);
try
{
}
catch
{ }
string urlStr = string.Format("<script>window.location.href ='DelGroup.aspx?i={0}&areaID={1}{2}'</script>", i, cbArea.SelectedValue, str);
Response.Write(urlStr);
}
protected void cbArea_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbArea.SelectedValue != "")
{
if (cbArea.SelectedItem.Text != "全部")
{
FillGrid(int.Parse(cbArea.SelectedItem.Value));
}
else
{
FillGrid(1);
btnAdd.Visible = false;
btnUpdate.Visible = false;
btnDel.Visible = false;
}
}
else
{
string goUrl = string.Format("<script>window.location.href = 'CorporationList.aspx?areaID={0}'</script>",cbArea.SelectedValue);
Response.Write(goUrl);
}
}
protected void gridView_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?