/* Adds item data to orderInfo list and displays it in order summary * ***************************************/ private void addItemBtn_Click(object sender, EventArgs e) { // Get item descipriton and determine if itemNumber exists in the database string materialSearch = "SELECT description FROM Materials WHERE itemID = '" + itemNumber.Text + "' LIMIT 1"; string result = dbconn.getString(materialSearch); // Hanle no matching item found in database if (result == null) { MessageBox.Show("Item number doesn't exist. Please try another item number.", "Invalid Item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); itemValidityMessage.Text = "Invalid Item Number"; itemValidityMessage.Visible = true; itemValidityMessage.ForeColor = errorColor; itemQuantity.Clear(); itemNumber.Clear(); itemNumber.Select(); } else { itemValidityMessage.Visible = false; // Hide invalid item number message // Retrieve item description from database string itemDescription = result; // Displays item in summary box and increments itemCount try { if (Convert.ToInt32(itemQuantity.Text) < 1 || Convert.ToInt32(itemQuantity.Text) > 100) { MessageBox.Show("Please enter an item quantity between 1 and 100.", "Invalid Quantity", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { // Add new order item to list orderInfo.Add(new TempOrderInfo() { itemNumber = Convert.ToInt32(itemNumber.Text), jobCode = Convert.ToInt32(jobCode.Text), description = itemDescription, quantity = Convert.ToInt32(itemQuantity.Text) }); // Add item to data grid view TempOrderInfo lastEntry = orderInfo.Last(); orderSummaryTable.Rows.Add(lastEntry.itemNumber, lastEntry.description, lastEntry.quantity); submitOrderBtn.Enabled = true; cancelBtn.Enabled = true; itemNumber.Clear(); itemQuantity.Clear(); itemNumber.Select(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private bool verifyCredentials(string userID, string password) //Function to verify user information and return whether access is permitted or denied. { //Create database and user objects projectDB db = new projectDB(); user currentUser = new user(); //local variables int uid, rank = 0; string fname, lname, username, employmentStatus = null; bool verified = false; //************************************************encrypt password password = db.encrypt(password); //Try to find the user int the database. try { //See if username and password match on database string query = "SELECT employeeID FROM Employees WHERE username='******' AND userPass ='******';"; verified = db.getBool(query, true); if (verified) { //Set user information uid = Convert.ToInt32(db.getString("SELECT employeeID FROM Employees WHERE username = '******' AND userPass = '******'; ")); rank = Convert.ToInt32(db.getString("SELECT rank FROM Employees WHERE username = '******' AND userPass = '******'; ")); fname = db.getString("SELECT firstName FROM Employees WHERE username = '******' AND userPass = '******'; "); lname = db.getString("SELECT lastName FROM Employees WHERE username = '******' AND userPass = '******'; "); employmentStatus = db.getString("SELECT employeeStatus FROM Employees WHERE username = '******' AND userPass = '******'; "); username = txtEmpID.Text; currentUser.set(uid, rank, fname, lname, employmentStatus, username); //verify everything worked if (employmentStatus != "Active") { lblError.Visible = true; return(false); } //Proceed with login Main form = new Main(currentUser); form.Show(); this.Hide(); return(true); } } catch { return(false); } lblError.Visible = true; return(false); }
private void login_Load(object sender, EventArgs e) { //Check if ANY users exist exit if program does not detect network to prevent exploit. bool ping = db.PingHost("104.248.117.10"); if (ping == false) { MessageBox.Show("No network detected. Program will close."); Application.Exit(); } string query = "SELECT MAX(employeeID) FROM Employees"; string result = db.getString(query); if (result == "1") { MessageBox.Show("No users were found in the system. Contact Technicial Support. If this is a new install, please enter default credentials below."); isNewInstall = true; } }
private void btnAddItem_Click(object sender, EventArgs e) { //Verify item and quantity are available in database and required rank try { string quantityReq = txtQuantity.Text; int currentQuantity = db.getInt("SELECT available FROM Equipment WHERE equipmentID =" + txtScanItem.Text + ";"); int newQuantity = currentQuantity - Convert.ToInt32(quantityReq); if (newQuantity < 0) { lblInformation.Text = "Not enough inventory to supply this order. \n\nContact Warehouse Personel or Inventory Management."; lblInformation.ForeColor = Color.Red; return; } string eqDescription = db.getString("SELECT description FROM Equipment WHERE equipmentID ='" + txtScanItem.Text + "';"); string query = "SELECT equipmentID FROM Equipment WHERE (equipmentID = '" + txtScanItem.Text + "' AND equipmentStatus ='In Stock' AND requiredRank <='" + currentUser.getRank() + "' AND available>='" + quantityReq + "');"; //If item is found: if (db.getBool(query, true)) { lblInformation.Text = "Item number: [" + txtScanItem.Text + "]\n\nQuantity: [" + quantityReq + "] successfully added."; lblInformation.ForeColor = Color.Blue; // Add new order item to list orderInfo.Add(new TempOrderInfo() { itemNumber = Convert.ToInt32(txtScanItem.Text), jobCode = Convert.ToInt32(txtJobCode.Text), description = eqDescription, quantity = Convert.ToInt32(txtQuantity.Text) }); // Add item to data grid view TempOrderInfo lastEntry = orderInfo.Last(); dt.Rows.Add(lastEntry.itemNumber, lastEntry.description, lastEntry.quantity); } else { lblInformation.Text = "Unable to add item. \nThis error will occur if the item is not in stock or does not exist. \n\n\nStock amount: " + currentQuantity + ". \n\n\nContact warehouse management if this problem persists."; lblInformation.ForeColor = Color.Red; } //Add item to datagridview list to be put in pending //Select field txtScanItem.Clear(); txtScanItem.Select(); } catch (Exception ex) { MessageBox.Show(ex.Message); } count++; }
private void btnReturnSubmit_Click(object sender, EventArgs e) { //Passes values to right and adds Job Code so User can confirm he is returning the correct equipment bool comboEmpty = true; try { if (comboStatus.Text != "") { comboEmpty = false; } //Job Code query to add to right side of view to confirm return. if (comboEmpty == false && txtReturnItem.Text != "") { switch (comboStatus.Text) { case "Working": { lblChkBox1.Text = "Returned"; break; } case "Not Working": { lblChkBox1.Text = "Damaged"; break; } } //Clears left side and populates right side for confirmation. comboStatus.SelectedIndex = 0; lblChkBox2.Text = txtReturnItem.Text; txtReturnItem.Text = null; lblChkBox3.Text = txtReturnEID.Text; //MySQL query to pull Job Code to confirm which item you are returning. //This step is to insure the User does not accidentally return the wrong item. string input1 = lblChkBox2.Text; string input2 = lblChkBox3.Text; string query1 = "SELECT jobCode FROM EquipmentRental WHERE equipmentID LIKE '%" + input1 + "%' AND employeeID LIKE '%" + currentUser.getID().ToString() + "%'"; lblJobCode.Text = (mydb.getString(query1)); string query2 = "SELECT rentalID FROM EquipmentRental WHERE equipmentID LIKE '%" + input1 + "%' AND employeeID LIKE '%" + currentUser.getID().ToString() + "%'"; lblRentalID.Text = (mydb.getString(query2));; lblReturnError.Text = ""; } else { lblReturnError.Text = "Please fill out both fields."; txtReturnItem.Text = ""; comboStatus.Text = ""; lblChkBox1.Text = ""; lblChkBox2.Text = ""; lblChkBox3.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }