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
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 System.Transactions;
using CY.BLL.OA;
 
namespace CY.WebForm.Pages.work
{
    //吴辉
    //工作考评
    public partial class BaoxiaoReplyAdd : BasePage
    {
        OA_WorkPlanBll oA_WorkReminderBll = null;
        OA_KaipiaoshenqingBLL _oA_KaipiaoshenqingBLL = null;
        EC_OrderBLL _eC_OrderBLL = null;
        OA_FukuanshenqingBLL _oA_FukuanshenqingBLL = null;
        EC_MemberBasicBLL _eC_MemberBasicBLL = null;
        OA_WorkPlan_attachmentBLL oA_WorkPlan_AttachmentBLL = null;
        OA_WorkPlan_shenpiBLL oA_WorkPlan_ShenpiBLL = null;
        OA_StaffBLL oA_StaffBLL = null;
        OA_DepartmentBll oA_DepartmentBll = null;
        public string planDataType = "";
        OA_SubjectSetBLL _OA_SubjectSetBLL = null;
        public BaoxiaoReplyAdd()
        {
            oA_WorkReminderBll = new OA_WorkPlanBll();
            _oA_KaipiaoshenqingBLL = new OA_KaipiaoshenqingBLL();
            _eC_OrderBLL = new EC_OrderBLL();
            _oA_FukuanshenqingBLL = new OA_FukuanshenqingBLL();
            _eC_MemberBasicBLL = new EC_MemberBasicBLL();
            oA_WorkPlan_AttachmentBLL = new OA_WorkPlan_attachmentBLL();
            oA_WorkPlan_ShenpiBLL = new OA_WorkPlan_shenpiBLL();
            oA_StaffBLL = new OA_StaffBLL();
            oA_DepartmentBll = new OA_DepartmentBll();
            _OA_SubjectSetBLL = new OA_SubjectSetBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //数据加载
        public void InitData()
        {
            //科目名称
            this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "贷");
            this.selSubject.DataBind();
            // this.selSubject.Items.Insert(0, new ListItem("请选择", ""));
 
            OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32());
            if (m_OA_WorkPlan != null)
            {
                planDataType = m_OA_WorkPlan.PlanDataType.Value.ToString();
                var department = oA_DepartmentBll.GetModelByKeyid(m_OA_WorkPlan.DepartId);
                if (department != null)
                {
                    this.spanDepart.InnerText = department.Name;
                }
                this.spanPlanPeople.InnerText = m_OA_WorkPlan.PlanPeople.ToString();
 
 
                this.txtPlanMoney.Value = m_OA_WorkPlan.PlanMoney.Value.ToString("0.00");
 
                this.selSubject.Value = m_OA_WorkPlan.RewardResult;
                this.txtPlanContent.Value = m_OA_WorkPlan.PlanContent;
                this.spanHoubufapiaoStatus.InnerText = m_OA_WorkPlan.HoubufapiaoStatusName;
                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();
 
 
                var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value);
                foreach (var a_WorkPlan_Shenpi in oA_WorkPlan_Shenpis)
                {
                    var oA_Staff = oA_StaffBLL.GetModelByMemberId(a_WorkPlan_Shenpi.ApprovalStaffId);
                    if (oA_Staff != null)
                    {
                        a_WorkPlan_Shenpi.ApprovalStaffName = oA_Staff.Name;
                    }
                }
 
                this.Repeater2.DataSource = oA_WorkPlan_Shenpis.OrderBy(x => x.Keyid);
                this.Repeater2.DataBind();
 
 
            }
        }
 
        //表单提交
        protected void btn_submit_form(object sender, EventArgs e)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
    new TransactionOptions
    {
        IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
        Timeout = TransactionManager.MaximumTimeout
    }
    )
             )
            {
                try
                {
                    string Messagezhuguan = null;
                    var oA_Staff = oA_StaffBLL.GetModelByMemberId(CurrentUser.TrueMemberId);
                    if (!oA_Staff.BF_IsBaoxiaozhuguan && !oA_Staff.BF_Isbaoxiaojingli)
                    {
                        JavaScript.MessageBox("你没有审批权限", this);
                        return;
                    }
                    OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32());
                    if (m_OA_WorkPlan.ApprovalStatus == 1 || m_OA_WorkPlan.ApprovalStatus == 2)
                    {
                        JavaScript.MessageBox("该报销已经审批完成", this);
                        return;
                    }
                    if (m_OA_WorkPlan.PlanMoney< this.txtPlanMoney.Value.ToDecimal2())
                    {
                        JavaScript.MessageBox("修改后的报销金额不能大于原报销金额", this);
                        return;
                    }
                    var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value).ToList();
 
 
                    if (oA_Staff.BF_IsBaoxiaozhuguan)
                    {
                        var oA_WorkPlan_Shenpis1 = oA_WorkPlan_Shenpis.Where(x => x.Buzhou == 1).ToList();
                        if (oA_WorkPlan_Shenpis1.Count > 1)
                        {
                            Messagezhuguan = "该流程已经不在主管审批步骤!";
                        }
 
                        var shenpicount = oA_WorkPlan_Shenpis1.Count(x => x.ApprovalStaffId == CurrentUser.TrueMemberId);
                        if (shenpicount > 0)
                        {
                            Messagezhuguan = "你已经审批过该流程!";
                        }
                    }
                    if (oA_Staff.BF_IsBaoxiaozhuguan && !oA_Staff.BF_Isbaoxiaojingli)
                    {
                        if (!string.IsNullOrEmpty(Messagezhuguan))
                        {
 
                            JavaScript.MessageBox(Messagezhuguan, this);
                            return;
                        }
                    }
 
                    string Messagejingli = null;
                    if (oA_Staff.BF_Isbaoxiaojingli)
                    {
                        if (oA_WorkPlan_Shenpis.Count > 2)
                        {
                            Messagejingli = "该流程已经审批完成!";
                        }
                        if (oA_WorkPlan_Shenpis.Count < 2)
                        {
                            Messagejingli = "没到经理审批步骤!";
                        }
                    }
                    if (!oA_Staff.BF_IsBaoxiaozhuguan && oA_Staff.BF_Isbaoxiaojingli)
                    {
                        if (!string.IsNullOrEmpty(Messagejingli))
                        {
 
                            JavaScript.MessageBox(Messagejingli, this);
                            return;
                        }
                    }
 
                    if (oA_Staff.BF_IsBaoxiaozhuguan && oA_Staff.BF_Isbaoxiaojingli)
                    {
                        if (!string.IsNullOrEmpty(Messagezhuguan) && !string.IsNullOrEmpty(Messagejingli))
                        {
 
                            JavaScript.MessageBox(Messagezhuguan + Messagejingli, this);
                            return;
                        }
                    }
 
                    m_OA_WorkPlan.PlanMoney = this.txtPlanMoney.Value.ToDecimal2();
                    m_OA_WorkPlan.RewardResult = this.selSubject.Value;
                    m_OA_WorkPlan.PlanContent = this.txtPlanContent.Value;
 
                    var a_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(this.selSubject.Value.ToInt32());
                    if (a_SubjectSet != null)
                    {
                        m_OA_WorkPlan.RewardContent = a_SubjectSet.SubjectName;
                    }
 
 
                    DateTime nowTime = DateTime.Now;
                    var res = false;
                    OA_WorkPlan_shenpi oA_WorkPlan_Shenpi = new OA_WorkPlan_shenpi();
                    oA_WorkPlan_Shenpi.OA_WorkPlanId = Request["keyid"].ToInt32();
                    oA_WorkPlan_Shenpi.ApprovalStaffId = CurrentUser.TrueMemberId;
                    oA_WorkPlan_Shenpi.ApprovalStatus = this.selApprovalStatus.Value.ToInt32();
                    oA_WorkPlan_Shenpi.ApprovalTime = nowTime;
                    oA_WorkPlan_Shenpi.ApprovalContent = this.txtApprovalContent.Value.Trim();
                    oA_WorkPlan_Shenpi.CreateTime = nowTime;
                    oA_WorkPlan_Shenpi.Operator = CurrentUser.TrueName;
                    if (oA_WorkPlan_Shenpis.Count == 2)
                    {
                        oA_WorkPlan_Shenpi.Buzhou = 2;
                    }
                    else
                    {
                        oA_WorkPlan_Shenpi.Buzhou = 1;
                    }
                    res = oA_WorkPlan_ShenpiBLL.InsertModel(oA_WorkPlan_Shenpi);
 
 
                    if (oA_WorkPlan_Shenpis.Count == 2 || this.selApprovalStatus.Value == "2")
                    {
 
                        m_OA_WorkPlan.ApprovalContent = this.txtApprovalContent.Value.Trim();
                        m_OA_WorkPlan.ApprovalStaffId = CurrentUser.TrueMemberId;
                        m_OA_WorkPlan.ApprovalStaffName = CurrentUser.TrueName;
                        m_OA_WorkPlan.ApprovalStatus = this.selApprovalStatus.Value.ToInt32();
                        m_OA_WorkPlan.ApprovalTime = nowTime;
                        m_OA_WorkPlan.PlanStatus = 2;
                        m_OA_WorkPlan.Operator = CurrentUser.ShortName;
                        m_OA_WorkPlan.LastUpdateTime = nowTime;
                        res = oA_WorkReminderBll.UpdateModel(m_OA_WorkPlan);
                    }
                    else
                    {
                        res = oA_WorkReminderBll.UpdateModel(m_OA_WorkPlan);
                    }
 
 
 
 
 
                    if (Request["keyid"].ToInt32() > 0)
                    {
                        if (res)
                        {
                            scope.Complete();
                            JavaScript.MessageBox("审批成功", this, true, true);
                        }
                          
                        else
                            JavaScript.MessageBox("操作失败", this);
                    }
                    else
                        JavaScript.MessageBox("操作失败", this);
                }
                catch (Exception ex)
                {
                    PAGEHandleException(ex);
                    JavaScript.MessageBox("操作失败", this);
                }
                finally
                {
                    // 释放资源
                    scope.Dispose();
                }
            }
        }
    }
}