SGGL_JT/SUBQHSE/FineUIPro.Web/HSSE/CostGoods/MeasuresEdit.aspx.cs

145 lines
5.0 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.CostGoods
{
public partial class MeasuresEdit: PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string MeasuresId
{
get
{
return (string)ViewState["MeasuresId"];
}
set
{
ViewState["MeasuresId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
////权限按钮方法
this.GetButtonPower();
this.MeasuresId = Request.Params["MeasuresId"];
if (!string.IsNullOrEmpty(this.MeasuresId))
{
Model.CostGoods_Measures model = BLL.CostgoodsMeasuresService.GetCostGoods_MeasuresById(this.MeasuresId);
if (model != null)
{
this.txtCode.Text = model.Code;
if (model.Category.HasValue)
{
this.dropCategory.SelectedValue = model.Category.Value.ToString();
}
this.txtAmount.Text = model.Amount.ToString();
this.txtDescribe.Text = model.Describe;
}
}
else
{
this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.CostGoodsMeasuresMenuId, this.ProjectId, null);
}
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
private void SaveData(string type)
{
Model.CostGoods_Measures table = new Model.CostGoods_Measures();
table.ProjectId = this.CurrUser.LoginProjectId;
table.Code = this.txtCode.Text;
table.Category = Funs.GetNewInt(this.dropCategory.SelectedValue);
table.Amount =Funs.GetNewDecimalOrZero(this.txtAmount.Text) ;
table.Describe = this.txtDescribe.Text;
table.CompileDate = DateTime.Now;
table.CompileMan = this.CurrUser.UserId;
if (string.IsNullOrEmpty(this.MeasuresId))
{
table.MeasuresId = SQLHelper.GetNewID(typeof(Model.CostGoods_Measures));
MeasuresId= table.MeasuresId;
BLL.CostgoodsMeasuresService.AddCostGoods_Measures(table);
}
else
{
table.MeasuresId = this.MeasuresId;
BLL.CostgoodsMeasuresService.UpdateCostGoods_Measures(table);
}
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.CostGoodsMeasuresMenuId, this.CurrUser.LoginProjectId, null, MeasuresId, table.CompileDate);
}
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.CostGoodsMeasuresMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.MeasuresId))
{
this.SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CostMeasuresAttachUrl&menuId={1}", this.MeasuresId, BLL.Const.CostGoodsMeasuresMenuId)));
}
#endregion
}
}