username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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;
using CY.BLL.Sys;
 
namespace CY.WebForm.Pages.work
{
    //吴辉
    //新增/修改公文管理    
    public partial class Adm_tongxunluAdd : BasePage
    {
        Adm_tongxunluBLL bll_Adm_tongxunluBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
        OA_DepartmentBll bll_OA_DepartmentBll = null;
        public string staffs = "";
        //初始化
        public Adm_tongxunluAdd()
        {
 
            bll_Adm_tongxunluBLL = new Adm_tongxunluBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
            bll_OA_DepartmentBll = new OA_DepartmentBll();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Pagination pa = new Pagination();
                pa.PageSize = 500;
                pa.PageIndex = 1;
                this.seltype.DataSource = bll_Sys_DictionaryBLL.GetDataByType("Sys_通讯录");
                this.seltype.DataValueField = "MeanValue";
                this.seltype.DataTextField = "Name";
                this.seltype.DataBind();
 
                InitData();
            }
        }
 
        //数据加载
        public void InitData()
        {
            this.seltype.Value = "";
            this.txtDanweiName.Value = "";
            this.txtLianxiren.Value = "";
            this.txtLianxidianhua.Value = "";
            this.txtBeuzhu.Text = "";
 
            if (string.IsNullOrEmpty(Request["keyid"]))
            {
                var oA_Staffs = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false).OrderBy(x => x.DepartmentId).ToList();
                for (int i = 0; i < oA_Staffs.Count; i++)
                {
                    if (i != 0 && oA_Staffs[i].DepartmentId != oA_Staffs[i - 1].DepartmentId)
                    {
                        var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId);
                        if (department != null)
                        {
                            staffs += "<br/>" + department.Name + ":";
                        }
                    }
                    if (i == 0)
                    {
                        var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId);
                        if (department != null)
                        {
                            staffs += department.Name + ":";
                        }
 
                    }
                    staffs += "   <input type=\"checkbox\" value='" + oA_Staffs[i].Keyid + "'   />" + oA_Staffs[i].Name;
 
                }
            }
 
 
 
            if (!string.IsNullOrEmpty(Request["keyid"]))
            {
                var adm_Tongxunlu = bll_Adm_tongxunluBLL.GetModelByKeyid(Request["keyid"].ToInt32().Value);
                if (adm_Tongxunlu != null)
                {
                    this.seltype.Value = adm_Tongxunlu.type_id.Value.ToString();
                    this.txtDanweiName.Value = adm_Tongxunlu.danwei_name;
                    this.txtLianxiren.Value = adm_Tongxunlu.lianxiren;
                    this.txtLianxidianhua.Value = adm_Tongxunlu.lianxidianhua;
                    this.txtBeuzhu.Text = adm_Tongxunlu.beuzhu;
 
 
                    var oA_Staffs = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false).OrderBy(x => x.DepartmentId).ToList();
                    for (int i = 0; i < oA_Staffs.Count; i++)
                    {
                        if (i != 0 && oA_Staffs[i].DepartmentId != oA_Staffs[i - 1].DepartmentId)
                        {
                            var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId);
                            if (department != null)
                            {
                                staffs += "<br/>" + department.Name + ":";
                            }
                        }
                        if (i == 0)
                        {
                            var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId);
                            if (department != null)
                            {
                                staffs += department.Name + ":";
                            }
 
                        }
 
                        var Jusequanxian = adm_Tongxunlu.Jusequanxian;
                        var Jusequanxians = Jusequanxian.Trim(',').Split(',');
                        if (Jusequanxians.Count(x => x == oA_Staffs[i].Keyid.Value.ToString()) > 0)
                        {
                            staffs += "   <input type=\"checkbox\" checked=\"checked\" value='" + oA_Staffs[i].Keyid + "'   />" + oA_Staffs[i].Name;
                        }
                        else
                        {
                            staffs += "   <input type=\"checkbox\" value='" + oA_Staffs[i].Keyid + "'   />" + oA_Staffs[i].Name;
                        }
 
 
 
                    }
                }
            }
           
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            try
            {
                DateTime nowTime = DateTime.Now;
                Adm_tongxunlu adm_Tongxunlu = new Adm_tongxunlu();
 
                if (!string.IsNullOrEmpty(Request["keyid"]))
                {
                    adm_Tongxunlu = bll_Adm_tongxunluBLL.GetModelByKeyid(Request["keyid"].ToInt32().Value);
 
                    adm_Tongxunlu.FirmId = CurrentUser.MemberId;
                    adm_Tongxunlu.type_id = this.seltype.Value.ToInt32().Value;
                    adm_Tongxunlu.danwei_name = this.txtDanweiName.Value.Trim();
                    adm_Tongxunlu.lianxiren = this.txtLianxiren.Value.Trim();
                    adm_Tongxunlu.lianxidianhua = this.txtLianxidianhua.Value.Trim();
                    adm_Tongxunlu.beuzhu = this.txtBeuzhu.Text.Trim();
                    adm_Tongxunlu.rec_status = "A";
                    adm_Tongxunlu.modifier = CurrentUser.ShortName;
                    adm_Tongxunlu.modifytime = DateTime.Now;
                    adm_Tongxunlu.Jusequanxian = "," + this.deleteKeyIds.Value + ",";
 
 
                    if (bll_Adm_tongxunluBLL.UpdateModel(adm_Tongxunlu))
                    {
                        JavaScript.MessageBox("修改成功", this, true, true);
                        //InitData();
                    }
                    else
                        JavaScript.MessageBox("修改失败", this);
                }
                else
                {
 
                    adm_Tongxunlu.FirmId = CurrentUser.MemberId;
                    adm_Tongxunlu.type_id = this.seltype.Value.ToInt32().Value;
                    adm_Tongxunlu.danwei_name = this.txtDanweiName.Value.Trim();
                    adm_Tongxunlu.lianxiren = this.txtLianxiren.Value.Trim();
                    adm_Tongxunlu.lianxidianhua = this.txtLianxidianhua.Value.Trim();
                    adm_Tongxunlu.beuzhu = this.txtBeuzhu.Text.Trim();
                    adm_Tongxunlu.rec_status = "A";
                    adm_Tongxunlu.creater = CurrentUser.ShortName;
                    adm_Tongxunlu.createtime = DateTime.Now;
                    adm_Tongxunlu.modifier = adm_Tongxunlu.creater;
                    adm_Tongxunlu.modifytime = adm_Tongxunlu.createtime;
                    adm_Tongxunlu.Jusequanxian = "," + this.deleteKeyIds.Value + ",";
 
 
 
 
                    if (bll_Adm_tongxunluBLL.InsertModel(adm_Tongxunlu))
                    {
                        JavaScript.MessageBox("新增成功", this, false, true);
                        InitData();
                    }
                    else
                        JavaScript.MessageBox("新增失败", this);
                }
                
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
      
    }
}