374 lines
15 KiB
C#
374 lines
15 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ZHGL.Plan
|
|
{
|
|
public partial class MainPlanEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string MainPlanId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["MainPlanId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["MainPlanId"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string State
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["State"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["State"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
MainPlanId = Request.Params["MainPlanId"];
|
|
this.HideOptions.Hidden = true;
|
|
this.rblIsAgree.Hidden = true;
|
|
this.drpPerson.DataTextField = "PersonName";
|
|
this.drpPerson.DataValueField = "PersonId";
|
|
this.drpPerson.DataSource = (from x in Funs.DB.Person_Persons where x.UnitId == Const.UnitId_SEDIN && x.DepartId == Const.Depart_constructionId select x).ToList();
|
|
this.drpPerson.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpPerson);
|
|
if (!string.IsNullOrEmpty(MainPlanId))
|
|
{
|
|
Model.Plan_MainPlan MainPlan = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(MainPlanId);
|
|
hdId.Text = this.MainPlanId;
|
|
txtPlanCode.Text = MainPlan.PlanCode;
|
|
txtFileName.Text = MainPlan.FileName;
|
|
List<string> list = BLL.CQMS_MainPlanApproveService.GetAudit3PersonIds(MainPlanId);
|
|
if (list.Count > 0)
|
|
{
|
|
this.drpPerson.SelectedValueArray = list.ToArray();
|
|
}
|
|
gvApprove.DataSource = BLL.CQMS_MainPlanApproveService.getListData(this.MainPlanId);
|
|
gvApprove.DataBind();
|
|
if (!string.IsNullOrEmpty(MainPlan.State))
|
|
{
|
|
State = MainPlan.State;
|
|
}
|
|
else
|
|
{
|
|
State = BLL.Const.MainPlan_Compile;
|
|
this.HideOptions.Hidden = true;
|
|
this.rblIsAgree.Hidden = true;
|
|
}
|
|
|
|
if (State == BLL.Const.MainPlan_Audit2)
|
|
{
|
|
this.next.Hidden = true;
|
|
this.HideOptions.Visible = false;
|
|
this.rblIsAgree.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
this.txtOpinions.Text = "同意";
|
|
this.HideOptions.Hidden = false;
|
|
this.rblIsAgree.Hidden = false;
|
|
}
|
|
if (State == BLL.Const.MainPlan_Complete || !string.IsNullOrEmpty(Request.Params["see"]))
|
|
{
|
|
this.btnSave.Visible = false;
|
|
this.btnSubmit.Visible = false;
|
|
this.next.Hidden = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间转换
|
|
/// </summary>
|
|
/// <param name="date"></param>
|
|
/// <returns></returns>
|
|
public string ConvertDate(object date)
|
|
{
|
|
if (date != null)
|
|
{
|
|
return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date));
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <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 "";
|
|
}
|
|
|
|
protected void imgBtnFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(hdId.Text))
|
|
{
|
|
hdId.Text = SQLHelper.GetNewID();
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=1&toKeyId={0}&path=FileUpload/CQMS/Plan&menuId={1}", hdId.Text, BLL.Const.MainPlanMenuId)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同意审核单选框改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.RadioButtonList1.SelectedValue.Equals("true"))
|
|
{
|
|
this.txtOpinions.Text = "同意";
|
|
}
|
|
else
|
|
{
|
|
this.txtOpinions.Text = string.Empty;
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
SaveMainPlan("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void SaveMainPlan(string saveType)
|
|
{
|
|
Model.Plan_MainPlan MainPlan = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(MainPlanId);
|
|
if (!string.IsNullOrEmpty(MainPlanId))
|
|
{
|
|
MainPlan.MainPlanId = MainPlanId;
|
|
if (saveType == "submit")
|
|
{
|
|
if (MainPlan.State == Const.MainPlan_Audit2)
|
|
{
|
|
Model.Plan_MainPlanApprove approve1 = new Model.Plan_MainPlanApprove();
|
|
approve1.MainPlanId = MainPlan.MainPlanId;
|
|
approve1.ApproveMan = this.CurrUser.PersonId;
|
|
approve1.ApproveType = Const.MainPlan_Audit2;
|
|
approve1.ApproveDate = DateTime.Now;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve1);
|
|
foreach (var item in this.drpPerson.SelectedValueArray)
|
|
{
|
|
if (item != Const._Null)
|
|
{
|
|
Model.Plan_MainPlanApprove approve = new Model.Plan_MainPlanApprove();
|
|
approve.MainPlanId = MainPlan.MainPlanId;
|
|
approve.ApproveMan = item;
|
|
approve.ApproveType = Const.MainPlan_Audit3;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve);
|
|
}
|
|
}
|
|
MainPlan.State = Const.MainPlan_Audit3;
|
|
}
|
|
else if (MainPlan.State == Const.MainPlan_Audit3)
|
|
{
|
|
Model.Plan_MainPlanApprove approve = BLL.CQMS_MainPlanApproveService.GetAudit3(MainPlanId, this.CurrUser.PersonId);
|
|
if (approve != null)
|
|
{
|
|
approve.ApproveDate = DateTime.Now;
|
|
approve.ApproveIdea = this.txtOpinions.Text.Trim();
|
|
approve.IsAgree = Convert.ToBoolean(this.RadioButtonList1.SelectedValue);
|
|
BLL.CQMS_MainPlanApproveService.UpdateMainPlanApprove(approve);
|
|
}
|
|
List<Model.Plan_MainPlanApprove> approve3s = BLL.CQMS_MainPlanApproveService.GetAudit3s(MainPlanId); //审批集合
|
|
List<Model.Plan_MainPlanApprove> approve3Ends = BLL.CQMS_MainPlanApproveService.GetAudit3Ends(MainPlanId); //审批完成集合
|
|
int okNum = approve3Ends.Count(x => x.IsAgree == true); //审批同意数量
|
|
if (approve3s.Count == approve3Ends.Count)
|
|
{
|
|
if (approve3s.Count == okNum) //全部同意,转至项目经理批准
|
|
{
|
|
var projectManage = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.ProjectId == MainPlan.ProjectId && x.States == Const.ProjectPersonStates_1 && x.RoleIds.Contains(Const.ProjectManager));
|
|
if (projectManage != null)
|
|
{
|
|
Model.Plan_MainPlanApprove approveP = new Model.Plan_MainPlanApprove();
|
|
approveP.MainPlanId = MainPlan.MainPlanId;
|
|
approveP.ApproveMan = projectManage.PersonId;
|
|
approveP.ApproveType = Const.MainPlan_Audit4;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approveP);
|
|
}
|
|
MainPlan.State = Const.MainPlan_Audit4;
|
|
}
|
|
else //有人不同意,质量经理(编制人)修改
|
|
{
|
|
Model.Plan_MainPlanApprove approveR = new Model.Plan_MainPlanApprove();
|
|
approveR.MainPlanId = MainPlan.MainPlanId;
|
|
approveR.ApproveMan = MainPlan.CompileMan;
|
|
approveR.ApproveType = Const.MainPlan_ReCompile;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approveR);
|
|
MainPlan.State = Const.MainPlan_ReCompile;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.Plan_MainPlanApprove approve1 = BLL.CQMS_MainPlanApproveService.GetMainPlanApproveByMainPlanId(MainPlanId);
|
|
approve1.ApproveDate = DateTime.Now;
|
|
approve1.ApproveIdea = this.txtOpinions.Text.Trim();
|
|
approve1.IsAgree = Convert.ToBoolean(this.RadioButtonList1.SelectedValue);
|
|
BLL.CQMS_MainPlanApproveService.UpdateMainPlanApprove(approve1);
|
|
if (this.RadioButtonList1.SelectedValue == "true")
|
|
{
|
|
var cnApprove = BLL.CQMS_MainPlanApproveService.GetAudit1(MainPlanId);
|
|
if (cnApprove != null)
|
|
{
|
|
Model.Plan_MainPlanApprove approveP = new Model.Plan_MainPlanApprove();
|
|
approveP.MainPlanId = MainPlan.MainPlanId;
|
|
approveP.ApproveMan = cnApprove.ApproveMan;
|
|
approveP.ApproveType = Const.MainPlan_Audit1;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approveP);
|
|
}
|
|
MainPlan.State = Const.MainPlan_Audit1;
|
|
}
|
|
else
|
|
{
|
|
Model.Plan_MainPlanApprove approveR = new Model.Plan_MainPlanApprove();
|
|
approveR.MainPlanId = MainPlan.MainPlanId;
|
|
approveR.ApproveMan = MainPlan.CompileMan;
|
|
approveR.ApproveType = Const.MainPlan_ReCompile;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approveR);
|
|
MainPlan.State = Const.MainPlan_ReCompile;
|
|
}
|
|
}
|
|
}
|
|
CQMS_MainPlanService.UpdateMainPlan(MainPlan);
|
|
}
|
|
LogService.AddSys_Log(CurrUser, MainPlan.PlanCode, MainPlan.MainPlanId, Const.MainPlanMenuId, "修改总包施工质量计划");
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
}
|
|
/// <summary>
|
|
/// 表格数据验证
|
|
/// </summary>
|
|
private bool validate()
|
|
{
|
|
bool res = false;
|
|
string err = string.Empty;
|
|
var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.hdId.Text);
|
|
if (att == null)
|
|
{
|
|
err += "请上传文件!";
|
|
}
|
|
if (this.drpPerson.SelectedItemArray.Length == 1 && this.drpPerson.SelectedValue == Const._Null)
|
|
{
|
|
err += "请选择评审人员!";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
SaveMainPlan("submit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string GetStringByArray(string[] array)
|
|
{
|
|
string str = string.Empty;
|
|
foreach (var item in array)
|
|
{
|
|
if (item != BLL.Const._Null)
|
|
{
|
|
str += item + ",";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(str))
|
|
{
|
|
str = str.Substring(0, str.LastIndexOf(","));
|
|
}
|
|
return str;
|
|
}
|
|
}
|
|
} |