private void btnAdd_Click(object sender, EventArgs e) { AddedProductGrid product = new AddedProductGrid() { ProductName = txtProductName.Text, ProductDescription = txtDescription.Text, Rate = decimal.Parse(txtRate.Text), Quantity = decimal.Parse(TxtQty.Text), Total = decimal.Parse(txtRate.Text) * decimal.Parse(TxtQty.Text) }; //Check whether the product is selected or not if (product.ProductName == "") { //Display error MEssage MessageBox.Show("Select the product first. Try Again."); } else { UpdateAddedProductGrid(product); dgvAddedProducts.DataSource = addedProductsDt; CalculateSubTotal(); //Clear the Textboxes txtSearchProduct.Text = ""; txtProductName.Text = ""; txtDescription.Text = "0.00"; txtRate.Text = "0.00"; TxtQty.Text = "0.00"; } }
private void UpdateAddedProductGrid(AddedProductGrid product) { listOfAddedProducts.Add(product); addedProductsDt = DataSetLinqOperators.ToDataTable(listOfAddedProducts); }