CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/CQMS/Comprehensive/ConTechnologyDisclosureEdit...

167 lines
6.7 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.CQMS.Comprehensive
{
public partial class ConTechnologyDisclosureEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string ConTechnologyDisclosureId
{
get
{
return (string)ViewState["ConTechnologyDisclosureId"];
}
set
{
ViewState["ConTechnologyDisclosureId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();
BLL.UnitWorkService.InitUnitWorkDownList(this.drpUnitWorkIds, this.CurrUser.LoginProjectId, false);
BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, false);
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
this.ConTechnologyDisclosureId = Request.Params["id"];
Model.Comprehensive_ConTechnologyDisclosure con = BLL.ConTechnologyDisclosureService.GetConTechnologyDisclosureById(this.ConTechnologyDisclosureId);
if (con != null)
{
this.ConTechnologyDisclosureId = con.ConTechnologyDisclosureId;
if (!string.IsNullOrEmpty(con.CNProfessionalId))
{
this.drpCNProfessionalId.SelectedValue = con.CNProfessionalId;
}
this.txtDisclosureCode.Text = con.DisclosureCode;
this.txtDisclosureName.Text = con.DisclosureName;
if (!string.IsNullOrEmpty(con.UnitId))
{
this.drpUnitId.SelectedValue = con.UnitId;
}
this.txtDisclosureMan.Text = con.DisclosureMan;
this.txtDisclosureDate.Text = con.DisclosureDate.HasValue ? string.Format("{0:yyyy-MM-dd}", con.DisclosureDate) : "";
if (!string.IsNullOrEmpty(con.UnitWorkId))
{
this.drpUnitWorkIds.SelectedValueArray = con.UnitWorkId.Split(',');
}
this.txtAttendMan.Text = con.AttendMan;
this.txtRemarkCode.Text = con.RemarkCode.HasValue ? con.RemarkCode.ToString() : "";
}
else
{
this.txtDisclosureDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (drpCNProfessionalId.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning);
return;
}
if (this.drpUnitId.SelectedValue == BLL.Const._Null)
{
Alert.ShowInTop("请选择交底负责单位!", MessageBoxIcon.Warning);
return;
}
var q = Funs.DB.Comprehensive_ConTechnologyDisclosure.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RemarkCode == Funs.GetNewInt(this.txtRemarkCode.Text.Trim()) && (x.ConTechnologyDisclosureId != this.ConTechnologyDisclosureId || (this.ConTechnologyDisclosureId == null && x.ConTechnologyDisclosureId != null)));
if (q != null)
{
Alert.ShowInTop("标志编号已存在!", MessageBoxIcon.Warning);
return;
}
Model.Comprehensive_ConTechnologyDisclosure newCon = new Model.Comprehensive_ConTechnologyDisclosure();
newCon.ProjectId = this.CurrUser.LoginProjectId;
newCon.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
newCon.DisclosureCode = this.txtDisclosureCode.Text.Trim();
newCon.DisclosureName = this.txtDisclosureName.Text.Trim();
newCon.UnitId = this.drpUnitId.SelectedValue;
newCon.DisclosureMan = this.txtDisclosureMan.Text.Trim();
newCon.DisclosureDate = Funs.GetNewDateTime(this.txtDisclosureDate.Text.Trim());
string ids = string.Empty;
var lists = this.drpUnitWorkIds.SelectedValueArray;
foreach (var item in lists)
{
ids += item + ",";
}
if (!string.IsNullOrEmpty(ids))
{
ids = ids.Substring(0, ids.LastIndexOf(","));
}
newCon.UnitWorkId = ids;
newCon.AttendMan = this.txtAttendMan.Text.Trim();
newCon.RemarkCode = Funs.GetNewInt(this.txtRemarkCode.Text.Trim());
if (string.IsNullOrEmpty(this.ConTechnologyDisclosureId))
{
newCon.ConTechnologyDisclosureId = SQLHelper.GetNewID(typeof(Model.Comprehensive_ConTechnologyDisclosure));
newCon.CompileMan = this.CurrUser.UserId;
newCon.CompileDate = DateTime.Now;
BLL.ConTechnologyDisclosureService.AddConTechnologyDisclosure(newCon);
}
else
{
newCon.ConTechnologyDisclosureId = this.ConTechnologyDisclosureId;
BLL.ConTechnologyDisclosureService.UpdateConTechnologyDisclosure(newCon);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == BLL.Const._Null)
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ConTechnologyDisclosureMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
}
}