username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
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
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.BLL.Sys;
using CY.Infrastructure.Common;
using CY.BLL;
using CY.Model.Inquiry;
using CY.BLL.OA;
using CY.Infrastructure.Query;
using CY.WebForm.Pages.common;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //后道外协
    public partial class AgOutsourcSingleAfterEdit : BasePage
    {
        EC_SpecialOrdersBLL bll_EC_SpecialOrdersBLL = null;
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        EC_OrderBLL bll_EC_OrderBLL = null;
        public Guid targetid = Guid.Empty;
 
        //初始化
        public AgOutsourcSingleAfterEdit()
        {
            bll_EC_SpecialOrdersBLL = new EC_SpecialOrdersBLL();
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_EC_OrderBLL = new EC_OrderBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        //加载合版施工单信息
        private bool InitData()
        {
            targetid = CurrentUser.MemberId;
 
            #region 获取订单及其相关
 
            EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            string orderIdStr = Request["orderid"];
            if (string.IsNullOrEmpty(orderIdStr))
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
            int? orderId = MyConvert.ConvertToInt32(orderIdStr);
            if (!orderId.HasValue)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
 
            EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.Value);
            if (null == _eC_OrderBasic)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("数据不存在!", this);
                return false;
            }
 
            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;
            }
 
            #endregion
 
            this.txtAfterWorksDemand.InnerText = _inquiryCommonModel.AfterWorksDemand;
            //this.txtPrintDemand.InnerText = _inquiryCommonModel.PrintDemand;
            this.txtPrintDemand.Visible = false;
 
            this.spanOrderNum.InnerText = _eC_OrderBasic.SellerOrderId;
            this.spanOrderType.InnerText = _eC_OrderBasic.OrderType.Name;
            this.spanOrderTitle.InnerText = _eC_OrderBasic.DocumentName;
            this.spanCustomName.InnerText = _eC_OrderBasic.BuyerName;
            this.txtPrintCount.Value = _eC_OrderBasic.OrderExtend.PrintNum.ToString2();
            //this.txtUnitPrice.Value = (_eC_OrderBasic.UnitPrice ?? 0).ToString("0.00");
            //this.txtAllMoney.Value = _eC_OrderBasic.SumPrice.Value.ToString("0.00");
 
            Pagination pa = new Pagination();
            pa.PageSize = 500;
            pa.PageIndex = 1;
            this.selOutFirm.DataSource = bll_OA_CorporateClientsBLL.SelectModelPage(pa, CurrentUser.MemberId, "");
            this.selOutFirm.DataTextField = "OutVendorName";
            this.selOutFirm.DataValueField = "FirmId";
            this.selOutFirm.DataBind();
 
            return true;
        }
 
        //提交事件
        protected void btn_Submit_form(object sender, EventArgs e)
        {
            try
            {
                if (SaveOrder())
                    JavaScript.RefreshDIVOpener(this);
                else
                    JavaScript.MessageBox("操作失败", this);
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
        //保存订单
        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;
            }
            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.Value.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.Value.ToGuid2();
            m_EC_OrderBasicNew.BuyerId = CurrentUser.MemberId;
            m_EC_OrderBasicNew.BuyerName = CurrentUser.Name;
            m_EC_OrderBasicNew.Creater = CurrentUser.ShortName;
            m_EC_OrderBasicNew.Operator = CurrentUser.ShortName;
            m_EC_OrderBasicNew.DeliveryTime = _eC_OrderBasic.DeliveryTime.ToDateTime2();
            m_EC_OrderBasicNew.DocumentName = _eC_OrderBasic.DocumentName;
            m_EC_OrderBasicNew.OrderTypeId = 4;
            m_EC_OrderBasicNew.PrintTypeId = _eC_OrderBasic.PrintTypeId;
            m_EC_OrderBasicNew.Remark = "";
            m_EC_OrderBasicNew.SellerName = m_OA_CorporateClients_Out.OutVendorName;
            m_EC_OrderBasicNew.SumPrice = this.txtAllMoney.Value.ToDecimal2();
            m_EC_OrderBasicNew.UnitPrice = this.txtUnitPrice.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 = _eC_OrderBasic.OrderExtend.ExigencyCaseId.Value.ToInt32();
            OrderExtend.FileId = 0;
            OrderExtend.InvoiceId = 0;
            OrderExtend.Operate = CurrentUser.ShortName;
            OrderExtend.PrintNum = this.txtPrintCount.Value.ToInt32();
            OrderExtend.ProofreadFileId = 0;
            OrderExtend.ProofreadWayId = 0;
            OrderExtend.ProofreadState = 0;
            OrderExtend.Remark = "";
            OrderExtend.SurplusPrintNum = this.txtPrintCount.Value.ToInt32();
 
 
            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 = "";
            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)
            };
 
            OA_OrderWorkListRelation m_OA_OrderWorkListRelation = new OA_OrderWorkListRelation();
            m_OA_OrderWorkListRelation.OrderId = _eC_OrderBasic.Keyid.ToInt32();
            m_OA_OrderWorkListRelation.RelationTargetId = 0;
            m_OA_OrderWorkListRelation.RelationTypeId = 3; //专版1,合版2,后道外协3,整单外协4
 
            return bll_EC_OrderBLL.OutOrder(m_EC_OrderBasicNew, m_EC_AcceptWayByOrder, m_EC_OrderPrintParameter, m_EC_OrderOperate, 3, orderIdStr);
 
        }
    }
}