424 lines
15 KiB
C#
424 lines
15 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using BLL;
|
|||
|
|
|||
|
namespace FineUIPro.Web.common.Resource
|
|||
|
{
|
|||
|
public partial class LawRegulationList : PageBase
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
///新建时生成新的法律法规编号
|
|||
|
/// </summary>
|
|||
|
public string NewLawRegulationId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["NewLawRegulationId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["NewLawRegulationId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
// 表头过滤
|
|||
|
FilterDataRowItem = FilterDataRowItemImplement;
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!");
|
|||
|
btnDelete.ConfirmText = String.Format("你确定要删除选中的 <b><script>{0}</script></b> 行数据吗?", Grid1.GetSelectedCountReference());
|
|||
|
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
// 绑定表格
|
|||
|
BindGrid("1","1");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
private void BindGrid(string type, string isModel)
|
|||
|
{
|
|||
|
string strSql = "select * , '" + Const.LawRegulationListMenuId + "' as menuId, (case when IsModel='1' then '内置项' when IsModel='2' then '已审核' else '未审核' end) as ModelName from Common_LawRegulation where Type=@Type";
|
|||
|
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@Type", type));
|
|||
|
|
|||
|
if (isModel == "1")
|
|||
|
{
|
|||
|
strSql += " AND (IsModel= '1' or IsModel='2')";
|
|||
|
}
|
|||
|
|
|||
|
else
|
|||
|
{
|
|||
|
strSql += " AND IsModel= '0'";
|
|||
|
}
|
|||
|
strSql += " order by LawRegulationCode";
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
|
|||
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
|
|||
|
// 获取当前分页数据
|
|||
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
|||
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
Grid1.DataSource = table;
|
|||
|
Grid1.DataBind();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#region 过滤表头
|
|||
|
/// <summary>
|
|||
|
/// 过滤表头
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据表头信息过滤列表数据
|
|||
|
/// </summary>
|
|||
|
/// <param name="sourceObj"></param>
|
|||
|
/// <param name="fillteredOperator"></param>
|
|||
|
/// <param name="fillteredObj"></param>
|
|||
|
/// <param name="column"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column)
|
|||
|
{
|
|||
|
bool valid = false;
|
|||
|
if (column == "LawRegulationName")
|
|||
|
{
|
|||
|
string sourceValue = sourceObj.ToString();
|
|||
|
string fillteredValue = fillteredObj.ToString();
|
|||
|
if (fillteredOperator == "equal" && sourceValue == fillteredValue)
|
|||
|
{
|
|||
|
valid = true;
|
|||
|
}
|
|||
|
else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
|
|||
|
{
|
|||
|
valid = true;
|
|||
|
}
|
|||
|
}
|
|||
|
return valid;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 点击TreeView
|
|||
|
/// <summary>
|
|||
|
/// 点击TreeView
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void tvType_NodeCommand(object sender, TreeCommandEventArgs e)
|
|||
|
{
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 页索引改变事件
|
|||
|
/// <summary>
|
|||
|
/// 页索引改变事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|||
|
{
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 排序
|
|||
|
/// <summary>
|
|||
|
/// 排序
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|||
|
{
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
#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);
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|||
|
{
|
|||
|
string rowID = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|||
|
Model.Common_LawRegulation law = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(rowID);
|
|||
|
|
|||
|
if (e.CommandName == "Delete")
|
|||
|
{
|
|||
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.LawRegulationListMenuId, Const.BtnDelete))
|
|||
|
{
|
|||
|
if (law.IsModel == "1")
|
|||
|
{
|
|||
|
ShowNotify("内置项无法删除");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BLL.AttachFileService.DeleteAttachFile(BLL.Funs.RootPath, rowID, Const.LawRegulationListMenuId);
|
|||
|
BLL.Common_LawRegulationService.DeleteLawRegulation(rowID);
|
|||
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除法律法规清单信息");
|
|||
|
ShowNotify("删除数据成功!(表格数据已重新绑定)");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|||
|
}
|
|||
|
}
|
|||
|
if (e.CommandName == "check")
|
|||
|
{
|
|||
|
law.IsModel = "2";
|
|||
|
BLL.Common_LawRegulationService.UpdateLawRegulation(law);
|
|||
|
}
|
|||
|
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void btnNew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
string type = "1";
|
|||
|
if (this.tvType.SelectedNode != null)
|
|||
|
{
|
|||
|
type = tvType.SelectedNodeID.Substring(0, 1);
|
|||
|
}
|
|||
|
|
|||
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.LawRegulationListMenuId, Const.BtnAdd))
|
|||
|
{
|
|||
|
NewLawRegulationId = SQLHelper.GetNewID(typeof(Model.Common_LawRegulation));
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("EditLawRegulation.aspx?newLawRegulationId={0}&type={1}", NewLawRegulationId, type, "新增 - ")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.LawRegulationListMenuId, Const.BtnModify))
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInParent("请至少选择一条记录!");
|
|||
|
return;
|
|||
|
}
|
|||
|
string rowId = Grid1.SelectedRowID;
|
|||
|
Model.Common_LawRegulation law = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(rowId);
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("EditLawRegulation.aspx?lawRegulationId={0}&type={1}", rowId, law.Type, "修改 - ")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|||
|
{
|
|||
|
btnEdit_Click(null, null);
|
|||
|
}
|
|||
|
|
|||
|
protected void btnDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.LawRegulationListMenuId, Const.BtnDelete))
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|||
|
{
|
|||
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|||
|
{
|
|||
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|||
|
Model.Common_LawRegulation law = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(rowID);
|
|||
|
|
|||
|
if (law != null && law.IsModel != "1")
|
|||
|
{
|
|||
|
BLL.AttachFileService.DeleteAttachFile(BLL.Funs.RootPath, rowID, Const.LawRegulationListMenuId);
|
|||
|
BLL.Common_LawRegulationService.DeleteLawRegulation(rowID);
|
|||
|
BLL.Sys_LogService.AddLog(Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除法律法规清单信息");
|
|||
|
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
|
|||
|
ShowNotify("删除数据成功!(表格数据已重新绑定)");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("内置项不能删除");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowNotify("您没有这个权限,请与管理员联系!");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
// 关闭窗体时未提交则删除已上传的附件
|
|||
|
if (!string.IsNullOrEmpty(NewLawRegulationId))
|
|||
|
{
|
|||
|
var q = BLL.Common_LawRegulationService.GetLawRegulationByLawRegulationId(NewLawRegulationId);
|
|||
|
if (q == null)
|
|||
|
{
|
|||
|
BLL.AttachFileService.DeleteAttachFile(BLL.Funs.RootPath, NewLawRegulationId, Const.LawRegulationListMenuId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (this.tvType.SelectedNode != null && this.tvType.SelectedNodeID.Length > 1)
|
|||
|
{
|
|||
|
BindGrid(tvType.SelectedNode.ParentNode.NodeID, tvType.SelectedNodeID.Substring(1));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
BindGrid("1", "1");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 把状态转换代号为文字形式
|
|||
|
/// </summary>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertGrade(object LawRegulationGrade)
|
|||
|
{
|
|||
|
if (LawRegulationGrade != null)
|
|||
|
{
|
|||
|
if (LawRegulationGrade.ToString() == "0")
|
|||
|
{
|
|||
|
return "未选择";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "1")
|
|||
|
{
|
|||
|
return "宪法";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "2")
|
|||
|
{
|
|||
|
return "法律";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "3")
|
|||
|
{
|
|||
|
return "行政法规";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "4")
|
|||
|
{
|
|||
|
return "规章";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "5")
|
|||
|
{
|
|||
|
return "自治/单行条例";
|
|||
|
}
|
|||
|
else if (LawRegulationGrade.ToString() == "6")
|
|||
|
{
|
|||
|
return "经济特区法规";
|
|||
|
}
|
|||
|
}
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 行绑定
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|||
|
{
|
|||
|
DataRowView row = e.DataItem as DataRowView;
|
|||
|
LinkButtonField lbtnCheck = Grid1.FindControl("lbtnCheck") as LinkButtonField;
|
|||
|
RenderField modelName = Grid1.FindControl("ModelName") as RenderField;
|
|||
|
if (row["IsModel"].ToString() == "1")
|
|||
|
{
|
|||
|
|
|||
|
lbtnCheck.Hidden = true;
|
|||
|
modelName.Hidden = false;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
else if (row["IsModel"].ToString() == "2")
|
|||
|
{
|
|||
|
lbtnCheck.Hidden = true;
|
|||
|
modelName.Hidden = false;
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
lbtnCheck.Hidden = false;
|
|||
|
modelName.Hidden = true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|