예제 #1
0
 private void Import()
 {
     try
     {
         string    flowCode  = this.tbFlow.Text.Trim() != string.Empty ? this.tbFlow.Text.Trim() : string.Empty;
         OrderHead orderHead = TheImportMgr.ReadBatchTransferFromXls(fileUpload.PostedFile.InputStream, this.CurrentUser, flowCode);
         Receipt   receipt   = TheOrderMgr.QuickReceiveOrder(flowCode, orderHead.OrderDetails, this.CurrentUser.Code);
         this.ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo);
     }
     catch (BusinessErrorException ex)
     {
         ShowErrorMessage(ex);
     }
 }
예제 #2
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;
            }
        }
    }
예제 #3
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        try
        {
            IList<TransformerDetail> transformerDetailList = this.ucList.PopulateTransformerDetailList();
            IList<OrderDetail> orderDetailList = new List<OrderDetail>();
            string currentFlow = string.Empty;

            foreach (TransformerDetail transformerDetail in transformerDetailList)
            {
                if (transformerDetail.CurrentQty != transformerDetail.AdjustQty)
                {
                    OrderLocationTransaction orderLocTrans = TheOrderLocationTransactionMgr.LoadOrderLocationTransaction(transformerDetail.OrderLocTransId);
                    if (currentFlow == string.Empty)
                    {
                        currentFlow = orderLocTrans.OrderDetail.OrderHead.Flow;
                    }
                    OrderDetail orderDetail = new OrderDetail();
                    orderDetail.Item = TheItemMgr.LoadItem(transformerDetail.ItemCode);
                    orderDetail.Uom = TheUomMgr.LoadUom(transformerDetail.UomCode);
                    if (transformerDetail.HuId != null && transformerDetail.HuId.Trim() != string.Empty)
                    {
                        Hu hu = this.TheHuMgr.CheckAndLoadHu(transformerDetail.HuId.Trim());
                        orderDetail.OrderedQty = transformerDetail.AdjustQty - hu.Qty;
                    }
                    else
                    {
                        orderDetail.OrderedQty = transformerDetail.AdjustQty - transformerDetail.CurrentQty;
                    }
                    orderDetail.UnitCount = transformerDetail.UnitCount;
                    orderDetail.HuId = transformerDetail.HuId;
                    orderDetail.HuLotNo = transformerDetail.LotNo;
                    if (transformerDetail.LocationFromCode != null)
                    {
                        orderDetail.LocationFrom = TheLocationMgr.LoadLocation(transformerDetail.LocationFromCode);
                    }
                    if (transformerDetail.LocationToCode != null)
                    {
                        orderDetail.LocationTo = TheLocationMgr.LoadLocation(transformerDetail.LocationToCode);

                    }

                    orderDetailList.Add(orderDetail);
                }
            }
            if (orderDetailList.Count > 0)
            {
                Receipt receipt = TheOrderMgr.QuickReceiveOrder(currentFlow, orderDetailList, this.CurrentUser.Code, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_ADJ, DateTime.Now, DateTime.Now, false, this.ReceiptNo, null);
                this.Visible = false;
                ShowSuccessMessage("MasterData.Receipt.Adjust.Successfully", this.ReceiptNo);
                if (AdjustEvent != null)
                {
                    AdjustEvent(receipt.ReceiptNo, e);
                }
            }
            else
            {
                ShowSuccessMessage("MasterData.Receipt.NoDetail.Adjust", this.ReceiptNo);
            }
        }
        catch (BusinessErrorException ex)
        {
            ShowErrorMessage(ex);
        }
    }
예제 #4
0
    private void SaveRender(object sender, EventArgs e)
    {
        if (this.IsReject || this.IsQuick)
        {
            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)
                    {
                        resultOrderDetailList.Add(orderDetail);
                    }
                }
            }

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

                DateTime winTime   = DateTime.Now;
                DateTime startTime = winTime;

                orderHead.OrderDetails = resultOrderDetailList;
                orderHead.WindowTime   = winTime;
                orderHead.StartTime    = startTime;

                orderHead.IsNewItem = this.NewItem;

                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, false, 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);

                            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 (QuickCreateEvent != null)
                    {
                        QuickCreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e);
                    }
                }
                else
                {
                    this.ShowErrorMessage("MasterData.Order.OrderHead.Not.Quick");
                }
            }
            catch (BusinessErrorException ex)
            {
                this.ShowErrorMessage(ex);
                return;
            }
        }
    }
예제 #5
0
    private void SaveRender(object sender, EventArgs e)
    {
        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)
                {
                    resultOrderDetailList.Add(orderDetail);
                }
            }
        }

        if (resultOrderDetailList.Count == 0)
        {
            this.ShowErrorMessage("MasterData.Order.OrderHead.OrderDetail.Required");
            return;
        }

        //创建订单
        try
        {
            Receipt receipt = TheOrderMgr.QuickReceiveOrder(this.CurrentFlowCode, resultOrderDetailList, this.CurrentUser.Code, BusinessConstants.CODE_MASTER_ORDER_SUB_TYPE_VALUE_NML, DateTime.Now, DateTime.Now, true, null, null);

            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("MasterData.Order.OrderHead.Transfer.AddOrder.Successfully");


            if (!this.cbContinuousCreate.Checked)
            {
                this.PageCleanup();
                if (CreateEvent != null)
                {
                    CreateEvent(new Object[] { receipt, orderHead.NeedPrintReceipt }, e);
                }
            }
            else
            {
                orderHead = TheOrderMgr.TransferFlow2Order(this.tbFlow.Text.Trim());
                InitDetailParamater(orderHead);
            }
        }
        catch (BusinessErrorException ex)
        {
            this.ShowErrorMessage(ex);
            return;
        }
    }
예제 #6
0
    private string CreateOrder(OrderHead orderHead)
    {
        IList <OrderDetail> resultOrderDetailList = new List <OrderDetail>();

        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;

                        resultOrderDetailList.Add(newOrderDetail);
                    }
                }
                else
                {
                    resultOrderDetailList.Add(orderDetail);
                }
            }
        }
        orderHead.OrderDetails = resultOrderDetailList;
        //TheOrderMgr.CreateOrder(orderHead, this.CurrentUser);

        Receipt receipt = TheOrderMgr.QuickReceiveOrder(orderHead.Flow, orderHead.OrderDetails, this.CurrentUser.Code, this.ModuleSubType, orderHead.WindowTime, orderHead.StartTime, false, orderHead.ReferenceOrderNo, orderHead.ExternalOrderNo);

        if (receipt.ReceiptDetails != null && receipt.ReceiptDetails.Count > 0)
        {
            orderHead = receipt.ReceiptDetails[0].OrderLocationTransaction.OrderDetail.OrderHead;
        }
        //ShowSuccessMessage("Receipt.Receive.Successfully", receipt.ReceiptNo);
        //return receipt.ReceiptNo;

        return(receipt.InProcessLocations.First().IpNo);
    }