예제 #1
0
 public string Stockin(StockInOrderVO orderVO)
 {
     if (null == orderVO || orderVO._StockinList.Count == 0)
     {
         return(string.Empty);
     }
     return(service.Stockin(orderVO));
 }
예제 #2
0
        /// <summary>
        /// 入库操作
        /// </summary>
        /// <param name="vo"></param>
        /// <returns>入库单号</returns>
        public string Stockin(StockInOrderVO vo)
        {
            string   orderNO = string.Empty;
            DateTime now     = DateTime.Now;

            if (null == vo)
            {
                return(orderNO);
            }
            decimal amount = 0;

            orderNO = GenOrderNO(string.Format("{0:yyyyMMdd}", now));
            foreach (StockIn sin in vo._StockinList)
            {
                sin.OrderNO = orderNO;
                amount     += (decimal)sin.Price * (int)sin.Num;
                Connector.Save <StockIn>(sin, true);

                Inventory inv = new Inventory();
                inv.GID     = sin.GID;
                inv.OrderNO = orderNO;
                inv.Num     = sin.Num;
                inv.Tmst    = now;
                Connector.Save <Inventory>(inv, true);
            }
            //入库流水
            AddChld(orderNO, vo.CrtUID);

            Order order = new Order();

            order.CustID      = vo.CustID;
            order.CustName    = vo.CustName;
            order.Direct      = vo.Direct;
            order.UptUID      = vo.UptUID;
            order.CrtUID      = vo.CrtUID;
            order.CrtTmst     = now;
            order.UptTmst     = now;
            order.OrderNO__PK = orderNO;
            order.Amount      = amount;
            Connector.Save <Order>(order);
            return(orderNO);
        }
예제 #3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            StockInOrderVO      orderVO = null;
            List <StockIn>      list    = new List <StockIn>();
            List <OrderGoodsVO> glist   = new List <OrderGoodsVO>();

            if (cboxNSupplier.SelectedIndex == -1)
            {
                return;
            }
            foreach (DataGridViewRow row in dtgvStockin.Rows)
            {
                object numObj   = row.Cells[colNum.Name].Value;
                object priceObj = row.Cells[colPrice.Name].Value;
                if (null == numObj || null == priceObj)
                {
                    continue;
                }

                StockIn sin = new StockIn();
                sin.Num   = StringUtil.Obj2Int(row.Cells[colNum.Name].Value);
                sin.Price = StringUtil.Obj2Decimal(row.Cells[colPrice.Name].Value);
                sin.GID   = StringUtil.Obj2Int(row.Cells[colGID.Name].Value);
                if (sin.Num * sin.Price == 0)
                {
                    continue;
                }
                if (!StringUtil.isEmpty(row.Cells[colMfDt.Name].Value + ""))
                {
                    DateTime?expDt        = null;
                    DateTime mfDt         = DateTime.ParseExact(StringUtil.Obj2Str(row.Cells[colMfDt.Name].Value), "yyyy/MM/dd", null);
                    string   shelfLifeStr = StringUtil.Obj2Str(row.Cells[colShelfLife.Name].Value);
                    string   num          = shelfLifeStr.Substring(0, shelfLifeStr.Length - 1);
                    string   term         = shelfLifeStr.Substring(shelfLifeStr.Length - 1);
                    if (term == TERM.DAY)
                    {
                        expDt = mfDt.AddDays(int.Parse(num));
                    }
                    else if (term == TERM.MONTH)
                    {
                        expDt = mfDt.AddMonths(int.Parse(num));
                    }
                    else if (term == TERM.YEAR)
                    {
                        expDt = mfDt.AddYears(int.Parse(num));
                    }
                    sin.ExpDt = expDt;
                    sin.MfDt  = mfDt;
                }
                list.Add(sin);

                OrderGoodsVO vo = new OrderGoodsVO();
                vo.GID   = StringUtil.Obj2Int(row.Cells[colGID.Name].Value);
                vo.GName = StringUtil.Obj2Str(row.Cells[colGName.Name].Value);
                vo.Num   = (int)sin.Num;
                vo.Price = (decimal)sin.Price;
                vo.Specs = StringUtil.Obj2Str(row.Cells[colSpecs.Name].Value);
                glist.Add(vo);
            }
            if (list.Count < 1)
            {
                return;
            }
            Customer         supplier    = cboxNSupplier.SelectedItem as Customer;
            OrderCnfrmDialog cnfrmDialog = new OrderCnfrmDialog("【进货单-明细】 " + supplier.CName, glist);
            DialogResult     rslt        = cnfrmDialog.ShowDialog();

            if (DialogResult.OK != rslt)
            {
                return;
            }

            orderVO              = new StockInOrderVO();
            orderVO.CustID       = supplier.CID__PK;
            orderVO.CustName     = supplier.CName;
            orderVO.Direct       = DIRECT.STOCK_IN;
            orderVO.UptUID       = MainForm.usr.UId__PK;
            orderVO.CrtUID       = MainForm.usr.UId__PK;
            orderVO._StockinList = list;

            string orderNO = stockinManager.Stockin(orderVO);

            if (!StringUtil.isEmpty(orderNO))
            {
                MessageBox.Show("进货单创建成功! 单号:" + orderNO, "操作结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dtgvStockin.Rows.Clear();
            }
            else
            {
                MessageBox.Show("进货单创建失败!", "操作结果", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }