public void Load() { Clear(); Product oProduct = new Product(CompanyID); dtItems = oMySql.GetDataTable("select p.Description, pc.ProductID, pc.Quantity, p.Price from ProductCompound pc Left join Product p on pc.CompanyID=p.CompanyID And pc.ProductID=p.ProductID Where pc.CompanyID='" + CompanyID + "' And CProductID='" + this.CProductID + "'", "ProductCompound"); foreach (DataRow row in dtItems.Rows) { oProduct.Find(row["ProductID"].ToString()); ProductCompoundItem oBC = new ProductCompoundItem(this.CompanyID); oBC.Description = oProduct.Description; oBC.Price = oProduct.Price; oBC.Quantity = (Int32)row["Quantity"]; Add(row["ProductID"].ToString(), oBC); } AddEmpty(); }
public void Save(String CompanyID, String ProductID) { Product oProduct = new Product(CompanyID); this.Delete(CompanyID, ProductID); foreach (DataRow _Row in dtItems.Rows) { ProductCompoundItem _Item = new ProductCompoundItem(CompanyID); if (_Row["ProductID"].ToString().Trim() == "") { continue; } _Item.CProductID = ProductID; _Item.CompanyID = CompanyID; _Item.ProductID = _Row["ProductID"].ToString(); _Item.Quantity = (Int32)_Row["Quantity"]; _Item.Insert(); } dtItems.Rows.Clear(); }