Пример #1
0
        public InboundDetailCtrl(InboundOrder inboundOrder, AllocateOrder order)
        {
            InitializeComponent();
            dataGridViewPagingSumCtrl = new DataGridViewPagingSumCtrl(dataGridView1, new string[] {
                xSDataGridViewTextBoxColumn.DataPropertyName,
                sDataGridViewTextBoxColumn.DataPropertyName,
                mDataGridViewTextBoxColumn.DataPropertyName,
                lDataGridViewTextBoxColumn.DataPropertyName,
                xLDataGridViewTextBoxColumn.DataPropertyName,
                xL2DataGridViewTextBoxColumn.DataPropertyName,
                xL3DataGridViewTextBoxColumn.DataPropertyName,
                xL4DataGridViewTextBoxColumn.DataPropertyName,
                xL5DataGridViewTextBoxColumn.DataPropertyName,
                xL6DataGridViewTextBoxColumn.DataPropertyName,
                fDataGridViewTextBoxColumn.DataPropertyName,

                sumCountDataGridViewTextBoxColumn.DataPropertyName,
                sumMoneyDataGridViewTextBoxColumn.DataPropertyName
            });
            dataGridViewPagingSumCtrl.Initialize();
            this.curInboundOrder = inboundOrder; Initialize();
            if (order.State == 1)
            {
                this.curDateTime = order.FinishedTime.ToString();
            }
            else
            {
                this.curDateTime = "";
            }
        }
Пример #2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
     {
         return;
     }
     if (e.RowIndex < 0 || e.ColumnIndex < 0)
     {
         return;
     }
     try
     {
         List <InboundOrder> list = (List <InboundOrder>) this.dataGridView1.DataSource;
         InboundOrder        item = list[e.RowIndex];
         if (this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.DataPropertyName == iDDataGridViewTextBoxColumn1.DataPropertyName)
         {
             this.skinSplitContainer1.Panel2Collapsed = false;
             this.InboundDetailClick?.Invoke(item, this.skinSplitContainer1.Panel2);
         }
         if (sourceOrderIDDataGridViewTextBoxColumn1.Index == e.ColumnIndex)
         {
             this.skinSplitContainer1.Panel2Collapsed = false;
             this.SourceDetailClick?.Invoke(item.SourceOrderID, this, this.skinSplitContainer1.Panel2);
         }
     }
     catch (Exception ee)
     {
         CommonGlobalUtil.ShowError(ee);
     }
 }
Пример #3
0
        public async Task <ApiData> Close(int id)
        {
            InboundOrder inboundOrder = await _session.GetAsync <InboundOrder>(id);

            if (inboundOrder == null)
            {
                throw new Exception("入库单不存在。");
            }

            if (inboundOrder.Closed)
            {
                throw new InvalidOperationException($"入库单已关闭。{inboundOrder.InboundOrderCode}");
            }

            inboundOrder.Closed   = true;
            inboundOrder.ClosedAt = DateTime.Now;
            _session.Update(inboundOrder);

            await _opHelper.SaveOpAsync(inboundOrder.InboundOrderCode);

            await _session.UpdateAsync(inboundOrder);

            _logger.Information("已关闭入库单 {inboundOrder}", inboundOrder);

            await _simpleEventBus.FireEventAsync(EventTypes.InboundOrderClosed, inboundOrder);

            return(this.Success());
        }
Пример #4
0
        private InboundPara BuildInboundPara()
        {
            if (this.curOutbound == null || this.curOutbound.OutboundOrder == null || this.curOutbound.OutboundDetails == null || this.curOutbound.OutboundDetails.Count == 0)
            {
                return(null);
            }

            int                totalCount     = 0;
            decimal            totalPrice     = 0;
            decimal            totalCost      = 0;
            List <BoundDetail> inboundDetails = new List <BoundDetail>();
            string             id             = IDHelper.GetID(OrderPrefix.InboundOrder, CommonGlobalCache.CurrentShop.AutoCode);

            foreach (BoundDetail detail in this.curOutbound.OutboundDetails)
            {
                //if (detail.SumCount <= 0)
                //{
                //    continue;

                //}
                totalCost  += detail.SumCost;
                totalCount += detail.SumCount;
                totalPrice += detail.SumMoney;
                inboundDetails.Add(OutboundDetailConvertToInboundDetail(detail, id));
            }
            if (CommonGlobalCache.CurrentUser.Type == UserInfoType.Admin)
            {
                AllocateOrder allocateOrder = CommonGlobalCache.ServerProxy.GetAllocateOrder(this.curOutbound.OutboundOrder.SourceOrderID);
                shopID = allocateOrder.DestShopID;
            }
            InboundOrder inboundOrder = new InboundOrder()
            {
                SourceOrderID  = this.curOutbound.OutboundOrder.SourceOrderID,
                ShopID         = shopID,
                ID             = id,
                OperatorUserID = //IsPos ? (string)this.guideComboBox1.SelectedValue :
                                 CommonGlobalCache.CurrentUserID,
                CreateTime = DateTime.Now,
                EntryTime  = DateTime.Now,
                TotalCost  = totalCost,
                TotalCount = totalCount,

                TotalPrice = totalPrice,
                Remarks    = this.skinTextBox_Remarks.SkinTxt.Text,
            };

            return(new InboundPara()
            {
                InboundOrder = inboundOrder,
                InboundDetails = inboundDetails
            });
        }
Пример #5
0
        public async Task <ApiData> Delete(int id)
        {
            InboundOrder inboundOrder = await _session.GetAsync <InboundOrder>(id);

            if (inboundOrder.Lines.Any(x => x.Dirty))
            {
                throw new InvalidOperationException("入库单已发生过操作。");
            }

            await _session.DeleteAsync(inboundOrder);

            _logger.Information("已删除入库单 {inboundOrder}", inboundOrder);
            await _opHelper.SaveOpAsync(inboundOrder.InboundOrderCode);

            return(this.Success());
        }
Пример #6
0
        public async Task <ApiData> Create(CreateInboundOrderArgs args)
        {
            InboundOrder inboundOrder = new InboundOrder();

            string prefix = $"IBO{DateTime.Now:yyMMdd}";
            int    next   = await _appSeqService.GetNextAsync(prefix);

            inboundOrder.InboundOrderCode = $"{prefix}{next:00000}";
            inboundOrder.BizType          = args.BizType;
            inboundOrder.BizOrder         = args.BizOrder;
            inboundOrder.Comment          = args.Comment;

            if (args.Lines == null || args.Lines.Count == 0)
            {
                throw new InvalidOperationException("入库单应至少有一个入库行。");
            }

            foreach (var lineInfo in args.Lines)
            {
                InboundLine line     = new InboundLine();
                var         material = await _session.Query <Material>()
                                       .Where(x => x.MaterialCode == lineInfo.MaterialCode)
                                       .SingleOrDefaultAsync();

                if (material == null)
                {
                    throw new InvalidOperationException($"未找到编码为 {lineInfo.MaterialCode} 的物料。");
                }
                line.Material         = material;
                line.QuantityExpected = lineInfo.QuantityExpected;
                line.QuantityReceived = 0;
                line.Batch            = lineInfo.Batch;
                line.StockStatus      = lineInfo.StockStatus;
                line.Uom = lineInfo.Uom;

                inboundOrder.AddLine(line);
                _logger.Information("已添加入库单明细,物料 {materialCode},批号 {batch},应入数量 {quantity}", line.Material.MaterialCode, line.Batch, line.QuantityReceived);
            }

            await _session.SaveAsync(inboundOrder);

            _logger.Information("已创建入库单 {inboundOrder}", inboundOrder);
            _ = await _opHelper.SaveOpAsync(inboundOrder.InboundOrderCode);

            return(this.Success());
        }
Пример #7
0
        private static InboundPara BuildInboundPara(Outbound curOutbound, AllocateOrder allocateOrder)
        {
            if (curOutbound == null || curOutbound.OutboundOrder == null || curOutbound.OutboundDetails == null || curOutbound.OutboundDetails.Count == 0)
            {
                return(null);
            }

            int                totalCount     = 0;
            decimal            totalCost      = 0;
            decimal            totalPrice     = 0;
            List <BoundDetail> inboundDetails = new List <BoundDetail>();
            string             id             = IDHelper.GetID(OrderPrefix.InboundOrder, CommonGlobalCache.CurrentShop.AutoCode);

            foreach (BoundDetail detail in curOutbound.OutboundDetails)
            {
                //if (detail.SumCount <= 0)
                //{
                //    continue;
                //}
                totalCost  += detail.SumCost;
                totalCount += detail.SumCount;
                totalPrice += detail.SumMoney;
                inboundDetails.Add(OutboundDetailConvertToInboundDetail(detail, id));
            }

            InboundOrder inboundOrder = new InboundOrder()
            {
                SourceOrderID  = curOutbound.OutboundOrder.SourceOrderID,
                ShopID         = allocateOrder.DestShopID,
                ID             = id,
                OperatorUserID = string.Empty,
                CreateTime     = allocateOrder.CreateTime,
                EntryTime      = DateTime.Now,
                TotalCost      = totalCost,
                TotalCount     = totalCount,
                TotalPrice     = totalPrice,
                Remarks        = "自动入库",
            };

            return(new InboundPara()
            {
                InboundOrder = inboundOrder,
                InboundDetails = inboundDetails
            });
        }
Пример #8
0
        public InboundDetailCtrl(InboundOrder inboundOrder)
        {
            InitializeComponent();
            dataGridViewPagingSumCtrl = new DataGridViewPagingSumCtrl(dataGridView1, new string[] {
                xSDataGridViewTextBoxColumn.DataPropertyName,
                sDataGridViewTextBoxColumn.DataPropertyName,
                mDataGridViewTextBoxColumn.DataPropertyName,
                lDataGridViewTextBoxColumn.DataPropertyName,
                xLDataGridViewTextBoxColumn.DataPropertyName,
                xL2DataGridViewTextBoxColumn.DataPropertyName,
                xL3DataGridViewTextBoxColumn.DataPropertyName,
                xL4DataGridViewTextBoxColumn.DataPropertyName,
                xL5DataGridViewTextBoxColumn.DataPropertyName,
                xL6DataGridViewTextBoxColumn.DataPropertyName,
                fDataGridViewTextBoxColumn.DataPropertyName,

                sumCountDataGridViewTextBoxColumn.DataPropertyName,
                sumMoneyDataGridViewTextBoxColumn.DataPropertyName
            });
            dataGridViewPagingSumCtrl.Initialize();
            this.curInboundOrder = inboundOrder; Initialize();
        }
Пример #9
0
        public async Task <ApiData> Edit(int id, EditInboundOrderArgs args)
        {
            InboundOrder inboundOrder = _session.Get <InboundOrder>(id);

            if (inboundOrder == null)
            {
                String errMsg = String.Format("入库单不存在。Id 是 {0}。", id);
                throw new InvalidOperationException(errMsg);
            }

            if (inboundOrder.Closed)
            {
                String errMsg = String.Format("入库单已关闭,不能编辑。单号:{0}。", inboundOrder.InboundOrderCode);
                throw new InvalidOperationException(errMsg);
            }

            var movingDown = await _session.Query <Port>().AnyAsync(x => x.CurrentUat == inboundOrder);

            if (movingDown)
            {
                String errMsg = String.Format("入库单正在下架,不能编辑。单号:{0}。", inboundOrder.InboundOrderCode);
                throw new InvalidOperationException(errMsg);
            }

            inboundOrder.Comment = args.Comment;

            if (args.Lines == null || args.Lines.Count == 0)
            {
                throw new InvalidOperationException("入库单应至少有一个入库行。");
            }

            foreach (var lineInfo in args.Lines)
            {
                switch (lineInfo.Op)
                {
                case "delete":
                {
                    var line = inboundOrder.Lines.Single(x => x.InboundLineId == lineInfo.InboundLineId);
                    if (line.Dirty)
                    {
                        string errMsg = String.Format("已发生过入库操作的明细不能删除。入库行#{0}。", line.InboundLineId);
                        throw new InvalidOperationException(errMsg);
                    }
                    inboundOrder.RemoveLine(line);
                    _logger.Information("已删除入库单明细 {inboundLineId}", line.InboundLineId);
                }
                break;

                case "edit":
                {
                    var line = inboundOrder.Lines.Single(x => x.InboundLineId == lineInfo.InboundLineId);
                    line.QuantityExpected = lineInfo.QuantityExpected;
                    if (line.QuantityReceived < line.QuantityReceived)
                    {
                        _logger.Warning("入库单明细 {inboundLineId} 的应入数量修改后小于已入数量", line.InboundLineId);
                    }
                }
                break;

                case "added":
                {
                    InboundLine line     = new InboundLine();
                    var         material = await _session.Query <Material>()
                                           .Where(x => x.MaterialCode == lineInfo.MaterialCode)
                                           .SingleOrDefaultAsync();

                    if (material == null)
                    {
                        throw new InvalidOperationException($"未找到物料。编码 {lineInfo.MaterialCode}。");
                    }
                    line.Material         = material;
                    line.QuantityExpected = lineInfo.QuantityExpected;
                    line.QuantityReceived = 0;
                    line.Batch            = lineInfo.Batch;
                    line.StockStatus      = lineInfo.StockStatus;
                    line.Uom = lineInfo.Uom;

                    inboundOrder.AddLine(line);
                    _logger.Information("已添加入库单明细,物料 {materialCode},批号 {batch},应入数量 {quantity}", line.Material.MaterialCode, line.Batch, line.QuantityReceived);
                }
                break;

                default:
                    break;
                }
            }

            await _session.UpdateAsync(inboundOrder);

            _logger.Information("已更新入库单 {inboundOrder}", inboundOrder);
            _ = await _opHelper.SaveOpAsync("{0}", inboundOrder);

            return(this.Success());
        }