441 lines
17 KiB
C#
441 lines
17 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.QuantityManagement
|
|
{
|
|
public partial class BaseEdit : PageBase
|
|
{
|
|
#region 定义变量
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string BaseId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["BaseId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["BaseId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string State
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["State"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["State"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();
|
|
this.BaseId = Request.Params["BaseId"];
|
|
plApprove1.Hidden = true;
|
|
plApprove2.Hidden = true;
|
|
rblIsAgree.Hidden = true;
|
|
rblIsAgree.SelectedValue = "true";
|
|
BLL.DrawingService.InitDrawingChangeDropDownList(drpDrawingNo, this.CurrUser.LoginProjectId, true);
|
|
BLL.TeamGroupService.InitTeamGroupProjectDropDownList(drpWorkTeam, this.CurrUser.LoginProjectId, true);
|
|
var Base = BLL.BaseService.GetBaseById(this.BaseId);
|
|
if (Base != null)
|
|
{
|
|
Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(Base.DrawingId);
|
|
Model.QuantityManagement_Change change = BLL.ChangeService.GetChangeById(Base.DrawingId);
|
|
this.BaseId = Base.BaseId;
|
|
plApprove1.Hidden = false;
|
|
plApprove2.Hidden = false;
|
|
var dt = BaseApproveService.getListData(BaseId);
|
|
gvApprove.DataSource = dt;
|
|
gvApprove.DataBind();
|
|
if (drawing != null)
|
|
{
|
|
this.txtWorkSection.Text = drawing.WorkSection;
|
|
this.drpDrawingNo.SelectedValue = Base.DrawingId;
|
|
this.txtDrawingName.Text = drawing.DrawingName;
|
|
}
|
|
else if (change != null)
|
|
{
|
|
this.txtWorkSection.Text = change.WorkSection;
|
|
this.drpDrawingNo.SelectedValue = Base.DrawingId;
|
|
this.txtDrawingName.Text = change.ChangeName;
|
|
}
|
|
this.txtPart.Text = Base.Part;
|
|
this.txtProjectContent.Text = Base.ProjectContent;
|
|
this.txtUnit.Text = Base.Unit;
|
|
if (Base.Amount != null)
|
|
{
|
|
this.txtAmount.Text = Base.Amount.ToString();
|
|
}
|
|
if (!string.IsNullOrEmpty(Base.WorkTeam))
|
|
{
|
|
this.drpWorkTeam.SelectedValue = Base.WorkTeam;
|
|
}
|
|
if (!string.IsNullOrEmpty(Base.State))
|
|
{
|
|
State = Base.State;
|
|
}
|
|
else
|
|
{
|
|
State = BLL.Const.Base_Compile;
|
|
this.rblIsAgree.Visible = false;
|
|
}
|
|
if (State != BLL.Const.Base_Complete)
|
|
{
|
|
//Funs.Bind(drpHandleType, BaseService.GetDHandleTypeByState(State));
|
|
BaseService.Init(drpHandleType, State, false);
|
|
}
|
|
if (State == BLL.Const.Base_Compile)
|
|
{
|
|
this.rblIsAgree.Visible = false;
|
|
UserService.InitUserDropDownList2(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
|
|
this.drpHandleMan.SelectedIndex = 1;
|
|
}
|
|
else
|
|
{
|
|
UserService.InitUserDropDownList2(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
|
|
this.rblIsAgree.Visible = true;
|
|
if (drpHandleType.SelectedValue == BLL.Const.Base_ReCompile)
|
|
{
|
|
var HandleMan = BLL.BaseApproveService.GetComplie(this.BaseId);
|
|
if (HandleMan != null)
|
|
{
|
|
this.drpHandleMan.SelectedValue = UserService.GetUserNameByUserId(HandleMan.ApproveMan);
|
|
}
|
|
}
|
|
}
|
|
|
|
//设置流程上是否有同意不同意
|
|
if (State == Const.Base_Audit1)
|
|
{
|
|
rblIsAgree.Hidden = false;
|
|
}
|
|
else
|
|
{
|
|
rblIsAgree.Hidden = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
State = Const.Base_Compile;
|
|
BaseService.Init(drpHandleType, State, false);
|
|
UserService.InitUserDropDownList2(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
|
|
}
|
|
//是否同意触发
|
|
if (!rblIsAgree.Hidden)
|
|
{
|
|
HandleType();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 待办事项的下拉框的处理
|
|
/// </summary>
|
|
public void HandleType()
|
|
{
|
|
drpHandleType.Items.Clear();
|
|
BaseService.Init(drpHandleType, State, false);
|
|
string res = null;
|
|
List<string> list = new List<string>();
|
|
list.Add(Const.Base_ReCompile);
|
|
var count = drpHandleType.Items.Count;
|
|
List<ListItem> listitem = new List<ListItem>();
|
|
if (rblIsAgree.SelectedValue.Equals("true"))
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
res = drpHandleType.Items[i].Value;
|
|
if (list.Contains(res))
|
|
{
|
|
var item = (drpHandleType.Items[i]);
|
|
listitem.Add(item);
|
|
}
|
|
}
|
|
if (listitem.Count > 0)
|
|
{
|
|
for (int i = 0; i < listitem.Count; i++)
|
|
{
|
|
drpHandleType.Items.Remove(listitem[i]);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
|
|
res = drpHandleType.Items[i].Value;
|
|
if (!list.Contains(res))
|
|
{
|
|
var item = drpHandleType.Items[i];
|
|
listitem.Add(item);
|
|
}
|
|
}
|
|
if (listitem.Count > 0)
|
|
{
|
|
for (int i = 0; i < listitem.Count; i++)
|
|
{
|
|
drpHandleType.Items.Remove(listitem[i]);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
if (count > 0)
|
|
{
|
|
drpHandleType.SelectedIndex = 0;
|
|
HandleMan();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 办理人员的自动筛选
|
|
/// </summary>
|
|
protected void HandleMan()
|
|
{
|
|
drpHandleMan.Items.Clear();
|
|
if (!string.IsNullOrEmpty(drpHandleType.SelectedText))
|
|
{
|
|
UserService.InitUserDropDownList2(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
|
|
if (drpHandleMan.Items.Count > 0)
|
|
{
|
|
drpHandleMan.SelectedIndex = 0;
|
|
}
|
|
if (drpHandleType.SelectedText.Contains("重新编制"))
|
|
{
|
|
UserService.InitUserDropDownList2(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
|
|
var HandleMan = BLL.BaseApproveService.GetComplie(this.BaseId);
|
|
if (HandleMan != null)
|
|
{
|
|
this.drpHandleMan.SelectedValue = HandleMan.ApproveMan;
|
|
}
|
|
}
|
|
if (drpHandleType.SelectedValue == BLL.Const.Base_Complete)
|
|
{
|
|
drpHandleMan.Items.Clear();
|
|
drpHandleMan.Enabled = false;
|
|
drpHandleMan.Required = false;
|
|
}
|
|
else
|
|
{
|
|
drpHandleMan.Enabled = true;
|
|
drpHandleMan.Required = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
HandleMan();
|
|
}
|
|
|
|
protected void rblIsAgree_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
HandleType();
|
|
}
|
|
|
|
protected void drpDrawingNo_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(this.drpDrawingNo.SelectedValue);
|
|
Model.QuantityManagement_Change change = BLL.ChangeService.GetChangeById(this.drpDrawingNo.SelectedValue);
|
|
if (drawing != null)
|
|
{
|
|
this.txtWorkSection.Text = drawing.WorkSection;
|
|
this.txtDrawingName.Text = drawing.DrawingName;
|
|
this.txtAmount.NoNegative = true;
|
|
}
|
|
else if (change != null)
|
|
{
|
|
this.txtWorkSection.Text = change.WorkSection;
|
|
this.txtDrawingName.Text = change.ChangeName;
|
|
this.txtAmount.NoNegative = false;
|
|
}
|
|
else
|
|
{
|
|
this.txtWorkSection.Text = string.Empty;
|
|
this.txtDrawingName.Text = string.Empty;
|
|
this.txtAmount.NoNegative = true;
|
|
}
|
|
}
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.drpDrawingNo.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择图号", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.drpWorkTeam.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择计划作业队", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(this.drpDrawingNo.SelectedValue);
|
|
if (drawing != null)
|
|
{
|
|
decimal d = Funs.GetNewDecimalOrZero(this.txtAmount.Text.Trim());
|
|
if (d < 0)
|
|
{
|
|
Alert.ShowInTop("图纸工程量总数不能为负数", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
Model.QuantityManagement_Base newBase = new Model.QuantityManagement_Base();
|
|
newBase.ProjectId = this.CurrUser.LoginProjectId;
|
|
newBase.DrawingId = this.drpDrawingNo.SelectedValue;
|
|
newBase.Part = this.txtPart.Text.Trim();
|
|
newBase.ProjectContent = this.txtProjectContent.Text.Trim();
|
|
newBase.Unit = this.txtUnit.Text.Trim();
|
|
newBase.Amount = Funs.GetNewDecimal(this.txtAmount.Text.Trim());
|
|
newBase.WorkTeam = this.drpWorkTeam.SelectedValue;
|
|
newBase.State = drpHandleType.SelectedValue.Trim();
|
|
if (string.IsNullOrEmpty(this.BaseId))
|
|
{
|
|
newBase.BaseId = SQLHelper.GetNewID(typeof(Model.QuantityManagement_Base));
|
|
newBase.CompileMan = this.CurrUser.UserId;
|
|
newBase.CompileDate = DateTime.Now;
|
|
//var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == newBase.BaseId);
|
|
//if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
//{
|
|
// Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
// return;
|
|
//}
|
|
BLL.BaseService.AddBase(newBase);
|
|
Model.QuantityManagement_BaseApprove approve1 = new Model.QuantityManagement_BaseApprove();
|
|
approve1.BaseId = newBase.BaseId;
|
|
approve1.ApproveDate = DateTime.Now;
|
|
approve1.ApproveMan = this.CurrUser.UserId;
|
|
approve1.ApproveType = BLL.Const.Base_Compile;
|
|
BLL.BaseApproveService.AddBaseApprove(approve1);
|
|
|
|
Model.QuantityManagement_BaseApprove approve = new Model.QuantityManagement_BaseApprove();
|
|
approve.BaseId = newBase.BaseId;
|
|
if (this.drpHandleMan.SelectedValue != "")
|
|
{
|
|
approve.ApproveMan = this.drpHandleMan.SelectedValue;
|
|
}
|
|
approve.ApproveType = this.drpHandleType.SelectedValue;
|
|
BLL.BaseApproveService.AddBaseApprove(approve);
|
|
}
|
|
else
|
|
{
|
|
newBase.BaseId = this.BaseId;
|
|
//var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.BaseId);
|
|
//if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
|
//{
|
|
// Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
// return;
|
|
//}
|
|
Model.QuantityManagement_BaseApprove approve1 = BLL.BaseApproveService.GetBaseApproveByBaseId(BaseId);
|
|
if (approve1 != null)
|
|
{
|
|
approve1.ApproveDate = DateTime.Now;
|
|
approve1.ApproveIdea = txtOpinions.Text.Trim();
|
|
approve1.IsAgree = Convert.ToBoolean(this.rblIsAgree.SelectedValue);
|
|
BLL.BaseApproveService.UpdateBaseApprove(approve1);
|
|
}
|
|
if (this.drpHandleMan.SelectedValue != null)
|
|
{
|
|
Model.QuantityManagement_BaseApprove approve = new Model.QuantityManagement_BaseApprove();
|
|
approve.BaseId = BaseId;
|
|
approve.ApproveMan = this.drpHandleMan.SelectedValue;
|
|
approve.ApproveType = this.drpHandleType.SelectedValue;
|
|
if (this.drpHandleType.SelectedValue == BLL.Const.Base_Complete)
|
|
{
|
|
approve.ApproveDate = DateTime.Now.AddMinutes(1);
|
|
}
|
|
BLL.BaseApproveService.AddBaseApprove(approve);
|
|
}
|
|
BLL.BaseService.UpdateBase(newBase);
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#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.UserId, BLL.Const.BaseMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|
{
|
|
this.btnSave.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 把状态转换代号为文字形式
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
if (state.ToString() == BLL.Const.Base_ReCompile)
|
|
{
|
|
return "重新编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Base_Compile)
|
|
{
|
|
return "编制";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Base_Audit1)
|
|
{
|
|
return "审核";
|
|
}
|
|
else if (state.ToString() == BLL.Const.Base_Complete)
|
|
{
|
|
return "审批完成";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
} |