username@email.com
2025-03-25 111fae25722710296a2ed9dce65dced57bb79419
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.EC;
using CY.Model;
using CY.Infrastructure.Common;
using CY.BLL.Integrity;
using CY.BLL;
using System.Threading.Tasks;
using System.Transactions;
using CY.BLL.OA;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //卖家评价
    public partial class Waixiefukuanshenqing : BasePage
    {
        EC_OrderBasicBLL bll_EC_OrderBasicBLL = null;
        EC_OrderBLL _eC_OrderBLL = null;
        OA_FukuanshenqingBLL _oA_FukuanshenqingBLL = null;
        OA_CorporateClientsBLL _oA_CorporateClientsBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
        OA_WorkPlanBll oA_WorkReminderBll = null;
        OA_SuppliersBLL _OA_SuppliersBLL = null;
 
 
        //初始化
        public Waixiefukuanshenqing()
        {
            bll_EC_OrderBasicBLL = new EC_OrderBasicBLL();
            _eC_OrderBLL = new EC_OrderBLL();
            _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            _oA_FukuanshenqingBLL = new OA_FukuanshenqingBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
            oA_WorkReminderBll = new OA_WorkPlanBll();
            _OA_SuppliersBLL = new OA_SuppliersBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                switch (Request["Target"])
                {
                    case "GetSuplier":
                        LoadCommunication();
                        break;
 
                    default:
                        if (!IsPostBack)
                        {
                            InitData();
                        }
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                //Response.Write("-1");
                Response.Write(ex.Message);
            }
            Response.End();
          
        }
 
        //绑定数据
        public void InitData()
        {
            string orderIdStr = Request["id"];
            string orderNoStr = Request["orderno"];
            if (!string.IsNullOrEmpty(orderIdStr))
            {
                this.ordernos.InnerText = orderNoStr.Trim(',');
                ////供应商
                //this.selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId);
                //this.selSuppliers.DataBind();
                //this.selSuppliers.Items.Insert(0, new ListItem("全部", ""));
 
                decimal total = 0;
 
                orderIdStr = orderIdStr.Trim(',');
                string[] idsArray = orderIdStr.Split(',');
                if (idsArray != null && idsArray.Length > 0)
                {
                    
                     
                    var models = _eC_OrderBLL.GetOrderByIds(orderIdStr).ToList();
                    if (models.Count > 0)
                    {
                      var  corporateClients = _oA_CorporateClientsBLL.GetModel(models[0].SellerId);
                        this.txtSupplierName.Value = corporateClients.OutVendorName;
                        this.selSuppliersss.Value = corporateClients.Keyid.ToString(); 
 
                     var sss =   _OA_SuppliersBLL.getSupplierByFirmId(CurrentUser.MemberId, corporateClients.OutVendorName.Trim()).ToList();
                        if (sss.Count > 0)
                        {
                            this.txtHuming.Value = sss[0].Huming;//  ["Huming"].ToString();
                            this.txtBank.Value = sss[0].Bank; //["Bank"].ToString();
                            this.txtAccountID.Value = sss[0].AccountID;//["AccountID"].ToString();
                        }
                    }
 
 
                    total = models.Sum(x => x.SumPrice) ?? 0;
 
 
 
 
                    ordernjine.InnerText = total.ToString("0.00");
                    this.txtZengjianmoney.Value = total.ToString("0.00");
                    //khname.InnerText = name;
                    //Dingdanshu.InnerText = orderIdStr.Split(',').Length +"个";
                }
                else
                {
                    JavaScript.CloseDIVOpener(this);
                }
            }
        }
 
 
        /// <summary>
        /// 加载供应商
        /// </summary>
        private void LoadCommunication()
        {
            Response.Clear();
            string id = Request["id"];
            if (string.IsNullOrEmpty(id))
            {
                Response.Write("-2");
                return;
            }
 
            var oA_Suppliers = _OA_SuppliersBLL.getSingleSupplier(id);
 
          
            Response.Write(null == oA_Suppliers ? "" : JsonHelper.GetJsonStringByObject(oA_Suppliers));
        }
 
        //提交事件
        protected void btn_Submit_form(object sender, EventArgs e)
        {
            AcceptAll3();                        
        }
 
        /// <summary>
        /// 批量开票申请
        /// </summary>
        public void AcceptAll3()
        {
 
            //if (string.IsNullOrEmpty(this.selSuppliers.Value))
            //{
            //    JavaScript.MessageBox("请选择收款单位!", this);
            //    return;
            //}
 
            if (this.txtZengjianmoney.Value.ToDecimal2()<=0)
            {
                JavaScript.MessageBox("请输入申请金额!", this);
                return;
            }
            string ids = Request["id"].Trim(',');
            string orderNoStr = Request["orderno"].Trim(',');
            string[] idsArray = ids.Split(',');
            if (idsArray != null && idsArray.Length > 0)
            {
                //EC_OrderBasic eC_OrderBasic = bll_EC_OrderBasicBLL.SelectModelById(idsArray[0].ToInt32().Value);
                //OA_CorporateClients oA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, eC_OrderBasic.BuyerId);
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
           new TransactionOptions
           {
               IsolationLevel = IsolationLevel.ReadCommitted,
               Timeout = TransactionManager.MaximumTimeout
           }
           )
                    )
                {
 
                    try
                    {
                        bool result = false;
 
                        OA_Fukuanshenqing oA_Fukuanshenqing = new OA_Fukuanshenqing();
 
 
 
                        oA_Fukuanshenqing.FirmId = CurrentUser.MemberId;
                        oA_Fukuanshenqing.SupplierId = this.selSuppliersss.Value;
                        oA_Fukuanshenqing.Fukuanshenqingstatus = 0;
                        oA_Fukuanshenqing.ApprovalStatus = 0;
                        oA_Fukuanshenqing.Fukuanmoney = this.txtZengjianmoney.Value.ToDecimal2();
 
                        oA_Fukuanshenqing.Bank = this.txtBank.Value;
                        oA_Fukuanshenqing.Huming = this.txtHuming.Value;
                        oA_Fukuanshenqing.AccountID = this.txtAccountID.Value;
                        oA_Fukuanshenqing.Yishoumoney = 0;
                        oA_Fukuanshenqing.Youwufapiao = 0;
                        oA_Fukuanshenqing.Fukuanyongtu = "外协加工费";
                        oA_Fukuanshenqing.FukuanStatus = 1 ;
                        oA_Fukuanshenqing.remark = "";
                        oA_Fukuanshenqing.DindanId = ids;
                       
 
 
 
                        oA_Fukuanshenqing.Creater = CurrentUser.ShortName;
                        oA_Fukuanshenqing.CreateTime = DateTime.Now;
                        oA_Fukuanshenqing.Updater = CurrentUser.ShortName;
                        oA_Fukuanshenqing.LastUpdateTime = DateTime.Now;
                        //var oA_Suppliers = _OA_SuppliersBLL.getSingleSupplier(this.selSuppliers.Value);
                        //var _SupplierName = "";
                        //if (oA_Suppliers != null)
                        //{
                        //    _SupplierName = oA_Suppliers.Name;
                        //}
 
                        var _SupplierName = this.txtSupplierName.Value;
                        oA_Fukuanshenqing.SupplierName = _SupplierName;
                        var id = _oA_FukuanshenqingBLL.InsertModel(oA_Fukuanshenqing);
 
                       
 
                        //需要添加审批信息
                        DateTime nowTime = DateTime.Now;
                            OA_WorkPlan 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 = 0;
                            m_OA_WorkPlan.EvaluationTime = nowTime;
                            m_OA_WorkPlan.RewardContent = "";
                            m_OA_WorkPlan.RewardMoney = 0;
                            m_OA_WorkPlan.RewardResult = "";
                            m_OA_WorkPlan.RewardType = 0;
 
                            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 = bll_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;
 
                            m_OA_WorkPlan.Operator = CurrentUser.ShortName;
                            m_OA_WorkPlan.PlanComplany = id.ToString();
                            m_OA_WorkPlan.PlanContent = orderNoStr + ",订单金额:" + this.ordernjine.InnerText + ", 收款单位:"+ _SupplierName + "。" ;
                            m_OA_WorkPlan.PlanDataType = 14;
                            m_OA_WorkPlan.PlanMoney = oA_Fukuanshenqing.Fukuanmoney;
                            m_OA_WorkPlan.PlanRemark = oA_Fukuanshenqing.remark;
                            m_OA_WorkPlan.PlanRunTime = DateTime.Now;
                            m_OA_WorkPlan.PlanTitle =  "订单金额:" + this.ordernjine.InnerText + ", 收款单位:" + _SupplierName + "。"; 
                            m_OA_WorkPlan.PlanType = 3;
                            m_OA_WorkPlan.LastUpdateTime = nowTime;
                        result = oA_WorkReminderBll.InsertModel(m_OA_WorkPlan);
 
 
 
 
                      
 
                        
                     
                        
 
                        if (!result)
                        {
                            return;
                        }
                        //}
                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        // 回滚事务
                    }
                    finally
                    {
                        // 释放资源
                        scope.Dispose();
                    }
                }
                //JavaScript.MessageBox("提交成功", this);
 
                //操作成功
                JavaScript.MessageBoxsssss("提交成功", this, true, true);
            }
        }
    }
}