private void btnSave_Click(object sender, EventArgs e) { try { if (dgvFinalProducts.RowCount < 1) { MessageBox.Show("Please Add Products Firts"); return; } AddUpdate add = new AddUpdate(); add.addTransactionDetails( Convert.ToInt32(cmbCustomer.SelectedValue), DateTime.Now.Date, Convert.ToDouble(txtBillAmount.Text) ); for (int i = 0; i < dgvFinalProducts.RowCount; i++) { add.addTransactionProductDetails( Convert.ToDouble(dgvFinalProducts.Rows[i].Cells[2].Value), //Quantity Convert.ToDouble(dgvFinalProducts.Rows[i].Cells[3].Value), //amount dgvFinalProducts.Rows[i].Cells[0].Value.ToString() //item name ); } //subtract stock for (int i = 0; i < dgvFinalProducts.RowCount; i++) { AddUpdate update = new AddUpdate(); update.addUpdateStockDetails( 0, // not being used 0, // not being used Convert.ToDouble(dgvFinalProducts.Rows[i].Cells[2].Value), // minus this quantuty 0, // not being used 0, // not being used dgvFinalProducts.Rows[i].Cells[0].Value.ToString(), //item name 0, 1 // UPDATE (MINUS STOCK) ); } dgvFinalProducts.DataSource = null; MessageBox.Show("Data Added"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { if ( string.IsNullOrEmpty(txtQuantity.Text) || string.IsNullOrEmpty(txtRate.Text) || string.IsNullOrEmpty(txtAmount.Text) ) { MessageBox.Show("Enter Complete Information"); } else { AddUpdate addUpdate = new AddUpdate(); addUpdate.addUpdateStockDetails( Convert.ToDouble(txtAmount.Text), Convert.ToDouble(txtRate.Text), Convert.ToDouble(txtQuantity.Text), Convert.ToInt32(cmbItemName.SelectedValue), Convert.ToInt32(cmbUnit.SelectedValue), "", //not being used 0, 0 // ADD ); MessageBox.Show("Stock Added"); txtAmount.Clear(); txtRate.Clear(); txtQuantity.Clear(); Get get = new Get(); dgvAllStockDetails.DataSource = null; dgvAllStockDetails.DataSource = get.getAllStockDetails(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }