540 lines
23 KiB
C#
540 lines
23 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.ZHGL.Plan
|
|
{
|
|
public partial class MainContractEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string MainContractId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["MainContractId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["MainContractId"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
public int ContactImg
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(ViewState["ContactImg"]);
|
|
}
|
|
set
|
|
{
|
|
ViewState["ContactImg"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义会签意见集合
|
|
/// </summary>
|
|
public static List<Model.ActionPlan_MainContractApprove> approves = new List<Model.ActionPlan_MainContractApprove>();
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
this.MainContractId = Request.Params["MainContractId"];
|
|
ProjectService.InitAllProjectDropDownList(this.drpProject, true);
|
|
var q = (from x in Funs.DB.Person_Persons where x.UnitId == Const.UnitId_SEDIN && x.DepartId == Const.Depart_constructionId && x.RoleIds != null && x.RoleIds != Const.NoOfficeRole && x.RoleIds != string.Empty && (!x.IsPost.HasValue || x.IsPost == true) orderby x.PersonName select x).ToList();
|
|
Model.ActionPlan_MainContract MainContract = BLL.MainContractService.GetMainContractById(this.MainContractId);
|
|
if (MainContract != null)
|
|
{
|
|
var compileMan = BLL.Person_PersonsService.GetPerson_PersonsById(MainContract.CompileMan);
|
|
if (compileMan != null)
|
|
{
|
|
q.Add(compileMan);
|
|
}
|
|
}
|
|
this.drpCompileMan.DataTextField = "PersonName";
|
|
this.drpCompileMan.DataValueField = "PersonId";
|
|
this.drpCompileMan.DataSource = q;
|
|
this.drpCompileMan.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpCompileMan);
|
|
this.drpPerson.DataTextField = "PersonName";
|
|
this.drpPerson.DataValueField = "PersonId";
|
|
this.drpPerson.DataSource = q;
|
|
this.drpPerson.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpPerson);
|
|
ContactImg = 0;
|
|
if (!string.IsNullOrEmpty(this.MainContractId))
|
|
{
|
|
if (MainContract != null)
|
|
{
|
|
HFMainContractId.Text = this.MainContractId;
|
|
this.ProjectId = MainContract.ProjectId;
|
|
if (MainContract.Edition != null)
|
|
{
|
|
txtEdition.Text = MainContract.Edition.ToString();
|
|
}
|
|
this.drpProject.SelectedValue = MainContract.ProjectId;
|
|
///读取编号
|
|
this.txtMainContractCode.Text = MainContract.MainContractCode;
|
|
this.txtMainContractName.Text = MainContract.MainContractName;
|
|
this.txtVersionNo.Text = MainContract.VersionNo;
|
|
if (!string.IsNullOrEmpty(MainContract.ProjectType))
|
|
{
|
|
this.drpProjectType.SelectedValue = MainContract.ProjectType;
|
|
}
|
|
else
|
|
{
|
|
this.drpProjectType.Hidden = true;
|
|
}
|
|
if (!string.IsNullOrEmpty(MainContract.CompileMan))
|
|
{
|
|
this.drpCompileMan.SelectedValue = MainContract.CompileMan;
|
|
}
|
|
if (MainContract.CompileDate != null)
|
|
{
|
|
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", MainContract.CompileDate);
|
|
}
|
|
List<string> list = BLL.MainContractApproveService.GetReviewingPersonIds(this.MainContractId);
|
|
if (list.Count > 0)
|
|
{
|
|
this.drpPerson.SelectedValueArray = list.ToArray();
|
|
}
|
|
bindApprove();
|
|
if (MainContract.States == Const.MainContract_ReCompile || MainContract.States == Const.MainContract_Compile)
|
|
{
|
|
this.Opinion.Hidden = true;
|
|
}
|
|
if (MainContract.States == Const.MainContract_Reviewing)
|
|
{
|
|
txtMainContractCode.Readonly = true;
|
|
txtMainContractName.Readonly = true;
|
|
txtVersionNo.Readonly = true;
|
|
drpProjectType.Readonly = true;
|
|
drpProject.Readonly = true;
|
|
drpCompileMan.Readonly = true;
|
|
txtCompileDate.Readonly = true;
|
|
drpPerson.Readonly = true;
|
|
ContactImg = -1;
|
|
}
|
|
}
|
|
WindowAtt_Close(null, null);
|
|
}
|
|
else
|
|
{
|
|
this.drpCompileMan.SelectedValue = this.CurrUser.PersonId;
|
|
this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
|
this.trAtt.Hidden = true;
|
|
txtEdition.Text = "0";
|
|
plApprove2.Hidden = true;
|
|
this.Opinion.Hidden = true;
|
|
////自动生成编码
|
|
//this.txtMainContractCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.OfficeMainContractMenuId, this.ProjectId, this.CurrUser.UnitId);
|
|
this.txtMainContractName.Text = this.SimpleForm1.Title;
|
|
this.txtVersionNo.Text = "V1.0";
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审批列表
|
|
/// </summary>
|
|
private void bindApprove()
|
|
{
|
|
var list = MainContractOpinionService.getListData(MainContractId, this.CurrUser.PersonId);
|
|
gvApprove.DataSource = list;
|
|
gvApprove.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpCompileMan.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择编制人!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpProject.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.drpCompileMan.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择编制人!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(HFMainContractId.Text))
|
|
{
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.drpPerson.SelectedItemArray.Length == 1 && this.drpPerson.SelectedValue == Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择评审人员!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
this.SaveData(BLL.Const.BtnSubmit);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
Model.ActionPlan_MainContract MainContract = new Model.ActionPlan_MainContract
|
|
{
|
|
MainContractCode = this.txtMainContractCode.Text.Trim(),
|
|
MainContractName = this.txtMainContractName.Text.Trim(),
|
|
VersionNo = this.txtVersionNo.Text.Trim(),
|
|
ProjectType = this.drpProjectType.SelectedValue,
|
|
};
|
|
if (this.drpProject.SelectedValue != BLL.Const._Null)
|
|
{
|
|
MainContract.ProjectId = this.drpProject.SelectedValue;
|
|
}
|
|
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
|
|
{
|
|
MainContract.CompileMan = this.drpCompileMan.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCompileDate.Text.Trim()))
|
|
{
|
|
MainContract.CompileDate = Convert.ToDateTime(this.txtCompileDate.Text.Trim());
|
|
}
|
|
int edtion = Convert.ToInt32(txtEdition.Text);
|
|
MainContract.Edition = edtion;
|
|
if (!string.IsNullOrEmpty(this.MainContractId))
|
|
{
|
|
MainContract.MainContractId = this.MainContractId;
|
|
Model.ActionPlan_MainContract MainContract1 = MainContractService.GetMainContractById(MainContractId);
|
|
if (type == BLL.Const.BtnSubmit)
|
|
{
|
|
if (MainContract1.States == Const.MainContract_Compile || MainContract1.States == Const.MainContract_ReCompile)
|
|
{
|
|
Model.ActionPlan_MainContractApprove approve = MainContractApproveService.GetConstructSoluAppByApproveMan(MainContractId, CurrUser.PersonId, Convert.ToInt32(MainContract1.Edition));
|
|
if (type == BLL.Const.BtnSubmit)
|
|
{
|
|
approve.ApproveDate = DateTime.Now;
|
|
}
|
|
approve.Edition = Convert.ToInt32(edtion);
|
|
MainContractApproveService.UpdateMainContractApprove(approve);
|
|
if (approve.IsAgree == true)
|
|
{
|
|
foreach (var item in this.drpPerson.SelectedValueArray)
|
|
{
|
|
if (item != Const._Null)
|
|
{
|
|
Model.ActionPlan_MainContractApprove approve2 = new Model.ActionPlan_MainContractApprove();
|
|
approve2.MainContractId = MainContract.MainContractId;
|
|
approve2.ApproveMan = item;
|
|
approve2.ApproveType = Const.MainContract_Reviewing;
|
|
approve2.Edition = Convert.ToInt32(edtion);
|
|
BLL.MainContractApproveService.AddMainContractApprove(approve2);
|
|
}
|
|
}
|
|
MainContract.States = Const.MainContract_Reviewing;
|
|
}
|
|
else
|
|
{
|
|
Model.ActionPlan_MainContractApprove reApprove = new Model.ActionPlan_MainContractApprove();
|
|
reApprove.MainContractId = MainContract.MainContractId;
|
|
reApprove.ApproveMan = MainContract1.CompileMan;
|
|
reApprove.ApproveType = Const.MainContract_ReCompile;
|
|
edtion++;
|
|
reApprove.Edition = edtion;
|
|
MainContractApproveService.AddMainContractApprove(reApprove);
|
|
MainContract.States = Const.MainContract_ReCompile;
|
|
}
|
|
}
|
|
else if (MainContract1.States == Const.MainContract_Reviewing)
|
|
{
|
|
MainContract.States = Const.MainContract_Reviewing;
|
|
Model.ActionPlan_MainContractApprove approve = MainContractApproveService.GetConstructSoluAppByApproveMan(MainContractId, CurrUser.PersonId, Convert.ToInt32(MainContract1.Edition));
|
|
if (approve != null)
|
|
{
|
|
approve.ApproveDate = DateTime.Now;
|
|
BLL.MainContractApproveService.UpdateMainContractApprove(approve);
|
|
}
|
|
List<Model.ActionPlan_MainContractApprove> approve3s = BLL.MainContractApproveService.GetReviewings(MainContractId, edtion); //审批集合
|
|
List<Model.ActionPlan_MainContractApprove> approve3Ends = BLL.MainContractApproveService.GetReviewingEnds(MainContractId, edtion); //审批完成集合
|
|
if (approve3s.Count == approve3Ends.Count)
|
|
{
|
|
MainContract.States = Const.MainContract_Complete;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MainContract.States = MainContract1.States;
|
|
}
|
|
//提交时候,更新提交版本
|
|
//if (CurrUser.PersonId.Equals(MainContract1.CompileMan))
|
|
//{
|
|
// if (MainContract1.States != Const.MainContract_Audit)
|
|
// {
|
|
// edtion++;
|
|
// }
|
|
// MainContract.Edition = Convert.ToInt32(edtion);
|
|
// MainContract.States = Const.MainContract_Audit;
|
|
//}
|
|
BLL.MainContractService.UpdateMainContract(MainContract);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, this.txtMainContractCode.Text, this.MainContractId, BLL.Const.OfficeMainContractMenuId, Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(HFMainContractId.Text))
|
|
{
|
|
MainContract.MainContractId = HFMainContractId.Text;
|
|
}
|
|
else
|
|
{
|
|
MainContract.MainContractId = SQLHelper.GetNewID(typeof(Model.ActionPlan_MainContract));
|
|
}
|
|
MainContract.States = BLL.Const.MainContract_Compile;
|
|
if (type == BLL.Const.BtnSubmit)
|
|
{
|
|
MainContract.States = BLL.Const.MainContract_Reviewing;
|
|
}
|
|
BLL.MainContractService.AddMainContract(MainContract);
|
|
if (type == BLL.Const.BtnSubmit)
|
|
{
|
|
Model.ActionPlan_MainContractApprove approve1 = new Model.ActionPlan_MainContractApprove();
|
|
approve1.MainContractId = MainContract.MainContractId;
|
|
approve1.ApproveDate = DateTime.Now;
|
|
approve1.ApproveMan = this.CurrUser.PersonId;
|
|
approve1.ApproveType = Const.MainContract_Compile;
|
|
approve1.Edition = Convert.ToInt32(txtEdition.Text);
|
|
MainContractApproveService.AddMainContractApprove(approve1);
|
|
foreach (var item in this.drpPerson.SelectedValueArray)
|
|
{
|
|
if (item != Const._Null)
|
|
{
|
|
Model.ActionPlan_MainContractApprove approve2 = new Model.ActionPlan_MainContractApprove();
|
|
approve2.MainContractId = MainContract.MainContractId;
|
|
approve2.ApproveMan = item;
|
|
approve2.ApproveType = Const.MainContract_Reviewing;
|
|
approve2.Edition = Convert.ToInt32(edtion);
|
|
BLL.MainContractApproveService.AddMainContractApprove(approve2);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.ActionPlan_MainContractApprove approve1 = new Model.ActionPlan_MainContractApprove();
|
|
approve1.MainContractId = MainContract.MainContractId;
|
|
approve1.ApproveMan = this.CurrUser.PersonId;
|
|
approve1.ApproveType = Const.MainContract_Compile;
|
|
approve1.Edition = Convert.ToInt32(txtEdition.Text);
|
|
MainContractApproveService.AddMainContractApprove(approve1);
|
|
}
|
|
BLL.LogService.AddSys_Log(this.CurrUser, this.txtMainContractCode.Text, this.MainContractId, BLL.Const.OfficeMainContractMenuId, Const.BtnAdd);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(HFMainContractId.Text)) //新增记录
|
|
{
|
|
HFMainContractId.Text = SQLHelper.GetNewID(typeof(Model.ActionPlan_MainContract));
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/MainContractAttachUrl&menuId={1}&type={2}", HFMainContractId.Text, BLL.Const.OfficeMainContractMenuId, ContactImg)));
|
|
}
|
|
|
|
protected void btnapprove_Click(object sender, EventArgs e)
|
|
{
|
|
//HFConstructSolutionId.Text
|
|
var approve = MainContractApproveService.GetMainContractApproveByApproveMan(HFMainContractId.Text, CurrUser.PersonId);
|
|
if (approve != null)
|
|
{
|
|
var approveId = approve.MainContractApproveId;
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
|
|
String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/MainContractAttachUrl&menuId={2}",
|
|
0, approveId, Const.OfficeMainContractMenuId)));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.divC.InnerHtml = string.Empty;
|
|
var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == HFMainContractId.Text);
|
|
if (getAtt != null)
|
|
{
|
|
this.divC.InnerHtml = UploadAttachmentService.ShowAttachment("../../", getAtt.AttachUrl);
|
|
}
|
|
else
|
|
{
|
|
this.trAtt.Hidden = true;
|
|
}
|
|
}
|
|
|
|
public string man(Object man)
|
|
{
|
|
string appman = string.Empty;
|
|
if (Person_PersonsService.GetPerson_PersonsById(man.ToString()) != null)
|
|
{
|
|
appman = Person_PersonsService.GetPerson_PersonsById(man.ToString()).PersonName;
|
|
}
|
|
return appman;
|
|
}
|
|
|
|
protected void gvApprove_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
object[] keys = gvApprove.DataKeys[e.RowIndex];
|
|
string fileId = string.Empty;
|
|
if (keys == null)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
fileId = keys[0].ToString();
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(
|
|
String.Format("../../AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/MainContractAttachUrl&menuId={2}",
|
|
-1, fileId, Const.OfficeMainContractMenuId)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
var opinions = BLL.MainContractOpinionService.GetMainContractOpinionByMainContractId(this.MainContractId, this.CurrUser.PersonId);
|
|
this.Grid1.DataSource = opinions;
|
|
this.Grid1.DataBind();
|
|
}
|
|
|
|
#region 新增
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MainContractOpinionEdit.aspx?MainContractId={0}", this.MainContractId, "编辑 - ")));
|
|
}
|
|
#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;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("MainContractOpinionEdit.aspx?MainContractOpinionId={0}", id, "编辑 - ")));
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
BLL.EquipmentInItemService.DeleteEquipmentInItemById(rowID);
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!(表格数据已重新绑定)", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
} |