Exemplo n.º 1
0
 public string StockOut(StockOutOrderVO vo)
 {
     if (null == vo)
     {
         return(string.Empty);
     }
     return(service.StockOut(vo));
 }
Exemplo n.º 2
0
        public string StockOut(StockOutOrderVO vo)
        {
            string   orderNO = string.Empty;
            DateTime now     = DateTime.Now;

            if (null == vo)
            {
                return(orderNO);
            }
            decimal amount = 0;
            string  uptSql = "UPDATE INVENTORY SET Num=Num-@outNum,Tmst=@tmst WHERE InvID=@invID";

            orderNO = GenOrderNO(string.Format("{0:yyyyMMdd}", now));
            foreach (StockOut sout in vo._StockOutList)
            {
                sout.OrderNO = orderNO;
                amount      += (decimal)sout.Price * (int)sout.Num;
                Connector.Save <StockOut>(sout, true);
                //记录流水
                AddChld((long)sout.InvID, vo.CrtUID, (int)sout.Num);
                Dictionary <string, object> values = new Dictionary <string, object>();
                values.Add("outNum", sout.Num);
                values.Add("tmst", now);
                values.Add("invID", sout.InvID);
                Connector.DbHelper.ExecuteSql(uptSql, values);
            }

            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);
        }
Exemplo n.º 3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            StockOutOrderVO     orderVO  = null;
            List <StockOut>     soutList = new List <StockOut>();
            List <OrderGoodsVO> glist    = new List <OrderGoodsVO>();

            if (cboxNResellers.SelectedIndex == -1)
            {
                return;
            }
            foreach (DataGridViewRow row in dtgvSOutGoods.Rows)
            {
                object numObj   = row.Cells[colNum.Name].Value;
                object priceObj = row.Cells[colPrice.Name].Value;
                if (null == numObj || null == priceObj)
                {
                    continue;
                }
                StockOut sout = new StockOut();
                sout.InvID = StringUtil.Obj2Long(row.Cells[colInvID.Name].Value);
                sout.Num   = StringUtil.Obj2Int(numObj);
                sout.Price = StringUtil.Obj2Decimal(priceObj);
                if (sout.Num * sout.Price == 0)
                {
                    continue;
                }
                soutList.Add(sout);

                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)sout.Num;
                vo.Price = (decimal)sout.Price;
                vo.Specs = StringUtil.Obj2Str(row.Cells[colSpecs.Name].Value);
                glist.Add(vo);
            }
            if (soutList.Count < 1)
            {
                return;
            }
            Customer         reseller    = cboxNResellers.SelectedItem as Customer;
            OrderCnfrmDialog cnfrmDialog = new OrderCnfrmDialog("【出货单-明细】 " + reseller.CName, glist);
            DialogResult     rslt        = cnfrmDialog.ShowDialog();

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

            orderVO               = new StockOutOrderVO();
            orderVO.Direct        = DIRECT.STOCK_OUT;
            orderVO._StockOutList = soutList;
            orderVO.CustID        = reseller.CID__PK;
            orderVO.CustName      = reseller.CName;
            Usr lgnUsr = MainForm.usr;

            orderVO.CrtUID = lgnUsr.UId__PK;
            orderVO.UptUID = lgnUsr.UId__PK;

            string orderNO = stockOutManager.StockOut(orderVO);

            if (!StringUtil.isEmpty(orderNO))
            {
                MainForm.Info("出货单创建成功! 单号:" + orderNO);
                dtgvSOutGoods.Rows.Clear();
            }
            else
            {
                MainForm.Warn("出货单创建失败!");
            }
        }