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; namespace CY.WebForm.Pages.business { //吴辉 //修改外协订单 public partial class AgOutsourcSingleAllUpdate : BasePage { OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null; Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; EC_OrderBLL bll_EC_OrderBLL = null; EC_OrderPrintParameterBLL _eC_OrderPrintParameterBLL = null; public string targetid =""; public AgOutsourcSingleAllUpdate() { bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL(); bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_EC_OrderBLL = new EC_OrderBLL(); _eC_OrderPrintParameterBLL = new EC_OrderPrintParameterBLL(); } /// /// 页面加载事件 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Page_Load_Default(); LoadOrderInfo(); } else { if (SaveOrder()) { //操作成功 JavaScript.RefreshDIVOpener(this); } else { //操作失败 JavaScript.MessageBox("操作失败!", this); Page_Load_Default(); LoadOrderInfo(); } } } private void LoadOrderInfo() { if (IsPostBack || IsCallback) return; this.txtDeliveryTime.Value = DateTime.Now.AddDays(15).ToString("yyyy-MM-dd"); EC_OrderBasicBLL _eC_OrderBasicBLL = new EC_OrderBasicBLL(); string orderIdStr = Request["orderid"]; string oldidStr = Request["oldid"]; targetid = orderIdStr; if (string.IsNullOrEmpty(orderIdStr) || string.IsNullOrEmpty(oldidStr)) { CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this); return ; } int? orderId = MyConvert.ConvertToInt32(orderIdStr); int? oldid = MyConvert.ConvertToInt32(oldidStr); if (!orderId.HasValue || !oldid.HasValue) { CY.WebForm.BasePage.JavaScript.MessageBox("未传递参数!", this); return ; } 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 ; } 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; this.selExigencyDegree.Value = _eC_OrderBasic.OrderExtend.ExigencyCaseId.ToString2(); this.txtDeliveryTime.Value = (_eC_OrderBasic.DeliveryTime ?? DateTime.Now.AddDays(15)).ToString("yyyy-MM-dd"); this.txtAllMoney.Value = (_eC_OrderBasic.SumPrice ?? 0).ToString("0.00"); this.spanOrderNum.InnerText = _Old_eC_OrderBasic.SellerOrderId; this.spanOrderType.InnerText = _Old_eC_OrderBasic.OrderType.Name; this.spanOrderTitle.InnerText = _Old_eC_OrderBasic.DocumentName; this.spanOrderDeliveryTime.InnerText = _Old_eC_OrderBasic.DeliveryTime == null ? "" : _eC_OrderBasic.DeliveryTime.Value.ToString("yyyy-MM-dd HH:mm"); this.spanOrderCustormName.InnerText = _Old_eC_OrderBasic.BuyerName; this.spanOrderCustormLevel.InnerText = _Old_eC_OrderBasic.OrderExtend.CustomerLevel.Name; this.spanOrderCustormPeople.InnerText = _Old_eC_OrderBasic.OrderExtend.Contacts; this.spanOrderCustormPhone.InnerText = _Old_eC_OrderBasic.OrderExtend.ContactPhone; this.spanOrderBusinessManage.InnerText = _Old_eC_OrderBasic.OrderExtend.BusinessManager.Name; this.spanOrderCustormManage.InnerText = _Old_eC_OrderBasic.OrderExtend.CustomerManager.Name; this.spanVerifyWay.InnerText = _Old_eC_OrderBasic.OrderExtend.ProofreadWay.Name; this.spanExigencyDegree.InnerText = _Old_eC_OrderBasic.OrderExtend.ExigencyCase.Name; this.spanUnitPrice.InnerText = (_Old_eC_OrderBasic.UnitPrice ?? 0).ToString("0.00"); this.spanSumPrice.InnerText = (_Old_eC_OrderBasic.SumPrice ??0).ToString("0.00"); this.spanSurplusPrintNum.InnerText = _Old_eC_OrderBasic.OrderExtend.PrintNum.ToString2(); this.spanSpecialOprator.InnerText = CurrentUser.ShortName; this.spanSpecialTime.InnerText = (_eC_OrderBasic.CreateTime ?? 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; 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(); } /// /// 默认执行方法 /// 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.Value = "0"; } } /// /// 保存点击事件 /// /// /// void btnSave_ServerClick(object sender, EventArgs e) { if (SaveOrder()) { //操作成功 JavaScript.RefreshDIVOpener(this); } else { //操作失败 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); EC_OrderBasic m_EC_OrderBasicNew = _eC_OrderBasicBLL.SelectModelById(orderid.Value); 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 = this.txtDeliveryTime.Value.ToDateTime2(); 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(); m_EC_OrderBasicNew.OrderExtend.ExigencyCaseId = this.selExigencyDegree.Value.ToInt32(); InquiryCommonModel m_InquiryCommonModel = new InquiryCommonModel(); m_InquiryCommonModel.PrintDemand = this.txtPrintDemand.Value; 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; #region 初始合作客户收货地址 EC_AcceptWayByOrder m_EC_AcceptWayByOrder = new EC_AcceptWayByOrderBLL().GetModelByTargetId(m_EC_OrderBasicNew.Keyid); m_EC_OrderBasicNew.AcceptWayByOrder.Keyid = (m_EC_AcceptWayByOrder == null ? new EC_AcceptWayByOrder() : m_EC_AcceptWayByOrder).Keyid; m_EC_OrderBasicNew.AcceptWayByOrder.TargetId = m_EC_OrderBasicNew.Keyid; m_EC_OrderBasicNew.AcceptWayByOrder.AcceptTypeId = 104;//Request["AcceptTypeId"].ToInt32(); m_EC_OrderBasicNew.AcceptWayByOrder.InvoiceDemand = Request["InvoiceId"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.Remark = Request["Remark"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.LastUpdateTime = DateTime.Now; m_EC_OrderBasicNew.AcceptWayByOrder.Operator = CurrentUser.ShortName; m_EC_OrderBasicNew.AcceptWayByOrder.City = ""; m_EC_OrderBasicNew.AcceptWayByOrder.Accepter = ""; m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhone = ""; m_EC_OrderBasicNew.AcceptWayByOrder.AppointCourierCompany = ""; m_EC_OrderBasicNew.AcceptWayByOrder.AccepterAddress = Request["AccepterAddress_HomeDelivery"].ToString2() ?? Request["selectProvince"].ToString2() + Request["selectCity"].ToString2() + Request["selectCounty"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhoneNum = ""; m_EC_OrderBasicNew.AcceptWayByOrder.AcceptContacts = ""; m_EC_OrderBasicNew.AcceptWayByOrder.FetchAddress = ""; m_EC_OrderBasicNew.AcceptWayByOrder.FetchPhoneNum = ""; m_EC_OrderBasicNew.AcceptWayByOrder.FetchContacts = ""; m_EC_OrderBasicNew.AcceptWayByOrder.AppointCourierCompany = ""; m_EC_OrderBasicNew.AcceptWayByOrder.TheAwb = ""; string ReceiptType = bll_Sys_DictionaryBLL.GetModelByKeyid(104);//Request["AcceptTypeId"].ToInt32() switch (ReceiptType) { case "自提": break; case "代发货运": m_EC_OrderBasicNew.AcceptWayByOrder.City = Request["City_OnBehalfOfCargo"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.Accepter = Request["Accepter_OnBehalfOfCargo"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhone = Request["AccepterPhone_OnBehalfOfCargo"].ToString2(); break; case "送货上门": m_EC_OrderBasicNew.AcceptWayByOrder.City = Request["City_HomeDelivery"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.Accepter = Request["Accepter_HomeDelivery"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhone = Request["AccepterPhone_HomeDelivery"].ToString2(); break; case "指定货运公司": m_EC_OrderBasicNew.AcceptWayByOrder.City = Request["City_OfficialFreightForwarder"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.Accepter = Request["Accepter_OfficialFreightForwarder"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhone = Request["AccepterPhone_OfficialFreightForwarder"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AppointCourierCompany = Request["AppointCourierCompany"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterAddress = Request["AccepterAddress"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AccepterPhoneNum = Request["AccepterPhoneNum"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AcceptContacts = Request["AcceptContacts"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.FetchAddress = Request["FetchAddress"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.FetchPhoneNum = Request["FetchPhoneNum"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.FetchContacts = Request["FetchContacts"].ToString2(); m_EC_OrderBasicNew.AcceptWayByOrder.AppointCourierCompany = Request["AppointCourierCompany"].ToString2(); break; default: break; } #endregion return bll_EC_OrderBLL.UpdateOutOrderInfo(m_EC_OrderBasicNew, m_EC_OrderBasicNew.OrderExtend, m_EC_OrderPrintParameter); } } }