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.Party { public partial class OrganizingLifeEdit : PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = Request.Params["organizingLifeId"]; string year = DateTime.Now.Year.ToString(); if (!string.IsNullOrEmpty(Request.Params["Year"])) { year = Request.Params["Year"]; } if (!string.IsNullOrEmpty(Request.Params["type"])) { this.btnSave.Hidden = true; } ConstValue.InitConstValueDropDownList(this.drpQuarter, ConstValue.Group_0011, true); PartyerService.InitPartyerDropDownList(drpPartyers, false); if (!string.IsNullOrEmpty(id)) { Model.Party_OrganizingLife organizingLife = BLL.OrganizingLifeService.GetOrganizingLifeById(id); if (organizingLife != null) { this.hdId.Text = id; if (organizingLife.Year != null) { this.txtYear.Text = organizingLife.Year.ToString(); } if (organizingLife.Quarter != null) { this.drpQuarter.SelectedValue = organizingLife.Quarter.ToString(); } this.txtTheme.Text = organizingLife.Theme; if (organizingLife.OrganizingLifeDate != null) { this.txtOrganizingLifeDate.Text = string.Format("{0:yyyy-MM-dd}", organizingLife.OrganizingLifeDate); } if (!string.IsNullOrEmpty(organizingLife.Partyers)) { this.drpPartyers.SelectedValueArray = organizingLife.Partyers.Split(','); } } } else { this.txtYear.Text = year; this.txtOrganizingLifeDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 { this.hdId.Text = SQLHelper.GetNewID(typeof(Model.Party_OrganizingLife)); } if (!string.IsNullOrEmpty(Request.Params["type"])) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/Party/OrganizingLife&menuId={1}", this.hdId.Text, BLL.Const.OrganizingLifeMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/Party/OrganizingLife&menuId={1}", this.hdId.Text, BLL.Const.OrganizingLifeMenuId))); } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpQuarter.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择季度", MessageBoxIcon.Warning); return; } string id = Request.Params["organizingLifeId"]; Model.Party_OrganizingLife newOrganizingLife = new Model.Party_OrganizingLife(); newOrganizingLife.Year = Funs.GetNewIntOrZero(this.txtYear.Text.Trim()); newOrganizingLife.Quarter = Funs.GetNewInt(this.drpQuarter.SelectedValue); newOrganizingLife.Theme = this.txtTheme.Text.Trim(); newOrganizingLife.OrganizingLifeDate = Funs.GetNewDateTimeOrNow(this.txtOrganizingLifeDate.Text.Trim()); string partyers = Funs.GetStringByArray(this.drpPartyers.SelectedValueArray); newOrganizingLife.Partyers = partyers; if (!string.IsNullOrEmpty(id)) { newOrganizingLife.OrganizingLifeId = id; BLL.OrganizingLifeService.UpdateOrganizingLife(newOrganizingLife); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newOrganizingLife.OrganizingLifeId = this.hdId.Text.Trim(); } else { newOrganizingLife.OrganizingLifeId = SQLHelper.GetNewID(typeof(Model.Party_OrganizingLife)); this.hdId.Text = newOrganizingLife.OrganizingLifeId; } newOrganizingLife.CompileMan = this.CurrUser.UserId; newOrganizingLife.CompileDate = DateTime.Now; BLL.OrganizingLifeService.AddOrganizingLife(newOrganizingLife); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }