SGGL_SHJ/SGGL/FineUIPro.Web/HSSE/CostGoods/CostManageItemEdit.aspx.cs

160 lines
5.8 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
using System;
namespace FineUIPro.Web.HSSE.CostGoods
{
public partial class CostManageItemEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string CostManageItemId
{
get
{
return (string)ViewState["CostManageItemId"];
}
set
{
ViewState["CostManageItemId"] = value;
}
}
/// <summary>
/// 费用管理主键
/// </summary>
private string CostManageId
{
get
{
return (string)ViewState["CostManageId"];
}
set
{
ViewState["CostManageId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.CostManageId = Request.Params["CostManageId"];
this.CostManageItemId = Request.Params["CostManageItemId"] ?? SQLHelper.GetNewID();
CostTypeService.InitCostTypeDropDownList(this.drpSupCostType, true);
2022-09-05 16:36:31 +08:00
if (!string.IsNullOrEmpty(this.CostManageItemId))
{
var costManageItem = BLL.CostManageItemService.GetCostManageItemById(this.CostManageItemId);
2022-09-05 16:36:31 +08:00
if (costManageItem != null)
{
this.CostManageId = costManageItem.CostManageId;
this.drpSupCostType.SelectedValue = costManageItem.SupCostTypeId;
CostTypeService.InitCostTypeItemDropDownList(this.drpCostType, this.drpSupCostType.SelectedValue, false);
this.drpCostType.SelectedValue = costManageItem.CostTypeId;
this.txtInvestCostProject.Text = costManageItem.InvestCostProject;
2022-09-05 16:36:31 +08:00
if (costManageItem.PriceMoney != null)
{
this.txtPriceMoney.Text = Convert.ToString(costManageItem.PriceMoney);
}
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
bool isSave = true;
2022-09-05 16:36:31 +08:00
Model.CostGoods_CostManageItem costManageItem = new Model.CostGoods_CostManageItem
{
CostManageId = this.CostManageId,
CostManageItemId = this.CostManageItemId,
InvestCostProject = this.txtInvestCostProject.Text.Trim(),
2022-09-05 16:36:31 +08:00
PriceMoney = Funs.GetNewDecimalOrZero(this.txtPriceMoney.Text.Trim()),
};
var getSupType = CostTypeService.GetCostTypeById(this.drpSupCostType.SelectedValue);
if (getSupType != null)
{
costManageItem.SupCostTypeId = getSupType.CostTypeId;
costManageItem.SupCostTypeName = getSupType.CostTypeName;
costManageItem.SupSortIndex = getSupType.CostTypeCode;
}
else
{
isSave = false;
}
var getCostType = CostTypeService.GetCostTypeItemById(this.drpCostType.SelectedValue);
if (getCostType != null)
{
costManageItem.CostTypeId = getCostType.CostTypeItemId;
costManageItem.CostTypeName = getCostType.CostTypeItemName;
costManageItem.SortIndex = getCostType.SortIndex;
}
else
{
isSave = false;
}
if (isSave)
2022-09-05 16:36:31 +08:00
{
var getItem = BLL.CostManageItemService.GetCostManageItemById(this.CostManageItemId);
if (getItem != null)
{
costManageItem.CostManageItemId = this.CostManageItemId;
BLL.CostManageItemService.UpdateCostManageItem(costManageItem);
}
else
{
costManageItem.CostManageItemId = this.CostManageItemId;
BLL.CostManageItemService.AddCostManageItem(costManageItem);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
2022-09-05 16:36:31 +08:00
}
else
{
Alert.ShowInTop("费用类别或分项存在问题,请重新选择!", MessageBoxIcon.Warning);
return;
2022-09-05 16:36:31 +08:00
}
}
#endregion
/// <summary>
/// 类型下拉框
2022-09-05 16:36:31 +08:00
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpSupCostType_SelectedIndexChanged(object sender, EventArgs e)
2022-09-05 16:36:31 +08:00
{
CostTypeService.InitCostTypeItemDropDownList(this.drpCostType, this.drpSupCostType.SelectedValue, false);
}
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CostManageItemAttachUrl&menuId={1}", this.CostManageItemId, BLL.Const.ProjectCostManageMenuId)));
2022-09-05 16:36:31 +08:00
}
#endregion
}
}