using System; using System.Linq; using BLL; namespace FineUIPro.Web.PublicInfo.FileControl { public partial class DomesticLawsRegulationsEdit : PageBase { #region 定义变量 /// /// 主键 /// private string DomesticLawsRegulationsId { get { return (string)ViewState["DomesticLawsRegulationsId"]; } set { ViewState["DomesticLawsRegulationsId"] = value; } } #endregion #region 加载 /// ///加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); //整理人 this.drpCompileMan.DataTextField = "UserName"; this.drpCompileMan.DataValueField = "UserId"; this.drpCompileMan.DataSource = BLL.Sys_UserService.GetUserList(); this.drpCompileMan.DataBind(); Funs.FineUIPleaseSelect(this.drpCompileMan, Resources.Lan.PleaseSelect); this.DomesticLawsRegulationsId = Request.Params["DomesticLawsRegulationsId"]; if (!string.IsNullOrEmpty(this.DomesticLawsRegulationsId)) { Model.FileControl_DomesticLawsRegulations domesticLawsRegulations = BLL.FileControl_DomesticLawsRegulationsService.GetDomesticLawsRegulationsById(this.DomesticLawsRegulationsId); if (domesticLawsRegulations != null) { this.txtDomesticLawsRegulationsCode.Text = domesticLawsRegulations.DomesticLawsRegulationsCode; this.txtDomesticLawsRegulationsName.Text = domesticLawsRegulations.DomesticLawsRegulationsName; this.txtAbstract.Text = domesticLawsRegulations.Abstract; if (!string.IsNullOrEmpty(domesticLawsRegulations.CompileMan)) { this.drpCompileMan.SelectedValue = domesticLawsRegulations.CompileMan; } if (domesticLawsRegulations.CompileDate.HasValue) { this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", domesticLawsRegulations.CompileDate); } this.txtRemark.Text = domesticLawsRegulations.Remarks; } } else { this.drpCompileMan.SelectedValue = this.CurrUser.UserId; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DomesticLawsRegulationsMenuId, Const.BtnSave)) { SaveData("1");//保存方法 } else { Alert.ShowInTop(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning); return; } } /// /// 保存方法 /// private void SaveData(string state) { //判断编号是否存在 var q1 = Funs.DB.FileControl_DomesticLawsRegulations.FirstOrDefault(x => x.DomesticLawsRegulationsCode == this.txtDomesticLawsRegulationsCode.Text.Trim() && (x.DomesticLawsRegulationsId.ToString() != this.DomesticLawsRegulationsId || (this.DomesticLawsRegulationsId == null && x.DomesticLawsRegulationsId != null))); if (q1 != null) { Alert.ShowInTop(Resources.Lan.DomesticLawsRegulationsCodeExists, MessageBoxIcon.Warning); return; } //判断名称是否存在 var q2 = Funs.DB.FileControl_DomesticLawsRegulations.FirstOrDefault(x => x.DomesticLawsRegulationsName == this.txtDomesticLawsRegulationsName.Text.Trim() && (x.DomesticLawsRegulationsId.ToString() != this.DomesticLawsRegulationsId || (this.DomesticLawsRegulationsId == null && x.DomesticLawsRegulationsId != null))); if (q2 != null) { Alert.ShowInTop(Resources.Lan.DomesticLawsRegulationsNameExists, MessageBoxIcon.Warning); return; } Model.FileControl_DomesticLawsRegulations newDomesticLawsRegulations = new Model.FileControl_DomesticLawsRegulations(); newDomesticLawsRegulations.DomesticLawsRegulationsCode = this.txtDomesticLawsRegulationsCode.Text.Trim(); newDomesticLawsRegulations.DomesticLawsRegulationsName = this.txtDomesticLawsRegulationsName.Text.Trim(); newDomesticLawsRegulations.Abstract = this.txtAbstract.Text.Trim(); if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { newDomesticLawsRegulations.CompileMan = this.drpCompileMan.SelectedValue; } newDomesticLawsRegulations.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()); newDomesticLawsRegulations.Remarks = this.txtRemark.Text.Trim(); if (!string.IsNullOrEmpty(this.DomesticLawsRegulationsId)) { newDomesticLawsRegulations.DomesticLawsRegulationsId = this.DomesticLawsRegulationsId; BLL.FileControl_DomesticLawsRegulationsService.UpdateDomesticLawsRegulations(newDomesticLawsRegulations); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DomesticLawsRegulationsMenuId, Const.BtnModify, newDomesticLawsRegulations.DomesticLawsRegulationsId); } else { this.DomesticLawsRegulationsId = SQLHelper.GetNewID(typeof(Model.FileControl_DomesticLawsRegulations)); newDomesticLawsRegulations.DomesticLawsRegulationsId = this.DomesticLawsRegulationsId; BLL.FileControl_DomesticLawsRegulationsService.AddDomesticLawsRegulations(newDomesticLawsRegulations); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.DomesticLawsRegulationsMenuId, Const.BtnAdd, newDomesticLawsRegulations.DomesticLawsRegulationsId); } if (state == "1") { ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } #endregion #region 附件上传 /// /// 上传附件资源 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.DomesticLawsRegulationsId)) { SaveData("0"); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/FileControl/DomesticLawsRegulations&menuId={1}&edit=1", this.DomesticLawsRegulationsId, BLL.Const.DomesticLawsRegulationsMenuId))); } #endregion } }