Пример #1
0
    public void btnAddOrUpdateDetailClick(object sender, EventArgs e)
    {
        bool            IsNew   = false;
        GatheringDetail oDetail = null;

        if (string.IsNullOrEmpty(hdDetailID.Value))
        {
            oDetail        = NewDetail();
            oDetail.Master = CurMaster;
            CurMaster.Details.Add(oDetail);
            oDetail.Id = Guid.NewGuid().ToString();
            IsNew      = true;
            this.gvDetailSource.NewBillList.Add(oDetail);
        }
        else
        {
            oDetail = CurMaster.Details.OfType <GatheringDetail>().FirstOrDefault(item => item.Id == hdDetailID.Value);
        }

        oDetail.Descript = txtDescript.Text;
        oDetail.Money    = UtilClass.ToDecimal(txtMoney.Text);
        ModelToView();
    }
Пример #2
0
        private void createGatheringForStoreOrder(long storeOrderId, IDAL dal)
        {
            try
            {
                // SEARCHING EXISTING RECORDS FOR THE STOREORDERID
                IUniParameter           prmStoreOrderId    = dal.CreateParameter("StoreOrderId", storeOrderId);
                IEnumerable <Gathering> existingGatherings = dal.List <Gathering>("WHS_LST_GATHERING_SP", prmStoreOrderId).ToList();
                if (existingGatherings.Count() > 0)
                {
                    try
                    {
                        foreach (Gathering g in existingGatherings)
                        {
                            dal.Delete <Gathering>(g.GatheringId);
                        }
                    }
                    catch
                    {
                        _logger.Error($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : ({storeOrderId.ToString()}, Exception : Gathering Deletion Transaction Failed");
                        throw new Exception("Gathering Deletion Transaction Failed");
                    }
                }

                // GET PRODUCTS OF THE STOREORDER AND DIVIDE IT INTO HEAVY/LIGHT GROUPS
                IEnumerable <StoreOrderDetail> orderDetails  = dal.List <StoreOrderDetail>("WHS_LST_STOREORDERDETAIL_SP", prmStoreOrderId).Where(od => (od.StoreOrderDetailId != 0) && (od.RevisedQuantity > 0)).ToList();
                IEnumerable <StoreOrderDetail> heavyProducts = orderDetails.Where(od => od.LoadOrder != null && od.LoadOrder.StartsWith("A"));
                //_logger.Debug($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : {storeOrderId} heavyProducts Output : {Newtonsoft.Json.JsonConvert.SerializeObject(heavyProducts)}");
                IEnumerable <StoreOrderDetail> lightProducts = orderDetails.Where(od => od.LoadOrder == null || !od.LoadOrder.StartsWith("A"));
                //_logger.Debug($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : {storeOrderId} lightProducts Output : {Newtonsoft.Json.JsonConvert.SerializeObject(lightProducts)}");

                // PREPARE GATHERING MODEL
                Gathering newGathering = new Gathering();
                newGathering.Event           = 1047;
                newGathering.Organization    = 1;
                newGathering.StoreOrder      = storeOrderId;
                newGathering.GatheringStatus = 1;
                newGathering.Priority        = 0;

                GatheringDetail gatheringDetail = new GatheringDetail();
                gatheringDetail.Event        = 1047;
                gatheringDetail.Organization = 1;
                gatheringDetail.PalletNo     = 1;

                // CREATE GATHERING AND DETAIL RECORDS FOR HEAVY PRODUCTS

                if (heavyProducts.Count() > 0)
                {
                    try
                    {
                        newGathering.GatheringType = 1;
                        long gatheringId = dal.Create <Gathering>(newGathering);
                        gatheringDetail.Gathering = gatheringId;

                        foreach (StoreOrderDetail hp in heavyProducts)
                        {
                            gatheringDetail.StoreOrderDetail = hp.StoreOrderDetailId;
                            dal.Create <GatheringDetail>(gatheringDetail);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : ({storeOrderId.ToString()}, Exception : Gathering For HeavyProducts Creation Failed, {ex.ToString()}");
                        new Exception("Gathering For HeavyProducts Creation Failed");
                    }
                }

                // CREATE GATHERING AND DETAIL RECORDS FOR LIGHT PRODUCTS
                if (lightProducts.Count() > 0)
                {
                    try
                    {
                        newGathering.GatheringType = 2;
                        long gatheringId = dal.Create <Gathering>(newGathering);
                        gatheringDetail.Gathering = gatheringId;

                        foreach (StoreOrderDetail lp in lightProducts)
                        {
                            gatheringDetail.StoreOrderDetail = lp.StoreOrderDetailId;
                            dal.Create <GatheringDetail>(gatheringDetail);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : ({storeOrderId.ToString()}, Exception : Gathering For LightProducts Creation Failed, {ex.ToString()}");
                        new Exception("Gathering For LightProducts Creation Failed");
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error($" ServiceName : StoreOrderService, MethodName : createGatheringForStoreOrder, Input : ({storeOrderId.ToString()}, Exception : {ex.ToString()}");
                throw ex;
            }
        }
Пример #3
0
    /// <summary>
    /// 新建明细
    /// </summary>
    /// <returns></returns>
    public GatheringDetail NewDetail()
    {
        GatheringDetail oDetail = new GatheringDetail();

        return(oDetail);
    }