public List <Bussiness_Logic.Service> GetAllServices() { List <Bussiness_Logic.Service> services = new List <Bussiness_Logic.Service>(); string query = $"SELECT * FROM [Service]"; SqlConnection conn = new SqlConnection(connect); SqlCommand command = new SqlCommand(query, conn); try { conn.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Bussiness_Logic.Service service = new Bussiness_Logic.Service(reader.GetString(1), reader.GetInt32(0), reader.GetString(3), reader.GetString(2), reader.GetBoolean(4)); services.Add(service); } } catch (Exception ex) { MessageBox.Show("Could not find Services " + ex.Message); } finally { conn.Close(); } return(services); }
private void btnUpdateState_Click(object sender, EventArgs e) { int serviceId = int.Parse(txtUpdate1ID.Text); int state = cmbUpdate1.Text == "Active" ? 1 : 0; Bussiness_Logic.Service service = new Bussiness_Logic.Service(); service.UpdateServiceState(serviceId, state); bs.DataSource = dataAccess.GetAllServices(); bs.ResetBindings(true); }
private void btnUpdateAll_Click(object sender, EventArgs e) { int serviceId = int.Parse(txtUpdateID.Text); string name = txtUpdateName.Text; string equip = txtUpdateType.Text; string workExpenses = txtUpdateExpenses.Text; int state = cmbUpdateAll.Text == "Active" ? 1 : 0; Bussiness_Logic.Service service = new Bussiness_Logic.Service(); service.UpdateService(serviceId, name, equip, workExpenses, state); bs.DataSource = dataAccess.GetAllServices(); bs.ResetBindings(true); }
private void btnAddService_Click(object sender, EventArgs e) { string name = txtName.Text; string equip = txtType.Text; string workExpenses = txtExpenses.Text; int state = cmbAdd.Text == "Active" ? 1 : 0; Bussiness_Logic.Service service = new Bussiness_Logic.Service(); service.AddService(name, equip, workExpenses, state); txtName.Clear(); txtType.Clear(); txtExpenses.Clear(); bs.DataSource = dataAccess.GetAllServices(); bs.ResetBindings(true); }