public object SelectSaloon(Saloons saloon) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "SP_SelectsSaloons"; sqlCommand.Parameters.AddWithValue("@saloonID", saloon.SaloonID); try { if (sqlConnection.State != ConnectionState.Open) { sqlConnection.ConnectionString = connectionPath; sqlConnection.Open(); } SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); DataTable dtSelectSaloon = new DataTable(); sqlDataAdapter.Fill(dtSelectSaloon); return(dtSelectSaloon); } catch (Exception ex) { var errorMessage = $"An error has occurred during deletion: {ex}"; return(false); } finally { sqlConnection.Close(); } }
public bool UpdateSaloon(Saloons saloon) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "SP_UpdatesSaloons"; sqlCommand.Parameters.AddWithValue("@saloonName", saloon.SaloonName); sqlCommand.Parameters.AddWithValue("@saloonCapacity", saloon.SaloonCapacity); sqlCommand.Parameters.AddWithValue("@saloonID", saloon.SaloonID); try { if (sqlConnection.State != ConnectionState.Open) { sqlConnection.ConnectionString = connectionPath; sqlConnection.Open(); } return(sqlCommand.ExecuteNonQuery() > 0); } catch (Exception ex) { var errorMessage = $"An error has occurred during deletion: {ex}"; return(false); } finally { sqlConnection.Close(); } }
public bool DeletesSaloon(Saloons saloon) { if (saloon.SaloonID <= 0) { return(false); } return(saloonsManagement.DeleteSaloon(saloon)); }
private void btnSelectsSaloon_Click(object sender, EventArgs e) { Saloons saloon = new Saloons { SaloonID = Convert.ToInt32(txtSelectsSaloon.Text.Trim()) }; SaloonsManagement saloonsManagement = new SaloonsManagement(); dtListSaloons.DataSource = saloonsManagement.SelectSaloon(saloon); }
public bool InsertsSaloon(Saloons saloon) { if (string.IsNullOrWhiteSpace(saloon.SaloonName)) { return(false); } if (saloon.SaloonName.Length > 20) { return(false); } if (saloon.SaloonCapacity <= 0) { return(false); } return(saloonsManagement.InsertSaloon(saloon)); }
private void btnDeleteSaloon_Click(object sender, EventArgs e) { Saloons saloon = new Saloons { SaloonID = Convert.ToInt32(txtDeleteSaloon.Text.Trim()) }; SaloonsController saloonsController = new SaloonsController(); bool IsSaloonDeleted = saloonsController.DeletesSaloon(saloon); if (IsSaloonDeleted) { string successMessage = "Salon silme başarılı."; MessageBox.Show(successMessage); } else { string failMessage = "Salon silme başarısız."; MessageBox.Show(failMessage); } }
private void btnInsertSaloon_Click(object sender, EventArgs e) { Saloons saloon = new Saloons { SaloonName = txtInsertSaloon.Text.Trim(), SaloonCapacity = Convert.ToInt32(txtInsertSaloonCapacity.Text.Trim()) }; SaloonsController saloonsController = new SaloonsController(); bool IsSaloonInserted = saloonsController.InsertsSaloon(saloon); if (IsSaloonInserted) { string successMessage = "Salon ekleme başarılı."; MessageBox.Show(successMessage); } else { string failMessage = "Salon ekleme başarısız."; MessageBox.Show(failMessage); } }