209 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			209 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| namespace FineUIPro.Web.HSSE.Resources
 | |
| {
 | |
|     using System;
 | |
|     using System.Collections.Generic;
 | |
|     using System.Data;
 | |
|     using System.Data.SqlClient;
 | |
|     using System.Linq;
 | |
|     using BLL;
 | |
| 
 | |
|     public partial class SignManage : PageBase
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 加载页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 Funs.DropDownPageSize(this.ddlPageSize);
 | |
|                 ////权限按钮方法
 | |
|                 this.GetButtonPower();
 | |
|                 this.btnNew.OnClientClick = Window1.GetShowReference("SignManageEdit.aspx") + "return false;";
 | |
|                 if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
 | |
|                 {
 | |
|                     Grid1.PageSize = this.CurrUser.PageSize.Value;
 | |
|                 } 
 | |
|                 this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | |
|                 this.drpSignType.DataTextField = "ConstText";
 | |
|                 this.drpSignType.DataValueField = "ConstValue";
 | |
|                 this.drpSignType.DataSource = BLL.ConstValue.drpConstItemList(ConstValue.Group_SignType);
 | |
|                 this.drpSignType.DataBind();
 | |
|                 Funs.FineUIPleaseSelect(this.drpSignType);
 | |
|                 // 绑定表格
 | |
|                 this.BindGrid();
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 绑定数据
 | |
|         /// </summary>
 | |
|         private void BindGrid()
 | |
|         {
 | |
|             string strSql = @"SELECT SignManage.SignManageId,SignManage.SignName,SignManage.SignCode,SignManage.SignLen,SignManage.SignWide,SignManage.SignHigh,SignManage.SignThick,SignManage.Material,SignManage.SignArea,SignManage.SignType,Const.ConstText AS SignTypeName,SignManage.SignImage,SignManage.SignUrl"
 | |
|                            + @" FROM Resources_SignManage AS SignManage"
 | |
|                            + @" LEFT JOIN Sys_Const AS Const ON Const.ConstValue=SignManage.SignType AND Const.GroupId='"+BLL.ConstValue.Group_SignType+"' WHERE 1=1 ";
 | |
|             List<SqlParameter> listStr = new List<SqlParameter>();      
 | |
|             if (!string.IsNullOrEmpty(this.txtSignCode.Text.Trim()))
 | |
|             {
 | |
|                 strSql += " AND SignManage.SignName LIKE @SignName";
 | |
|                 listStr.Add(new SqlParameter("@SignName", "%" + this.txtSignCode.Text.Trim() + "%"));
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.drpSignType.SelectedValue) && this.drpSignType.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 strSql += " AND SignManage.SignType LIKE @SignType";
 | |
|                 listStr.Add(new SqlParameter("@SignType", this.drpSignType.SelectedValue));
 | |
|             }
 | |
| 
 | |
|             SqlParameter[] parameter = listStr.ToArray();
 | |
|             DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
 | |
|             Grid1.RecordCount = tb.Rows.Count;
 | |
|             var table = this.GetPagedDataTable(Grid1, tb);
 | |
|             Grid1.DataSource = table;
 | |
|             Grid1.DataBind();
 | |
|         }
 | |
| 
 | |
|         #region 查询
 | |
|         /// <summary>
 | |
|         /// 查询
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void TextBox_TextChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             this.BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 获取按钮权限
 | |
|         /// <summary>
 | |
|         /// 获取按钮权限
 | |
|         /// </summary>
 | |
|         /// <param name="button"></param>
 | |
|         /// <returns></returns>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SignManageMenuId);
 | |
|             if (buttonList.Count() > 0)
 | |
|             {
 | |
|                 if (buttonList.Contains(BLL.Const.BtnAdd))
 | |
|                 {
 | |
|                     this.btnNew.Hidden = false;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnModify))
 | |
|                 {
 | |
|                     this.btnMenuEdit.Hidden = false;
 | |
|                 }
 | |
|                 if (buttonList.Contains(BLL.Const.BtnDelete))
 | |
|                 {
 | |
|                     this.btnMenuDelete.Hidden = false;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region  删除数据
 | |
|         /// <summary>
 | |
|         /// 右键删除事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuDelete_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.DeleteData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 删除方法
 | |
|         /// </summary>
 | |
|         private void DeleteData()
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length > 0)
 | |
|             {
 | |
|                 foreach (int rowIndex in Grid1.SelectedRowIndexArray)
 | |
|                 {
 | |
|                     string rowID = Grid1.DataKeys[rowIndex][0].ToString();
 | |
|                     var newSignManage = BLL.SignManageService.GetSignManageBySignManageId(rowID);
 | |
|                     if (newSignManage != null)
 | |
|                     {
 | |
|                         BLL.LogService.AddSys_Log(this.CurrUser, newSignManage.SignCode, newSignManage.SignManageId, BLL.Const.SignManageMenuId, BLL.Const.BtnModify);
 | |
|                         BLL.SignManageService.DeleteSignManage(rowID);
 | |
|                     }
 | |
|                 }
 | |
| 
 | |
|                 BindGrid();
 | |
|                 ShowNotify("删除数据成功!");
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 分页
 | |
|         /// <summary>
 | |
|         /// 分页
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 分页显示条数下拉框
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | |
|             BindGrid();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 排序
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | |
|         {
 | |
|             BindGrid();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         /// <summary>
 | |
|         /// Grid行双击事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 右键编辑事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnMenuEdit_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             this.EditData();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 编辑数据方法
 | |
|         /// </summary>
 | |
|         private void EditData()
 | |
|         {
 | |
|             if (Grid1.SelectedRowIndexArray.Length == 0)
 | |
|             {
 | |
|                 Alert.ShowInParent("请至少选择一条记录!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             string Id = Grid1.SelectedRowID;
 | |
|             PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SignManageEdit.aspx?SignManageId={0}", Id, "编辑 - ")));
 | |
|         }
 | |
|     }
 | |
| } |