private void btnSearch_Click(object sender, EventArgs e) { switch (cboSearch.SelectedItem.ToString()) { case "All": //validate input from user if (!Validator.IsProvided(txtSearch, lblEmpty)) { } else { DataGridDB.GetDGData("SELECT * FROM PRODUCTS WHERE lower(CONCAT(ProductId, ProdName)) like '%" + txtSearch.Text.ToLower() + "%'", productGridView, bindingSourceProduct); //if there are is no match to the database: if (productGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(prodQryAll, productGridView, bindingSourceProduct); } } break; case "Id": if (!Validator.IsProvided(txtSearch, lblEmpty) || !Validator.IsNonZeroPositiveInt(txtSearch, lblId)) { } else { DataGridDB.GetDGData("SELECT * from Products where lower(ProductId) like '%" + txtSearch.Text + "%'", productGridView, bindingSourceProduct); //if there are is no match to the database: if (productGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(prodQryAll, productGridView, bindingSourceProduct); } } break; case "Name": if (!Validator.IsProvided(txtSearch, lblEmpty) || !Validator.IsString(txtSearch, lblName)) { } else { DataGridDB.GetDGData("SELECT * from Products where lower(ProdName) like '%" + txtSearch.Text + "%'", productGridView, bindingSourceProduct); //if there are is no match to the database: if (productGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(prodQryAll, productGridView, bindingSourceProduct); } } break; } }
private void AdminControlSup_Load(object sender, EventArgs e) { //select a default value for search option (combo box) cboSearch.SelectedIndex = 0; //set the source of the data to be displayed in the grid view supplierGridView.DataSource = bindingSourceSupplier; //get table for packages DataGridDB.GetDGData(supQryAll, supplierGridView, bindingSourceSupplier); }
private void AdminControlPdct_Load(object sender, EventArgs e) { //select a default value for search option (combo box) cboSearch.SelectedIndex = 0; //set the source of the data to be displayed in the grid view productGridView.DataSource = bindingSourceProduct; //get table for packages DataGridDB.GetDGData(prodQryAll, productGridView, bindingSourceProduct); }
private void AdminControlPkg_Load(object sender, EventArgs e) { //select a default value for search option (combo box) cboSearch.SelectedIndex = 0; cboDate.SelectedIndex = 0; cboCurrency.SelectedIndex = 0; //set the source of the data to be displayed in the grid view packageGridView.DataSource = bindingSourcePackage; //get table for packages DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); }
private void btnRefresh_Click(object sender, EventArgs e) { //get table for products DataGridDB.GetDGData(prodQryAll, productGridView, bindingSourceProduct); }
private void btnRefresh_Click(object sender, EventArgs e) { //get table for suppliers DataGridDB.GetDGData(supQryAll, supplierGridView, bindingSourceSupplier); }
//button to allow user to search in the database based on their search criteria private void btnSearch_Click(object sender, EventArgs e) { switch (cboSearch.SelectedItem.ToString()) { case "All": //validate input from user if (!Validator.IsProvided(txtSearch, lblEmpty)) { } else { DataGridDB.GetDGData("SELECT * from Packages where lower(CONCAT(PackageId, PkgName, PkgStartDate, PkgEndDate, PkgDesc, PkgBasePrice, PkgAgencyCommission)) like '%" + txtSearch.Text.ToLower() + "%'", packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } } break; case "Id": if (!Validator.IsProvided(txtSearch, lblEmpty) || !Validator.IsNonZeroPositiveInt(txtSearch, lblId)) { } else { DataGridDB.GetDGData("SELECT * from Packages where lower(PackageId) like '%" + txtSearch.Text + "%'", packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } } break; case "Name": if (!Validator.IsProvided(txtSearch, lblEmpty) || !Validator.IsString(txtSearch, lblName)) { } else { DataGridDB.GetDGData("SELECT * from Packages where lower(PkgName) like '%" + txtSearch.Text + "%'", packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } } break; case "Start Date": case "End Date": string tableDate; if (cboSearch.SelectedItem.ToString() == "Start Date") { tableDate = "PkgStartDate"; } else { tableDate = "PkgEndDate"; } switch (cboDate.SelectedItem.ToString()) { case "Before:": var sqlBefore = String.Format("SELECT * from Packages where {0} <= '{1}'", tableDate, dateTimePickerPkg.Value.Date); DataGridDB.GetDGData(sqlBefore, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; case "After:": var sqlAfter = String.Format("SELECT * from Packages where {0} >= '{1}'", tableDate, dateTimePickerPkg.Value.Date); DataGridDB.GetDGData(sqlAfter, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; case "Exactly on:": var sqlExact = String.Format("SELECT * from Packages where {0} = '{1}'", tableDate, dateTimePickerPkg.Value.Date); DataGridDB.GetDGData(sqlExact, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; } break; case "Base Price": case "Commission": if (!Validator.IsProvided(txtSearch, lblEmpty) || !Validator.IsNonNegativeDecimal(txtSearch, lblCurrency)) { } else { string tableCurrency; if (cboSearch.SelectedItem.ToString() == "Base Price") { tableCurrency = "PkgBasePrice"; } else { tableCurrency = "PkgAgencyCommission"; } switch (cboCurrency.SelectedItem.ToString()) { case "Above:": var sqlAbove = String.Format("SELECT * from Packages where {0} >= '{1}'", tableCurrency, Convert.ToDecimal(txtSearch.Text)); DataGridDB.GetDGData(sqlAbove, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 1) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; case "Below:": var sqlBelow = String.Format("SELECT * from Packages where {0} <= '{1}'", tableCurrency, Convert.ToDecimal(txtSearch.Text)); DataGridDB.GetDGData(sqlBelow, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; case "Exactly:": var sqlExact = String.Format("SELECT * from Packages where {0} = '{1}'", tableCurrency, Convert.ToDecimal(txtSearch.Text)); DataGridDB.GetDGData(sqlExact, packageGridView, bindingSourcePackage); //if there are is no match to the database: if (packageGridView.Rows.Count == 0) { MessageBox.Show("Unable to find a match"); DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); } break; } } break; } }
private void btnRefresh_Click(object sender, EventArgs e) { //get table for packages DataGridDB.GetDGData(pkgQryAll, packageGridView, bindingSourcePackage); }