private void restoreVendor(string sql) { clsLists.vendor.Clear(); //Start with an empty ArrayList // Restore information from vendor database using a data reader. try { openDatabaseConnection(); mDB.Open(); OleDbCommand cmd; cmd = new OleDbCommand(sql, mDB); OleDbDataReader rdr; rdr = cmd.ExecuteReader(); while (rdr.Read() == true) { clsVendor ven = new clsVendor((int)rdr["VendorID"], (string)rdr["StoreName"], (string)rdr["StoreCity"], (string)rdr["StoreState"], (string)rdr["StoreWebsite"]); clsLists.vendor.Add(ven); } rdr.Close(); } catch (Exception ex) { clsValidate.ShowMessage("There was an unexpected problem reading from the DB: " + ex.Message); } finally { closeDatabaseConnection(); } }
int IComparer.Compare(object object1, object object2) { clsVendor name1 = (clsVendor)object1; clsVendor name2 = (clsVendor)object2; return(name1.StoreName.CompareTo(name2.StoreName)); }
public static ArrayList queryVendor(string sql) { ArrayList vendor = new ArrayList(); try { openDatabaseConnection(); mdb.Open(); OleDbCommand cmd; cmd = new OleDbCommand(sql, mdb); OleDbDataReader rdr; rdr = cmd.ExecuteReader(); while (rdr.Read() == true) { clsVendor newVendor = new clsVendor((int)rdr["VendorID"], (string)rdr["StoreName"], (string)rdr["StoreCity"], (string)rdr["StoreState"], (string)rdr["StoreWebsite"]); vendor.Add(newVendor); } rdr.Close(); } catch (Exception ex) { MessageBox.Show("There was an unexpected problem reading from the DB: " + ex.Message); } finally { closeDatabaseConnection(); } return(vendor); }
public ActionResult Vendor_Registration(Vendor objVendor) { bool Result = false; clsVendor objclsVendor = new clsVendor(); if (objclsVendor.VendorCRUD(objVendor, Enums.Action.CREATE)) { Result = true; } return(RedirectToAction("ShowCredentials", "Users", new { isShow = Result })); }
private void btnDeleteVendor_Click(object sender, EventArgs e) { //Code to Delete the selected record string sql; int locDelete = lstVendor.SelectedIndex - 2; // account for two-line header // Make sure a valid client was selected if (locDelete < 0 || locDelete > (clsLists.vendor.Count - 1)) { clsValidate.ShowMessage("Please select a valid vendor in the list to remove."); lstVendor.SelectedIndex = -1; return; } if (MessageBox.Show("Please confirm that you wish to delete the record for " + txtStoreName.Text, "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.No) { MessageBox.Show("Delete request ignored."); lstVendor.SelectedIndex = -1; return; } clsVendor vendor = (clsVendor)clsLists.vendor[locDelete]; // Remove the vendor from the DB try { openDatabaseConnection(); mDB.Open(); sql = "DELETE FROM Vendor WHERE [VendorID] =" + vendor.VendorID; OleDbCommand cmd = new OleDbCommand(sql, mDB); cmd.ExecuteNonQuery(); } catch (Exception ex) { clsValidate.ShowMessage("There was an unexpected problem removing the vendor from the DB" + ex.Message); } finally { closeDatabaseConnection(); } restoreVendor("SELECT * FROM Vendor"); displayElements(); clsValidate.ShowMessage("The vendor was removed from the database"); txtStoreName.Clear(); txtStoreCity.Clear(); txtStoreState.Clear(); txtStoreWebsite.Clear(); txtStoreName.Focus(); txtSearch.Clear(); }
// Open a browser and go to the website of the selected index. private void btnWebsite_Click(object sender, EventArgs e) { int locSelected = lstVendor.SelectedIndex - 2; if (locSelected < 0 || locSelected > (clsLists.vendor.Count - 1)) { clsValidate.ShowMessage("Please select a valid Vendor."); lstVendor.SelectedIndex = -1; return; } clsVendor vendor = (clsVendor)clsLists.vendor[locSelected]; System.Diagnostics.Process.Start("http://" + vendor.StoreWebsite); }
public ActionResult Vendor_Registration(Vendor objVendor, HttpPostedFileBase IMAGE_LOGO, HttpPostedFileBase IMAGE_AADHAR, HttpPostedFileBase IMAGE_PAN, HttpPostedFileBase IMAGE_GST) { int ReturnId = 0; Guid objLogo = Guid.NewGuid(); Guid objAadhar = Guid.NewGuid(); Guid objPan = Guid.NewGuid(); Guid objGST = Guid.NewGuid(); if (IMAGE_LOGO != null) { objVendor.IMAGELOGO = Common.ConvertDBnullToString(objLogo); objVendor.IMAGELOGO = objVendor.IMAGELOGO + Path.GetExtension(IMAGE_LOGO.FileName); string path = Path.Combine(Server.MapPath("~/Upload/Vendor/"), objVendor.IMAGELOGO); IMAGE_LOGO.SaveAs(path); } if (IMAGE_AADHAR != null) { objVendor.IMAGEAADHAR = Common.ConvertDBnullToString(objAadhar); objVendor.IMAGEAADHAR = objVendor.IMAGEAADHAR + Path.GetExtension(IMAGE_AADHAR.FileName); string path = Path.Combine(Server.MapPath("~/Upload/Vendor/"), objVendor.IMAGEAADHAR); IMAGE_AADHAR.SaveAs(path); } if (IMAGE_PAN != null) { objVendor.IMAGEPAN = Common.ConvertDBnullToString(objPan); objVendor.IMAGEPAN = objVendor.IMAGEPAN + Path.GetExtension(IMAGE_PAN.FileName); string path = Path.Combine(Server.MapPath("~/Upload/Vendor/"), objVendor.IMAGEPAN); IMAGE_PAN.SaveAs(path); } if (IMAGE_GST != null) { objVendor.IMAGEGST = Common.ConvertDBnullToString(objGST); objVendor.IMAGEGST = objVendor.IMAGEGST + Path.GetExtension(IMAGE_GST.FileName); string path = Path.Combine(Server.MapPath("~/Upload/Vendor/"), objVendor.IMAGEGST); IMAGE_GST.SaveAs(path); } clsVendor objclsVendor = new clsVendor(); ReturnId = objclsVendor.VendorCRUD(objVendor, Enums.Action.CREATE); return(RedirectToAction("ShowCredentials", "Users", new { OutputId = ReturnId, EntityType = "VENDOR" })); }
// Set the selected index of the list box to populate data in the appropriate textboxes. private void lstVendor_SelectedIndexChanged_1(object sender, EventArgs e) { int locSelected = lstVendor.SelectedIndex - 2; if (locSelected < 0 || locSelected > (clsLists.vendor.Count - 1)) { clsValidate.ShowMessage("Please select a valid Vendor."); lstVendor.SelectedIndex = -1; return; } clsVendor vendor = (clsVendor)clsLists.vendor[locSelected]; txtStoreName.Text = vendor.StoreName; txtSearch.Text = vendor.StoreName; txtStoreCity.Text = vendor.StoreCity; txtStoreState.Text = vendor.StoreState; txtStoreWebsite.Text = vendor.StoreWebsite; txtStoreName.Focus(); }
private void btnUpdateVendor_Click(object sender, EventArgs e) { //Code to update Selected record string sql; int locUpdate = lstVendor.SelectedIndex - 2; // account for two-line header // Make sure a valid client was selected if (locUpdate < 0 || locUpdate > (clsLists.vendor.Count - 1)) { clsValidate.ShowMessage("Please select a valid vendor in the list to modify."); lstVendor.SelectedIndex = -1; return; } if (!clsValidate.validateInput(txtStoreName, out StoreName)) { return; } if (!clsValidate.validateInput(txtStoreCity, out StoreCity)) { return; } if (!clsValidate.validateInput(txtStoreState, out StoreState)) { return; } if (!clsValidate.validateInput(txtStoreWebsite, out StoreWebsite)) { return; } // Confirm the record update if (MessageBox.Show("Please confirm that you wish to update the record for " + txtStoreName.Text, "Confirm Update", MessageBoxButtons.YesNo) == DialogResult.No) { MessageBox.Show("Update request ignored."); lstVendor.SelectedIndex = -1; return; } // Update the record with sql code. try { clsVendor vendor = (clsVendor)clsLists.vendor[locUpdate]; openDatabaseConnection(); mDB.Open(); OleDbCommand cmd; sql = "UPDATE Vendor SET " + "StoreName = " + clsSQL.ToSql(txtStoreName.Text) + ", " + "StoreCity = " + clsSQL.ToSql(txtStoreCity.Text) + ", " + "StoreState = " + clsSQL.ToSql(txtStoreState.Text) + ", " + "StoreWebsite = " + clsSQL.ToSql(txtStoreWebsite.Text) + "WHERE [VendorID] = " + vendor.VendorID; cmd = new OleDbCommand(sql, mDB); cmd.ExecuteNonQuery(); } catch (Exception ex) { clsValidate.ShowMessage("There was an unexpected error: " + ex.Message); } finally { closeDatabaseConnection(); } restoreVendor("SELECT * FROM Vendor"); displayElements(); clsValidate.ShowMessage("The record was updated"); txtStoreName.Clear(); txtStoreCity.Clear(); txtStoreState.Clear(); txtStoreWebsite.Clear(); txtStoreName.Focus(); txtSearch.Clear(); }