1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
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 = "";
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                DateTime nowTime = DateTime.Now;
                OA_Document m_OA_Document = new OA_Document();
                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<OA_Document> m_OA_DocumentList = bll_OA_DocumentBLL.SelectModelListByPostId(CurrentUser.MemberId, Date1, Date2, this.txtDM_PostingId.SelectedValue.ToInt32()) as List<OA_Document>;
                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");
            }
        }
    }
}