412 lines
14 KiB
C#
412 lines
14 KiB
C#
using BLL;
|
|
using FineUIPro.Web.ZHGL.Plan;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FineUIPro.Web.CQMS.Plan
|
|
{
|
|
public partial class MainPlan : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
// 表头过滤
|
|
//FilterDataRowItem = FilterDataRowItemImplement;
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
//权限按钮方法
|
|
GetButtonPower();
|
|
btnNew.OnClientClick = Window1.GetShowReference("MainPlanEdit.aspx") + "return false;";
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected DataTable insklistData()
|
|
{
|
|
string strSql = @"SELECT ins.MainPlanId,ins.PlanCode,ins.ProjectId,ins.FileName,"
|
|
+ @" ins.CompileDate,ins.State,"
|
|
+ @" u.PersonName as CompileManName"
|
|
+ @" FROM Plan_MainPlan ins"
|
|
+ @" left join Person_Persons u on u.PersonId = ins.CompileMan"
|
|
+ @" where ins.ProjectId=@ProjectId";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return tb;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
|
|
public void BindGrid()
|
|
{
|
|
DataTable tb = insklistData();
|
|
|
|
// 2.获取当前分页数据
|
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|
|
|
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 TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 过滤表头、排序、分页、关闭窗口
|
|
/// <summary>
|
|
/// 过滤表头
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_FilterChange(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
Grid1.PageIndex = e.NewPageIndex;
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
//Grid1.SortDirection = e.SortDirection;
|
|
//Grid1.SortField = e.SortField;
|
|
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 Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
BindGrid();
|
|
string str = this.hdID.Text;
|
|
if (!string.IsNullOrEmpty(str))
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MainPlanEdit.aspx?MainPlanId={0}", str, "查看 - ")));
|
|
}
|
|
this.hdID.Text = string.Empty;
|
|
}
|
|
#endregion
|
|
|
|
#region Grid双击事件
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnMenuModify_Click(null, null);
|
|
}
|
|
#endregion
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 编辑按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuModify_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var ins = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(id);
|
|
|
|
if (ins != null)
|
|
{
|
|
if (ins.State.Equals(Const.MainPlan_Complete))
|
|
{
|
|
Alert.ShowInTop("流程已闭环,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.Plan_MainPlanApprove approve = BLL.CQMS_MainPlanApproveService.GetMainPlanApproveByMainPlanId(id);
|
|
if (approve != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(approve.ApproveMan))
|
|
{
|
|
if (this.CurrUser.PersonId == approve.ApproveMan || CurrUser.PersonId == Const.sysglyId)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MainPlanEdit.aspx?MainPlanId={0}", id, "编辑 - ")));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 批量删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var ins = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(id);
|
|
if (File.Exists(Funs.RootPath+ins.FilePath))
|
|
{
|
|
File.Delete(Funs.RootPath + ins.FilePath);
|
|
|
|
}
|
|
////删除附件表
|
|
BLL.CommonService.DeleteAttachFileById(id);
|
|
BLL.CQMS_MaterialTestService.DeleteMaterialTestById(id);
|
|
BLL.CQMS_NoticeAndSupervisionService.DeleteNoticeAndSupervisionById(id);
|
|
BLL.CQMS_MainPlanApproveService.DeleteMainPlanApprovesByMainPlanId(id);
|
|
BLL.CQMS_MainPlanService.DeleteMainPlanById(id);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, ins.PlanCode, id, BLL.Const.MainPlanMenuId, "删除总包施工质量计划");
|
|
Grid1.DataBind();
|
|
BindGrid();
|
|
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
#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.ProjectId, this.CurrUser.PersonId, BLL.Const.MainPlanMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuModify.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == BLL.Const.MainPlan_ReCompile)
|
|
{
|
|
return "重新编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Compile)
|
|
{
|
|
return "编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit1)
|
|
{
|
|
return "施工经理审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit2)
|
|
{
|
|
return "部门评审小组审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit3)
|
|
{
|
|
return "审核中";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit4)
|
|
{
|
|
return "项目经理批准";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Audit5)
|
|
{
|
|
return "评审小组组长确认";
|
|
}
|
|
else if (state.ToString() == BLL.Const.MainPlan_Complete)
|
|
{
|
|
return "审批完成";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
//<summary>
|
|
//获取办理人姓名
|
|
//</summary>
|
|
//<param name="state"></param>
|
|
//<returns></returns>
|
|
protected string ConvertMan(object MainPlanId)
|
|
{
|
|
if (MainPlanId != null)
|
|
{
|
|
Model.Plan_MainPlanApprove a = BLL.CQMS_MainPlanApproveService.GetMainPlanApproveByMainPlanId(MainPlanId.ToString());
|
|
if (a != null)
|
|
{
|
|
if (a.ApproveMan != null)
|
|
{
|
|
return BLL.Person_PersonsService.GetPersonsNameById(a.ApproveMan);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var ins = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(id);
|
|
|
|
if (ins != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MainPlanView.aspx?MainPlanId={0}", id, "查看 - ")));
|
|
}
|
|
}
|
|
|
|
protected void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
protected void btnRset_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
protected void imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(Grid1.SelectedRowID))
|
|
{
|
|
var ins = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(Grid1.SelectedRowID);
|
|
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/OnlineEditing.aspx?UserId={0}&PCUrl={1}", this.CurrUser.PersonId, ins.FilePath)));
|
|
// PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/IndexOffice.aspx?cmd={0}|CQMSMainPlan", Grid1.SelectedRowID, "查看 -")));
|
|
PageContext.RegisterStartupScript(Window1.GetHideReference());
|
|
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} |