167 lines
6.1 KiB
C#
167 lines
6.1 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
#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"];
|
|||
|
BLL.DrawingService.InitDrawingDropDownList(drpDrawingNo, this.CurrUser.LoginProjectId, true);
|
|||
|
var Base = BLL.BaseService.GetBaseById(this.BaseId);
|
|||
|
if (Base != null)
|
|||
|
{
|
|||
|
Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(Base.DrawingId);
|
|||
|
this.BaseId = Base.BaseId;
|
|||
|
if (drawing != null)
|
|||
|
{
|
|||
|
this.txtWorkSection.Text = drawing.WorkSection;
|
|||
|
this.drpDrawingNo.SelectedValue = Base.DrawingId;
|
|||
|
this.txtDrawingName.Text = drawing.DrawingName;
|
|||
|
}
|
|||
|
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();
|
|||
|
}
|
|||
|
this.txtWorkTeam.Text = Base.WorkTeam;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void drpDrawingNo_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Model.QuantityManagement_Drawing drawing = BLL.DrawingService.GetDrawingById(this.drpDrawingNo.SelectedValue);
|
|||
|
if (drawing != null)
|
|||
|
{
|
|||
|
this.txtWorkSection.Text = drawing.WorkSection;
|
|||
|
this.txtDrawingName.Text = drawing.DrawingName;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.txtWorkSection.Text = string.Empty;
|
|||
|
this.txtDrawingName.Text = string.Empty;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#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;
|
|||
|
}
|
|||
|
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.txtWorkTeam.Text.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);
|
|||
|
}
|
|||
|
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;
|
|||
|
//}
|
|||
|
var oldBase = Funs.DB.QuantityManagement_Base.Where(u => u.BaseId == this.BaseId).FirstOrDefault();
|
|||
|
if (oldBase == null)
|
|||
|
{
|
|||
|
newBase.CompileMan = this.CurrUser.UserId;
|
|||
|
newBase.CompileDate = DateTime.Now;
|
|||
|
BLL.BaseService.AddBase(newBase);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newBase.CompileMan = oldBase.CompileMan;
|
|||
|
newBase.CompileDate = oldBase.CompileDate;
|
|||
|
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
|
|||
|
}
|
|||
|
}
|