xinjiang/SGGL/FineUIPro.Web/TestRun/DriverGoods/GoodsBuyEdit.aspx.cs

105 lines
4.3 KiB
C#
Raw Normal View History

2024-11-19 09:45:27 +08:00
using BLL;
using System;
namespace FineUIPro.Web.TestRun.DriverGoods
{
public partial class GoodsBuyEdit : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.CurrUser.LoginProjectId, true);
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.DriverGoods_GoodsBuy data = BLL.GoodsBuyService.GetGoodsBuyById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtCode.Text = data.Code;
this.txtBuyName.Text = data.BuyName;
this.txtBuyCode.Text = data.BuyCode;
if (!string.IsNullOrEmpty(data.CompileMan))
{
this.drpCompileMan.SelectedValue = data.CompileMan;
}
this.txtApprovalDate.Text = data.ApprovalDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.ApprovalDate) : "";
this.txtSubmitDate.Text = data.SubmitDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.SubmitDate) : "";
this.txtGetGoodsDate.Text = data.GetGoodsDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.GetGoodsDate) : "";
this.txtRemark.Text = data.Remark;
}
}
}
}
#endregion
#region
/// <summary>
/// 附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DriverGoods_GoodsBuy));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverGoods/GoodsBuy&menuId={1}", this.hdId.Text, BLL.Const.GoodsBuyMenuId)));
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string id = Request.Params["id"];
Model.DriverGoods_GoodsBuy newData = new Model.DriverGoods_GoodsBuy();
newData.Code = this.txtCode.Text.Trim();
newData.BuyName = this.txtBuyName.Text.Trim();
newData.BuyCode = this.txtBuyCode.Text.Trim();
if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
{
newData.CompileMan = this.drpCompileMan.SelectedValue;
}
newData.ApprovalDate = Funs.GetNewDateTime(this.txtApprovalDate.Text.Trim());
newData.SubmitDate = Funs.GetNewDateTime(this.txtSubmitDate.Text.Trim());
newData.GetGoodsDate = Funs.GetNewDateTime(this.txtGetGoodsDate.Text.Trim());
newData.Remark = this.txtRemark.Text.Trim();
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.GoodsBuyId = id;
BLL.GoodsBuyService.UpdateGoodsBuy(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.GoodsBuyId = this.hdId.Text.Trim();
}
else
{
newData.GoodsBuyId = SQLHelper.GetNewID(typeof(Model.DriverGoods_GoodsBuy));
this.hdId.Text = newData.GoodsBuyId;
}
BLL.GoodsBuyService.AddGoodsBuy(newData);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}