SGGL_SHJ/SGGL/FineUIPro.Web/PHTGL/BillOfQuantities/PHTGL_QuantityEdit.aspx.cs

122 lines
5.2 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.PHTGL.BillOfQuantities
{
public partial class PHTGL_QuantityEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
public string Type
{
get { return (string)ViewState["Type"]; }
set { ViewState["Type"] = value; }
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
////权限按钮方法
// this.GetButtonPower();
this.Id = Request.Params["Id"];
this.Type = Request.Params["Type"];
if (!string.IsNullOrEmpty(this.Id))
{
Model.PHTGL_Quantity model = BLL.PHTGL_QuantityService.GetPHTGL_QuantityById(this.Id);
if (model != null)
{
this.txtMajor.Text = model.Major;
this.txtSubProject.Text = model.SubProject;
this.txtSubItemProject.Text = model.SubItemProject;
this.txtProjectCode.Text = model.ProjectCode;
this.txtProjectName.Text = model.ProjectName;
this.txtProjectDescription.Text = model.ProjectDescription;
this.txtUnitOfMeasurement.Text = model.UnitOfMeasurement;
this.txtQuantity.Text = model.Quantity;
this.txtTotalCostFixedComprehensiveUnitPrice.Text = model.TotalCostFixedComprehensiveUnitPrice;
this.txtMainMaterialCost.Text = model.MainMaterialCost;
this.txtTotalPrice.Text = model.TotalPrice;
this.txtCalculationRule.Text = model.CalculationRule;
this.txtWorkContent.Text = model.WorkContent;
this.txtRemarks.Text = model.Remarks;
}
}
else
{
this.txtMajor.Text = BLL.PHTGL_QuantityService.GetMajorItems().Where(x => x.Text == Type).Select(x => x.Value).FirstOrDefault() ?? "";
}
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.Id))
{
Model.PHTGL_Quantity table = new Model.PHTGL_Quantity();
table.Major = this.txtMajor.Text;
table.SubProject = this.txtSubProject.Text;
table.SubItemProject = this.txtSubItemProject.Text;
table.ProjectCode = this.txtProjectCode.Text;
table.ProjectName = this.txtProjectName.Text;
table.ProjectDescription = this.txtProjectDescription.Text;
table.UnitOfMeasurement = this.txtUnitOfMeasurement.Text;
table.Quantity = this.txtQuantity.Text;
table.TotalCostFixedComprehensiveUnitPrice = this.txtTotalCostFixedComprehensiveUnitPrice.Text;
table.MainMaterialCost = this.txtMainMaterialCost.Text;
table.TotalPrice = this.txtTotalPrice.Text;
table.CalculationRule = this.txtCalculationRule.Text;
table.WorkContent = this.txtWorkContent.Text;
table.Remarks = this.txtRemarks.Text;
table.Id = SQLHelper.GetNewID(typeof(Model.PHTGL_Quantity));
table.IsTemplate = true;
BLL.PHTGL_QuantityService.AddPHTGL_Quantity(table);
}
else
{
var table = PHTGL_QuantityService.GetPHTGL_QuantityById(Id);
table.Major = this.txtMajor.Text;
table.SubProject = this.txtSubProject.Text;
table.SubItemProject = this.txtSubItemProject.Text;
table.ProjectCode = this.txtProjectCode.Text;
table.ProjectName = this.txtProjectName.Text;
table.ProjectDescription = this.txtProjectDescription.Text;
table.UnitOfMeasurement = this.txtUnitOfMeasurement.Text;
table.Quantity = this.txtQuantity.Text;
table.TotalCostFixedComprehensiveUnitPrice = this.txtTotalCostFixedComprehensiveUnitPrice.Text;
table.MainMaterialCost = this.txtMainMaterialCost.Text;
table.TotalPrice = this.txtTotalPrice.Text;
table.CalculationRule = this.txtCalculationRule.Text;
table.WorkContent = this.txtWorkContent.Text;
table.Remarks = this.txtRemarks.Text;
BLL.PHTGL_QuantityService.UpdatePHTGL_Quantity(table);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
}