private void UpdateButton_Click(object sender, EventArgs e) { const string errorMessage = "A supplier with this name doesn't exist.\n\nPlease enter a different name."; _connection = DB_Connect.connect(); _connection.Open(); if (IfSupplierExists(_connection, SNTextBox.Text)) { var sqlQuery = @"UPDATE[Suppliers] SET[SupplierName] = '" + SNTextBox.Text + "', [SupplierAddress] = '" + SATextBox.Text + "' , [SupplierNumber] = '" + SNUTextBox.Text + "', [SupplierEmail] = '" + SETextBox.Text + "' WHERE[SupplierName] = '" + SNTextBox.Text + "'"; ClearText(); SNTextBox.Focus(); _command = new SqlCommand(sqlQuery, _connection); _command.ExecuteNonQuery(); } else { MessageBox.Show(errorMessage); SNTextBox.Clear(); SNTextBox.Focus(); } _connection.Close(); LoadData(); }
private void AddButton_Click(object sender, EventArgs e) { const string errorMessage = "A supplier with this name already exists.\n\nPlease enter a different name."; _connection = DB_Connect.connect(); _connection.Open(); if (IfSupplierExists(_connection, SNTextBox.Text)) { MessageBox.Show(errorMessage); SNTextBox.Clear(); SNTextBox.Focus(); } else { var sqlQuery = @"INSERT INTO[Suppliers] ([SupplierName], [SupplierAddress], [SupplierNumber], [SupplierEmail]) VALUES ('" + SNTextBox.Text + "', '" + SATextBox.Text + "', '" + SNUTextBox.Text + "', '" + SETextBox.Text + "')"; _command = new SqlCommand(sqlQuery, _connection); _command.ExecuteNonQuery(); ClearText(); SNTextBox.Focus(); } _connection.Close(); LoadData(); }
private void ClearText() { SETextBox.Clear(); SATextBox.Clear(); SNTextBox.Clear(); SNUTextBox.Clear(); }
private void ClearText() { PCTextBox.Clear(); PNTextBox.Clear(); SNTextBox.Clear(); SCTextBox.Clear(); PriceTextBox.Clear(); StockTextBox.Clear(); }
private void AddAccount() { string name = FNTextBox.Text + " " + SNTextBox.Text; string x = GenerateUN(FNTextBox.Text.ToLower(), DEPcb.Text.ToUpper()); var success = "You have successfully created an account!\n\nYour username is : " + x + "\nYour password is : default\n\nThis can be changed when you log in for the first time."; _connection = DB_Connect.connect(); _connection.Open(); var sqlQuery = @"INSERT INTO[Users] ([Name], [Department], [UserName], [Password], [AccessLevel]) VALUES ('" + name + "', '" + DEPcb.Text + "', '" + x + "', '" + "default" + "', '" + ALcb.Text + "')"; _command = new SqlCommand(sqlQuery, _connection); _command.ExecuteNonQuery(); FNTextBox.Clear(); SNTextBox.Clear(); DEPcb.SelectedIndex = -1; ALcb.SelectedIndex = -1; FNTextBox.Focus(); MessageBox.Show(success); _connection.Close(); }
private void DeleteButton_Click(object sender, EventArgs e) { const string errorMessage = "This supplier does not exist!"; _connection = DB_Connect.connect(); if (IfSupplierExists(_connection, SNTextBox.Text)) { _connection.Open(); var sqlQuery = @"DELETE FROM[Suppliers] WHERE[SupplierName] = '" + SNTextBox.Text + "'"; _command = new SqlCommand(sqlQuery, _connection); _command.ExecuteNonQuery(); _connection.Close(); } else { MessageBox.Show(errorMessage); } ClearText(); SNTextBox.Focus(); LoadData(); }