username@email.com
2025-01-17 8d51a0762a43eedada5eb15bd24180d7204e63b3
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
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.BLL.Sys;
using CY.BLL.EC;
using CY.Infrastructure.DESEncrypt;
using CY.Infrastructure.Query;
using CY.BLL.OA;
using System.Transactions;
 
namespace CY.WebForm.Pages.work
{
    //吴辉
    //新增请示
    public partial class MyBaoxiaoAdd : BasePage
    {
 
        OA_DepartmentBll departmentBll = null;
        OA_StaffBLL oA_StaffBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        OA_WorkPlanBll oA_WorkReminderBll = null;
        OA_CarDictionaryBLL bll_OA_CarDictionaryBLL = null;
        OA_SuppliersBLL _OA_SuppliersBLL = null;
        OA_SubjectSetBLL _OA_SubjectSetBLL = null;
        OA_WorkPlan_attachmentBLL oA_WorkPlan_AttachmentBLL = null;
        OA_WorkPlan_shenpiBLL oA_WorkPlan_ShenpiBLL = null;
        public string reado = "";
        public MyBaoxiaoAdd()
        {
            departmentBll = new OA_DepartmentBll();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            oA_WorkReminderBll = new OA_WorkPlanBll();
            oA_StaffBLL = new OA_StaffBLL();
            bll_OA_CarDictionaryBLL = new OA_CarDictionaryBLL();
            _OA_SuppliersBLL = new OA_SuppliersBLL();
            _OA_SubjectSetBLL = new OA_SubjectSetBLL();
            oA_WorkPlan_AttachmentBLL = new OA_WorkPlan_attachmentBLL();
            oA_WorkPlan_ShenpiBLL = new OA_WorkPlan_shenpiBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
                  this.txtStaff.Value = CurrentUser.TrueName;
             var staff  =   oA_StaffBLL.GetModelByKeyid(CurrentUser.StaffId);
                if (staff != null)
                {
                    this.txtDepart.Value = staff.DepartmentName;
                }
                //科目名称
                this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "贷");
                this.selSubject.DataBind();
                this.selSubject.Items.Insert(0, new ListItem("请选择", ""));
 
 
                InitData();
            }
        }
 
        //数据加载
        public void InitData()
        {
            if (Request["keyid"].ToInt32() > 0)
            {
                var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value).ToList();
                if (oA_WorkPlan_Shenpis.Count > 0)
                {
                    txtPlanMoney.Disabled = true;
                    selSubject.Disabled = true;
                    txtPlanContent.Disabled = true;
                    selHoubufapiaoStatus.Disabled = true;
                   
                }
 
                OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32());
                if (m_OA_WorkPlan != null)
                {
 
                    this.txtPlanMoney.Value = m_OA_WorkPlan.PlanMoney.Value.ToString("0.00");
                    this.selHoubufapiaoStatus.Value = m_OA_WorkPlan.HoubufapiaoStatus.ToString();
                    this.selSubject.Value = m_OA_WorkPlan.RewardResult;
                    this.txtPlanContent.Value = m_OA_WorkPlan.PlanContent.ToString();
                }
 
                var sss = oA_WorkPlan_AttachmentBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value);
 
                this.RepClientList.DataSource = sss.Where(x => x.AttachmentType == 1);
                this.RepClientList.DataBind();
 
                this.Repeater1.DataSource = sss.Where(x => x.AttachmentType == 2);
                this.Repeater1.DataBind();
            }
 
 
          
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
             var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(',');
                if(HideKeyidFapiao.Length<=1 && this.selHoubufapiaoStatus.Value  == "1")
                {
                    JavaScript.MessageBox("选择有发票必须上传发票", this);
                    return;
                }
 
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
     new TransactionOptions
     {
         IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
         Timeout = TransactionManager.MaximumTimeout
     }
     )
              )
            {
                try
                {
 
 
                    DateTime nowTime = DateTime.Now;
                    OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32());
                    if (m_OA_WorkPlan == null)
                    {
                        m_OA_WorkPlan = new OA_WorkPlan();
                        m_OA_WorkPlan.ApprovalContent = "";
                        m_OA_WorkPlan.ApprovalStaffId = Guid.Empty;
                        m_OA_WorkPlan.ApprovalStaffName = "";
                        m_OA_WorkPlan.ApprovalStatus = 0;
                        m_OA_WorkPlan.ApprovalTime = nowTime;
                        m_OA_WorkPlan.EvaluationContent = "";
                        m_OA_WorkPlan.EvaluationStaff = "";
                        m_OA_WorkPlan.EvaluationStaffId = Guid.Empty;
                        m_OA_WorkPlan.EvaluationStatus = 2;
                        m_OA_WorkPlan.EvaluationTime = nowTime;
                        m_OA_WorkPlan.RewardMoney = 0;
                        m_OA_WorkPlan.RewardType = 1;
 
 
                        m_OA_WorkPlan.PlanStartTime = nowTime;
                        m_OA_WorkPlan.PlanStatus = 1;
                        m_OA_WorkPlan.SentStaffId = CurrentUser.TrueMemberId;
                        m_OA_WorkPlan.MemberId = CurrentUser.MemberId;
 
                        OA_Staff m_OA_Staff = oA_StaffBLL.GetModelByMemberId(CurrentUser.TrueMemberId);
                        if (m_OA_Staff != null)
                            m_OA_WorkPlan.DepartId = m_OA_Staff.DepartmentId;
                        else
                            m_OA_WorkPlan.DepartId = 0;
 
                        m_OA_WorkPlan.PlanPeople = CurrentUser.TrueName;
                        m_OA_WorkPlan.ReciveStaffId = CurrentUser.TrueMemberId;
                    }
                    else
                    {
 
                    }
                    m_OA_WorkPlan.RewardResult = this.selSubject.Value;
                    var a_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(this.selSubject.Value.ToInt32());
                    if (a_SubjectSet != null)
                    {
                        m_OA_WorkPlan.RewardContent = a_SubjectSet.SubjectName;
                    }
 
                    m_OA_WorkPlan.PlanComplany = "";
                    m_OA_WorkPlan.Operator = CurrentUser.ShortName;
                    m_OA_WorkPlan.HoubufapiaoStatus = this.selHoubufapiaoStatus.Value.ToInt32();
 
 
                    m_OA_WorkPlan.PlanContent = this.txtPlanContent.Value.Trim();
                    m_OA_WorkPlan.PlanDataType = 17;
                    m_OA_WorkPlan.PlanMoney = this.txtPlanMoney.Value.Trim().ToDecimal2() ?? 0;
                    m_OA_WorkPlan.PlanRemark = "";
                    m_OA_WorkPlan.PlanRunTime = DateTime.Now;
                    m_OA_WorkPlan.PlanTitle = "";
 
                    m_OA_WorkPlan.PlanType = 3;
                    m_OA_WorkPlan.LastUpdateTime = nowTime;
 
                    if (Request["keyid"].ToInt32() > 0)
                    {
                        bool res = true;
                        var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value).ToList();
                        if (oA_WorkPlan_Shenpis.Count == 0)
                        {
                            res = oA_WorkReminderBll.UpdateModel(m_OA_WorkPlan);
                        }
 
                        if (res)
                        {
                            //var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(',');
                            var HideAttachmentFapiao = Request["HideAttachmentFapiao"].Split(',');
 
 
                            var HideKeyidFujian = Request["HideKeyidFujian"].Split(',');
                            var HideAttachmentFujian = Request["HideAttachmentFujian"].Split(',');
                            //需要删除的附件
                          var oA_WorkPlan_Attachments =  oA_WorkPlan_AttachmentBLL.GetModelByKaipiaoId(m_OA_WorkPlan.Keyid.Value);
                            List<int> HideKeyidFujianid = new List<int>();
                            for (int i = 0; i < HideKeyidFapiao.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(HideKeyidFapiao[i]) && HideKeyidFapiao[i].ToInt32() != 0)
                                {
                                    HideKeyidFujianid.Add(HideKeyidFapiao[i].ToInt32().Value);
                                }
                            }
                            for (int i = 0; i < HideKeyidFujian.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(HideKeyidFujian[i]) && HideKeyidFujian[i].ToInt32() != 0)
                                {
                                    HideKeyidFujianid.Add(HideKeyidFujian[i].ToInt32().Value);
                                }
                            }
                            var oA_WorkPlan_Attachments1 = oA_WorkPlan_Attachments.Where(x => !HideKeyidFujianid.Contains(x.Keyid)).ToList();
 
                            foreach(var oa_WorkPlan_Attachment  in oA_WorkPlan_Attachments1)
                            {
                                res =  oA_WorkPlan_AttachmentBLL.DeleteModel(oa_WorkPlan_Attachment);
                            }
 
                            for (int i = 0; i < HideKeyidFapiao.Length; i++)
                            {
                                if (string.IsNullOrEmpty(HideKeyidFapiao[i]))
                                {
                                    var a_WorkPlan_Attachment = new OA_WorkPlan_attachment();
                                    a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid;
                                    a_WorkPlan_Attachment.AttachmentType = 1;
                                    a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFapiao[i];
                                    a_WorkPlan_Attachment.CreateTime = DateTime.Now;
                                    a_WorkPlan_Attachment.Operator = CurrentUser.TrueName;
                                    var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment);
                                }
                                else
                                {
                                    continue;
                                }
                            }
 
 
                            for (int i = 0; i < HideKeyidFujian.Length; i++)
                            {
                                if (string.IsNullOrEmpty(HideKeyidFujian[i]))
                                {
                                    var a_WorkPlan_Attachment = new OA_WorkPlan_attachment();
                                    a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid;
                                    a_WorkPlan_Attachment.AttachmentType = 2;
                                    a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFujian[i];
                                    a_WorkPlan_Attachment.CreateTime = DateTime.Now;
                                    a_WorkPlan_Attachment.Operator = CurrentUser.TrueName;
                                    var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            scope.Complete();
                            JavaScript.MessageBox("更新成功", this, true, true);
                        }
                        else
                            JavaScript.MessageBox("操作失败", this);
                    }
                    else
                    {
                        var aaaa = oA_WorkReminderBll.InserModelAndGetId(m_OA_WorkPlan);
                        m_OA_WorkPlan.Keyid = aaaa;
                        if (aaaa > 0)
                        {
                            //var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(',');
                            var HideAttachmentFapiao = Request["HideAttachmentFapiao"].Split(',');
 
 
                            var HideKeyidFujian = Request["HideKeyidFujian"].Split(',');
                            var HideAttachmentFujian = Request["HideAttachmentFujian"].Split(',');
                            for (int i = 0; i < HideKeyidFapiao.Length; i++)
                            {
                                if (string.IsNullOrEmpty(HideKeyidFapiao[i]))
                                {
                                    var a_WorkPlan_Attachment = new OA_WorkPlan_attachment();
                                    a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid;
                                    a_WorkPlan_Attachment.AttachmentType = 1;
                                    a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFapiao[i];
                                    a_WorkPlan_Attachment.CreateTime = DateTime.Now;
                                    a_WorkPlan_Attachment.Operator = CurrentUser.TrueName;
                                    var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment);
                                }
                                else
                                {
                                    continue;
                                }
                            }
 
 
                            for (int i = 0; i < HideKeyidFujian.Length; i++)
                            {
                                if (string.IsNullOrEmpty(HideKeyidFujian[i]))
                                {
                                    var a_WorkPlan_Attachment = new OA_WorkPlan_attachment();
                                    a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid;
                                    a_WorkPlan_Attachment.AttachmentType = 2;
                                    a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFujian[i];
                                    a_WorkPlan_Attachment.CreateTime = DateTime.Now;
                                    a_WorkPlan_Attachment.Operator = CurrentUser.TrueName;
                                    var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment);
                                }
                                else
                                {
                                    continue;
                                }
                            }
 
                            scope.Complete();
 
 
                            JavaScript.MessageBox("新增成功", this, true, true);
                        }
                        else
                            JavaScript.MessageBox("操作失败", this);
                    }
                }
                catch (Exception ex)
                {
 
                    PAGEHandleException(ex);
                    JavaScript.MessageBox("操作失败", this);
                }
                finally
                {
                    // 释放资源
                    scope.Dispose();
                }
            }
 
        }
    }
}