private void updateButton_Click(object sender, EventArgs e) { BusShedul aShedul = new BusShedul(); aShedul.BusName = busTextBox.Text; aShedul.NoOfSeat = seatTextBox.Text; aShedul.TypeOfTrip = typeTextBox.Text; aShedul.StartFrom = locate1TextBox.Text; aShedul.ArriveTo = locate2TextBox.Text; aShedul.DriverName = driverNameTextBox.Text; aShedul.DriverContact = contactTextBox.Text; aShedul.HelperName = helperNameTextBox.Text; aShedul.HelperContact = contact2TextBox.Text; aShedul.Time = timePicker.Text; BusShedulBL busBLOBj = new BusShedulBL(); bool result = busBLOBj.UpdateNewBusShedulBL(aShedul); if (result) { MessageBox.Show("Successfully Updated", "Done", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.PopulateGridView(); IntitialButtonMood(); CleanTextBar(); } else { MessageBox.Show("Something went Wrong!", "Aleart", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool DeleteBusShedulBL(BusShedul aShedul) { if (aShedul.BusName == "" || aShedul.StartFrom == "" || aShedul.ArriveTo == "" || aShedul.DriverName == "" || aShedul.TypeOfTrip == "" || aShedul.Time == "") { return(false); } else { BusShedulDA busShedulDAOBj = new BusShedulDA(); bool result = busShedulDAOBj.DeleteBusShedulFromDB(aShedul); return(result); } }
public bool DeleteBusShedulFromDB(BusShedul aShedul) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "DELETE FROM ScheduleTable WHERE BusName = '" + aShedul.BusName + "' AND Time = '" + aShedul.Time + "'"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
public bool UpdateNewBusShedulToDB(BusShedul aShedul) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "Update ScheduleTable Set Time = '" + aShedul.Time + "', StartFrom = '" + aShedul.StartFrom + "', ArriveTo = '" + aShedul.ArriveTo + "', BusName = '" + aShedul.BusName + "', SeatCapacity = '" + aShedul.NoOfSeat + "', TypeOfTrip = '" + aShedul.TypeOfTrip + "', DriverName = '" + aShedul.DriverName + "', DriverContact = '" + aShedul.DriverContact + "', HelperName = '" + aShedul.HelperName + "', HelperContact = '" + aShedul.HelperContact + "' WHERE BusName = '" + aShedul.BusName + "' AND TIME = '" + aShedul.Time + "'"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
public bool SaveNewBusShedulToDB(BusShedul aShedul) { SqlConnection connection = DataBaseConnection.OpenAnSqlConnection(); string query = "INSERT INTO ScheduleTable VALUES ('" + aShedul.Time + "','" + aShedul.StartFrom + "','" + aShedul.ArriveTo + "', '" + aShedul.BusName + "', '" + aShedul.NoOfSeat + "', '" + aShedul.TypeOfTrip + "','" + aShedul.DriverName + "', '" + aShedul.DriverContact + "','" + aShedul.HelperName + "', '" + aShedul.HelperContact + "')"; SqlCommand command = new SqlCommand(query, connection); int rowsAffected = command.ExecuteNonQuery(); if (rowsAffected == 1) { command.Dispose(); return(true); } else { command.Dispose(); return(false); } }
private void SAVEButton_Click(object sender, EventArgs e) { BusShedul aShedul = new BusShedul(); aShedul.BusName = busTextBox.Text; aShedul.NoOfSeat = seatTextBox.Text; aShedul.TypeOfTrip = typeTextBox.Text; aShedul.StartFrom = locate1TextBox.Text; aShedul.ArriveTo = locate2TextBox.Text; aShedul.DriverName = driverNameTextBox.Text; aShedul.DriverContact = contactTextBox.Text; aShedul.HelperName = helperNameTextBox.Text; aShedul.HelperContact = contact2TextBox.Text; aShedul.Time = timePicker.Text; BusShedulBL busBLOBj = new BusShedulBL(); bool result = busBLOBj.SaveNewBusShedulBL(aShedul); if (result) { MessageBox.Show("Successfully added new Schedule!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.PopulateGridView(); IntitialButtonMood(); CleanTextBar(); } else { DialogResult dialog = MessageBox.Show("Please fill all the text", "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (dialog == DialogResult.Cancel) { this.Close(); } } }