SGGL_SHJ/SGGL/FineUIPro.Web/ZHGL/Plan/ActionPlanList.aspx.cs

355 lines
14 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.ZHGL.Plan
{
public partial class ActionPlanList : 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();
this.btnNew.OnClientClick = Window1.GetShowReference("ActionPlanListEdit.aspx") + "return false;";
ProjectService.InitAllProjectDropDownList(this.drpProject, false);
drpProject.Items.Insert(0, new FineUIPro.ListItem("公司本部", "Company"));
Funs.FineUIPleaseSelect(drpProject, "按项目/公司本部查询");
// 绑定表格
this.BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = "SELECT ActionPlanList.ActionPlanListId,ActionPlanList.ProjectId,Project.ProjectName,ActionPlanListCode,ActionPlanList.ActionPlanListName,ActionPlanList.VersionNo,(CASE ActionPlanList.ProjectType WHEN '1' THEN 'EPC' WHEN '2' THEN 'EPCM' WHEN '3' THEN 'C' WHEN '4' THEN '其他' END ) AS ProjectType,ActionPlanList.ActionPlanListContents,ActionPlanList.CompileMan,Users.PersonName AS CompileManName, ActionPlanList.CompileDate,ActionPlanList.States"
+ @" FROM ActionPlan_ActionPlanList AS ActionPlanList "
+ @" LEFT JOIN Base_Project AS Project ON ActionPlanList.ProjectId=Project.ProjectId "
+ @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON ActionPlanList.ActionPlanListId=FlowOperate.DataId AND FlowOperate.IsClosed <> 1"
+ @" LEFT JOIN Person_Persons AS OperateUser ON FlowOperate.OperaterId=OperateUser.PersonId "
+ @" LEFT JOIN Person_Persons AS Users ON Users.PersonId = ActionPlanList.CompileMan "
+ @" WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (this.drpProject.SelectedValue != BLL.Const._Null)
{
if (this.drpProject.SelectedValue == "Company")
{
strSql += " AND ActionPlanList.ProjectId is null";
}
else
{
strSql += " AND ActionPlanList.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
}
}
if (!string.IsNullOrEmpty(this.txtActionPlanListCode.Text.Trim()))
{
strSql += " AND ActionPlanListCode LIKE @ActionPlanListCode";
listStr.Add(new SqlParameter("@ActionPlanListCode", "%" + this.txtActionPlanListCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtActionPlanListName.Text.Trim()))
{
strSql += " AND ActionPlanListName LIKE @ActionPlanListName";
listStr.Add(new SqlParameter("@ActionPlanListName", "%" + this.txtActionPlanListName.Text.Trim() + "%"));
}
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();
}
#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();
}
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
BLL.LogService.AddSys_Log(this.CurrUser, string.Empty, string.Empty, BLL.Const.OfficeActionPlanListMenuId, Const.BtnQuery);
}
#endregion
#region
/// <summary>
/// 双击事件
/// </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 id = Grid1.SelectedRowID.Split(',')[0];
Model.ActionPlan_ActionPlanList actionPlanList = ActionPlanListService.GetActionPlanListById(id);
if (actionPlanList.States == Const.ActionPlanList_Complete)
{
Alert.ShowInTop("该文件已经审批完成,无法操作,请右键查看!", MessageBoxIcon.Warning);
return;
}
else if (actionPlanList.States == Const.ActionPlanList_Compile)
{
if (actionPlanList.CompileMan == CurrUser.PersonId || CurrUser.PersonId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
}
else
{
Alert.ShowInTop("您不是编制人,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
else if (actionPlanList.States == Const.ActionPlanList_Review || actionPlanList.States == Const.ActionPlanList_Reviewing || actionPlanList.States == Const.ActionPlanList_ReCompile || actionPlanList.States == Const.ActionPlanList_Review2)
{
Model.ActionPlan_ActionPlanListApprove approve = ActionPlanListApproveService.GetActionPlanListApproveByApproveMan(id, CurrUser.PersonId);
if (approve != null || CurrUser.PersonId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
return;
//Response.Redirect("ActionPlanListAudit.aspx?actionPlanListId=" + id);
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", id, "查看 - ")));
}
else
{
if (actionPlanList.CompileMan.Equals(CurrUser.PersonId))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
}
else
{
Alert.ShowInTop("您不是办理用户,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
}
}
#endregion
protected void btnMenuView_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID.Split(',')[0];
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListView.aspx?ActionPlanListId={0}", id)));
}
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
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 getV = BLL.ActionPlanListService.GetActionPlanListById(rowID);
if (getV != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, getV.ActionPlanListCode, getV.ActionPlanListId, BLL.Const.OfficeActionPlanListMenuId, Const.BtnDelete);
BLL.ActionPlanListService.DeleteActionPlanListById(rowID);
}
}
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete(string id, 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()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.OfficeActionPlanListMenuId);
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>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("安全实施计划" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 5000;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
#endregion
/// <summary>
/// 把办理人转换代号为文字形式
/// </summary>
/// <param name="ActionPlanListId"></param>
/// <returns></returns>
///
public static string ConvertApproveMan(object ActionPlanListId)
{
string name = string.Empty;
if (ActionPlanListId != null)
{
var approves = BLL.ActionPlanListApproveService.GetActionPlanListApprovesNotHandleList(ActionPlanListId.ToString());
foreach (var item in approves)
{
name += BLL.Person_PersonsService.GetPersonsNameById(item.ApproveMan) + ",";
}
if (!string.IsNullOrEmpty(name))
{
name = name.Substring(0, name.Length - 1);
}
}
return name;
}
}
}