Ejemplo n.º 1
0
    private void ReceiveRender(object sender, EventArgs e)
    {
        OrderHead orderHead     = this.ucDetail.PopulateReceiveOrder();
        bool      isOddCreateHu = (bool)sender;

        try
        {
            Receipt receipt = TheOrderMgr.ReceiveOrder(orderHead.OrderDetails, this.CurrentUser, isOddCreateHu);
            this.FV_Order.DataBind();
            UpdateView();
            ShowSuccessMessage("MasterData.Order.OrderHead.Receive.Successfully", this.OrderNo);
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 2
0
    private void ReceiveRender(object sender, EventArgs e)
    {
        OrderHead orderHead = this.ucDetail.PopulateReceiveOrder();

        try
        {
            Receipt receipt = TheOrderMgr.ReceiveOrder(orderHead.OrderDetails, this.CurrentUser);
            this.FV_Order.DataBind();
            UpdateView();
            ShowSuccessMessage("MasterData.Order.OrderHead.Receive.Successfully", this.OrderNo);

            //    //barcode
            //    if (receipt != null)
            //    {
            //        IList<object> huDetailObj = new List<object>();
            //        IList<HuDetail> huDetailList = new List<HuDetail>();
            //        IList<ReceiptDetail> receiptDetailList = receipt.ReceiptDetails;
            //        if (receiptDetailList != null && receiptDetailList.Count > 0)
            //        {
            //            foreach (ReceiptDetail receiptDetail in receiptDetailList)
            //            {
            //                HuDetail huDetail = TheHuDetailMgr.LoadHuDetail(receiptDetail.HuId, receiptDetail.LotNo, receiptDetail.OrderLocationTransaction.Item.Code);
            //                if (huDetail != null)
            //                {
            //                    huDetailList.Add(huDetail);
            //                }
            //            }
            //            if (huDetailList != null && huDetailList.Count > 0)
            //            {
            //                huDetailObj.Add(huDetailList);
            //                //TheReportBarCodeMgr.FillValues("BarCode.xls", huDetailObj);
            //                huDetailObj.Add(CurrentUser.Code);
            //                string barCodeUrl = TheReportMgr.WriteToFile("BarCode.xls", huDetailObj,"BarCode.xls");
            //                Page.ClientScript.RegisterStartupScript(GetType(), "method", " <script language='javascript' type='text/javascript'>PrintOrder('" + barCodeUrl + "'); </script>");
            //            }
            //        }
            //    }
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }
Ejemplo n.º 3
0
    private void ReceiveRender(object sender, EventArgs e)
    {
        bool isOddCreateHu = (bool)sender;

        IList <ReceiptDetail> receiptDetailList = this.ucDetailList.PopulateReceiptDetailList();
        bool isReceiptOneItem = bool.Parse(TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_IS_RECEIPT_ONE_ITEM).Value);

        if (this.ModuleType == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION && this.ModuleSubType == BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ && isReceiptOneItem && receiptDetailList.Count > 1)
        {
            ShowErrorMessage("MasterData.Receipt.One.Item");
            return;
        }
        IList <OrderLocationTransaction> inLocTransList = new List <OrderLocationTransaction>();

        foreach (ReceiptDetail receiptDetail in receiptDetailList)
        {
            OrderLocationTransaction ol = receiptDetail.OrderLocationTransaction;
            ol.CurrentReceiveQty = ol.UnitQty * (receiptDetail.ReceivedQty.HasValue ? (decimal)receiptDetail.ReceivedQty : 0);
            ol.CurrentRejectQty  = ol.UnitQty * (receiptDetail.RejectedQty.HasValue ? (decimal)receiptDetail.RejectedQty : 0);
            ol.CurrentScrapQty   = ol.UnitQty * (receiptDetail.ScrapQty.HasValue ? (decimal)receiptDetail.ScrapQty : 0);
            inLocTransList.Add(ol);
        }

        IList <OrderLocationTransaction> orderLocTransList = this.ucInLocTransList.InLocTransList;  //投入原材料List
        IList <OrderLocationTransaction> outLocTransList   = new List <OrderLocationTransaction>(); //非零原材料List
        IList <OrderLocationTransaction> rwoLocTransList   = new List <OrderLocationTransaction>(); //返工成品List


        foreach (OrderLocationTransaction inLocTrans in this.ucInLocTransList.InLocTransList)
        {
            if (inLocTrans.BomDetail == null)
            {
                rwoLocTransList.Add(inLocTrans);
            }
            else if (inLocTrans.CurrentReceiveQty != 0)
            {
                outLocTransList.Add(inLocTrans);
            }
        }

        try
        {
            #region 正常生产收货
            if (outLocTransList.Count > 0)
            {
                foreach (ReceiptDetail receiptDetail in receiptDetailList)
                {
                    foreach (OrderLocationTransaction orderLocationTransaction in outLocTransList)
                    {
                        MaterialFlushBack materialFlushBack = new MaterialFlushBack();
                        materialFlushBack.RawMaterial = orderLocationTransaction.Item;
                        materialFlushBack.Uom         = orderLocationTransaction.OrderDetail.Uom;
                        materialFlushBack.Operation   = orderLocationTransaction.Operation;
                        materialFlushBack.Qty         = orderLocationTransaction.CurrentReceiveQty;
                        IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList);
                        foreach (MaterialFlushBack m in materialFlushBackList)
                        {
                            if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id)
                            {
                                if (m.OrderLocationTransaction.UnitQty != 0)
                                {
                                    m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty;
                                }
                                materialFlushBack = m;
                                receiptDetail.AddMaterialFlushBack(materialFlushBack);
                                break;
                            }
                        }
                    }
                }
            }
            #endregion


            #region 新品收货
            if (this.IsNewItem)
            {
                IList <TransformerDetail> transformerDetailList = this.ucNewItemInLocTransList.NewItemInLocTransList; //新品原材料List
                if (transformerDetailList.Count > 0)
                {
                    foreach (ReceiptDetail receiptDetail in receiptDetailList)
                    {
                        foreach (TransformerDetail transformerDetail in transformerDetailList)
                        {
                            MaterialFlushBack materialFlushBack        = new MaterialFlushBack();
                            LocationLotDetail newItemLocationLotDetail = TheLocationLotDetailMgr.LoadLocationLotDetail(transformerDetail.LocationLotDetId);
                            materialFlushBack.RawMaterial = newItemLocationLotDetail.Item;
                            materialFlushBack.Uom         = newItemLocationLotDetail.Hu.Uom;
                            materialFlushBack.Qty         = newItemLocationLotDetail.Qty;
                            materialFlushBack.HuId        = newItemLocationLotDetail.Hu.HuId;

                            IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList);
                            foreach (MaterialFlushBack m in materialFlushBackList)
                            {
                                if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id)
                                {
                                    if (m.OrderLocationTransaction.UnitQty != 0)
                                    {
                                        m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty;
                                    }
                                    materialFlushBack = m;
                                    receiptDetail.AddMaterialFlushBack(materialFlushBack);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            #region 返工收货
            if (rwoLocTransList.Count > 0)
            {
                foreach (OrderLocationTransaction rwoOrderLocTran in rwoLocTransList)
                {
                    foreach (ReceiptDetail receiptDetail in receiptDetailList)
                    {
                        if (receiptDetail.OrderLocationTransaction.Item.Code == rwoOrderLocTran.Item.Code)
                        {
                            MaterialFlushBack materialFlushBack = new MaterialFlushBack();
                            materialFlushBack.RawMaterial = rwoOrderLocTran.Item;
                            materialFlushBack.Uom         = rwoOrderLocTran.OrderDetail.Uom;
                            materialFlushBack.Operation   = rwoOrderLocTran.Operation;
                            materialFlushBack.Qty         = rwoOrderLocTran.CurrentReceiveQty;
                            IList <MaterialFlushBack> materialFlushBackList = TheMaterialFlushBackMgr.AssignMaterialFlushBack(materialFlushBack, inLocTransList);
                            foreach (MaterialFlushBack m in materialFlushBackList)
                            {
                                if (m.OrderLocationTransaction.OrderDetail.Id == receiptDetail.OrderLocationTransaction.OrderDetail.Id)
                                {
                                    if (m.OrderLocationTransaction.UnitQty != 0)
                                    {
                                        m.Qty = m.Qty / m.OrderLocationTransaction.UnitQty;
                                    }
                                    materialFlushBack = m;
                                    receiptDetail.AddMaterialFlushBack(materialFlushBack);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            #endregion


            Receipt   receipt   = TheOrderMgr.ReceiveOrder(receiptDetailList, this.CurrentUser, null, null, null, true, isOddCreateHu);
            OrderHead orderHead = TheOrderHeadMgr.LoadOrderHead(this.OrderNo);

            if (RefreshListEvent != null)
            {
                this.RefreshListEvent(new object[] { receipt.ReceiptNo, orderHead.NeedPrintReceipt }, e);
            }
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
        }
    }