using BLL; using System; using System.Web; namespace FineUIPro.Web.ZHGL.Meeting { public partial class CompanySafetyMeetingEdit : PageBase { #region 定义项 /// /// 主键 /// public string CompanySafetyMeetingId { get { return (string)ViewState["CompanySafetyMeetingId"]; } set { ViewState["CompanySafetyMeetingId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); this.CompanySafetyMeetingId = Request.Params["CompanySafetyMeetingId"]; if (!string.IsNullOrEmpty(this.CompanySafetyMeetingId)) { Model.Meeting_CompanySafetyMeeting CompanySafetyMeeting = BLL.CompanySafetyMeetingService.GetCompanySafetyMeetingById(this.CompanySafetyMeetingId); if (CompanySafetyMeeting != null) { this.txtCompanySafetyMeetingCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.CompanySafetyMeetingId); this.txtCompanySafetyMeetingName.Text = CompanySafetyMeeting.CompanySafetyMeetingName; this.txtCompanySafetyMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", CompanySafetyMeeting.CompanySafetyMeetingDate); if (!string.IsNullOrEmpty(CompanySafetyMeeting.CompileMan)) { this.drpCompileMan.SelectedValue = CompanySafetyMeeting.CompileMan; } if (CompanySafetyMeeting.AttentPersonNum != null) { this.txtAttentPersonNum.Text = CompanySafetyMeeting.AttentPersonNum.ToString(); } this.txtCompanySafetyMeetingContents.Text = HttpUtility.HtmlDecode(CompanySafetyMeeting.CompanySafetyMeetingContents); this.txtMeetingHours.Text = Convert.ToString(CompanySafetyMeeting.MeetingHours); this.txtMeetingHostMan.Text = CompanySafetyMeeting.MeetingHostMan; this.txtAttentPerson.Text = CompanySafetyMeeting.AttentPerson; } } else { this.drpCompileMan.SelectedValue = this.CurrUser.UserId; this.txtCompanySafetyMeetingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); var codeTemplateRule = BLL.SysConstSetService.GetCodeTemplateRuleByMenuId(BLL.Const.ProjectWeekMeetingMenuId); if (codeTemplateRule != null) { this.txtCompanySafetyMeetingContents.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template); } ////自动生成编码 this.txtCompanySafetyMeetingCode.Text = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.CompanySafetyMeetingMenuId, null, this.CurrUser.UnitId); this.txtCompanySafetyMeetingName.Text = this.SimpleForm1.Title; this.txtMeetingHours.Text = "1"; this.txtMeetingHostMan.Text = this.CurrUser.UserName; } } } #endregion /// /// 初始化下拉框 /// private void InitDropDownList() { UserService.InitUserDropDownList(this.drpCompileMan, null, true); } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存数据 /// /// private void SaveData(string type) { Model.Meeting_CompanySafetyMeeting CompanySafetyMeeting = new Model.Meeting_CompanySafetyMeeting { CompanySafetyMeetingCode = this.txtCompanySafetyMeetingCode.Text.Trim(), CompanySafetyMeetingName = this.txtCompanySafetyMeetingName.Text.Trim(), CompanySafetyMeetingDate = Funs.GetNewDateTime(this.txtCompanySafetyMeetingDate.Text.Trim()) }; if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { CompanySafetyMeeting.CompileMan = this.drpCompileMan.SelectedValue; } CompanySafetyMeeting.AttentPersonNum = Funs.GetNewIntOrZero(this.txtAttentPersonNum.Text.Trim()); CompanySafetyMeeting.CompanySafetyMeetingContents = HttpUtility.HtmlEncode(this.txtCompanySafetyMeetingContents.Text); CompanySafetyMeeting.CompileDate = DateTime.Now; CompanySafetyMeeting.MeetingHours = Funs.GetNewInt(this.txtMeetingHours.Text.Trim()); CompanySafetyMeeting.MeetingHostMan = this.txtMeetingHostMan.Text.Trim(); CompanySafetyMeeting.AttentPerson = this.txtAttentPerson.Text.Trim(); if (!string.IsNullOrEmpty(this.CompanySafetyMeetingId)) { CompanySafetyMeeting.CompanySafetyMeetingId = this.CompanySafetyMeetingId; BLL.CompanySafetyMeetingService.UpdateCompanySafetyMeeting(CompanySafetyMeeting); BLL.LogService.AddSys_Log(this.CurrUser, CompanySafetyMeeting.CompanySafetyMeetingCode, CompanySafetyMeeting.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId, BLL.Const.BtnModify); } else { this.CompanySafetyMeetingId = SQLHelper.GetNewID(typeof(Model.Meeting_CompanySafetyMeeting)); CompanySafetyMeeting.CompanySafetyMeetingId = this.CompanySafetyMeetingId; BLL.CompanySafetyMeetingService.AddCompanySafetyMeeting(CompanySafetyMeeting); BLL.LogService.AddSys_Log(this.CurrUser, CompanySafetyMeeting.CompanySafetyMeetingCode, CompanySafetyMeeting.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId, BLL.Const.BtnAdd); } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.CompanySafetyMeetingId)) { SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}", this.CompanySafetyMeetingId, BLL.Const.CompanySafetyMeetingMenuId))); } #endregion protected void btnAttachUrl1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.CompanySafetyMeetingId)) { SaveData(Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}&strParam=1", this.CompanySafetyMeetingId, Const.CompanySafetyMeetingMenuId))); } protected void btnAttachUrl2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.CompanySafetyMeetingId)) { SaveData(Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/CompanySafetyMeetingAttachUrl&menuId={1}&strParam=2", this.CompanySafetyMeetingId, Const.CompanySafetyMeetingMenuId))); } /// /// 计算参会人数 /// /// /// protected void txtAttentPerson_Blur(object sender, EventArgs e) { string str = this.txtAttentPerson.Text.Trim(); if (!string.IsNullOrEmpty(str)) { if (str.Contains(",")) { this.txtAttentPersonNum.Text = str.Split(',').Length.ToString(); } else if (str.Contains(",")) { this.txtAttentPersonNum.Text = str.Split(',').Length.ToString(); } else if (str.Contains(";")) { this.txtAttentPersonNum.Text = str.Split(';').Length.ToString(); } else if (str.Contains(";")) { this.txtAttentPersonNum.Text = str.Split(';').Length.ToString(); } } } } }