/** * 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; using System.Transactions; namespace CY.WebForm.Pages.business { public partial class DeliverPlanPaiche : BasePage { OA_DeliverPlanBLL _OA_DeliverPlanBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; OA_CarManageBll _OA_CarManageBll = null; OA_DeliverPlanPaicheBLL _OA_DeliverPlanPaicheBLL = null; //初始化 public DeliverPlanPaiche() { _OA_DeliverPlanBLL = new OA_DeliverPlanBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); _OA_CarManageBll = new OA_CarManageBll(); _OA_DeliverPlanPaicheBLL = new OA_DeliverPlanPaicheBLL(); } /// /// 页面加载事件 /// /// /// 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(); } /// /// 默认执行方法 /// private void Page_Load_Default() { if (!IsPostBack && !IsCallback) { this.selCarId.DataSource = _OA_CarManageBll.SelectListByFirmId(CurrentUser.MemberId); this.selCarId.DataTextField = "CarNumber"; this.selCarId.DataValueField = "Keyid"; this.selCarId.DataBind(); this.selCarId.Items.Insert(0, new ListItem("请选择", "")); var ids = Request["ids"].ToString().Trim(',').Split(','); //var dizhi = ""; for (int i = 0; i < ids.Length; i++) { var deliverPlan = _OA_DeliverPlanBLL.GetModelByKeyid(ids[i].ToGuid2(), null, null); if(i == 0) { //dizhi = deliverPlan.Dizhi; if (deliverPlan.DeliverTime.HasValue) { this.txtDeliverTime.Value = deliverPlan.DeliverTime.Value.ToString("yyyy-MM-dd"); } } //else //{ // if(deliverPlan.Dizhi != dizhi) // { // //操作成功 // JavaScript.MessageBox("不同地址的订单不能统一派车", this, true, false); // return; // } //} if(deliverPlan.CarId.HasValue && deliverPlan.CarId.Value > 0) { //操作成功 JavaScript.MessageBox("已经派车的送货单不能重复派车", this, true, false); return; } } } } /// /// 保存点击事件 /// /// /// protected void btnSave_ServerClick(object sender, EventArgs e) { if (SaveOrder()) { //操作成功 JavaScript.MessageBox("操作成功", this, true,true); } else { //操作失败 JavaScript.MessageBox("操作失败", this); } } /// /// 加载客户联系方式 /// 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)); } /// /// 保存订单 /// private bool SaveOrder() { bool isWin = false; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, Timeout = TransactionManager.MaximumTimeout } ) ) { try { var ids = Request["ids"].ToString().Trim(',').Split(','); OA_DeliverPlan oA_DeliverPlanPaiche = null; var Keyid = Guid.NewGuid(); int DriverId = 0; var i = 0; var carManage = _OA_CarManageBll.GetModelByKeyid(this.selCarId.Value.ToInt32()); if (carManage != null) { DriverId = carManage.StaffID ?? 0; } else { DriverId = 0; } var dingdanhao = "送货单:"; foreach (var keyid in ids) { var deliverPlan = _OA_DeliverPlanBLL.GetModelByKeyid(keyid.ToGuid2(), null, null); if (i == 0) { oA_DeliverPlanPaiche = deliverPlan; } dingdanhao += deliverPlan.SellerOrderId + ","; deliverPlan.CarId = this.selCarId.Value.ToInt32(); deliverPlan.DriverId = DriverId; deliverPlan.DeliverPlanPaicheid = Keyid; deliverPlan.Updater = CurrentUser.TrueMemberId; deliverPlan.LastUpdateTime = DateTime.Now; isWin = _OA_DeliverPlanBLL.UpdateModel(deliverPlan); } oA_DeliverPlanPaiche.Keyid = Keyid; oA_DeliverPlanPaiche.DeliverTime = this.txtDeliverTime.Value.ToDateTime2(); oA_DeliverPlanPaiche.Remark = dingdanhao.Trim(',')+"。" + this.txtZhuyishixiang.Value; oA_DeliverPlanPaiche.shuliang = ids.Length; var oA_DeliverPlans = _OA_DeliverPlanPaicheBLL.GetModelByDeliveredTime(CurrentUser.MemberId, oA_DeliverPlanPaiche.DeliverTime.Value).Max(x=>x.Sort); if (oA_DeliverPlans.HasValue) { oA_DeliverPlanPaiche.Sort = oA_DeliverPlans.Value + 1; } else { oA_DeliverPlanPaiche.Sort = 1; } isWin = _OA_DeliverPlanPaicheBLL.InsertModel(oA_DeliverPlanPaiche); scope.Complete(); } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } finally { // 释放资源 scope.Dispose(); } } return isWin; } /// /// 重新加载客户列表 /// /// private string ReLoadClients() { try { string res = ""; OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL(); IList m_OA_CorporateClientsList = bll_OA_CorporateClientsBLL.SelectListByFirmId(CurrentUser.MemberId) as IList; 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 + (""); } } } return res; } catch (Exception ex) { PAGEHandleException(ex); return ""; } } } }