468 lines
18 KiB
C#
468 lines
18 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.CQMS.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.drpHandleType.DataTextField = "Text";
|
|
this.drpHandleType.DataValueField = "Value";
|
|
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.Audit.Hidden = false;
|
|
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_Complete.ToString())
|
|
{
|
|
drpHandleType.DataSource = BLL.CQMS_MainPlanService.GetDHandleTypeByState(State, MainPlanId);
|
|
drpHandleType.DataBind();
|
|
}
|
|
|
|
if (State == BLL.Const.MainPlan_Compile || State == BLL.Const.MainPlan_ReCompile)
|
|
{
|
|
this.HideOptions.Visible = false;
|
|
this.rblIsAgree.Visible = false;
|
|
this.drpHandleMan.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
this.HideOptions.Hidden = false;
|
|
this.rblIsAgree.Hidden = false;
|
|
}
|
|
if (State == Const.MainPlan_Audit2)
|
|
{
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
if (State == BLL.Const.MainPlan_Complete || !string.IsNullOrEmpty(Request.Params["see"]))
|
|
{
|
|
this.btnSave.Visible = false;
|
|
this.btnSubmit.Visible = false;
|
|
this.next.Hidden = true;
|
|
}
|
|
drpHandleType_SelectedIndexChanged(null, null);
|
|
}
|
|
else
|
|
{
|
|
string prefix = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId) + "-ZBJH-";
|
|
txtPlanCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "Plan_MainPlan", "PlanCode", this.CurrUser.LoginProjectId, prefix);
|
|
txtFileName.Text = "总包施工质量计划";
|
|
drpHandleType.DataSource = BLL.CQMS_MainPlanService.GetDHandleTypeByState(BLL.Const.MainPlan_Compile,string.Empty);
|
|
drpHandleType.DataBind();
|
|
drpHandleType_SelectedIndexChanged(null, null);
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
string State = BLL.CQMS_MainPlanService.GetMainPlanByMainPlanId(this.MainPlanId).State;
|
|
if (this.RadioButtonList1.SelectedValue.Equals("true"))
|
|
{
|
|
if (State == Const.MainPlan_Audit1)
|
|
{
|
|
var auditApproves = Funs.DB.Plan_MainPlanApprove.FirstOrDefault(x => x.MainPlanId == MainPlanId && x.ApproveType == Const.MainPlan_Audit3);
|
|
if (auditApproves == null) //未进入小组评审
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(this.drpHandleMan);
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false);
|
|
}
|
|
}
|
|
if (State == Const.MainPlan_Audit4)
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(this.drpHandleMan);
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
this.drpHandleType.SelectedIndex = 0;
|
|
if (State == Const.MainPlan_Audit2)
|
|
{
|
|
this.drpHandleMan.SelectedIndex = 2;
|
|
}
|
|
else
|
|
{
|
|
this.drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(drpHandleMan);
|
|
this.drpHandleType.SelectedIndex = 1;
|
|
ListItem item = new ListItem();
|
|
var user = BLL.Person_PersonsService.GetPerson_PersonsById(BLL.CQMS_MainPlanApproveService.GetAuditMan(this.MainPlanId, BLL.Const.MainPlan_Compile).ApproveMan);
|
|
item.Value = user.PersonId;
|
|
item.Text = user.PersonName;
|
|
this.drpHandleMan.Items.Add(item);
|
|
this.drpHandleMan.SelectedIndex = 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 办理步骤下拉框改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.drpHandleMan.Items.Clear();
|
|
Funs.FineUIPleaseSelect(this.drpHandleMan);
|
|
if (this.drpHandleType.SelectedValue == BLL.Const.MainPlan_Complete || this.drpHandleType.SelectedValue == BLL.Const.MainPlan_Audit2)
|
|
{
|
|
this.drpHandleMan.Enabled = false;
|
|
}
|
|
else if (this.drpHandleType.SelectedValue == BLL.Const.MainPlan_ReCompile)
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
string userId = (from x in Funs.DB.Plan_MainPlanApprove where x.MainPlanId == MainPlanId && x.ApproveType == BLL.Const.MainPlan_Compile select x.ApproveMan).First();
|
|
ListItem lis = new ListItem(BLL.Person_PersonsService.GetPersonsNameById(userId), userId);
|
|
this.drpHandleMan.Items.Add(lis);
|
|
this.drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
else if (this.drpHandleType.SelectedValue == BLL.Const.MainPlan_Audit5)
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
string userId = (from x in Funs.DB.Plan_MainPlanApprove where x.MainPlanId == MainPlanId && x.ApproveType == BLL.Const.MainPlan_Audit2 select x.ApproveMan).First();
|
|
ListItem lis = new ListItem(BLL.Person_PersonsService.GetPersonsNameById(userId), userId);
|
|
this.drpHandleMan.Items.Add(lis);
|
|
this.drpHandleMan.SelectedIndex = 1;
|
|
}
|
|
else
|
|
{
|
|
this.drpHandleMan.Enabled = true;
|
|
if (this.drpHandleType.SelectedValue == BLL.Const.MainPlan_Audit1)
|
|
{
|
|
SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false);
|
|
}
|
|
else
|
|
{
|
|
SitePerson_PersonService.InitProjectUserListByProjectUnitTypeDropDownList(drpHandleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_1, false);
|
|
}
|
|
this.drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
SaveMainPlan("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void SaveMainPlan(string saveType)
|
|
{
|
|
Model.Plan_MainPlan MainPlan = new Model.Plan_MainPlan();
|
|
MainPlan.ProjectId = this.CurrUser.LoginProjectId;
|
|
MainPlan.PlanCode = this.txtPlanCode.Text.Trim();
|
|
MainPlan.FileName = this.txtFileName.Text.Trim();
|
|
if (saveType == "submit")
|
|
{
|
|
MainPlan.State = this.drpHandleType.SelectedValue;
|
|
}
|
|
else
|
|
{
|
|
Model.Plan_MainPlan MainPlan1 = CQMS_MainPlanService.GetMainPlanByMainPlanId(MainPlanId);
|
|
if (MainPlan1 != null)
|
|
{
|
|
if (string.IsNullOrEmpty(MainPlan1.State))
|
|
{
|
|
MainPlan.State = BLL.Const.MainPlan_Compile;
|
|
}
|
|
else
|
|
{
|
|
MainPlan.State = MainPlan1.State;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MainPlan.State = BLL.Const.MainPlan_Compile;
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(MainPlanId))
|
|
{
|
|
MainPlan.MainPlanId = MainPlanId;
|
|
CQMS_MainPlanService.UpdateMainPlan(MainPlan);
|
|
if (saveType == "submit")
|
|
{
|
|
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.drpHandleMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
Model.Plan_MainPlanApprove approve = new Model.Plan_MainPlanApprove();
|
|
approve.MainPlanId = MainPlan.MainPlanId;
|
|
approve.ApproveMan = this.drpHandleMan.SelectedValue;
|
|
approve.ApproveType = this.drpHandleType.SelectedValue;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(hdId.Text))
|
|
{
|
|
MainPlan.MainPlanId = SQLHelper.GetNewID();
|
|
}
|
|
else
|
|
{
|
|
MainPlan.MainPlanId = hdId.Text;
|
|
}
|
|
MainPlan.CompileMan = this.CurrUser.PersonId;
|
|
MainPlan.CompileDate = DateTime.Now;
|
|
CQMS_MainPlanService.AddMainPlan(MainPlan);
|
|
if (saveType == "submit")
|
|
{
|
|
Model.Plan_MainPlanApprove approve1 = new Model.Plan_MainPlanApprove();
|
|
approve1.MainPlanId = MainPlan.MainPlanId;
|
|
approve1.ApproveMan = this.CurrUser.PersonId;
|
|
approve1.ApproveType = BLL.Const.MainPlan_Compile;
|
|
approve1.ApproveDate = DateTime.Now;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve1);
|
|
Model.Plan_MainPlanApprove approve = new Model.Plan_MainPlanApprove();
|
|
approve.MainPlanId = MainPlan.MainPlanId;
|
|
if (this.drpHandleMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
approve.ApproveMan = this.drpHandleMan.SelectedValue;
|
|
}
|
|
approve.ApproveType = this.drpHandleType.SelectedValue;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve);
|
|
}
|
|
else
|
|
{
|
|
Model.Plan_MainPlanApprove approve1 = new Model.Plan_MainPlanApprove();
|
|
approve1.MainPlanId = MainPlan.MainPlanId;
|
|
approve1.ApproveMan = this.CurrUser.PersonId;
|
|
approve1.ApproveType = BLL.Const.MainPlan_Compile;
|
|
BLL.CQMS_MainPlanApproveService.AddMainPlanApprove(approve1);
|
|
}
|
|
}
|
|
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 (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
if (this.drpHandleMan.Enabled == true && this.drpHandleMan.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择办理人!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |