Esempio n. 1
0
 private void btngdadd_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txtgdProdNm.Text))
     {
         MessageBox.Show("Please enter Product code");
         txtgdProdNm.Focus();
         return;
     }
     if (String.IsNullOrEmpty(txtgdQty.Text))
     {
         MessageBox.Show("Please enter Quantity");
         txtgdQty.Focus();
         return;
     }
     if (Convert.ToDecimal(txtgdQty.Text) <= 0)
     {
         MessageBox.Show("Please enter valid quantity");
         txtgdQty.Focus();
         return;
     }
     foreach (DataGridViewRow row in dgvgd.Rows)
     {
         if (row.Cells[0].Value.ToString() == txtgdProdNm.Text)
         {
             MessageBox.Show("Product " + txtgdProdNm.Text + " is already added");
             return;
         }
     }
     try
     {
         PriceRepository price   = new PriceRepository();
         decimal         amt     = Convert.ToDecimal(txtgdQty.Text) * Convert.ToDecimal(txtgdCp.Text);
         decimal         prcexcl = price.CalculateVat(amt, Convert.ToDecimal(txtgdVatcd.Text));
         decimal         vatamt  = amt - prcexcl;
         dgvgd.Rows.Add(txtgdProdNm.Text, txtgdDesc.Text, txtgdUnit.Text, txtgdQty.Text, txtgdCp.Text, vatamt, prcexcl);
         btngdclear_Click(sender, e);
         calculateamounts();
         txtgdProdNm.Focus();
     }
     catch (Exception exe)
     {
         MessageBox.Show(exe.Message);
     }
 }