using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using CY.Model; using CY.BLL; using CY.Infrastructure.Common; using CY.Infrastructure.Query; namespace CY.WebForm.Pages.work { //吴辉 //新增/修改公文管理 public partial class OA_DocumentAdd : BasePage { OA_DocumentBLL bll_OA_DocumentBLL = null; OA_DocumentDicBLL bll_OA_DocumentDicBLL = null; //初始化 public OA_DocumentAdd() { bll_OA_DocumentBLL = new OA_DocumentBLL(); bll_OA_DocumentDicBLL = new OA_DocumentDicBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Pagination pa = new Pagination(); pa.PageSize = 500; pa.PageIndex = 1; this.txtDM_PostingId.DataSource = bll_OA_DocumentDicBLL.SelectModelPage(pa, CurrentUser.MemberId, null, null, null, null, null); this.txtDM_PostingId.DataTextField = "ParType"; this.txtDM_PostingId.DataValueField = "Keyid"; this.txtDM_PostingId.DataBind(); this.txtDM_PostingId.Items.Insert(0, new ListItem("请选择", "")); InitData(); } } //数据加载 public void InitData() { this.txtDM_Title.Value = ""; this.txtDM_Content.Text = ""; this.txtDM_ThemeWords.Value = ""; this.txtDM_CCUnit.Text = ""; this.txtDM_PrintNumber.Value = ""; this.txtDM_PostingId.SelectedValue = ""; this.txtDM_PostingFirmName.InnerHtml = ""; this.txtDM_DocumentType.Value = ""; this.txtDM_Number.Value = ""; this.txtDM_DocumentNumber.InnerHtml = ""; if (!string.IsNullOrEmpty(Request["keyid"])) { OA_Document m_OA_Document = bll_OA_DocumentBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_Document != null) { this.txtDM_Title.Value = m_OA_Document.DM_Title.ToString2(); ; this.txtDM_Content.Text = m_OA_Document.DM_Content; this.txtDM_ThemeWords.Value = m_OA_Document.DM_ThemeWords; this.txtDM_CCUnit.Text = m_OA_Document.DM_CCUnit; this.txtDM_PrintNumber.Value = m_OA_Document.DM_PrintNumber.HasValue ? m_OA_Document.DM_PrintNumber.Value.ToString() : ""; this.txtDM_PostingId.SelectedValue = m_OA_Document.DM_PostingId.HasValue ? m_OA_Document.DM_PostingId.Value.ToString() : ""; OA_DocumentDic m_OA_DocumentDic = bll_OA_DocumentDicBLL.GetModelByKeyid(this.txtDM_PostingId.SelectedValue.ToInt32()); this.txtDM_PostingFirmName.InnerHtml = m_OA_DocumentDic.ParName; this.txtDM_DocumentType.Value = m_OA_Document.DM_DocumentType; this.txtDM_Number.Value = m_OA_Document.DM_Number.HasValue ? m_OA_Document.DM_Number.Value.ToString() : ""; this.txtDM_DocumentNumber.InnerHtml = m_OA_Document.DM_DocumentNumber; } } } //表单提交 protected void btn_submit_form(object sender, EventArgs e) { try { DateTime nowTime = DateTime.Now; OA_Document m_OA_Document = new OA_Document(); if (!string.IsNullOrEmpty(Request["keyid"])) { m_OA_Document = bll_OA_DocumentBLL.GetModelByKeyid(Request["keyid"].ToInt32()); m_OA_Document.FirmId = CurrentUser.MemberId; m_OA_Document.DM_PromulgatedDate = nowTime; m_OA_Document.DM_DelTime = nowTime; m_OA_Document.DM_PrintTime = nowTime; m_OA_Document.DM_PrintStatus = 1; m_OA_Document.DM_Status = 1; OA_DocumentDic m_OA_DocumentDic = bll_OA_DocumentDicBLL.GetModelByKeyid(this.txtDM_PostingId.SelectedValue.ToInt32()); m_OA_Document.DM_PostingId = this.txtDM_PostingId.SelectedValue.ToInt32(); m_OA_Document.DM_PostingName = m_OA_DocumentDic.ParType; m_OA_Document.DM_PostingFirmName = m_OA_DocumentDic.ParName; m_OA_Document.DM_DocumentType = this.txtDM_DocumentType.Value.ToString2(); m_OA_Document.DM_Number = this.txtDM_Number.Value.ToInt32(); //m_OA_Document.DM_DocumentNumber = m_OA_DocumentDic.ParType + "(" + DateTime.Now.Year.ToString2() + ")" + "第 " + this.txtDM_Number.Value.ToInt32().Value.ToString("000") + " 号"; m_OA_Document.DM_Title = this.txtDM_Title.Value.ToString2(); m_OA_Document.DM_Content = this.txtDM_Content.Text.ToString2(); m_OA_Document.DM_ThemeWords = this.txtDM_ThemeWords.Value.ToString2(); m_OA_Document.DM_CCUnit = this.txtDM_CCUnit.Text.ToString2(); m_OA_Document.DM_PrintNumber = this.txtDM_PrintNumber.Value.ToInt32(); m_OA_Document.LastUpdateTime = nowTime; m_OA_Document.Operator = CurrentUser.ShortName; if (bll_OA_DocumentBLL.UpdateModel(m_OA_Document)) { JavaScript.MessageBox("修改成功", this, true, true); //InitData(); } else JavaScript.MessageBox("修改失败", this); } else { m_OA_Document.FirmId = CurrentUser.MemberId; m_OA_Document.DM_PromulgatedDate = nowTime; m_OA_Document.DM_DelTime = nowTime; m_OA_Document.DM_PrintTime = nowTime; m_OA_Document.DM_PrintStatus = 1; m_OA_Document.DM_Status = 1; OA_DocumentDic m_OA_DocumentDic = bll_OA_DocumentDicBLL.GetModelByKeyid(this.txtDM_PostingId.SelectedValue.ToInt32()); m_OA_Document.DM_PostingId = this.txtDM_PostingId.SelectedValue.ToInt32(); m_OA_Document.DM_PostingName = m_OA_DocumentDic.ParType; m_OA_Document.DM_PostingFirmName = m_OA_DocumentDic.ParName; m_OA_Document.DM_DocumentType = this.txtDM_DocumentType.Value.ToString2(); m_OA_Document.DM_Number = this.txtDM_Number.Value.ToInt32(); m_OA_Document.DM_DocumentNumber = m_OA_DocumentDic.ParType + "(" + DateTime.Now.Year.ToString2() + ")" + "第 " + this.txtDM_Number.Value.ToInt32().Value.ToString("000") + " 号"; m_OA_Document.DM_Title = this.txtDM_Title.Value.ToString2(); m_OA_Document.DM_Content = this.txtDM_Content.Text.ToString2(); m_OA_Document.DM_ThemeWords = this.txtDM_ThemeWords.Value.ToString2(); m_OA_Document.DM_CCUnit = this.txtDM_CCUnit.Text.ToString2(); m_OA_Document.DM_PrintNumber = this.txtDM_PrintNumber.Value.ToInt32(); m_OA_Document.LastUpdateTime = nowTime; m_OA_Document.Operator = CurrentUser.ShortName; if (bll_OA_DocumentBLL.InsertModel(m_OA_Document)) { JavaScript.MessageBox("新增成功", this, false, true); InitData(); } else JavaScript.MessageBox("新增失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } //发文部门切换 protected void ChangeDM_PostingId(object sender, EventArgs e) { if (this.txtDM_PostingId.SelectedValue.ToInt32() > 0) { OA_DocumentDic m_OA_DocumentDic = bll_OA_DocumentDicBLL.GetModelByKeyid(this.txtDM_PostingId.SelectedValue.ToInt32()); this.txtDM_PostingFirmName.InnerText = m_OA_DocumentDic.ParName; string outnumber = string.Empty; int No = 0; DateTime? Date1 = (DateTime.Now.Year.ToString() + "-1-1").ToDateTime2(); DateTime? Date2 = ((DateTime.Now.Year + 1).ToString() + "-1-1").ToDateTime2(); List m_OA_DocumentList = bll_OA_DocumentBLL.SelectModelListByPostId(CurrentUser.MemberId, Date1, Date2, this.txtDM_PostingId.SelectedValue.ToInt32()) as List; if (m_OA_DocumentList.Count > 0) { int? a = m_OA_DocumentList[0].DM_Number + 1; No = a.Value; } else { No = 1; } outnumber += m_OA_DocumentDic.ParType + "(" + DateTime.Now.Year.ToString2() + ")" + "第 " + No.ToString("000") + " 号"; this.txtDM_DocumentNumber.InnerText = outnumber; this.txtDM_Number.Value = No.ToString(); this.txtDM_Number.Attributes.Add("min", No.ToString()); } else { this.txtDM_PostingFirmName.InnerText = ""; this.txtDM_DocumentNumber.InnerText = ""; this.txtDM_Number.Value = "1"; this.txtDM_Number.Attributes.Add("min", "0"); } } } }