using BLL;
using System;
namespace FineUIPro.Web.HSSE.CostGoods
{
public partial class CostManageItemEdit : PageBase
{
#region 定义项
///
/// 主键
///
private string CostManageItemId
{
get
{
return (string)ViewState["CostManageItemId"];
}
set
{
ViewState["CostManageItemId"] = value;
}
}
///
/// 费用管理主键
///
private string CostManageId
{
get
{
return (string)ViewState["CostManageId"];
}
set
{
ViewState["CostManageId"] = value;
}
}
#endregion
#region 加载
///
/// 加载页面
///
///
///
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);
if (!string.IsNullOrEmpty(this.CostManageItemId))
{
var costManageItem = BLL.CostManageItemService.GetCostManageItemById(this.CostManageItemId);
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;
if (costManageItem.PriceMoney != null)
{
this.txtPriceMoney.Text = Convert.ToString(costManageItem.PriceMoney);
}
}
}
}
}
#endregion
#region 保存
///
/// 保存按钮
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
bool isSave = true;
Model.CostGoods_CostManageItem costManageItem = new Model.CostGoods_CostManageItem
{
CostManageId = this.CostManageId,
CostManageItemId = this.CostManageItemId,
InvestCostProject = this.txtInvestCostProject.Text.Trim(),
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)
{
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());
}
else
{
Alert.ShowInTop("费用类别或分项存在问题,请重新选择!", MessageBoxIcon.Warning);
return;
}
}
#endregion
///
/// 类型下拉框
///
///
///
protected void drpSupCostType_SelectedIndexChanged(object sender, EventArgs e)
{
CostTypeService.InitCostTypeItemDropDownList(this.drpCostType, this.drpSupCostType.SelectedValue, false);
}
#region 附件上传
///
/// 上传附件
///
///
///
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)));
}
#endregion
}
}