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 定义变量 /// /// 主键 /// public string ConTechnologyDisclosureId { get { return (string)ViewState["ConTechnologyDisclosureId"]; } set { ViewState["ConTechnologyDisclosureId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// 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 保存 /// /// 保存按钮 /// /// /// 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 获取按钮权限 /// /// 获取按钮权限 /// /// /// 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 } }