private void btnUpdateSupplier_Click(object sender, EventArgs e) { if (Validation.IsPresent(txtSupplier, "Supplier Name", lblSuppError)) { updateSupplierName(lstSupplier.SelectedItem.ToString(), txtSupplier.Text); gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers(); ResetPrdSupplierPage(); ResetProductSupllierList(); ResetSupplierList(); List <int> suppupdated = SuppliersDB.GetSupplierIDs(); List <string> supplier = new List <string>(); foreach (var sup in suppupdated) { supplier.Add(SuppliersDB.GetSupplier(sup).SupName); } comboSupplier.DataSource = supplier; List <int> prod = ProductsDB.GetProductID(); List <string> product = new List <string>(); foreach (var prd in prod) { product.Add(ProductsDB.GetProduct(prd).ProdName); } comboProduct.DataSource = null; comboProduct.DataSource = product; txtSupplier.Text = ""; lblSuppError.Text = ""; } }
//PAGE LOAD private void TravelExpert_Load(object sender, EventArgs e) { this.FormBorderStyle = FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; foreach (var pkg in pack) { lstPkg.Items.Add(pkg.PkgName); } gridProductSuppliers.DataSource = productSupplierList; gridProductSuppliers.Columns[0].Visible = false; foreach (var prd in prod) { product.Add(ProductsDB.GetProduct(prd).ProdName); } foreach (var sup in supp) { supplier.Add(SuppliersDB.GetSupplier(sup).SupName); } var distinctPrd = productSupplierList.Select(o => o.ProdName).Distinct().ToList(); comboPrdPack.DataSource = distinctPrd; comboProduct.DataSource = product; comboSupplier.DataSource = supplier; var lstsup = new List <string>(); foreach (var supname in productSupplierList) { if (supname.ProdName == comboPrdPack.SelectedItem.ToString()) { listSuppPkg.Items.Add(supname.SupName); } } gridProductSuppliers.Columns[1].HeaderText = "Product Supplier ID"; gridProductSuppliers.Columns[2].HeaderText = "Product Name"; gridProductSuppliers.Columns[3].HeaderText = "Supplier Name"; gridProductSuppliers.Columns[1].Width = 150; gridProductSuppliers.Columns[2].Width = 300; gridProductSuppliers.Columns[3].Width = 300; gridProductSuppliers.ClearSelection(); ResetPrdSupplierPage(); ResetProductList(); ResetSupplierList(); //disables the DateTimePickers, re-enabled when add or edit button clicked dtpPkgStrt.Enabled = false; dtpPkgEndDate.Enabled = false; }
// Adding Supplier to supplier table private void btnSaveAddSupp_Click(object sender, EventArgs e) { if (Validation.IsPresent(txtSupplier, "Supplier Name", lblSuppError)) { Suppliers suppAdd = new Suppliers(); List <int> supp = SuppliersDB.GetSupplierIDs(); var newsuppindex = supp[supp.Count - 1] + 1; suppAdd.SupplierID = newsuppindex; suppAdd.SupName = txtSupplier.Text; SuppliersDB.AddSupplier(suppAdd); gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers(); List <int> suppupdated = SuppliersDB.GetSupplierIDs(); List <string> supplier = new List <string>(); foreach (var sup in suppupdated) { supplier.Add(SuppliersDB.GetSupplier(sup).SupName); } comboSupplier.DataSource = null; comboSupplier.DataSource = supplier; List <int> prod = ProductsDB.GetProductID(); List <string> product = new List <string>(); foreach (var prd in prod) { product.Add(ProductsDB.GetProduct(prd).ProdName); } comboProduct.DataSource = null; comboProduct.DataSource = product; ResetSupplierList(); ResetPrdSupplierPage(); ResetProductSupllierList(); txtSupplier.Text = ""; lblSuppError.Text = ""; } }
private void saveProdSup_Click(object sender, EventArgs e) { ResetPrdSupplierPage(); try { Products_Suppliers addPrdSupp = new Products_Suppliers(); List <int> prod = ProductsDB.GetProductID(); List <int> supp = SuppliersDB.GetSupplierIDs(); foreach (var item in prod) { if (comboProduct.SelectedItem.ToString() == ProductsDB.GetProduct(item).ProdName) { addPrdSupp.ProductId = item; } } foreach (var item in supp) { if (comboSupplier.SelectedItem.ToString() == SuppliersDB.GetSupplier(item).SupName) { addPrdSupp.SupplierId = item; } } Products_SuppliersDB.AddProdSupplier(addPrdSupp); gridProductSuppliers.DataSource = null; gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers(); gridProductSuppliers.Columns[0].Visible = false; gridProductSuppliers.Columns[1].HeaderText = "Product Supplier ID"; gridProductSuppliers.Columns[2].HeaderText = "Product Name"; gridProductSuppliers.Columns[3].HeaderText = "Supplier Name"; gridProductSuppliers.Columns[1].Width = 150; gridProductSuppliers.Columns[2].Width = 300; gridProductSuppliers.Columns[3].Width = 300; ResetProductList(); ResetSupplierList(); ResetPrdSupplierPage(); ResetProductSupllierList(); } catch { lblPckProdError.Text = "Same Product Supplier Already Exist"; } }
public void updateSupplierName(string supplierName, string updatedsupplierName) { List <int> supp = SuppliersDB.GetSupplierIDs(); foreach (var item in supp) { if (supplierName == SuppliersDB.GetSupplier(item).SupName) { Suppliers updatedSupplier = new Suppliers(); updatedSupplier.SupplierID = item; updatedSupplier.SupName = updatedsupplierName; SuppliersDB.UpdateSupplier(item, updatedSupplier); } } }
// Adding Product to Product list ** Need Validation of Data private void btnAddSaveProd_Click(object sender, EventArgs e) { if (Validation.IsPresent(txtProductName, "Product Name", lblProdsError)) { Products prodAdd = new Products(); prodAdd.ProdName = txtProductName.Text; List <int> prod = ProductsDB.GetProductID(); List <string> product = new List <string>(); foreach (var prd in prod) { product.Add(ProductsDB.GetProduct(prd).ProdName); } comboProduct.DataSource = null; comboProduct.DataSource = product; List <int> suppupdated = SuppliersDB.GetSupplierIDs(); List <string> supplier = new List <string>(); foreach (var sup in suppupdated) { supplier.Add(SuppliersDB.GetSupplier(sup).SupName); } comboSupplier.DataSource = null; comboSupplier.DataSource = supplier; ProductsDB.AddProduct(prodAdd); gridProductSuppliers.DataSource = Products_SuppliersDB.GetProductsSuppliers(); ResetProductList(); ResetPrdSupplierPage(); ResetProductSupllierList(); txtProductName.Text = ""; lblProdsError.Text = ""; } }
public void ResetSupplierList() { lstSupplier.Items.Clear(); List <int> supp1 = SuppliersDB.GetSupplierIDs(); foreach (var supItem in supp1) { lstSupplier.Items.Add(SuppliersDB.GetSupplier(supItem).SupName); } btnAddSupplier.Visible = true; btnAddSupplier.Enabled = true; btnEditSupplier.Visible = true; btnEditSupplier.Enabled = true; lblSupplierName.Visible = false; txtSupplier.Visible = false; btnSaveAddSupp.Visible = false; btnUpdateSupplier.Visible = false; lstSupplier.Enabled = true; }