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
/**  
* OrderEdit.aspx.cs
*
* 功 能: 订单列表
* 类 名: OrderEdit
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013-5-8 13:55       吴崎均    初版
* V0.02  2013-5-8 15:47       吴崎均    实现下拉数据绑定与数据级联
* V0.03  2013-5-8 18:00       吴崎均    初步完成新增线下订单(未调试)
*/
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;
 
namespace CY.WebForm.Pages.business
{
    public partial class DeliverPlanWentiAdd : BasePage
    {
        public int Orderid = 0;
        public int printNum = 0;
 
        OA_CarManageBll _OA_CarManageBll = null;
        OA_DeliverPlanPaicheBLL oA_DeliverPlanBLL = null;
        OA_StaffBLL _OA_StaffBLL = null;
 
        //初始化
        public DeliverPlanWentiAdd()
        {
 
          
            _OA_CarManageBll = new OA_CarManageBll();
            oA_DeliverPlanBLL = new OA_DeliverPlanPaicheBLL();
            _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 "GetCommunication":
                        LoadCommunication();
                        break;
                    case "ReBindClients":
                        Response.Write(ReLoadClients());
                        break;
                    
                    default:
                        Page_Load_Default();
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                //Response.Write("-1");
                Response.Write(ex.Message);
            }
            Response.End();
        }
 
       
 
        /// <summary>
        /// 默认执行方法
        /// </summary>
        private void Page_Load_Default()
        {
 
          
         
            if (!IsPostBack && !IsCallback)
            {
 
                Sys_DictionaryBLL _sys_DictionaryBLL = new Sys_DictionaryBLL();//字典业务逻辑操作类对象
                SysInquiry_PrintingTypeBLL _sysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL();//印刷业务类型业务逻辑操作类对象
                OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
                EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
 
              
 
                IList<OA_CorporateClients> corporateClients = _oA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList<OA_CorporateClients>;
                if (null != corporateClients)
                {
                    corporateClients.Where(cc => CurrentUser.MemberId.Equals(cc.MemberId) && corporateClients.Remove(cc));
                }
                this.selBuyerId.DataSource = corporateClients;
                this.selBuyerId.DataBind();
                this.selBuyerId.Items.Insert(0, new ListItem("请选择", ""));
 
 
                var  oA_Staffs = _OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId,false,false);
               
 
                this.selFankuiren.DataSource = oA_Staffs;
                this.selFankuiren.DataTextField = "Name";
                this.selFankuiren.DataValueField = "Keyid";
                this.selFankuiren.DataBind();
                this.selFankuiren.Items.Insert(0, new ListItem("请选择", ""));
 
                this.selFankuiren.Value = CurrentUser.StaffId.Value.ToString();
 
 
 
 
 
 
            }
        }
 
        /// <summary>
        /// 保存点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
 
            if (SaveOrder())
            {
                //操作成功
                JavaScript.MessageBox("操作成功", this, true,true);
            }
            else
            {
                //操作失败
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
        
 
 
 
        /// <summary>
        /// 加载客户联系方式 
        /// </summary>
        private void LoadCommunication()
        {
            Response.Clear();
            string id = Request["id"];
            if (string.IsNullOrEmpty(id))
            {
                Response.Write("-2");
                return;
            }
 
            OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            OA_CorporateClients m_OA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, id.ToGuid2());
            OA_CustomerCommunications _oA_CustomerCommunications = _oA_CorporateClientsBLL.GetModel_CustomerCommunications(m_OA_CorporateClients.Keyid);
            _oA_CustomerCommunications.DegreeImportanId = m_OA_CorporateClients.DegreeImportanId;
            _oA_CustomerCommunications.AccountManagerId = m_OA_CorporateClients.AccountManagerId;
            _oA_CustomerCommunications.BusinessManagerId = m_OA_CorporateClients.BusinessManagerId;
            _oA_CustomerCommunications.CompanyName = m_OA_CorporateClients.CompanyName;
            Response.Write(null == _oA_CustomerCommunications ? "" : JsonHelper.GetJsonStringByObject(_oA_CustomerCommunications));
        }
 
         
 
 
 
 
 
        /// <summary>
        /// 保存订单
        /// </summary>
        private bool SaveOrder()
        {
           
 
                bool isWin = false;
            try
            {
                var keyid = Request["keyid"];
                EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL();
               
                OA_CorporateClientsBLL _oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
                
                string SellerOrderId = "";
 
                
               
 
 
                OA_DeliverPlan oA_DeliverPlan = new OA_DeliverPlan();
                oA_DeliverPlan.Lianxiren = "";
                oA_DeliverPlan.Keyid = Guid.NewGuid();
                oA_DeliverPlan.FirmId = CurrentUser.MemberId;
                oA_DeliverPlan.DeliverTime = DateTime.Now;
                oA_DeliverPlan.DeliveredTime = oA_DeliverPlan.DeliverTime;
                if (string.IsNullOrWhiteSpace(this.selBuyerId.Value))
                {
                    oA_DeliverPlan.BuyerId = Guid.Empty;
                    oA_DeliverPlan.BusinessManagerId = 0;
                    oA_DeliverPlan.Biddingcompany = 0;
 
                }
                else
                {
                    oA_DeliverPlan.BuyerId = this.selBuyerId.Value.ToGuid2();
                    OA_CorporateClients oA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, this.selBuyerId.Value.ToGuid2());
                    oA_DeliverPlan.BusinessManagerId = oA_CorporateClients.BusinessManagerId ?? 0;
                    oA_DeliverPlan.Biddingcompany = oA_CorporateClients.Biddingcompany ?? 0;
                  
                }
               
                //oA_DeliverPlan.DeliveredTime = null;
                oA_DeliverPlan.Zhuyishixiang = "";
                oA_DeliverPlan.Gongzuokaoping = "";
                oA_DeliverPlan.CarId = 0;
                oA_DeliverPlan.DriverId = this.selFankuiren.Value.ToInt32();
 
 
 
                oA_DeliverPlan.Transferstatus = 1;
                oA_DeliverPlan.TransfersTime = null;
                oA_DeliverPlan.Sort = 1;
                oA_DeliverPlan.Creater = CurrentUser.TrueMemberId;
                oA_DeliverPlan.CreateTime = DateTime.Now;
                oA_DeliverPlan.Updater = CurrentUser.TrueMemberId;
                oA_DeliverPlan.LastUpdateTime = DateTime.Now;
                oA_DeliverPlan.SellerOrderId = SellerOrderId;
                oA_DeliverPlan.Dianhua = "";
                oA_DeliverPlan.Dizhi = "";
                oA_DeliverPlan.wentifankui = this.txtRemark.Value;
                oA_DeliverPlan.Remark = "";
                oA_DeliverPlan.shifouDelivery = 0;
                oA_DeliverPlan.CompanyName = this.txtCompanyName.Value;
 
                isWin = oA_DeliverPlanBLL.InsertModel(oA_DeliverPlan);
 
 
 
            }
            catch (Exception ex)
            {
                isWin = false;
            }
            
 
 
 
 
            return isWin;
        }
 
       
        
        /// <summary>
        /// 重新加载客户列表
        /// </summary>
        /// <returns></returns>
        private string ReLoadClients()
        {
            try
            {
                string res = "<option value=''>请选择</option>";
                OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
                IList<OA_CorporateClients> m_OA_CorporateClientsList = bll_OA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList<OA_CorporateClients>;
                if (null != m_OA_CorporateClientsList)
                {
                    m_OA_CorporateClientsList.Where(cc => CurrentUser.MemberId.Equals(cc.MemberId) && m_OA_CorporateClientsList.Remove(cc));
                    if (m_OA_CorporateClientsList.Count > 0)
                    {
                        foreach (var m_OA_CorporateClients in m_OA_CorporateClientsList)
                        {
                            res = res + ("<option value='" + m_OA_CorporateClients.MemberId + "'>" + m_OA_CorporateClients.CompanyName + "</option>");
                        }
                    }
                }
                return res;
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                return "";
            }
        }
    }
}