143 lines
5.2 KiB
C#
143 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using BLL;
|
|
|
|
namespace FineUIPro.Web.common.BaseInfo
|
|
{
|
|
public partial class UnitEdit : PageBase
|
|
{
|
|
#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();
|
|
string unitId = Request.Params["unitId"];
|
|
|
|
if (!string.IsNullOrEmpty(unitId))
|
|
{
|
|
var unit = BLL.Base_UnitService.GetUnit(unitId);
|
|
if (unit != null)
|
|
{
|
|
this.txtUnitCode.Text = unit.UnitCode;
|
|
this.txtUnitName.Text = unit.UnitName;
|
|
this.txtCorporate.Text = unit.Corporate;
|
|
this.txtTelephone.Text = unit.Telephone;
|
|
this.txtFax.Text = unit.Fax;
|
|
this.txtAddress.Text = unit.Address;
|
|
this.txtProjectRange.Text = unit.ProjectRange;
|
|
|
|
if (unit.IsMain == true)
|
|
{
|
|
this.cbkIsMain.Checked = true;
|
|
}
|
|
else
|
|
{
|
|
cbkIsMain.Checked = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.UnitMenuId, BLL.Const.BtnSave))
|
|
{
|
|
string unitId = Request.Params["unitId"];
|
|
Model.Base_Unit newUnit = new Model.Base_Unit();
|
|
newUnit.UnitId = unitId;
|
|
newUnit.UnitCode = this.txtUnitCode.Text;
|
|
newUnit.UnitName = this.txtUnitName.Text;
|
|
newUnit.Corporate = this.txtCorporate.Text;
|
|
newUnit.Address = this.txtAddress.Text;
|
|
newUnit.Telephone = this.txtTelephone.Text;
|
|
newUnit.Fax = this.txtFax.Text;
|
|
newUnit.ProjectRange = this.txtProjectRange.Text.Trim();
|
|
if (this.cbkIsMain.Checked)
|
|
{
|
|
newUnit.IsMain = true;
|
|
}
|
|
else
|
|
{
|
|
newUnit.IsMain = false;
|
|
}
|
|
|
|
newUnit.IsSubUnit = false;
|
|
|
|
if (string.IsNullOrEmpty(unitId))
|
|
{
|
|
newUnit.IsSubUnit = Convert.ToBoolean(Request.Params["IsSubUnit"]);
|
|
newUnit.UnitId = SQLHelper.GetNewID(typeof(Model.Base_Unit));
|
|
if (!BLL.Base_UnitService.IsExistUnitCode(newUnit.UnitId, this.txtUnitCode.Text) && !BLL.Base_UnitService.IsExistUnitName(newUnit.UnitId, this.txtUnitName.Text))
|
|
{
|
|
|
|
BLL.Base_UnitService.AddUnit(newUnit);
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加单位");
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("此单位编号或名称已存在!");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!BLL.Base_UnitService.IsExistUnitCode(unitId, this.txtUnitCode.Text) && !BLL.Base_UnitService.IsExistUnitName(newUnit.UnitId, this.txtUnitName.Text))
|
|
{
|
|
BLL.Base_UnitService.updateUnit(newUnit);
|
|
BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改单位");
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("此单位编号或名称已存在!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("您没有这个权限,请与管理员联系!!");
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭按钮
|
|
protected void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
#endregion
|
|
|
|
protected void cbkIsMain_CheckedChanged(object sender, CheckedEventArgs e)
|
|
{
|
|
|
|
if (this.cbkIsMain.Checked)
|
|
{
|
|
if (Base_UnitService.IsExitMain())
|
|
{
|
|
Alert.ShowInParent("本单位已存在!");
|
|
this.cbkIsMain.Checked = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |