username@email.com
2025-05-09 66beb245e516809514642c00922f0339bf760518
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.Sys;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Common;
using CY.WebForm.Pages.common;
using CY.BLL.EC;
using CY.Model.Inquiry;
using CY.Infrastructure.Query;
using System.Configuration;
 
namespace CY.WebForm.Pages.business
{
    public partial class AgOutsourcSingleAllEdit : BasePage
    {
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        EC_OrderBLL bll_EC_OrderBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
 
        public Guid targetid = Guid.Empty;
        public static string Keyid;
        public static bool IsFiles = false;
 
        public string strUploadFileURL
        {
            get
            {
                return ConfigurationManager.AppSettings["UploadFileURL"];
            }
        }
 
        public AgOutsourcSingleAllEdit()
        {
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_EC_OrderBLL = new EC_OrderBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
        }
 
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                switch (Request["Target"])
                {
                    case "ToUpSetData":
                        Page_Load_Default();
                        LoadOrderInfo();
                        return;
                    default:
                        Page_Load_Default();
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                Response.Write("-1");
            }
            Response.End();
        }
 
        private void LoadOrderInfo()
        {
            if (IsPostBack || IsCallback)
                return;
            targetid = CurrentUser.MemberId;
            this.txtDeliveryTime.Value = DateTime.Now.AddDays(15).ToString("yyyy-MM-dd");
            EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            string orderIdStr = Request["orderid"];
            //Keyid = Request["orderid"];
            if (string.IsNullOrEmpty(orderIdStr) || "0".Equals(orderIdStr))
                return;
            else
                ;
            if (string.IsNullOrEmpty(orderIdStr))
            {
                JavaScript.MessageBox("未传递参数!", this);
                return;
            }
            int? orderid = MyConvert.ConvertToInt32(orderIdStr);
            if (!orderid.HasValue)
            {
                JavaScript.MessageBox("未传递参数!", this);
                return;
            }
            EC_OrderPrintParameterBLL _eC_OrderPrintParameterBLL = new EC_OrderPrintParameterBLL();
            EC_OrderPrintParameter _eC_OrderPrintParameter = _eC_OrderPrintParameterBLL.GetModel(orderid.Value);
            InquiryCommonModel _inquiryCommonModel = null;
            if (null == _eC_OrderPrintParameter)
            {
                _inquiryCommonModel = new InquiryCommonModel();
            }
            else
            {
                _inquiryCommonModel = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), _eC_OrderPrintParameter.PrintParameter) as InquiryCommonModel;
            }
            this.txtAfterWorksDemand.InnerText = _inquiryCommonModel.AfterWorksDemand;
            this.txtPrintDemand.InnerText = _inquiryCommonModel.PrintDemand;
 
            EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderid.Value);
            this.spanOrderNum.InnerText = _eC_OrderBasic.SellerOrderId;
            this.spanOrderType.InnerText = _eC_OrderBasic.OrderType.Name;
            this.spanOrderTitle.InnerText = _eC_OrderBasic.DocumentName;
            this.spanOrderDeliveryTime.InnerText = _eC_OrderBasic.DeliveryTime == null ? "" : _eC_OrderBasic.DeliveryTime.Value.ToString("yyyy-MM-dd HH:mm");
 
            this.spanOrderCustormName.InnerText = _eC_OrderBasic.BuyerName;
            this.spanOrderCustormLevel.InnerText = _eC_OrderBasic.OrderExtend.CustomerLevel.Name;
            this.spanOrderCustormPeople.InnerText = _eC_OrderBasic.OrderExtend.Contacts;
            this.spanOrderCustormPhone.InnerText = _eC_OrderBasic.OrderExtend.ContactPhone;
            this.spanOrderBusinessManage.InnerText = _eC_OrderBasic.OrderExtend.BusinessManager.Name;
            this.spanOrderCustormManage.InnerText = _eC_OrderBasic.OrderExtend.CustomerManager.Name;
            this.spanVerifyWay.InnerText = _eC_OrderBasic.OrderExtend.ProofreadWay.Name;
            this.spanExigencyDegree.InnerText = _eC_OrderBasic.OrderExtend.ExigencyCase.Name;
 
            this.spanUnitPrice.InnerText = (_eC_OrderBasic.UnitPrice ?? 0).ToString("0.00");
            this.spanSumPrice.InnerText = (_eC_OrderBasic.SumPrice ??0).ToString("0.00");
            this.spanSurplusPrintNum.InnerText = _eC_OrderBasic.OrderExtend.SurplusPrintNum.ToString2();
 
            //this.spanSpecialOprator.InnerText = CurrentUser.ShortName;
            this.selBusinessManager.Value = _eC_OrderBasic.Creater;
            this.spanSpecialTime.InnerText = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            this.txtRemark.Value = _eC_OrderBasic.Remark.ToString2();
 
            Pagination pa = new Pagination();
            pa.PageSize = 500;
            pa.PageIndex = 1;
            var ss = bll_OA_CorporateClientsBLL.SelectModelPage(pa, CurrentUser.MemberId, "");
            this.selOutFirm.DataSource = ss;
            this.selOutFirm.DataTextField = "OutVendorName";
            this.selOutFirm.DataValueField = "FirmId";
            this.selOutFirm.DataBind();
            this.selOutFirm.Items.Insert(0, new ListItem("请选择", ""));
           var aaa  = ss.FirstOrDefault(x => x.OutVendorName == "其他");
            if (aaa != null)
            {
                this.selOutFirm.SelectedValue = aaa.FirmId.ToString();
            }
            selOutFirm_SelectedIndexChanged(null, null);
        }
 
        /// <summary>
        /// 默认执行方法
        /// </summary>
        private void Page_Load_Default()
        {
 
            btnSave.ServerClick += new EventHandler(btnSave_ServerClick);
            if (!IsPostBack && !IsCallback)
            {
                this.selExigencyDegree.DataSource = bll_Sys_DictionaryBLL.GetDataByType("OA_紧急程度");
                this.selExigencyDegree.DataBind();
                this.selExigencyDegree.Items.Add(new ListItem("请选择", ""));
                this.selExigencyDegree.Value = "0";
 
                this.selBusinessManager.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false);
                this.selBusinessManager.DataTextField = "Name";
                this.selBusinessManager.DataValueField = "Name";
                this.selBusinessManager.DataBind();
                //this.selBusinessManager.Items.Insert(0, new ListItem("全部", ""));
            }
        }
 
        /// <summary>
        /// 保存点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnSave_ServerClick(object sender, EventArgs e)
        {
 
            if (SaveOrder())
            {
                //操作成功
                JavaScript.RefreshDIVOpener(this);
            }
            else
            {
                //操作失败
                JavaScript.MessageBox("操作失败!", this);
            }
        }
 
        /// <summary>
        /// 保存订单
        /// </summary>
        private bool SaveOrder()
        {
            EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            string orderIdStr = Request["orderid"];
            if (string.IsNullOrEmpty(orderIdStr) || "0".Equals(orderIdStr))
                return false;
 
            if (string.IsNullOrEmpty(orderIdStr))
            {
                JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
            if (string.IsNullOrEmpty(this.selOutFirm.SelectedValue))
            {
                JavaScript.MessageBox("未选择外协厂商!", this);
                return false;
            }
            
            int? orderid = MyConvert.ConvertToInt32(orderIdStr);
            if (!orderid.HasValue)
            {
                JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
 
            OA_CorporateClients m_OA_CorporateClients_Out = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(this.selOutFirm.SelectedValue.ToGuid2(),CurrentUser.MemberId);
            OA_CustomerCommunications m_OA_CustomerCommunications_Out = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(m_OA_CorporateClients_Out.Keyid);
 
            EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderid.Value);
 
            EC_OrderExtend OrderExtend = new EC_OrderExtend(); 
            EC_OrderBasic m_EC_OrderBasicNew = new EC_OrderBasic();
            m_EC_OrderBasicNew.SellerId = this.selOutFirm.SelectedValue.ToGuid2();
            m_EC_OrderBasicNew.BuyerId = CurrentUser.MemberId;
            m_EC_OrderBasicNew.BuyerName = CurrentUser.Name;
            m_EC_OrderBasicNew.Creater = this.selBusinessManager.Value;// CurrentUser.ShortName;
            m_EC_OrderBasicNew.Operator = CurrentUser.ShortName;
            m_EC_OrderBasicNew.DeliveryTime = this.txtDeliveryTime.Value.ToDateTime2();
            m_EC_OrderBasicNew.DocumentName = _eC_OrderBasic.DocumentName;
            m_EC_OrderBasicNew.OrderTypeId = 2;
            m_EC_OrderBasicNew.PrintTypeId = _eC_OrderBasic.PrintTypeId;
            m_EC_OrderBasicNew.Remark = this.txtRemark.Value.ToString2();
            m_EC_OrderBasicNew.SellerName = m_OA_CorporateClients_Out.OutVendorName;
            m_EC_OrderBasicNew.SumPrice = this.txtAllMoney.Value.ToDecimal2();
 
            if (m_OA_CorporateClients_Out.Keyid != m_OA_CorporateClients_Out.FirmId)
            {
                m_EC_OrderBasicNew.OutId = orderid;
            }
            else
            {
                m_EC_OrderBasicNew.OutId = 0;
            }
 
            OrderExtend.BusinessManagerId = 0;
            OrderExtend.ContactPhone = m_OA_CustomerCommunications_Out.CompanyPhone;
            OrderExtend.Contacts = m_OA_CustomerCommunications_Out.BusinessManagers;
            OrderExtend.CustomerLevelId = m_OA_CorporateClients_Out.DegreeImportanId ?? 0;
            OrderExtend.CustomerManagerId = 0;
            OrderExtend.ExigencyCaseId = this.selExigencyDegree.Value.ToInt32();
            OrderExtend.FileId = 0;
            OrderExtend.InvoiceId = 0;
            OrderExtend.Operate = CurrentUser.ShortName;
            OrderExtend.PrintNum = _eC_OrderBasic.OrderExtend.SurplusPrintNum;
            OrderExtend.ProofreadFileId = 0;
            OrderExtend.ProofreadWayId = 0;
            OrderExtend.ProofreadState = 0;
            OrderExtend.Remark = "";
            OrderExtend.SurplusPrintNum = _eC_OrderBasic.OrderExtend.SurplusPrintNum;
 
            EC_AcceptWayByOrder m_EC_AcceptWayByOrder = new EC_AcceptWayByOrder();
            PayAbout.FillOrder(m_EC_OrderBasicNew, m_EC_AcceptWayByOrder);
            m_EC_OrderBasicNew.OrderExtend = OrderExtend;
 
            EC_OrderOperate m_EC_OrderOperate = new EC_OrderOperate();
            m_EC_OrderOperate.LastUpdateTime = DateTime.Now;
            m_EC_OrderOperate.OperateType = 3;
            m_EC_OrderOperate.Operator = CurrentUser.ShortName;
            m_EC_OrderOperate.OrderId = orderid;
            m_EC_OrderOperate.Remark = "";
 
            InquiryCommonModel m_InquiryCommonModel = new InquiryCommonModel();
            m_InquiryCommonModel.PrintDemand = this.txtPrintDemand.Value;
            m_InquiryCommonModel.PrintTypeId = _eC_OrderBasic.PrintTypeId.Value;
            m_InquiryCommonModel.PrintTypeName = _eC_OrderBasic.PrintType.PrintName;
            m_InquiryCommonModel.AfterWorksDemand = this.txtAfterWorksDemand.Value;
 
            EC_OrderPrintParameter m_EC_OrderPrintParameter = new EC_OrderPrintParameter()//订单印刷参数
            {
                PrintParameter = SerializationHelper.Serialize(m_InquiryCommonModel)
            };
 
            //return bll_EC_OrderBLL.OutOrder(m_EC_OrderBasicNew, m_EC_AcceptWayByOrder, m_EC_OrderPrintParameter, m_EC_OrderOperate, 4, orderIdStr);
            bool isWin = false;
            isWin = bll_EC_OrderBLL.OutOrder(m_EC_OrderBasicNew, m_EC_AcceptWayByOrder, m_EC_OrderPrintParameter, m_EC_OrderOperate, 4, orderIdStr);
            if (!isWin)
            {
                return false;
            }
            if (this.cbkIsAllRecovery.Visible == true)
            {
                if (this.cbkIsAllRecovery.Checked == true)
                {
                    LF_OrderFile lfModel = new LF_OrderFile();
                    LF_OrderFileBLL lF_OrderFileBLL = new LF_OrderFileBLL();
 
                    EC_OrderBasic OrderModel = new EC_OrderBasic();
                    lfModel = lF_OrderFileBLL.GetModel(Convert.ToInt32(m_EC_OrderBasicNew.Keyid));
                    if (lfModel == null)
                    {
                        return false;
                    }
                    if (m_EC_OrderBasicNew.OutId > 0)
                    {
                        OrderModel = _eC_OrderBasicBLL.SelectModelById(Convert.ToInt32(_eC_OrderBasic.OutId));
                        lfModel.OrderId = Convert.ToInt32(_eC_OrderBasic.Keyid);
                    }
 
                    isWin = lF_OrderFileBLL.InserModel(lfModel);
                    if (!isWin)
                    {
                        return false;
                    }
                }
            }
            if (IsFiles)
            {
                OA_OrderWorkListRelation OrderWorkListRelationModel = new OA_OrderWorkListRelation();
                OrderWorkListRelationModel = bll_EC_OrderBLL.GetModelById(Convert.ToInt32(Request["orderid"]));
                if (OrderWorkListRelationModel != null)
                {
                    Keyid = OrderWorkListRelationModel.RelationTargetId.ToString();
                }
                string script = "<script>CheckSaveIsShowFiles()</script>";
                this.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", script);
            }
            return true;
 
 
        }
 
        protected void selOutFirm_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(selOutFirm.SelectedValue != "")
            {
                OA_CorporateClients oA_CorporateClientsModel = new OA_CorporateClients();
                oA_CorporateClientsModel = bll_OA_CorporateClientsBLL.GetModelByMemberIdAndName(CurrentUser.MemberId, selOutFirm.SelectedItem.Text.ToString());
                if (oA_CorporateClientsModel.Keyid != oA_CorporateClientsModel.FirmId)
                {
                    trFile.Visible = true;
                    LF_OrderFile lfModel = new LF_OrderFile();
                    LF_OrderFileBLL lF_OrderFileBLL = new LF_OrderFileBLL();
                    lfModel = lF_OrderFileBLL.GetModel(Convert.ToInt32(Request["orderid"]));
                    if (lfModel == null)
                    {
                        cbkIsAllRecovery.Visible = false;
                        IsFiles = true;
                    }
                    else
                    {
                        cbkIsAllRecovery.Visible = true;
                        IsFiles = false;
                    }
 
 
                }
                else
                {
                    trFile.Visible = false;
                    IsFiles = false;
                }
            }
            else
            {
                trFile.Visible = false;
                IsFiles = false;
            }
            string script = "<script>ReceiptT('member', '"+ CurrentUser.MemberId + "', 4, 100)</script>";
            this.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", script);
            
        }
    }
}