private void button_Click(object sender, RoutedEventArgs e) { try { var p = (Product)cbbProduct.SelectedItem; var index = txtQuantity.Text.IndexOf('_'); int quantity = 0; if (index > 0) { quantity = int.Parse(txtQuantity.Text.Substring(0, index)); } else { quantity = int.Parse(txtQuantity.Text); } if (nextIden == 0) { nextIden = InvoiceDetailBLL.GetCurrentIdentity() + 1; } InvoiceDetail id = new InvoiceDetail(nextIden, p, quantity); id.Product = ProductList.Where(q => q.ProductID == p.ProductID).FirstOrDefault().Name; InvoiceDetails.Add(id); dgdProduct.Items.Refresh(); } catch (Exception g) { System.Windows.Forms.MessageBox.Show(g.Message); } }
public static bool InsertDetail(InvoiceDetail d) { string sql = "spInsertInvoiceDetail"; SqlParameter InvoiceID = new SqlParameter("@InvoiceID", d.InvoiceID); SqlParameter ProductID = new SqlParameter("@ProductID", d.ProductID); SqlParameter Quantity = new SqlParameter("@Quantity", d.Quantity); SqlParameter SubTotal = new SqlParameter("@SubTotal", d.SubTotal); return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, InvoiceID, ProductID, Quantity, SubTotal); }