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
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 AgOutsourcSingleAfterUpdate : BasePage
    {
        EC_SpecialOrdersBLL bll_EC_SpecialOrdersBLL = null;
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        EC_OrderBLL bll_EC_OrderBLL = null;
        EC_OrderPrintParameterBLL _eC_OrderPrintParameterBLL = null;
        public Guid targetid = Guid.Empty;
 
        //初始化
        public AgOutsourcSingleAfterUpdate()
        {
            bll_EC_SpecialOrdersBLL = new EC_SpecialOrdersBLL();
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_EC_OrderBLL = new EC_OrderBLL();
            _eC_OrderPrintParameterBLL = new EC_OrderPrintParameterBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }
 
        /// <summary>
        /// 加载后道外协单信息
        /// </summary>
        private bool InitData()
        {
            targetid = CurrentUser.MemberId;
 
            #region 获取订单及其相关
 
            EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            string orderIdStr = Request["orderid"];
            string oldidStr = Request["oldid"];
            if (string.IsNullOrEmpty(orderIdStr) || string.IsNullOrEmpty(oldidStr))
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
            int? orderId = MyConvert.ConvertToInt32(orderIdStr);
            int? oldid = MyConvert.ConvertToInt32(oldidStr);
            if (!orderId.HasValue || !oldid.HasValue)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this);
                return false;
            }
 
            EC_OrderBasic _eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderId.Value);
            EC_OrderBasic _Old_eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(oldid.Value);
            if (null == _eC_OrderBasic || null == _Old_eC_OrderBasic)
            {
                CY.WebForm.BasePage.JavaScript.MessageBox("数据不存在!", this);
                return false;
            }
 
           
            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.txtPrintCount.Value = _eC_OrderBasic.OrderExtend.PrintNum.ToString2();
            this.txtAllMoney.Value = (_eC_OrderBasic.SumPrice??0).ToString("0.00");
            this.txtUnitPrice.Value = (_eC_OrderBasic.UnitPrice??0).ToString("0.00");
 
            this.spanCustomName.InnerText = _Old_eC_OrderBasic.BuyerName;
 
            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();
 
            this.selOutFirm.Value = _eC_OrderBasic.SellerId.ToString2();
 
            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);
            }
        }
 
        /// <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;
            }
            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);
 
            EC_OrderBasic m_EC_OrderBasicNew = _eC_OrderBasicBLL.SelectModelById(orderid.Value);
 
 
            m_EC_OrderBasicNew.SellerId = this.selOutFirm.Value.ToGuid2();
            m_EC_OrderBasicNew.Creater = CurrentUser.ShortName;
            m_EC_OrderBasicNew.Operator = CurrentUser.ShortName;
            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();
 
            m_EC_OrderBasicNew.OrderExtend.PrintNum = this.txtPrintCount.Value.ToInt32();
            m_EC_OrderBasicNew.OrderExtend.SurplusPrintNum = this.txtPrintCount.Value.ToInt32();
            
            InquiryCommonModel m_InquiryCommonModel = new InquiryCommonModel();
            m_InquiryCommonModel.PrintDemand = "";
            m_InquiryCommonModel.PrintTypeId = m_EC_OrderBasicNew.PrintTypeId.Value;
            m_InquiryCommonModel.PrintTypeName = m_EC_OrderBasicNew.PrintType.PrintName;
            m_InquiryCommonModel.AfterWorksDemand = this.txtAfterWorksDemand.Value;
 
            EC_OrderPrintParameter _eC_OrderPrintParameter = _eC_OrderPrintParameterBLL.GetModel(m_EC_OrderBasicNew.Keyid.Value);
            EC_OrderPrintParameter m_EC_OrderPrintParameter = new EC_OrderPrintParameter()//订单印刷参数
            {
                PrintParameter = SerializationHelper.Serialize(m_InquiryCommonModel)
            };
            m_EC_OrderPrintParameter.OrderId = _eC_OrderPrintParameter.OrderId;
 
            return bll_EC_OrderBLL.UpdateOutOrderInfo(m_EC_OrderBasicNew, m_EC_OrderBasicNew.OrderExtend, m_EC_OrderPrintParameter);
 
        }
    }
}