240 lines
7.8 KiB
C#
240 lines
7.8 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.BaseInfo
|
|
{
|
|
public partial class RiskLevel : PageBase
|
|
{
|
|
#region 加载页面
|
|
/// <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();
|
|
btnNew.OnClientClick = Window1.GetShowReference("RiskLevelEdit.aspx") + "return false;";
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT RiskLevelId
|
|
, RiskLevel
|
|
, RiskLevelName
|
|
, MinValue
|
|
, MaxValue
|
|
, ControlMeasures
|
|
, Days
|
|
, Remark
|
|
FROM dbo.Base_RiskLevel ";
|
|
SqlParameter[] parameter = null;
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 页索引改变事件
|
|
/// <summary>
|
|
/// 页索引改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 排序
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 分页选择下拉改变事件
|
|
/// <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();
|
|
}
|
|
#endregion
|
|
|
|
#region 弹出编辑窗口关闭事件
|
|
/// <summary>
|
|
/// 弹出编辑窗体关闭事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <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.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string RegisterTypesId = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RiskLevelEdit.aspx?RiskLevelId={0}", RegisterTypesId, "编辑 - ")));
|
|
}
|
|
#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 (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HazardRegisterTypesMenuId, Const.BtnDelete))
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
bool isShow = false;
|
|
if (Grid1.SelectedRowIndexArray.Length == 1)
|
|
{
|
|
isShow = true;
|
|
}
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
if (this.judgementDelete(rowID, isShow))
|
|
{
|
|
var riskLevel = Funs.DB.Base_RiskLevel.FirstOrDefault(x=>x.RiskLevelId==rowID);
|
|
if (riskLevel != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, riskLevel.RiskLevelName, riskLevel.RiskLevelId, BLL.Const.RiskLevelMenuId, BLL.Const.BtnDelete);
|
|
Funs.DB.Base_RiskLevel.DeleteOnSubmit(riskLevel);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否可删除
|
|
/// </summary>
|
|
/// <param name="rowID"></param>
|
|
/// <param name="isShow"></param>
|
|
/// <returns></returns>
|
|
private bool judgementDelete(string rowID, bool isShow)
|
|
{
|
|
string content = string.Empty;
|
|
if (string.IsNullOrEmpty(content))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
if (isShow)
|
|
{
|
|
Alert.ShowInTop(content);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
#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.RiskLevelMenuId);
|
|
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
|
|
}
|
|
} |