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); } } }