101 lines
3.4 KiB
C#
101 lines
3.4 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.HJGL.BaseInfo
|
|
{
|
|
public partial class WarehouseEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string WarehouseId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WarehouseId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WarehouseId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.txtWarehouseName.Focus();
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
this.WarehouseId = Request.Params["WarehouseId"];
|
|
if (!string.IsNullOrEmpty(this.WarehouseId))
|
|
{
|
|
Model.Base_Warehouse warehouse = BLL.Base_WarehouseService.GetWarehouseByWarehouseId(this.WarehouseId);
|
|
if (warehouse != null)
|
|
{
|
|
this.txtWarehouseName.Text = warehouse.WarehouseName;
|
|
this.txtRemark.Text = warehouse.Remark;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
// 唯一性检查:仓库名称在项目内不能重复
|
|
var q = Funs.DB.Base_Warehouse.FirstOrDefault(x => x.WarehouseName == this.txtWarehouseName.Text.Trim()
|
|
&& (x.WarehouseId != this.WarehouseId || (this.WarehouseId == null && x.WarehouseId != null))
|
|
&& x.ProjectId == this.CurrUser.LoginProjectId);
|
|
if (q != null)
|
|
{
|
|
Alert.ShowInTop("此仓库名称已存在!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
Model.Base_Warehouse newWarehouse = new Model.Base_Warehouse
|
|
{
|
|
WarehouseName = this.txtWarehouseName.Text.Trim(),
|
|
Remark = this.txtRemark.Text.Trim(),
|
|
ProjectId = this.CurrUser.LoginProjectId,
|
|
ModifyUserId = this.CurrUser.PersonId,
|
|
ModifyTime = DateTime.Now
|
|
};
|
|
|
|
if (!string.IsNullOrEmpty(this.WarehouseId))
|
|
{
|
|
// 更新
|
|
newWarehouse.WarehouseId = this.WarehouseId;
|
|
BLL.Base_WarehouseService.UpdateWarehouse(newWarehouse);
|
|
}
|
|
else
|
|
{
|
|
// 新增
|
|
this.WarehouseId = SQLHelper.GetNewID(typeof(Model.Base_Warehouse));
|
|
newWarehouse.WarehouseId = this.WarehouseId;
|
|
newWarehouse.CreateUserId = this.CurrUser.PersonId;
|
|
newWarehouse.CreateTime = DateTime.Now;
|
|
BLL.Base_WarehouseService.AddWarehouse(newWarehouse);
|
|
}
|
|
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
}
|
|
}
|