private void fillcombo(ComboBox cb) { for (int i = 0; i <= currentUser.getRank(); i++) { cb.Items.Add(i); } }
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++; }