Esempio n. 1
0
    protected void lbtnQty_Click(object sender, EventArgs e)
    {
        string flowItem = ((LinkButton)sender).CommandArgument;

        string[] argument = flowItem.Split('|');
        string   flow     = argument[0];
        string   item     = argument[1];

        DetachedCriteria criteria = CloneHelper.DeepClone <DetachedCriteria>(this.DetailCriteria);

        criteria.Add(Expression.Eq("Item", item));
        criteria.Add(Expression.Eq("Flow", flow));



        IList <WoReceiptView> woReceiptDetailList = TheCriteriaMgr.FindAll <WoReceiptView>(criteria);

        this.ucList.UpdateView(woReceiptDetailList);
        this.ucList.Visible = true;
    }
Esempio n. 2
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationDetail));

        criteria.CreateAlias("Location", "l");

        #region Customize
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        #endregion

        #region Select Parameters
        CriteriaHelper.SetLocationCriteria(criteria, "l.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);

        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
Esempio n. 3
0
        protected internal virtual object GetRefillEntity(int index, Type type)
        {
            object obj = null;

            try
            {
                if (m_dgv.Rows[index].Tag != null && type != null && type.Equals(m_dgv.Rows[index].Tag))
                {
                    obj = CloneHelper.Clone(m_dgv.Rows[index].Tag);
                }
                else if (type != null)
                {
                    obj = Activator.CreateInstance(type);
                }
            }
            catch
            {
            }
            if (obj != null)
            {
                GetPropertyArray(obj);
                for (int i = 0; i < m_columnMembers.Length; i++)
                {
                    try
                    {
                        if (m_complex[i])
                        {
                            PropertyHelper.SetPropertyValue(m_columnMembers[i].Member, obj, m_dgv[m_columnMembers[i].ColumnName, index].Value);
                        }
                        else
                        {
                            PropertyHelper.SetPropertyValue(m_infos[i], obj, m_dgv[m_columnMembers[i].ColumnName, index].Value);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            return(obj);
        }
Esempio n. 4
0
        public void CloneBasicTypes()
        {
            Assert.AreEqual('a', CloneHelper <char> .GetCloner().Clone('a'));

            Assert.AreEqual(false, CloneHelper <bool> .GetCloner().Clone(false));

            Assert.AreEqual(123, CloneHelper <byte> .GetCloner().Clone(123));
            Assert.AreEqual(1234, CloneHelper <ushort> .GetCloner().Clone(1234));
            Assert.AreEqual(123456, CloneHelper <uint> .GetCloner().Clone(123456));
            Assert.AreEqual(12345678901, CloneHelper <ulong> .GetCloner().Clone(12345678901));

            Assert.AreEqual(-123, CloneHelper <sbyte> .GetCloner().Clone(-123));
            Assert.AreEqual(-1234, CloneHelper <short> .GetCloner().Clone(-1234));
            Assert.AreEqual(-123456, CloneHelper <int> .GetCloner().Clone(-123456));
            Assert.AreEqual(-12345678901, CloneHelper <long> .GetCloner().Clone(-12345678901));

            Assert.AreEqual(decimal.Parse("12345678901234567890123456789"), CloneHelper <decimal> .GetCloner().Clone(decimal.Parse("12345678901234567890123456789")));

            Assert.AreEqual(0.5F, CloneHelper <double> .GetCloner().Clone(0.5f));
            Assert.AreEqual(0.5, CloneHelper <double> .GetCloner().Clone(0.5));
        }
Esempio n. 5
0
        protected override void CreateOrUpdateObject(object obj)
        {
            PriceListDetail priceListDetail = (PriceListDetail)obj;

            priceListDetail.IsProvisionalEstimate = CheckProvisionalEstimate(priceListDetail.UnitPrice);


            PriceListDetail newPriceListDetail =
                this.priceListDetailMgr.LoadPriceListDetail(priceListDetail.PriceList.Code, priceListDetail.Currency.Code,
                                                            priceListDetail.Item.Code, priceListDetail.Uom.Code, priceListDetail.StartDate);

            if (newPriceListDetail == null)
            {
                this.priceListDetailMgr.CreatePriceListDetail(priceListDetail);
            }
            else
            {
                CloneHelper.CopyProperty(priceListDetail, newPriceListDetail, this.fields);
                this.priceListDetailMgr.UpdatePriceListDetail(newPriceListDetail);
            }
        }
Esempio n. 6
0
    protected void ODS_Routing_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        Flow flow    = (Flow)e.InputParameters[0];
        Flow oldFlow = TheFlowMgr.LoadFlow(FlowCode);

        CloneHelper.CopyProperty(oldFlow, flow, EditFields, true);

        Controls_TextBox tbRouting = (Controls_TextBox)(this.FV_Routing.FindControl("tbRouting"));

        if (!IsReturn)
        {
            flow.Routing = TheRoutingMgr.LoadRouting(tbRouting.Text);
        }
        else
        {
            flow.ReturnRouting = TheRoutingMgr.LoadRouting(tbRouting.Text);
        }
        flow.LastModifyUser = this.CurrentUser;
        flow.LastModifyDate = DateTime.Now;
        flow.Version       += 1;
    }
Esempio n. 7
0
    public void Init(TerrainMakerEditorWindow root)
    {
        m_Root = root;

        //更新编辑器配置
        string totalTerrainMakerDefineSettingPath = Application.dataPath + "/" + TerrainMakerDefineSettingPath;

        LogHelper.Trace?.Log("TerrainMakerTool", "totalTerrainMakerDefineSettingPath", totalTerrainMakerDefineSettingPath);
        if (File.Exists(totalTerrainMakerDefineSettingPath))
        {
            string defineSettingStr = File.ReadAllText(totalTerrainMakerDefineSettingPath);
            m_ToolSetting = LitJson.JsonMapper.ToObject <ToolSetting>(defineSettingStr);
        }
        else
        {
            m_ToolSetting = new ToolSetting();
        }
        __CreateToolConfig();

        LogHelper.Trace?.Log("TerrainMakerTool", "m_ToolSetting", LogHelper.Object2String(m_ToolSetting));


        //更新地形配置
        string totalDefaultTerrainInfoPath = Application.dataPath + "/" + m_ToolSetting.DefaultTerrainInfoPath;

        LogHelper.Trace?.Log("TerrainMakerTool", "totalDefaultTerrainInfoPath", totalDefaultTerrainInfoPath);
        if (File.Exists(totalDefaultTerrainInfoPath))
        {
            string defaultTerrainInfo = File.ReadAllText(totalDefaultTerrainInfoPath);
            m_CurrentDefaultTerrainInfo = LitJson.JsonMapper.ToObject <DefaultTerrainInfo>(defaultTerrainInfo);
        }
        else
        {
            m_CurrentDefaultTerrainInfo = new DefaultTerrainInfo();
        }
        __CreateDefaultTerrainInfo();
        m_RecordDefaultTerrainInfo = CloneHelper.DeepClone(m_CurrentDefaultTerrainInfo) as DefaultTerrainInfo;

        LogHelper.Trace?.Log("TerrainMakerTool", "m_RecordDefaultTerrainInfo", LogHelper.Object2String(m_RecordDefaultTerrainInfo));
    }
Esempio n. 8
0
    protected override void DoSearch()
    {
        if (SearchEvent != null)
        {
            string location  = this.tbLocation.Text.Trim() != string.Empty ? this.tbLocation.Text.Trim() : string.Empty;
            string startDate = this.tbStartDate.Text.Trim() != string.Empty ? this.tbStartDate.Text.Trim() : string.Empty;
            string endDate   = this.tbEndDate.Text.Trim() != string.Empty ? this.tbEndDate.Text.Trim() : string.Empty;
            string orderNo   = this.tbOrderNo.Text.Trim() != string.Empty ? this.tbOrderNo.Text.Trim() : string.Empty;
            string status    = this.ddlStatus.SelectedValue.Trim();

            DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(CycleCount));
            selectCriteria.CreateAlias("Location", "l");
            selectCriteria.CreateAlias("l.Region", "r");

            if (location != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("Location.Code", location));
            }
            if (startDate != string.Empty)
            {
                selectCriteria.Add(Expression.Ge("EffectiveDate", DateTime.Parse(startDate)));
            }
            if (endDate != string.Empty)
            {
                selectCriteria.Add(Expression.Le("EffectiveDate", DateTime.Parse(endDate)));
            }
            if (orderNo != string.Empty)
            {
                selectCriteria.Add(Expression.Like("Code", orderNo, MatchMode.Start));
            }
            if (status != string.Empty)
            {
                selectCriteria.Add(Expression.Eq("Status", status));
            }

            DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(selectCriteria);
            selectCountCriteria.SetProjection(Projections.Count("Code"));
            SearchEvent((new object[] { selectCriteria, selectCountCriteria }), null);
        }
    }
Esempio n. 9
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationDetail));

        criteria.CreateAlias("Location", "l");

        #region Customize
        criteria.Add(Expression.Not(Expression.Eq("Qty", new decimal(0))));
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        #endregion

        #region Select Parameters
        CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(criteria, "Location.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.GroupProperty("Item").As("Item"));

        if (this._criteriaParam.ClassifiedParty)
        {
            projectionList.Add(Projections.GroupProperty("l.Region").As("Region"));
        }
        if (this._criteriaParam.ClassifiedLocation)
        {
            projectionList.Add(Projections.GroupProperty("Location").As("Location"));
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationDetail)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
Esempio n. 10
0
    public void BindList(List <TransformerDetail> transformerDetailList, bool addNewRow)
    {
        List <TransformerDetail> list = CloneHelper.DeepClone <List <TransformerDetail> >(transformerDetailList);

        if (list == null)
        {
            list = new List <TransformerDetail>();
        }

        if (addNewRow)
        {
            //增加新行
            list.Add(new TransformerDetail());
        }
        this.GV_List.DataSource = list;
        this.GV_List.DataBind();

        if (addNewRow)
        {
            this.InitialInput();
        }
    }
        public IList <InProcessLocationDetail> SummarizeInProcessLocationDetails(IList <InProcessLocationDetail> inProcessLocationDetailList)
        {
            IList <InProcessLocationDetail> ipDetList = new List <InProcessLocationDetail>();

            if (inProcessLocationDetailList != null && inProcessLocationDetailList.Count > 0)
            {
                foreach (InProcessLocationDetail ipDetail in inProcessLocationDetailList)
                {
                    if (ipDetail.HuId == null)
                    {
                        //不支持Hu,不需要汇总
                        return(inProcessLocationDetailList);
                    }

                    bool isExist = false;
                    foreach (InProcessLocationDetail ipDet in ipDetList)
                    {
                        //OrderLocationTransaction相同的汇总
                        if (ipDetail.OrderLocationTransaction.Id == ipDet.OrderLocationTransaction.Id)
                        {
                            ipDet.Qty += ipDetail.Qty;
                            ipDet.AddHuInProcessLocationDetails(ipDetail);
                            isExist = true;
                            break;
                        }
                    }
                    if (!isExist)
                    {
                        InProcessLocationDetail inProcessLocationDetail = new InProcessLocationDetail();
                        CloneHelper.CopyProperty(ipDetail, inProcessLocationDetail, new string[] { "Id", "HuId" }, true);
                        inProcessLocationDetail.AddHuInProcessLocationDetails(ipDetail);
                        ipDetList.Add(inProcessLocationDetail);
                    }
                }
            }

            return(ipDetList);
        }
Esempio n. 12
0
        public ServiceResponse <Student> SaveStudent(Student student)
        {
            var result = new ServiceResponse <Student>();

            if (student == null)
            {
                result.AddMessage("Student null request");
                result.Success = false;
                return(result);
            }

            if (string.IsNullOrEmpty(student.Id))
            {
                var saveStudentRequest = CloneHelper.Clone <Student>(student);
                saveStudentRequest.Id = Guid.NewGuid().ToString();
                DummyDatabase.Students.Add(saveStudentRequest);
                result.Data = saveStudentRequest;
            }
            else
            {
                var updatedStudent = DummyDatabase.Students.FirstOrDefault(p => p.Id == student.Id);
                if (updatedStudent != null)
                {
                    if (!string.IsNullOrEmpty(student.Surname))
                    {
                        updatedStudent.Surname = student.Surname;
                    }
                    if (!string.IsNullOrEmpty(student.Given))
                    {
                        updatedStudent.Given = student.Given;
                    }
                }
                result.Data = updatedStudent;
            }

            result.Success = true;
            return(result);
        }
Esempio n. 13
0
        public void CreateFlowDetailTrack(FlowDetail flowDetail, string eventCode)
        {
            FlowDetailTrack flowDetailTrack = new FlowDetailTrack();

            CloneHelper.CopyProperty(flowDetail, flowDetailTrack, FlowDetail2FlowDetailTrackCloneFields);
            flowDetailTrack.FlowDetailId   = flowDetail.Id;
            flowDetailTrack.Flow           = flowDetail.Flow.Code;
            flowDetailTrack.Item           = flowDetail.Item.Code;
            flowDetailTrack.Customer       = flowDetail.Customer != null ? flowDetail.Customer.Code : string.Empty;
            flowDetailTrack.Uom            = flowDetail.Uom != null ? flowDetail.Uom.Code : string.Empty;
            flowDetailTrack.Bom            = flowDetail.Bom != null ? flowDetail.Bom.Code : string.Empty;
            flowDetailTrack.BillFrom       = flowDetail.BillFrom != null ? flowDetail.BillFrom.Code : string.Empty;
            flowDetailTrack.BillTo         = flowDetail.BillTo != null ? flowDetail.BillTo.Code : string.Empty;
            flowDetailTrack.LocationFrom   = flowDetail.LocationFrom != null ? flowDetail.LocationFrom.Code : string.Empty;
            flowDetailTrack.LocationTo     = flowDetail.LocationTo != null ? flowDetail.LocationTo.Code : string.Empty;
            flowDetailTrack.LastModifyUser = flowDetail.LastModifyUser.Code;
            flowDetailTrack.LastModifyDate = DateTime.Now;
            flowDetailTrack.PriceListFrom  = flowDetail.PriceListFrom != null ? flowDetail.PriceListFrom.Code : string.Empty;
            flowDetailTrack.PriceListTo    = flowDetail.PriceListTo != null ? flowDetail.PriceListTo.Code : string.Empty;
            flowDetailTrack.EventCode      = eventCode;

            base.CreateFlowDetailTrack(flowDetailTrack);
        }
        /// <summary>
        /// The build content.
        /// </summary>
        /// <param name="display">
        /// The display.
        /// </param>
        /// <returns>
        /// The <see cref="IProductContent"/>.
        /// </returns>
        public IProductContent BuildContent(ProductDisplay display)
        {
            if (!display.DetachedContents.Any(x => x.CanBeRendered))
            {
                return(null);
            }

            // assert there is at least one the can be rendered
            var detachedContent = display.DetachedContents.FirstOrDefault(x => x.CanBeRendered);

            if (detachedContent == null)
            {
                return(null);
            }

            var publishedContentType = PublishedContentType.Get(PublishedItemType.Content, detachedContent.DetachedContentType.UmbContentType.Alias);

            var optionContentTypes = GetProductOptionContentTypes(display);

            var clone = CloneHelper.JsonClone <ProductDisplay>(display);

            return(new ProductContent(publishedContentType, optionContentTypes, clone, _parent, _defaultStoreLanguage));
        }
Esempio n. 15
0
        private void WorkCalendarContinuousTime(List <WorkCalendar> workCalendars)
        {
            List <WorkCalendar> addList = new List <WorkCalendar>();

            if (workCalendars != null && workCalendars.Count > 0)
            {
                for (int i = 0; i < workCalendars.Count - 1; i++)
                {
                    if (DateTime.Compare(workCalendars[i].EndTime, workCalendars[i + 1].StartTime) < 0)
                    {
                        if (workCalendars[i].Type == BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE_VALUE_WORK)
                        {
                            WorkCalendar workCalendar = new WorkCalendar();
                            DateTime     startTime    = workCalendars[i].EndTime;
                            CloneHelper.CopyProperty(workCalendars[i], workCalendar);
                            workCalendar.ShiftCode = null;
                            workCalendar.ShiftName = null;
                            workCalendar.Type      = BusinessConstants.CODE_MASTER_WORKCALENDAR_TYPE_VALUE_REST;
                            workCalendar.StartTime = workCalendars[i].EndTime;
                            workCalendar.EndTime   = workCalendars[i + 1].StartTime;

                            addList.Add(workCalendar);
                        }
                        else
                        {
                            workCalendars[i].EndTime = workCalendars[i + 1].StartTime;
                        }
                    }
                }
            }

            if (addList.Count > 0)
            {
                workCalendars.AddRange(addList);
            }
            workCalendars.Sort(WorkCalendarTimeCompare);
        }
Esempio n. 16
0
 /// <summary>
 /// 克隆一个完整的用户账户信息类
 /// </summary>
 /// <returns></returns>
 public object Clone( )
 {
     return(CloneHelper.CloneObject(this));
 }
Esempio n. 17
0
        private Hu CreateHuFromOdd(ReceiptDetail receiptDetail, User user)
        {
            OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction;
            OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
            OrderHead   orderHead   = orderDetail.OrderHead;
            Receipt     receipt     = receiptDetail.Receipt;

            int     huLotSize = orderDetail.HuLotSize.Value;
            decimal qty       = 0; //累计库存Odd数量

            #region 循环获取库存Odd数量
            IList <HuOdd> huOddList = this.huOddMgr.GetHuOdd(
                orderDetail.Item, orderDetail.UnitCount, orderDetail.Uom,
                orderDetail.DefaultLocationFrom, orderDetail.DefaultLocationTo,
                BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE);

            if (huOddList != null && huOddList.Count > 0)
            {
                foreach (HuOdd huOdd in huOddList)
                {
                    qty += huOdd.OddQty - huOdd.CreatedQty;
                }

                if (qty + receiptDetail.ReceivedQty.Value >= huLotSize)
                {
                    #region 满足批量,创建Hu
                    DateTime dateTimeNow = DateTime.Now;

                    #region 更新库存Odd,出库
                    foreach (HuOdd huOdd in huOddList)
                    {
                        //全部关闭
                        huOdd.CurrentCreateQty = huOdd.OddQty - huOdd.CreatedQty;
                        huOdd.CreatedQty       = huOdd.OddQty;
                        huOdd.LastModifyDate   = dateTimeNow;
                        huOdd.LastModifyUser   = user;
                        huOdd.Status           = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;

                        this.huOddMgr.UpdateHuOdd(huOdd);

                        //出库
                        this.locationMgr.InventoryOut(huOdd, receiptDetail, user);
                    }
                    #endregion

                    #region 可能还有零头,需要更新receiptDetail收货数量,等于收货数 + 库存Odd数 - Hu批量
                    receiptDetail.ReceivedQty = qty + receiptDetail.ReceivedQty.Value - huLotSize;
                    #endregion

                    #region 创建Hu
                    ReceiptDetail clonedReceiptDetail = new ReceiptDetail();
                    CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail);
                    clonedReceiptDetail.ReceivedQty = huLotSize;
                    clonedReceiptDetail.RejectedQty = 0;
                    IList <Hu> huList = this.huMgr.CreateHu(clonedReceiptDetail, user);

                    return(huList[0]);

                    #endregion

                    #endregion
                }
            }

            return(null);

            #endregion
        }
Esempio n. 18
0
        public void CreateReceipt(Receipt receipt, User user, bool isOddCreateHu)
        {
            log.Debug("Start create receipt");
            #region 查找所有的发货项,收货单打印模板,收货差异处理选项
            string      orderType       = null;
            Party       partyFrom       = null;
            Party       partyTo         = null;
            ShipAddress shipFrom        = null;
            ShipAddress shipTo          = null;
            string      dockDescription = null;
            string      receiptTemplate = null;
            string      huTemplate      = null;
            string      grGapTo         = null;
            IList <InProcessLocationDetail> inProcessLocationDetailList = new List <InProcessLocationDetail>();
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    InProcessLocation currentIp = inProcessLocationMgr.LoadInProcessLocation(inProcessLocation.IpNo);
                    if (currentIp.Status == BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
                    {
                        throw new BusinessErrorException("InProcessLocation.Error.StatusErrorWhenReceive", currentIp.Status, currentIp.IpNo);
                    }

                    if (orderType == null)
                    {
                        orderType = inProcessLocation.OrderType;
                    }

                    //判断OrderHead的PartyFrom是否一致
                    if (partyFrom == null)
                    {
                        partyFrom = inProcessLocation.PartyFrom;
                    }
                    else if (inProcessLocation.PartyFrom.Code != partyFrom.Code)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyFromNotEqual");
                    }

                    //判断OrderHead的PartyFrom是否一致
                    if (partyTo == null)
                    {
                        partyTo = inProcessLocation.PartyTo;
                    }
                    else if (inProcessLocation.PartyTo.Code != partyTo.Code)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.PartyToNotEqual");
                    }

                    //判断OrderHead的ShipFrom是否一致
                    if (shipFrom == null)
                    {
                        shipFrom = inProcessLocation.ShipFrom;
                    }
                    else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipFrom, shipFrom))
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipFromNotEqual");
                    }

                    //判断OrderHead的ShipTo是否一致
                    if (shipTo == null)
                    {
                        shipTo = inProcessLocation.ShipTo;
                    }
                    else if (!AddressHelper.IsAddressEqual(inProcessLocation.ShipTo, shipTo))
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.ShipToNotEqual");
                    }

                    if (dockDescription == null)
                    {
                        dockDescription = inProcessLocation.DockDescription;
                    }
                    else if (inProcessLocation.DockDescription != dockDescription)
                    {
                        throw new BusinessErrorException("Order.Error.ReceiveOrder.DockDescriptionNotEqual");
                    }

                    //判断收货单打印模板是否一致
                    if (receiptTemplate == null)
                    {
                        receiptTemplate = inProcessLocation.ReceiptTemplate;
                    }
                    else
                    {
                        if (inProcessLocation.ReceiptTemplate != null && inProcessLocation.ReceiptTemplate != receiptTemplate)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.ReceiptTemplateNotEqual");
                        }
                    }

                    //判断条码打印模板是否一致
                    if (huTemplate == null)
                    {
                        huTemplate = inProcessLocation.HuTemplate;
                    }
                    else
                    {
                        if (inProcessLocation.HuTemplate != null && inProcessLocation.HuTemplate != huTemplate)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.HuTemplateNotEqual");
                        }
                    }

                    #region 查找收货差异处理选项
                    if (grGapTo == null)
                    {
                        grGapTo = inProcessLocation.GoodsReceiptGapTo;
                    }
                    else
                    {
                        if (inProcessLocation.GoodsReceiptGapTo != null && inProcessLocation.GoodsReceiptGapTo != grGapTo)
                        {
                            throw new BusinessErrorException("Order.Error.ReceiveOrder.GoodsReceiptGapToNotEqual");
                        }
                    }
                    #endregion

                    IListHelper.AddRange <InProcessLocationDetail>(
                        inProcessLocationDetailList, this.inProcessLocationDetailMgr.GetInProcessLocationDetail(inProcessLocation));
                }
            }
            #endregion

            IList <ReceiptDetail> targetReceiptDetailList = receipt.ReceiptDetails;
            receipt.ReceiptDetails = null;   //清空Asn明细,稍后填充

            #region 创建收货单Head
            receipt.ReceiptNo       = numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_RECEIPT);
            receipt.OrderType       = orderType;
            receipt.CreateDate      = DateTime.Now;
            receipt.CreateUser      = user;
            receipt.PartyFrom       = partyFrom;
            receipt.PartyTo         = partyTo;
            receipt.ShipFrom        = shipFrom;
            receipt.ShipTo          = shipTo;
            receipt.DockDescription = dockDescription;
            receipt.ReceiptTemplate = receiptTemplate;
            receipt.IsPrinted       = false;
            receipt.NeedPrint       = false;
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    if (inProcessLocation.NeedPrintReceipt)
                    {
                        receipt.NeedPrint = true;
                        break;
                    }
                }
            }

            this.CreateReceipt(receipt);
            log.Debug("Create receipt " + receipt.ReceiptNo + " head successful");
            #endregion

            #region HU处理/入库操作/创建收货明细
            log.Debug("Start create receipt detail");
            IList <LocationLotDetail> inspectLocationLotDetailList = new List <LocationLotDetail>();
            foreach (ReceiptDetail receiptDetail in targetReceiptDetailList)
            {
                OrderLocationTransaction orderLocationTransaction = receiptDetail.OrderLocationTransaction;
                OrderDetail orderDetail = orderLocationTransaction.OrderDetail;
                OrderHead   orderHead   = orderDetail.OrderHead;

                if (orderHead.CreateHuOption == BusinessConstants.CODE_MASTER_CREATE_HU_OPTION_VALUE_GR &&
                    receiptDetail.HuId == null)         //如果订单设置为收货时创建Hu,但是收货时已经扫描过Hu了,按已扫描处理
                {
                    #region 收货时创建Hu
                    log.Debug("Create receipt detail with generate barcode.");
                    #region 生产本次收货+剩余零头生成Hu
                    decimal oddQty = 0;

                    if (!isOddCreateHu && orderDetail.HuLotSize.HasValue &&
                        orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)    //只有生产支持零头
                    {
                        #region 查找剩余零头 + 本次收货数是否能够生成Hu
                        Hu oddHu = this.CreateHuFromOdd(receiptDetail, user);
                        if (oddHu != null)
                        {
                            log.Debug("Generate barcode using odd qty.");
                            //如果零头生成了Hu,本次收货数会扣减
                            #region 创建Hu
                            IList <Hu> oddHuList = new List <Hu>();
                            oddHuList.Add(oddHu);
                            IList <ReceiptDetail> oddReceiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, oddHuList);
                            log.Debug("Generate odd barcode successful.");
                            #endregion

                            #region 入库
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetailList[0], user, receiptDetail.PutAwayBinCode);
                            log.Debug("odd Inventory in successful.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection && orderHead.NeedInspection && orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                    locationLotDetail.CurrentInspectQty = locationLotDetail.Qty;
                                    inspectLocationLotDetailList.Add(locationLotDetail);
                                }
                            }
                            #endregion
                        }
                        #endregion

                        oddQty = receiptDetail.ReceivedQty.HasValue && orderDetail.HuLotSize.HasValue ?
                                 receiptDetail.ReceivedQty.Value % orderDetail.HuLotSize.Value : 0; //收货零头数
                        log.Debug("Receive odd qty is " + oddQty);

                        receiptDetail.ReceivedQty = receiptDetail.ReceivedQty.Value - oddQty; //收货数量凑整
                    }
                    #endregion

                    #region 满包装/零头创建Hu处理
                    if (receiptDetail.ReceivedQty.HasValue ||
                        receiptDetail.RejectedQty.HasValue ||
                        receiptDetail.ScrapQty.HasValue)
                    {
                        //创建Hu
                        IList <Hu> huList = this.huMgr.CreateHu(receiptDetail, user);
                        log.Debug("Create barcode successful.");

                        //创建收货项
                        IList <ReceiptDetail> receiptDetailList = this.receiptDetailMgr.CreateReceiptDetail(receipt, orderLocationTransaction, huList);
                        log.Debug("Create receipt detail successful.");

                        #region 如果还有次品或者废品收货,添加到收货列表
                        if ((receiptDetail.RejectedQty.HasValue && receiptDetail.RejectedQty > 0) ||
                            (receiptDetail.ScrapQty.HasValue && receiptDetail.ScrapQty > 0))
                        {
                            ReceiptDetail rejAndScrapReceiptDetail = new ReceiptDetail();
                            CloneHelper.CopyProperty(receiptDetail, rejAndScrapReceiptDetail);
                            rejAndScrapReceiptDetail.ReceivedQty    = null;
                            rejAndScrapReceiptDetail.PutAwayBinCode = null;
                            rejAndScrapReceiptDetail.Receipt        = receipt;

                            this.receiptDetailMgr.CreateReceiptDetail(rejAndScrapReceiptDetail);

                            receiptDetailList.Add(rejAndScrapReceiptDetail);
                            receipt.AddReceiptDetail(rejAndScrapReceiptDetail);
                        }
                        #endregion

                        foreach (ReceiptDetail huReceiptDetail in receiptDetailList)
                        {
                            #region 匹配ReceiptDetail和InProcessLocationDetail,Copy相关信息
                            if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)
                            {
                                IList <InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);
                                if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 0)
                                {
                                    if (matchInProcessLocationDetailList.Count > 1)
                                    {
                                        //只有当ASN中包含条码,按数量收货,并收货后创建条码才有可能发生这种情况。
                                        //变态才这么干。
                                        log.Error("只有当ASN中包含条码,按数量收货,并收货后创建条码才有可能发生这种情况。");
                                        throw new BusinessErrorException("你是变态才这么设置。");
                                    }

                                    //如果找到匹配项,只可能有一个
                                    huReceiptDetail.PlannedBill   = matchInProcessLocationDetailList[0].PlannedBill;
                                    huReceiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment;
                                    huReceiptDetail.ShippedQty    = matchInProcessLocationDetailList[0].Qty;

                                    this.receiptDetailMgr.UpdateReceiptDetail(huReceiptDetail);
                                }

                                //收货创建HU,分配PlannedAmount,todo:考虑余数
                                huReceiptDetail.PlannedAmount = receiptDetail.PlannedAmount / receiptDetail.ReceivedQty.Value * huReceiptDetail.ReceivedQty.Value;
                            }
                            #endregion

                            #region 入库
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(huReceiptDetail, user, receiptDetail.PutAwayBinCode);
                            log.Debug("Inventory in successful.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection &&
                                orderHead.NeedInspection &&
                                orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML &&
                                huReceiptDetail.ReceivedQty.HasValue &&
                                huReceiptDetail.ReceivedQty > 0)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT)
                                    {
                                        LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                        locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty;
                                        inspectLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 生产剩余零头处理
                    if (oddQty > 0)
                    {
                        log.Debug("Start handle odd qty.");
                        ReceiptDetail oddReceiptDetail = new ReceiptDetail();
                        CloneHelper.CopyProperty(receiptDetail, oddReceiptDetail);

                        oddReceiptDetail.ReceivedQty = oddQty;
                        oddReceiptDetail.RejectedQty = 0;
                        oddReceiptDetail.ScrapQty    = 0;

                        #region 零头入库
                        oddReceiptDetail.Receipt = receipt;
                        IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(oddReceiptDetail, user, receiptDetail.PutAwayBinCode);
                        #endregion

                        #region 零头创建收货明细
                        this.receiptDetailMgr.CreateReceiptDetail(oddReceiptDetail);
                        receipt.AddReceiptDetail(oddReceiptDetail);
                        #endregion

                        #region 创建HuOdd
                        LocationLotDetail locationLotDetail = locationLotDetailMgr.LoadLocationLotDetail(inventoryTransactionList[0].LocationLotDetailId);
                        this.huOddMgr.CreateHuOdd(oddReceiptDetail, locationLotDetail, user);
                        #endregion
                        log.Debug("End handle odd qty.");
                    }
                    #endregion

                    #endregion
                }
                else
                {
                    #region 收货时不创建Hu
                    log.Debug("Create receipt detail with no generate barcode.");

                    #region 更新Hu上的OrderNo、ReceiptNo和AntiResloveHu
                    if (receiptDetail.HuId != null && receiptDetail.HuId.Trim() != string.Empty)
                    {
                        Hu   hu        = this.huMgr.LoadHu(receiptDetail.HuId);
                        bool isUpdated = false;

                        if (hu.OrderNo == null || hu.ReceiptNo == null)
                        {
                            if (hu.OrderNo == null)
                            {
                                log.Debug("Update hu OrderNo " + orderHead.OrderNo + ".");
                                hu.OrderNo = orderHead.OrderNo;
                            }

                            if (hu.ReceiptNo == null)
                            {
                                log.Debug("Update hu ReceiptNo " + receipt.ReceiptNo + ".");
                                hu.ReceiptNo = receipt.ReceiptNo;
                            }

                            isUpdated = true;
                        }

                        if (hu.AntiResolveHu == null &&
                            orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                        {
                            hu.AntiResolveHu = orderHead.AntiResolveHu;
                            isUpdated        = true;
                        }

                        if (isUpdated)
                        {
                            this.huMgr.UpdateHu(hu);
                        }
                    }
                    #endregion

                    IList <ReceiptDetail> noCreateHuReceiptDetailList = new List <ReceiptDetail>();

                    #region 匹配ReceiptDetail和InProcessLocationDetail,Copy相关信息
                    log.Debug("Start match ReceiptDetail and InProcessLocationDetail.");
                    if (orderHead.Type != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION &&
                        orderHead.SubType != BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ)     //收货调整已经匹配过InProcessLocationDetail,不需要在匹配
                    {
                        IList <InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);
                        log.Debug("Find matched InProcessLocationDetailList, count = " + matchInProcessLocationDetailList != null ? matchInProcessLocationDetailList.Count : 0);

                        if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count == 1)
                        {
                            //一次收货对应一次发货。
                            log.Debug("one ipdet vs one receiptdet.");
                            receiptDetail.PlannedBill   = matchInProcessLocationDetailList[0].PlannedBill;
                            receiptDetail.IsConsignment = matchInProcessLocationDetailList[0].IsConsignment;
                            if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP)
                            {
                                receiptDetail.ShippedQty = 0 - matchInProcessLocationDetailList[0].Qty;
                            }
                            else
                            {
                                receiptDetail.ShippedQty = matchInProcessLocationDetailList[0].Qty;
                            }
                            receiptDetail.ReceivedInProcessLocationDetail = matchInProcessLocationDetailList[0];
                            noCreateHuReceiptDetailList.Add(receiptDetail);
                        }
                        else if (matchInProcessLocationDetailList != null && matchInProcessLocationDetailList.Count > 1)
                        {
                            //一次收货对应多次发货。
                            //如:发货按条码,收货按数量。
                            log.Debug("multi ipdet vs one receiptdet.");
                            decimal totalRecQty = receiptDetail.ReceivedQty.Value;
                            InProcessLocationDetail lastInProcessLocationDetail = null;
                            log.Debug("Start Fetch matched InProcessLocationDetailList.");
                            foreach (InProcessLocationDetail inProcessLocationDetail in matchInProcessLocationDetailList)
                            {
                                lastInProcessLocationDetail = inProcessLocationDetail; //记录最后一次发货项,供没有对应发货的收货项使用

                                if (inProcessLocationDetail.ReceivedQty.HasValue && Math.Abs(inProcessLocationDetail.ReceivedQty.Value) >= Math.Abs(inProcessLocationDetail.Qty))
                                {
                                    continue;
                                }

                                if (Math.Abs(totalRecQty) > 0)
                                {
                                    log.Debug("Start cloned ReceiptDetail.");
                                    ReceiptDetail clonedReceiptDetail = new ReceiptDetail();
                                    CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail);
                                    log.Debug("End cloned ReceiptDetail.");

                                    clonedReceiptDetail.PlannedBill   = inProcessLocationDetail.PlannedBill;
                                    clonedReceiptDetail.IsConsignment = inProcessLocationDetail.IsConsignment;

                                    #region
                                    if (matchInProcessLocationDetailList[0].InProcessLocation.Type == BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_GAP)
                                    {
                                        inProcessLocationDetail.Qty = 0 - inProcessLocationDetail.Qty;
                                    }
                                    #endregion

                                    if (Math.Abs(totalRecQty) > Math.Abs(inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero)))
                                    {
                                        clonedReceiptDetail.ReceivedQty = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                        clonedReceiptDetail.ShippedQty  = inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                        totalRecQty -= inProcessLocationDetail.Qty - (inProcessLocationDetail.ReceivedQty.HasValue ? inProcessLocationDetail.ReceivedQty.Value : decimal.Zero);
                                    }
                                    else
                                    {
                                        clonedReceiptDetail.ReceivedQty = totalRecQty;
                                        clonedReceiptDetail.ShippedQty  = totalRecQty;
                                        totalRecQty = 0;
                                    }

                                    //因为去掉了数量,记录已经匹配的发货项,避免差异处理的时候匹配多条而产生差异。
                                    clonedReceiptDetail.ReceivedInProcessLocationDetail = inProcessLocationDetail;

                                    noCreateHuReceiptDetailList.Add(clonedReceiptDetail);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            log.Debug("End Fetch matched InProcessLocationDetailList.");

                            //超收,没有找到对应的发货项,只记录收货数,发货数记0
                            if (Math.Abs(totalRecQty) > 0)
                            {
                                ReceiptDetail clonedReceiptDetail = new ReceiptDetail();
                                CloneHelper.CopyProperty(receiptDetail, clonedReceiptDetail);

                                clonedReceiptDetail.ShippedQty  = 0;
                                clonedReceiptDetail.ReceivedQty = totalRecQty;
                                clonedReceiptDetail.ReceivedInProcessLocationDetail = lastInProcessLocationDetail;

                                noCreateHuReceiptDetailList.Add(clonedReceiptDetail);
                            }
                        }
                        else
                        {
                            noCreateHuReceiptDetailList.Add(receiptDetail);
                        }
                    }
                    else
                    {
                        noCreateHuReceiptDetailList.Add(receiptDetail);
                    }
                    log.Debug("End match ReceiptDetail and InProcessLocationDetail.");
                    #endregion

                    foreach (ReceiptDetail noCreateHuReceiptDetail in noCreateHuReceiptDetailList)
                    {
                        noCreateHuReceiptDetail.Receipt = receipt;

                        if (noCreateHuReceiptDetail.ReceivedQty != 0)
                        {
                            #region 入库
                            log.Debug("Start Inventory In.");
                            IList <InventoryTransaction> inventoryTransactionList = this.locationMgr.InventoryIn(noCreateHuReceiptDetail, user, noCreateHuReceiptDetail.PutAwayBinCode);
                            log.Debug("End Inventory In.");
                            #endregion

                            #region 是否检验
                            if (orderDetail.NeedInspection && orderHead.NeedInspection && inventoryTransactionList != null && inventoryTransactionList.Count > 0 &&
                                orderHead.SubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML)
                            {
                                foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList)
                                {
                                    if (inventoryTransaction.Location.Code != BusinessConstants.SYSTEM_LOCATION_REJECT)
                                    {
                                        LocationLotDetail locationLotDetail = this.locationLotDetailMgr.LoadLocationLotDetail(inventoryTransaction.LocationLotDetailId);
                                        locationLotDetail.CurrentInspectQty = inventoryTransaction.Qty;
                                        inspectLocationLotDetailList.Add(locationLotDetail);
                                    }
                                }
                            }
                            #endregion
                        }

                        #region 创建收货明细
                        log.Debug("Start Create Receipt Detail.");
                        this.receiptDetailMgr.CreateReceiptDetail(noCreateHuReceiptDetail);
                        receipt.AddReceiptDetail(noCreateHuReceiptDetail);
                        log.Debug("End Create Receipt Detail.");
                        #endregion
                    }

                    #endregion
                }
            }
            #endregion

            #region 检验
            if (inspectLocationLotDetailList.Count > 0)
            {
                //对于没有Hu的,如果收货时已经回冲了负数库存,也就是库存数量和待检验数量不一致可能会有问题
                //增加ipno,receiptno,isseperated字段
                this.inspectOrderMgr.CreateInspectOrder(inspectLocationLotDetailList, user, receipt.InProcessLocations[0].IpNo, receipt.ReceiptNo, false);
            }
            #endregion

            //#region 匹配收货发货项,查找差异
            //IList<InProcessLocationDetail> gapInProcessLocationDetailList = new List<InProcessLocationDetail>();

            //#region 发货项不匹配
            //foreach (InProcessLocationDetail inProcessLocationDetail in inProcessLocationDetailList)
            //{
            //    if (inProcessLocationDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
            //        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)   //生产暂时不支持差异
            //    {
            //        decimal receivedQty = 0;  //发货项的累计收货数

            //        //一条发货项可能对应多条收货项
            //        foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails)
            //        {
            //            //匹配收货项和发货项
            //            if (receiptDetail.ReceivedInProcessLocationDetail != null)
            //            {
            //                //对于已经匹配的,直接按发货项匹配
            //                if (receiptDetail.ReceivedInProcessLocationDetail.Id == inProcessLocationDetail.Id)
            //                {
            //                    if (receiptDetail.ReceivedQty.HasValue)
            //                    {
            //                        receivedQty += receiptDetail.ReceivedQty.Value;
            //                    }
            //                }
            //            }
            //            else if (OrderHelper.IsInProcessLocationDetailMatchReceiptDetail(
            //                inProcessLocationDetail, receiptDetail))
            //            {
            //                if (receiptDetail.ReceivedQty.HasValue)
            //                {
            //                    receivedQty += receiptDetail.ReceivedQty.Value;
            //                }
            //            }
            //        }

            //        if (receivedQty != inProcessLocationDetail.Qty)
            //        {
            //            #region 收货数量和发货数量不匹配,记录差异
            //            InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail();
            //            gapInProcessLocationDetail.Qty = receivedQty - inProcessLocationDetail.Qty;
            //            gapInProcessLocationDetail.OrderLocationTransaction = inProcessLocationDetail.OrderLocationTransaction;
            //            //gapInProcessLocationDetail.HuId = inProcessLocationDetail.HuId;
            //            gapInProcessLocationDetail.LotNo = inProcessLocationDetail.LotNo;
            //            gapInProcessLocationDetail.IsConsignment = inProcessLocationDetail.IsConsignment;
            //            gapInProcessLocationDetail.PlannedBill = inProcessLocationDetail.PlannedBill;

            //            gapInProcessLocationDetailList.Add(gapInProcessLocationDetail);
            //            #endregion
            //        }
            //    }
            //}
            //#endregion

            //#region 收货项不匹配
            //foreach (ReceiptDetail receiptDetail in receipt.ReceiptDetails)
            //{
            //    if (receiptDetail.OrderLocationTransaction.OrderDetail.OrderHead.Type
            //        != BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION)   //生产暂时不支持差异
            //    {
            //        IList<InProcessLocationDetail> matchInProcessLocationDetailList = OrderHelper.FindMatchInProcessLocationDetail(receiptDetail, inProcessLocationDetailList);

            //        if (matchInProcessLocationDetailList == null || matchInProcessLocationDetailList.Count == 0)
            //        {
            //            OrderLocationTransaction outOrderLocationTransaction =
            //                this.orderLocationTransactionMgr.GetOrderLocationTransaction(receiptDetail.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_OUT)[0];
            //            #region 没有找到和收货项对应的发货项
            //            InProcessLocationDetail gapInProcessLocationDetail = new InProcessLocationDetail();
            //            gapInProcessLocationDetail.Qty = receiptDetail.ReceivedQty.Value;
            //            gapInProcessLocationDetail.OrderLocationTransaction = outOrderLocationTransaction;
            //            //gapInProcessLocationDetail.HuId = receiptDetail.HuId;
            //            gapInProcessLocationDetail.LotNo = receiptDetail.LotNo;
            //            gapInProcessLocationDetail.IsConsignment = receiptDetail.IsConsignment;
            //            gapInProcessLocationDetail.PlannedBill = receiptDetail.PlannedBill;

            //            gapInProcessLocationDetailList.Add(gapInProcessLocationDetail);
            //            #endregion
            //        }
            //    }
            //}
            //#endregion
            //#endregion

            #region 关闭InProcessLocation
            if (receipt.InProcessLocations != null && receipt.InProcessLocations.Count > 0)
            {
                foreach (InProcessLocation inProcessLocation in receipt.InProcessLocations)
                {
                    if (inProcessLocation.IsAsnUniqueReceipt)
                    {
                        //不支持多次收货直接关闭
                        this.inProcessLocationMgr.CloseInProcessLocation(inProcessLocation, user);
                    }
                    else
                    {
                        this.inProcessLocationMgr.TryCloseInProcessLocation(inProcessLocation, user);
                    }

                    //transportationOrderMgr.TryCompleteTransportationOrder(inProcessLocation, user);
                }
            }
            #endregion
        }
Esempio n. 19
0
    private void SaveRender(object sender, EventArgs e)
    {
        if (this.cvStartTime.IsValid || this.IsReject)
        {
            IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>();
            OrderHead           orderHead             = CloneHelper.DeepClone <OrderHead>((OrderHead)sender); //Clone:避免修改List Page的TheOrder,导致出错

            if (orderHead != null && orderHead.OrderDetails != null && orderHead.OrderDetails.Count > 0)
            {
                foreach (OrderDetail orderDetail in orderHead.OrderDetails)
                {
                    if (orderDetail.OrderedQty != 0)
                    {
                        if (orderDetail.Item.Type == BusinessConstants.CODE_MASTER_ITEM_TYPE_VALUE_K)
                        {
                            IList <Item>    newItemList = new List <Item>(); //填充套件子件
                            decimal?        convertRate = null;
                            IList <ItemKit> itemKitList = null;

                            var maxSequence = orderHead.OrderDetails.Max(o => o.Sequence);
                            itemKitList = this.TheItemKitMgr.GetChildItemKit(orderDetail.Item);
                            for (int i = 0; i < itemKitList.Count; i++)
                            {
                                Item item = itemKitList[i].ChildItem;
                                if (!convertRate.HasValue)
                                {
                                    if (itemKitList[i].ParentItem.Uom.Code != orderDetail.Item.Uom.Code)
                                    {
                                        convertRate = this.TheUomConversionMgr.ConvertUomQty(orderDetail.Item, orderDetail.Item.Uom, 1, itemKitList[i].ParentItem.Uom);
                                    }
                                    else
                                    {
                                        convertRate = 1;
                                    }
                                }
                                OrderDetail newOrderDetail = new OrderDetail();

                                newOrderDetail.OrderHead     = orderDetail.OrderHead;
                                newOrderDetail.Sequence      = maxSequence + (i + 1);
                                newOrderDetail.IsBlankDetail = false;
                                newOrderDetail.Item          = item;



                                newOrderDetail.Uom         = item.Uom;
                                newOrderDetail.UnitCount   = orderDetail.Item.UnitCount * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.OrderedQty  = orderDetail.OrderedQty * itemKitList[i].Qty * convertRate.Value;
                                newOrderDetail.PackageType = orderDetail.PackageType;

                                #region 价格字段

                                if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                                {
                                    if (orderDetail.PriceListFrom != null && orderDetail.PriceListFrom.Code != string.Empty)
                                    {
                                        newOrderDetail.PriceListFrom = ThePurchasePriceListMgr.LoadPurchasePriceList(orderDetail.PriceListFrom.Code);

                                        if (newOrderDetail.PriceListFrom != null)
                                        {
                                            newOrderDetail.PriceListDetailFrom = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListFrom, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                                        }
                                    }
                                }
                                else if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                                {
                                    if (orderDetail.PriceListTo != null && orderDetail.PriceListTo.Code != string.Empty)
                                    {
                                        newOrderDetail.PriceListTo = TheSalesPriceListMgr.LoadSalesPriceList(orderDetail.PriceListTo.Code);
                                    }
                                    if (newOrderDetail.PriceListTo != null)
                                    {
                                        newOrderDetail.PriceListDetailTo = this.ThePriceListDetailMgr.GetLastestPriceListDetail(newOrderDetail.PriceListTo, item, DateTime.Now, newOrderDetail.OrderHead.Currency, item.Uom);
                                    }
                                }

                                #endregion
                                resultOrderDetailList.Add(newOrderDetail);
                            }
                        }
                        else
                        {
                            resultOrderDetailList.Add(orderDetail);
                        }
                    }
                }
            }
            if (resultOrderDetailList.Count == 0)
            {
                this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required");
                return;
            }
            else
            {
                Flow currentFlow = TheFlowMgr.LoadFlow(CurrentFlowCode, true);

                DateTime winTime   = this.tbWinTime.Text.Trim() == string.Empty ? DateTime.Now : DateTime.Parse(this.tbWinTime.Text);
                DateTime startTime = winTime;

                if (this.tbStartTime.Text != string.Empty)
                {
                    startTime = DateTime.Parse(this.tbStartTime.Text.Trim());
                }
                else
                {
                    double leadTime = this.hfLeadTime.Value == string.Empty ? 0 : double.Parse(this.hfLeadTime.Value);
                    double emTime   = this.hfEmTime.Value == string.Empty ? 0 : double.Parse(this.hfEmTime.Value);
                    double lTime    = this.cbIsUrgent.Checked ? emTime : leadTime;
                    startTime = winTime.AddHours(0 - lTime);
                }

                orderHead.OrderDetails  = resultOrderDetailList;
                orderHead.WindowTime    = winTime;
                orderHead.StartTime     = startTime;
                orderHead.IsAutoRelease = this.cbReleaseOrder.Checked;

                orderHead.IsNewItem = this.NewItem;
                if (this.cbIsUrgent.Checked)
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_URGENT;
                }
                else
                {
                    orderHead.Priority = BusinessConstants.CODE_MASTER_ORDER_PRIORITY_VALUE_NORMAL;
                }
                if (this.tbRefOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ReferenceOrderNo = this.tbRefOrderNo.Text.Trim();
                }
                if (this.tbExtOrderNo.Text.Trim() != string.Empty)
                {
                    orderHead.ExternalOrderNo = this.tbExtOrderNo.Text.Trim();
                }
            }

            //创建订单
            try
            {
                if (this.IsQuick)
                {
                    Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser.Code, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, this.cbIsUrgent.Checked, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo);
                    if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0)
                    {
                        orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead;
                        if (this.cbPrintOrder.Checked)
                        {
                            IList <OrderDetail> orderDetails = orderHead.OrderDetails;
                            IList <object>      list         = new List <object>();
                            list.Add(orderHead);
                            list.Add(orderDetails);

                            IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo);
                            list.Add(orderLocationTransactions);

                            //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list);
                            string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list);

                            Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>");
                        }
                    }
                    this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo);

                    if (!this.cbContinuousCreate.Checked)
                    {
                        this.PageCleanup();
                        if (QuickCreateEvent != null)
                        {
                            QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e);
                        }
                    }
                    else
                    {
                        orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim());
                        InitDetailParamater(orderHead);
                    }
                }
                else
                {
                    TheOrderMgr.CreateOrder(orderHead, this.CurrentUser);
                    if (this.cbPrintOrder.Checked)
                    {
                        IList <OrderDetail> orderDetails = orderHead.OrderDetails;
                        IList <object>      list         = new List <object>();
                        list.Add(orderHead);
                        list.Add(orderDetails);

                        IList <OrderLocationTransaction> orderLocationTransactions = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(orderHead.OrderNo);
                        list.Add(orderLocationTransactions);

                        //TheReportProductionMgr.FillValues(orderHead.OrderTemplate, list);
                        string printUrl = TheReportMgr.WriteToFile(orderHead.OrderTemplate, list);

                        Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + printUrl + "'); </script>");
                    }
                    this.ShowSuccessMessage("MasterData.Order.OrderHead.AddOrder.Successfully", orderHead.OrderNo);
                    if (!this.cbContinuousCreate.Checked)
                    {
                        this.PageCleanup();
                        if (CreateEvent != null)
                        {
                            CreateEvent(orderHead.OrderNo, e);
                        }
                    }
                    else
                    {
                        orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim());
                        InitDetailParamater(orderHead);
                    }
                }
            }
            catch (BusinessErrorException ex)
            {
                this.ShowErrorMessage(ex);
                return;
            }
        }
    }
Esempio n. 20
0
        private DetachedCriteria AddSortingField()
        {
            if (this.SortExpression == "Descending" || this.SortingFields.Count == 0)
            {
                return(this.SelectCriteria);
            }
            else
            {
                //由于不提供Remove Order方法,只能一直Add Order,如果出现对同一字段多次会出错。
                //现在每次排序前克隆一个新的selectCriteria,手工过滤同一字段多次排序问题
                DetachedCriteria selectCriteria = CloneHelper.DeepClone <DetachedCriteria>(this.SelectCriteria);

                int fieldCount = 0;
                //存放相同别名
                Dictionary <string, string> aliasDict = CloneHelper.DeepClone <Dictionary <string, string> >(this.Alias as Dictionary <string, string>);
                if (aliasDict == null)
                {
                    aliasDict = new Dictionary <string, string>();
                }

                for (int i = (SortingFields.Count - 1); i >= 0; i--)
                {
                    IDictionary <string, string> field = SortingFields[i];
                    IEnumerator <KeyValuePair <string, string> > fieldEnum = field.GetEnumerator();
                    fieldEnum.MoveNext();
                    string sortExpression = fieldEnum.Current.Key;
                    string sortDirection  = fieldEnum.Current.Value;

                    if (sortExpression.LastIndexOf(".") != -1)
                    {
                        string alias      = sortExpression.Substring(0, sortExpression.LastIndexOf("."));
                        string orderField = sortExpression.Substring(sortExpression.LastIndexOf("."));
                        if (CurrentSortDirection == SortDirection.Ascending)
                        {
                            if (aliasDict.ContainsKey(alias))
                            {
                                selectCriteria.AddOrder(Order.Asc(aliasDict[alias] + orderField));
                            }
                            else
                            {
                                selectCriteria.CreateAlias(alias, "A" + fieldCount).AddOrder(Order.Asc("A" + fieldCount + orderField));
                                aliasDict[alias] = "A" + fieldCount;
                            }
                        }
                        else
                        {
                            if (aliasDict.ContainsKey(alias))
                            {
                                selectCriteria.AddOrder(Order.Desc(aliasDict[alias] + orderField));
                            }
                            else
                            {
                                selectCriteria.CreateAlias(alias, "A" + fieldCount).AddOrder(Order.Desc("A" + fieldCount + orderField));
                                aliasDict[alias] = "A" + fieldCount;
                            }
                        }
                        fieldCount++;
                    }
                    else
                    {
                        if (CurrentSortDirection == SortDirection.Ascending)
                        {
                            selectCriteria.AddOrder(Order.Asc(sortExpression));
                        }
                        else
                        {
                            selectCriteria.AddOrder(Order.Desc(sortExpression));
                        }
                    }
                }
                return(selectCriteria);
            }
        }
Esempio n. 21
0
        private List <WorkCalendar> SpecialTimeWizard(DateTime date, string region, string workcenter, List <WorkCalendar> workCalendars)
        {
            List <WorkCalendar> addList = new List <WorkCalendar>();

            date = date.Date;
            string   dayofweek      = date.DayOfWeek.ToString();
            DateTime dateShiftStart = date;
            DateTime dateShiftEnd   = date.AddDays(1);

            if (workCalendars.Count > 0)
            {
                dateShiftStart = workCalendars[0].StartTime;
                dateShiftEnd   = workCalendars[workCalendars.Count - 1].EndTime;
            }
            IList specialTimes = SpecialTimeMgr.GetReferSpecialTimeWizard(dateShiftStart, dateShiftEnd, region, workcenter);

            if (specialTimes.Count > 0)
            {
                foreach (WorkCalendar workCalendar in workCalendars)
                {
                    WorkCalendar newWorkCalendar = new WorkCalendar();
                    foreach (SpecialTime specialTime in specialTimes)
                    {
                        //SpecialTime            ------
                        //WorkCalendar                   ------
                        if (DateTime.Compare(specialTime.EndTime, workCalendar.StartTime) <= 0)
                        {
                            continue;
                        }
                        //SpecialTime                            ------
                        //WorkCalendar                   ------
                        else if (DateTime.Compare(specialTime.StartTime, workCalendar.EndTime) >= 0)
                        {
                            continue;
                        }
                        else
                        {
                            if (specialTime.Type == workCalendar.Type)
                            {
                                continue;
                            }
                            else
                            {
                                if (DateTime.Compare(specialTime.StartTime, workCalendar.StartTime) <= 0)
                                {
                                    //SpecialTime              ----------
                                    //WorkCalendar               ------
                                    if (DateTime.Compare(specialTime.EndTime, workCalendar.EndTime) >= 0)
                                    {
                                        workCalendar.Type = specialTime.Type;
                                    }
                                    //SpecialTime            ------
                                    //WorkCalendar               ------
                                    else
                                    {
                                        newWorkCalendar = new WorkCalendar();
                                        CloneHelper.CopyProperty(workCalendar, newWorkCalendar);
                                        newWorkCalendar.EndTime = specialTime.EndTime;
                                        newWorkCalendar.Type    = specialTime.Type;
                                        addList.Add(newWorkCalendar);

                                        workCalendar.StartTime = specialTime.EndTime;
                                    }
                                }
                                else
                                {
                                    //SpecialTime                    ------
                                    //WorkCalendar               ------
                                    if (DateTime.Compare(specialTime.EndTime, workCalendar.EndTime) >= 0)
                                    {
                                        newWorkCalendar = new WorkCalendar();
                                        CloneHelper.CopyProperty(workCalendar, newWorkCalendar);
                                        newWorkCalendar.StartTime = specialTime.StartTime;
                                        newWorkCalendar.EndTime   = workCalendar.EndTime;
                                        newWorkCalendar.Type      = specialTime.Type;
                                        addList.Add(newWorkCalendar);

                                        workCalendar.EndTime = specialTime.StartTime;
                                    }
                                    //SpecialTime                  ------
                                    //WorkCalendar               ----------
                                    else
                                    {
                                        newWorkCalendar = new WorkCalendar();
                                        CloneHelper.CopyProperty(workCalendar, newWorkCalendar);
                                        newWorkCalendar.EndTime = specialTime.StartTime;
                                        newWorkCalendar.Type    = workCalendar.Type;
                                        addList.Add(newWorkCalendar);

                                        newWorkCalendar = new WorkCalendar();
                                        CloneHelper.CopyProperty(workCalendar, newWorkCalendar);
                                        newWorkCalendar.StartTime = specialTime.EndTime;
                                        newWorkCalendar.Type      = workCalendar.Type;
                                        addList.Add(newWorkCalendar);

                                        workCalendar.StartTime = specialTime.StartTime;
                                        workCalendar.EndTime   = specialTime.EndTime;
                                        workCalendar.Type      = specialTime.Type;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                return(workCalendars);
            }

            workCalendars.AddRange(addList);
            workCalendars.Sort(WorkCalendarTimeCompare);

            return(workCalendars);
        }
Esempio n. 22
0
 /// <inheritdoc/>
 public override IDockable?Clone()
 {
     return(CloneHelper.CloneDocumentDock(this));
 }
Esempio n. 23
0
 public object DeepCopy(object value)
 {
     return(value == null ? null : CloneHelper.Clone(value as T));
 }
Esempio n. 24
0
        public void CreateOrder(OrderHead order, string userCode)
        {
            if (order.OrderDetails == null || order.OrderDetails.Count == 0)
            {
                return;
            }

            IList <OrderHead> orderList = new List <OrderHead>();

            //OrderLotSize
            Flow flow = this.FlowMgr.LoadFlow(order.Flow);

            if (order.OrderDetails.Count == 1 && flow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
            {
                FlowDetail fd           = order.OrderDetails[0].FlowDetail;
                decimal    orderLotSize = fd.OrderLotSize.HasValue ? (decimal)fd.OrderLotSize : 0;
                decimal    reqQty       = order.OrderDetails[0].RequiredQty;
                decimal    remainReqQty = order.OrderDetails[0].RequiredQty;

                if (orderLotSize > 0)
                {
                    OrderDetail od = order.OrderDetails[0];

                    decimal oddQty = reqQty % orderLotSize;
                    if (oddQty > 0)
                    {
                        order.OrderDetails[0].RequiredQty = oddQty;
                        order.OrderDetails[0].OrderedQty  = oddQty;
                        orderList.Add(order);
                    }

                    int count = (int)Math.Floor(reqQty / orderLotSize);
                    for (int i = 0; i < count; i++)
                    {
                        OrderHead or = new OrderHead();
                        or = OrderMgr.TransferFlow2Order(order.Flow);
                        CloneHelper.CopyProperty(order, or, new string[] { "OrderNo", "OrderDetails" }, true);
                        if (or.OrderDetails != null && or.OrderDetails.Count > 0)
                        {
                            foreach (OrderDetail orderDetail in or.OrderDetails)
                            {
                                if (orderDetail.FlowDetail.Id == od.FlowDetail.Id && od.FlowDetail.Id > 0)
                                {
                                    orderDetail.RequiredQty = orderLotSize;
                                    orderDetail.OrderedQty  = orderLotSize;
                                }
                            }
                        }

                        orderList.Add(or);
                    }
                }
                else
                {
                    orderList.Add(order);
                }
            }
            else
            {
                orderList.Add(order);
            }

            //Write to DB
            if (orderList != null && orderList.Count > 0)
            {
                foreach (OrderHead oh in orderList)
                {
                    try
                    {
                        //all Empty check
                        bool isValid = false;
                        foreach (OrderDetail od in oh.OrderDetails)
                        {
                            if (od.RequiredQty > 0)
                            {
                                isValid = true;
                                break;
                            }
                        }

                        if (isValid)
                        {
                            //oh.Shift = shiftMgr.LoadShift("A");//temp,todo

                            log.Debug("Begin to create order," + oh.Flow);

                            this.OrderMgr.CreateOrder(oh, userCode);

                            log.Debug("End to create order," + oh.OrderNo);
                            log.Debug("----------------------------------Invincible's dividing line---------------------------------------");
                        }
                    }
                    catch (Exception ex)
                    {
                        this.OrderMgr.CleanSession();
                        log.Error("create order fail", ex);
                        log.Debug("----------------------------------Invincible's dividing line---------------------------------------");
                    }
                }
            }
        }
Esempio n. 25
0
    public string AdjustInProcessLocationTo()
    {
        try
        {
            InProcessLocation ip      = TheInProcessLocationMgr.LoadInProcessLocation(this.IpNo, true);
            Receipt           receipt = new Receipt();
            InProcessLocation nmlIp   = CloneHelper.DeepClone(ip);
            IList <InProcessLocationDetail> nmlReceiptDetailList = new List <InProcessLocationDetail>();
            foreach (InProcessLocationDetail ipdet in ip.InProcessLocationDetails)
            {
                #region 对应的ipdet
                InProcessLocationDetail nmlInProcessLocationDetail = new InProcessLocationDetail();
                nmlInProcessLocationDetail.Qty = 0 - ipdet.Qty;
                nmlInProcessLocationDetail.OrderLocationTransaction = TheOrderLocationTransactionMgr.GetOrderLocationTransaction(ipdet.OrderLocationTransaction.OrderDetail, BusinessConstants.IO_TYPE_IN)[0];
                nmlInProcessLocationDetail.IsConsignment            = ipdet.IsConsignment;
                nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill;
                nmlReceiptDetailList.Add(nmlInProcessLocationDetail);
                #endregion

                #region 收货单明细
                ReceiptDetail receiptDetail = new ReceiptDetail();
                receiptDetail.Receipt     = receipt;
                receiptDetail.ReceivedQty = nmlInProcessLocationDetail.Qty;
                receiptDetail.ShippedQty  = nmlInProcessLocationDetail.Qty;
                receiptDetail.OrderLocationTransaction = nmlInProcessLocationDetail.OrderLocationTransaction;
                receiptDetail.IsConsignment            = ipdet.IsConsignment;
                nmlInProcessLocationDetail.PlannedBill = ipdet.PlannedBill;

                OrderDetail orderDetail = receiptDetail.OrderLocationTransaction.OrderDetail;

                OrderHead orderHead = orderDetail.OrderHead;

                if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT)
                {
                    PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListFrom, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency);
                    if (priceListDetail == null)
                    {
                        throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code });
                    }
                    receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty;
                }
                else if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_DISTRIBUTION)
                {
                    PriceListDetail priceListDetail = ThePriceListDetailMgr.GetLastestPriceListDetail(orderDetail.DefaultPriceListTo, orderDetail.Item, DateTime.Now, orderDetail.OrderHead.Currency);
                    if (priceListDetail == null)
                    {
                        throw new BusinessErrorException("Order.Error.NoPriceListReceipt", new string[] { orderDetail.Item.Code });
                    }
                    receiptDetail.PlannedAmount = priceListDetail.UnitPrice * (decimal)receiptDetail.ReceivedQty;
                }

                receipt.AddReceiptDetail(receiptDetail);
                #endregion
            }


            nmlIp.InProcessLocationDetails = nmlReceiptDetailList;
            if (receipt.InProcessLocations == null)
            {
                receipt.InProcessLocations = new List <InProcessLocation>();
            }
            receipt.InProcessLocations.Add(nmlIp);

            TheReceiptMgr.CreateReceipt(receipt, this.CurrentUser);
            return(receipt.ReceiptNo);
        }
        catch (BusinessErrorException ex)
        {
            throw (ex);
        }
    }
Esempio n. 26
0
        public void SaveOrder(OrderModel orderInfo)
        {
            orderInfo.ClOrderId     = _fix.GetNewClOrderID();
            orderInfo.OrigClOrderId = orderInfo.ClOrderId;
            _sql.StartTransaction("RAMData");
            try
            {
                switch (orderInfo.InternalOrderType)
                {
                case 1:
                {
                    OrderModel stage = CloneHelper.ShallowClone(orderInfo);
                    stage.InternalOrderType = 0;
                    stage.ClOrderId         = _fix.GetNewClOrderID();
                    stage.OrigClOrderId     = stage.ClOrderId;
                    orderInfo.StageOrderId  = stage.ClOrderId;
                    FillModel fill = new FillModel
                    {
                        AvgPx        = orderInfo.AvgPrice,
                        ClOrderId    = orderInfo.ClOrderId,
                        CumQty       = orderInfo.Quantity,
                        LastQty      = orderInfo.Quantity,
                        LeavesQty    = 0,
                        OrderQty     = orderInfo.Quantity,
                        Side         = orderInfo.Side,
                        OrdStatus    = orderInfo.OrderStatus,
                        TickerSymbol = orderInfo.TickerSymbol,
                        ExecId       = _fix.GetNewClOrderID(),
                        ExecType     = 2,
                        OrderId      = _fix.GetNewClOrderID(),
                    };
                    _sql.SaveDataInTransaction("dbo.spOrder_Insert", stage);
                    _sql.SaveDataInTransaction("dbo.spOrder_Insert", orderInfo);
                    _sql.SaveDataInTransaction("dbo.spFill_Insert", fill);
                }
                break;

                case 2:
                {
                    _fix.SendOrder(orderInfo);
                    OrderModel stage = CloneHelper.ShallowClone(orderInfo);
                    stage.InternalOrderType = 0;
                    stage.ClOrderId         = _fix.GetNewClOrderID();
                    stage.OrigClOrderId     = stage.ClOrderId;
                    orderInfo.StageOrderId  = stage.ClOrderId;
                    _sql.SaveDataInTransaction("dbo.spOrder_Insert", stage);
                    _sql.SaveDataInTransaction("dbo.spOrder_Insert", orderInfo);
                }
                break;

                default:
                    _sql.SaveDataInTransaction("dbo.spOrder_Insert", orderInfo);
                    break;
                }
                _sql.CommitTransaction();
            }
            catch (Exception)
            {
                _sql.RollbackTransaction();
                throw;
            }
        }
Esempio n. 27
0
    protected void ODS_Flow_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        Flow flow    = (Flow)e.InputParameters[0];
        Flow oldFlow = TheFlowMgr.LoadFlow(FlowCode);

        CloneHelper.CopyProperty(oldFlow, flow, EditFields, true);

        Controls_TextBox tbRefFlow   = (Controls_TextBox)this.FV_Flow.FindControl("tbRefFlow");
        Controls_TextBox tbPartyFrom = (Controls_TextBox)this.FV_Flow.FindControl("tbPartyFrom");
        Controls_TextBox tbPartyTo   = (Controls_TextBox)this.FV_Flow.FindControl("tbPartyTo");

        Controls_TextBox tbLocFrom = (Controls_TextBox)this.FV_Flow.FindControl("tbLocFrom");
        Controls_TextBox tbLocTo   = (Controls_TextBox)this.FV_Flow.FindControl("tbLocTo");

        com.Sconit.Control.CodeMstrDropDownList ddlGrGapTo           = (com.Sconit.Control.CodeMstrDropDownList) this.FV_Flow.FindControl("ddlGrGapTo");
        com.Sconit.Control.CodeMstrDropDownList ddlCheckDetailOption = (com.Sconit.Control.CodeMstrDropDownList)(this.FV_Flow.FindControl("ddlCheckDetailOption"));

        com.Sconit.Control.CodeMstrDropDownList ddlOrderTemplate   = (com.Sconit.Control.CodeMstrDropDownList)(this.FV_Flow.FindControl("ddlOrderTemplate"));
        com.Sconit.Control.CodeMstrDropDownList ddlAsnTemplate     = (com.Sconit.Control.CodeMstrDropDownList)(this.FV_Flow.FindControl("ddlAsnTemplate"));
        com.Sconit.Control.CodeMstrDropDownList ddlReceiptTemplate = (com.Sconit.Control.CodeMstrDropDownList)(this.FV_Flow.FindControl("ddlReceiptTemplate"));
        com.Sconit.Control.CodeMstrDropDownList ddlHuTemplate      = (com.Sconit.Control.CodeMstrDropDownList)(this.FV_Flow.FindControl("ddlHuTemplate"));

        com.Sconit.Control.CodeMstrDropDownList ddlCreateHuOption = (com.Sconit.Control.CodeMstrDropDownList) this.FV_Flow.FindControl("ddlCreateHuOption");

        Controls_TextBox tbTPriceList         = (Controls_TextBox)this.FV_Flow.FindControl("tbTPriceList");
        Controls_TextBox tbTRoute             = (Controls_TextBox)this.FV_Flow.FindControl("tbTRoute");
        Controls_TextBox tbCarrier            = (Controls_TextBox)this.FV_Flow.FindControl("tbCarrier");
        Controls_TextBox tbCarrierBillAddress = (Controls_TextBox)this.FV_Flow.FindControl("tbCarrierBillAddress");
        Controls_TextBox tbCurrency           = (Controls_TextBox)this.FV_Flow.FindControl("tbCurrency");

        if (tbRefFlow != null && tbRefFlow.Text.Trim() != string.Empty)
        {
            flow.ReferenceFlow = TheFlowMgr.CheckAndLoadFlow(tbRefFlow.Text.Trim()).Code;
        }
        if (tbPartyFrom != null && tbPartyFrom.Text.Trim() != string.Empty)
        {
            flow.PartyFrom = ThePartyMgr.LoadParty(tbPartyFrom.Text.Trim());
        }
        if (tbPartyTo != null && tbPartyTo.Text.Trim() != string.Empty)
        {
            flow.PartyTo = ThePartyMgr.LoadParty(tbPartyTo.Text.Trim());
        }
        if (tbLocFrom != null && tbLocFrom.Text.Trim() != string.Empty)
        {
            flow.LocationFrom = TheLocationMgr.LoadLocation(tbLocFrom.Text.Trim());
        }
        if (tbLocTo != null && tbLocTo.Text.Trim() != string.Empty)
        {
            flow.LocationTo = TheLocationMgr.LoadLocation(tbLocTo.Text.Trim());
        }
        if (ddlOrderTemplate.SelectedIndex != -1)
        {
            flow.OrderTemplate = ddlOrderTemplate.SelectedValue;
        }
        if (ddlAsnTemplate.SelectedIndex != -1)
        {
            flow.AsnTemplate = ddlAsnTemplate.SelectedValue;
        }
        if (ddlReceiptTemplate.SelectedIndex != -1)
        {
            flow.ReceiptTemplate = ddlReceiptTemplate.SelectedValue;
        }
        if (ddlHuTemplate.SelectedIndex != -1)
        {
            flow.HuTemplate = ddlHuTemplate.SelectedValue;
        }
        if (ddlGrGapTo.SelectedIndex != -1)
        {
            flow.GoodsReceiptGapTo = ddlGrGapTo.SelectedValue;
        }
        if (ddlCheckDetailOption.SelectedIndex != -1)
        {
            flow.CheckDetailOption = ddlCheckDetailOption.SelectedValue;
        }
        if (ddlCreateHuOption.SelectedIndex != -1)
        {
            flow.CreateHuOption = ddlCreateHuOption.SelectedValue;
        }
        if (tbTPriceList != null && tbTPriceList.Text.Trim() != string.Empty)
        {
            flow.TransportPriceList = TheTransportPriceListMgr.LoadTransportPriceList(tbTPriceList.Text.Trim());
        }
        if (tbTRoute != null && tbTRoute.Text.Trim() != string.Empty)
        {
            flow.TransportationRoute = TheTransportationRouteMgr.LoadTransportationRoute(tbTRoute.Text.Trim());
        }
        if (tbCarrier != null && tbCarrier.Text.Trim() != string.Empty)
        {
            flow.Carrier = TheCarrierMgr.LoadCarrier(tbCarrier.Text.Trim());
        }
        if (tbCarrierBillAddress != null && tbCarrierBillAddress.Text.Trim() != string.Empty)
        {
            flow.CarrierBillAddress = TheAddressMgr.LoadBillAddress(tbCarrierBillAddress.Text.Trim());
        }
        if (tbCurrency != null && tbCurrency.Text.Trim() != string.Empty)
        {
            flow.Currency = TheCurrencyMgr.LoadCurrency(tbCurrency.Text.Trim());
        }
        else
        {
            string currencyCode = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_BASE_CURRENCY).Value;
            flow.Currency = TheCurrencyMgr.LoadCurrency(currencyCode);
        }
        flow.BillSettleTerm    = null;
        flow.CheckDetailOption = BusinessConstants.CODE_MASTER_CHECK_ORDER_DETAIL_OPTION_VALUE_NOT_CHECK;
        flow.LastModifyUser    = this.CurrentUser;
        flow.LastModifyDate    = DateTime.Now;
        flow.Version          += 1;
    }
Esempio n. 28
0
        public Document CloneDocument(Session targetSession)
        {
            CloneHelper helper = new CloneHelper(targetSession);

            return((Document)helper.Clone(this));
        }
Esempio n. 29
0
        public Bill VoidBill(string billNo, User user)
        {
            Bill     oldBill     = this.CheckAndLoadBill(billNo, true);
            DateTime dateTimeNow = DateTime.Now;

            #region 检查状态
            if (oldBill.Status != BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE)
            {
                throw new BusinessErrorException("Bill.Error.StatusErrorWhenVoid", oldBill.Status, oldBill.BillNo);
            }
            #endregion

            #region 创建作废账单
            Bill voidBill = new Bill();
            CloneHelper.CopyProperty(oldBill, voidBill, this.BillCloneField);

            voidBill.BillNo = this.numberControlMgr.GenerateNumber(BusinessConstants.CODE_PREFIX_BILL_RED);
            voidBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
            if (oldBill.Discount.HasValue)
            {
                voidBill.Discount = 0 - oldBill.Discount.Value;
            }
            voidBill.ReferenceBillNo = oldBill.BillNo;
            voidBill.BillType        = BusinessConstants.CODE_MASTER_BILL_TYPE_VALUE_CANCEL;
            voidBill.CreateDate      = dateTimeNow;
            voidBill.CreateUser      = user;
            voidBill.LastModifyDate  = dateTimeNow;
            voidBill.LastModifyUser  = user;

            this.CreateBill(voidBill);
            #endregion

            #region 创建作废账单明细
            foreach (BillDetail oldBillDetail in oldBill.BillDetails)
            {
                BillDetail voidBillDetail = new BillDetail();
                CloneHelper.CopyProperty(oldBillDetail, voidBillDetail, this.BillDetailCloneField);
                voidBillDetail.BilledQty   = 0 - oldBillDetail.BilledQty;
                voidBillDetail.Discount    = 0 - oldBillDetail.Discount;
                voidBillDetail.OrderAmount = 0 - oldBillDetail.OrderAmount;
                voidBillDetail.Bill        = voidBill;

                this.billDetailMgr.CreateBillDetail(voidBillDetail);
                voidBill.AddBillDetail(voidBillDetail);

                //反向更新ActingBill
                this.actingBillMgr.ReverseUpdateActingBill(null, voidBillDetail, user);
            }
            #endregion

            #region 记录开票事务
            foreach (BillDetail billDetail in oldBill.BillDetails)
            {
                this.billTransactionMgr.RecordBillTransaction(billDetail, user, true);
            }
            #endregion

            #region 更新原账单
            oldBill.ReferenceBillNo = voidBill.BillNo;
            oldBill.Status          = BusinessConstants.CODE_MASTER_STATUS_VALUE_VOID;
            oldBill.LastModifyDate  = dateTimeNow;
            oldBill.LastModifyUser  = user;

            //原账单暂估标记去掉
            oldBill.HasProvEst = false;
            this.UpdateBill(oldBill);
            #endregion

            return(voidBill);
        }
Esempio n. 30
0
        private ActingBill RetriveActingBill(PlannedBill plannedBill, DateTime dateTimeNow, User user)
        {
            DateTime effectiveDate = DateTime.Parse(plannedBill.EffectiveDate.ToShortDateString());   //仅保留年月日

            DetachedCriteria criteria = DetachedCriteria.For <ActingBill>();

            criteria.Add(Expression.Eq("OrderNo", plannedBill.OrderNo));
            if (plannedBill.ExternalReceiptNo != null)
            {
                criteria.Add(Expression.Eq("ExternalReceiptNo", plannedBill.ExternalReceiptNo));
            }
            else
            {
                criteria.Add(Expression.IsNull("ExternalReceiptNo"));
            }
            criteria.Add(Expression.Eq("ReceiptNo", plannedBill.ReceiptNo));
            criteria.Add(Expression.Eq("TransactionType", plannedBill.TransactionType));
            criteria.Add(Expression.Eq("Item", plannedBill.Item));
            criteria.Add(Expression.Eq("BillAddress", plannedBill.BillAddress));
            criteria.Add(Expression.Eq("Uom", plannedBill.Uom));
            criteria.Add(Expression.Eq("UnitCount", plannedBill.UnitCount));
            criteria.Add(Expression.Eq("PriceList", plannedBill.PriceList));
            criteria.Add(Expression.Eq("UnitPrice", plannedBill.UnitPrice));
            criteria.Add(Expression.Eq("Currency", plannedBill.Currency));
            criteria.Add(Expression.Eq("IsIncludeTax", plannedBill.IsIncludeTax));
            if (plannedBill.TaxCode != null)
            {
                criteria.Add(Expression.Eq("TaxCode", plannedBill.TaxCode));
            }
            else
            {
                criteria.Add(Expression.IsNull("TaxCode"));
            }

            if (plannedBill.LocationFrom != null)
            {
                criteria.Add(Expression.Eq("LocationFrom", plannedBill.LocationFrom));
            }
            else
            {
                criteria.Add(Expression.IsNull("LocationFrom"));
            }

            criteria.Add(Expression.Eq("IsProvisionalEstimate", plannedBill.IsProvisionalEstimate));
            criteria.Add(Expression.Eq("EffectiveDate", effectiveDate));

            IList <ActingBill> actingBillList = this.criteriaMgr.FindAll <ActingBill>(criteria);

            ActingBill actingBill = null;

            if (actingBillList.Count == 0)
            {
                actingBill = new ActingBill();
                CloneHelper.CopyProperty(plannedBill, actingBill, PlannedBill2ActingBillCloneField);
                actingBill.EffectiveDate = effectiveDate;
                actingBill.CreateUser    = user;
                actingBill.CreateDate    = dateTimeNow;
            }
            else if (actingBillList.Count == 1)
            {
                actingBill = actingBillList[0];
            }
            else
            {
                throw new TechnicalException("Acting bill record consolidate error, find target acting bill number great than 1.");
            }


            actingBill.BillQty += plannedBill.CurrentActingQty;
            if (actingBill.BillQty != actingBill.BilledQty)
            {
                actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE;
            }
            else
            {
                actingBill.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CLOSE;
            }
            actingBill.LastModifyUser = user;
            actingBill.LastModifyDate = dateTimeNow;
            return(actingBill);
        }