Beispiel #1
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);
            }
        }