private void ComboBox1_TextChanged(object sender, EventArgs e) { try { string query = @"SELECT DEP_Description FROM Departments WHERE DEP_Name = '" + departmentsCombo.Text + @"'"; SQLClass net = new SQLClass(query, false); List <string> read = net.Read(); label10.Text = read[0]; } catch (Exception ex) { } }
//delete supplier button private void Button9_Click(object sender, EventArgs e) { //if a something is selected if (dataGridView3.SelectedCells.Count > 0) { if (ConfimationBox("Are you sure you wish to delete?")) { string q1 = "DELETE FROM Suppliers WHERE SUP_Code = " + dataGridView3.SelectedRows[0].Cells[0].Value; SQLClass net1 = new SQLClass(q1, true); #if DEBUG outputFile.WriteLine(DateTime.Now + "" + "Deleted Supplier where PK was " + dataGridView3.SelectedRows[0].Cells[4].Value); #endif StoreIndices(); RefreshTables(); dataGridView1.Rows[_indices[SelectionItemTypes.Product]].Selected = true; dataGridView2.Rows[_indices[SelectionItemTypes.Barcode]].Selected = true; editing = false; } } }
//Delete product Button private void Button2_Click(object sender, EventArgs e) { //if a something is selected if (dataGridView1.SelectedCells.Count > 0) { if (ConfimationBox("Are you sure you wish to delete?")) { SQLClass net = new SQLClass("DELETE FROM Products WHERE PRO_PK = " + dataGridView1.SelectedRows[0].Cells[_PKCOLUMN].Value, true); #if DEBUG outputFile.WriteLine(DateTime.Now + "" + "Deleted Product where PK was " + dataGridView1.SelectedRows[0].Cells[_PKCOLUMN].Value); #endif RefreshTables(); editing = false; } } }
bool IsSupplierFree(string s, TextBox t) { SQLClass net = new SQLClass((@"SELECT SUP_Code FROM Suppliers WHERE SUP_Code = '" + s + @"'"), false); List <string> read = net.Read(); if (read.Count == 0) { return(true); } else { if (dataGridView3.SelectedRows[0].Cells[0].Value.ToString() == s && editing == true) { return(true); } } InvalidInput(t, "Supplier code already in use"); return(false); }
//checks DB for other products with the same product ID bool IsProductNumberFree(string s, TextBox t) { SQLClass net = new SQLClass((@"SELECT PRO_Code FROM Products WHERE PRO_Code = '" + s + @"'"), false); List <string> read = net.Read(); if (read.Count == 0) { return(true); } else { if (dataGridView1.SelectedRows[0].Cells[0].Value.ToString() == s && editing == true) { return(true); } } InvalidInput(t, "Product ID already in use"); return(false); }
void SetupForm() { //add to arrays { _userEntryHeaders.Add(label2); _userEntryHeaders.Add(label3); _userEntryHeaders.Add(label4); _userEntryHeaders.Add(label5); _userEntryHeaders.Add(label6); _userEntryHeaders.Add(label7); _userEntryHeaders.Add(label8); _userEntryHeaders.Add(label12); _userEntryHeaders.Add(label13); _userEntryHeaders.Add(label14); _userEntryHeaders.Add(label15); _userEntryHeaders.Add(label16); _userEntryProducts.Add(textBox1); _userEntryProducts.Add(textBox2); _userEntryProducts.Add(textBox3); _userEntryProducts.Add(textBox4); _userEntryProducts.Add(textBox5); _userEntryProducts.Add(textBox6); _userEntryBarcodes.Add(textBox7); _userEntryBarcodes.Add(textBox8); _userEntrySuppliers.Add(textBox9); _userEntrySuppliers.Add(textBox10); _userEntrySuppliers.Add(textBox11); } //set text, disable { for (int i = 0; i < _userEntryHeaders.Count; i++) { _userEntryHeaders[i].Text = _names[i]; } for (int i = 0; i < _userEntryProducts.Count; i++) { _userEntryProducts[i].Enabled = false; } for (int i = 0; i < _userEntryBarcodes.Count; i++) { _userEntryBarcodes[i].Enabled = false; } for (int i = 0; i < _userEntrySuppliers.Count; i++) { _userEntrySuppliers[i].Enabled = false; } departmentsCombo.Enabled = false; } //combobox1 populate { SQLClass net = new SQLClass("SELECT DEP_Name FROM Departments", false); List <string> read = net.Read(); for (int i = 0; i < read.Count; i++) { Label temp1 = new Label { Name = "lb" + i.ToString(), Text = read[i] }; departmentsCombo.Items.Add(temp1); departmentsCombo.DisplayMember = "Text"; } } }