public ProductForm(Product prod, DataTable deps, DataTable produser) { InitializeComponent(); product = prod; _deps = deps; _produser = produser; }
private void DelProductBtn_Click(object sender, EventArgs e) { int index = dataGridViewProducts.CurrentCell.RowIndex; Product product = new Product(); product.SetValues( Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["Id"].Value), dataGridViewProducts.Rows[index].Cells["Title"].Value.ToString(), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["PurchasePrice"].Value), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["Markup"].Value), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["Price"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["DepartmentId"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["ProduserId"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["Quantity"].Value), Convert.ToBoolean(dataGridViewProducts.Rows[index].Cells["CriticalQ"].Value)); client.DelProduct(product); //_waitForResponse.WaitOne(); }
void SetProduct(Product product) { if (product.Id == 0) { product.SetId(client.GetCurIdentity("Product") + 1); } ProductForm pf = new ProductForm(product, _db._ds.Tables["Department"], _db._ds.Tables["Client"]); pf.ShowDialog(); product = pf.product; if (product.Id != 0) { client.SetProduct(product); //_waitForResponse.WaitOne(); } bsProducts = new BindingSource { DataSource = _db._ds.Tables["Product"] }; dataGridViewProducts.DataSource = bsProducts; bindingNavigatorProducts.BindingSource = bsProducts; ProductsBinding(); }
private void OnEditProduct(object sender, EventArgs e) { int index = dataGridViewProducts.CurrentCell.RowIndex; Product product = new Product(); product.SetValues( Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["Id"].Value), dataGridViewProducts.Rows[index].Cells["Title"].Value.ToString(), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["PurchasePrice"].Value), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["Markup"].Value), Convert.ToDouble(dataGridViewProducts.Rows[index].Cells["Price"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["DepartmentId"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["ProduserId"].Value), Convert.ToInt32(dataGridViewProducts.Rows[index].Cells["Quantity"].Value), Convert.ToBoolean(dataGridViewProducts.Rows[index].Cells["CriticalQ"].Value)); SetProduct(product); }
public void SetProduct(Product product) { DataRow row = _db._ds.Tables["Product"].Rows.Find(product.Id); if (row == null) { row = _db._ds.Tables["Product"].NewRow(); row["Id"] = product.Id; row["Title"] = product.Title; row["PurchasePrice"] = product.PurchasePrice; row["Markup"] = product.Markup; row["Price"] = product.Price; row["DepartmentId"] = product.DepartmentId; row["ProduserId"] = product.ProduserId; row["Quantity"] = product.Quantity; row["CriticalQ"] = product.CriticalQ; _db._ds.Tables["Product"].Rows.Add(row); } else { row["Id"] = product.Id; row["Title"] = product.Title; row["PurchasePrice"] = product.PurchasePrice; row["Markup"] = product.Markup; row["Price"] = product.Price; row["DepartmentId"] = product.DepartmentId; row["ProduserId"] = product.ProduserId; row["Quantity"] = product.Quantity; row["CriticalQ"] = product.CriticalQ; } _db._adapterProduct.Update(_db._ds.Tables["Product"]); OnDBChanged(_db); }
public void DelProduct(Product product) { _db._ds.Tables["Product"].Rows.Find(product.Id).Delete(); _db._adapterProduct.Update(_db._ds.Tables["Product"]); OnDBChanged(_db); }