コード例 #1
0
ファイル: StockEntry.cs プロジェクト: sandeepnayak77/RawForm
 public void CalllbackFromCustDetails(StockEntry lcstockentry, CustomerInfoDetails custInfo, string billNo)
 {
     StockUpdate(lcstockentry);
     SellerEntry(billNo, lcstockentry._grandTotal, custInfo);
 }
コード例 #2
0
ファイル: StockEntry.cs プロジェクト: sandeepnayak77/RawForm
        public void StockUpdate(StockEntry myStockentry)
        {
            for (int i = 0; i < myStockentry.dataGridView1.RowCount - 1; i++)
            {
                int     _prodID = Convert.ToInt32(myStockentry.dataGridView1.Rows[i].Cells[0].Value);
                int     _stockID = Convert.ToInt32(myStockentry.dataGridView1.Rows[i].Cells["StockID"].Value);
                decimal _stock, _ob, _cb, _buyQty, _unitPrice, _totalPrice;
                var     database = new InventoryEntities();
                var     list     = (from c in database.ProductStocks
                                    join d in database.StockChilds on c.StockID equals d.StockID
                                    where c.ProductID == _prodID
                                    select new
                {
                    c.Stock,
                    d.OpeningBalance,
                    d.ClosingBalance,
                }).FirstOrDefault();

                var txnTypelist = (from c in database.TransactionTypes
                                   where c.TransactionTypeName == "Buy"
                                   select new
                {
                    c.TransactionTypeID
                }).FirstOrDefault();

                int _txnType = txnTypelist.TransactionTypeID;

                _stock      = Convert.ToDecimal(list.Stock);
                _buyQty     = Convert.ToDecimal(myStockentry.dataGridView1.Rows[i].Cells["NewStock"].Value);
                _unitPrice  = Convert.ToDecimal(myStockentry.dataGridView1.Rows[i].Cells["CostPrice"].Value);
                _totalPrice = _unitPrice * _buyQty;

                _ob = _stock;
                _cb = _stock + _buyQty;

                var txnDetail = new TransactionDetail();

                txnDetail.ProductID       = _prodID;
                txnDetail.TranctionTypeID = _txnType;
                txnDetail.Quantity        = _buyQty;
                txnDetail.UnitPrice       = _unitPrice;
                txnDetail.TotalPrice      = _totalPrice;
                txnDetail.OpeningBalance  = _ob;
                txnDetail.ClosingBalance  = _cb;
                txnDetail.UpdatedOn       = System.DateTime.Now;
                txnDetail.BillNumber      = myStockentry._billNumber;

                database.TransactionDetails.Add(txnDetail);

                var stocklist = (from c in database.ProductStocks
                                 where c.StockID == _stockID
                                 select c).FirstOrDefault();

                stocklist.Stock = _cb;

                var stockchildlist = (from c in database.StockChilds
                                      where c.StockID == _stockID
                                      select c).FirstOrDefault();
                stockchildlist.OpeningBalance = _cb;
                stockchildlist.ClosingBalance = _cb;

                database.SaveChanges();
            }
        }