コード例 #1
0
        private void btnAddNewStock_Click(object sender, EventArgs e)
        {
            if (cboProductName.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Product Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboProductName.Focus();
                return;
            }
            if (cboSupplierName.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Supplier Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboSupplierName.Focus();
                return;
            }
            if (txtQuantity.Text == "")
            {
                MessageBox.Show("Please Enter Product Quantity!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtQuantity.Focus();
                return;
            }


            StockDetails sd = new StockDetails();

            sd.StockNo    = txtStockNo.Text;
            sd.ProductID  = Convert.ToInt32(cboProductName.SelectedValue);
            sd.SupplierID = Convert.ToInt32(cboSupplierName.SelectedValue);
            sd.Quantity   = Convert.ToInt32(txtQuantity.Text);
            sd.Date       = dateTimePicker1.MinDate;

            bool isexists = bts.CheckExistingProductStockById(Convert.ToInt32(cboProductName.SelectedValue.ToString()));

            if (isexists)
            {
                TempStockDetails tsd = new TempStockDetails();
                tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString());

                tsd.Quantity = tsd.Quantity + Convert.ToInt32(txtQuantity.Text);
                int j = bts.UpdateExistingTempStock(tsd);
            }
            else
            {
                TempStockDetails tsd = new TempStockDetails();
                tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString());
                tsd.Quantity  = Convert.ToInt32(txtQuantity.Text);
                int k = bts.AddNewTempStock(tsd);
            }
            int i = blst.AddNewStock(sd);

            if (i > 0)
            {
                MessageBox.Show("Stock Added Successfully", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Clear();
                LoadStockID();
            }
        }
コード例 #2
0
        public int UpdateExistingTempStock(TempStockDetails tsd)
        {
            tblTemp_Stock tts = _db.tblTemp_Stock.Where(s => s.ProductID == tsd.ProductID).FirstOrDefault();

            tts.ProductID = tsd.ProductID;
            //tblTemp_Stock ttq = _db.tblTemp_Stock.Where(s => s.Quantity == tsd.Quantity).FirstOrDefault();
            //ttq.Quantity = tsd.Quantity;
            tts.Quantity = (tsd.Quantity + tts.Quantity);
            return(_db.SaveChanges());
        }
コード例 #3
0
        public int AddNewTempStock(TempStockDetails tsd)
        {
            tblTemp_Stock tts = new tblTemp_Stock();
            //tblProduct tp = new tblProduct();
            tblStock ts = new tblStock();

            tts.ProductID = tsd.ProductID;
            tts.Quantity  = tsd.Quantity;
            _db.tblTemp_Stock.Add(tts);
            return(_db.SaveChanges());
        }
コード例 #4
0
        private void btnUpdateStock_Click(object sender, EventArgs e)
        {
            if (cboProductName.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Product Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboProductName.Focus();
                return;
            }
            if (cboSupplierName.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Supplier Name!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboSupplierName.Focus();
                return;
            }
            if (txtQuantity.Text == "")
            {
                MessageBox.Show("Please Enter Product Quantity!!!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtQuantity.Focus();
                return;
            }
            //For Updating temp_stock
            TempStockDetails tsd = new TempStockDetails();

            tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString());
            tsd.Quantity  = ((tsd.Quantity + Convert.ToInt32(txtQuantity.Text)) - Convert.ToInt32(txtQuantityInitial.Text));
            int j = bts.UpdateExistingTempStock(tsd);

            //For Updating Stock Record or List
            StockDetails sd = new StockDetails();

            sd.StockID    = Convert.ToInt32(txtStockID.Text);
            sd.StockNo    = txtStockNo.Text;
            sd.ProductID  = Convert.ToInt32(cboProductName.SelectedValue);
            sd.SupplierID = Convert.ToInt32(cboSupplierName.SelectedValue);
            sd.Quantity   = Convert.ToInt32(txtQuantity.Text);
            sd.Date       = dateTimePicker1.MinDate;
            int i = blst.UpdateStock(sd);

            if (i > 0)
            {
                MessageBox.Show("Stock Updated Successfully", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Clear();
                LoadStockID();
                btnAddNewStock.Enabled = true;
                btnUpdateStock.Enabled = false;
                btnDeleteStock.Enabled = false;
            }
        }
コード例 #5
0
 private void btnDeleteStock_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are You Sure Want To Delete Stock Record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         //For Updating temp_stock
         TempStockDetails tsd = new TempStockDetails();
         tsd.ProductID = Convert.ToInt32(cboProductName.SelectedValue.ToString());
         tsd.Quantity  = tsd.Quantity - Convert.ToInt32(txtQuantity.Text);
         int j = bts.UpdateExistingTempStock(tsd);
         //For Deleting Stock Record
         int i = blst.DeleteStock(Convert.ToInt32(txtStockID.Text));
         if (i > 0)
         {
             Clear();
             MessageBox.Show("Stock Record Deleted Successfully");
             LoadStockID();
             btnAddNewStock.Enabled = true;
             btnUpdateStock.Enabled = false;
             btnDeleteStock.Enabled = false;
         }
     }
 }