private void button1_Click(object sender, EventArgs e) { //creez o tabela intermediara pentru memorare date solicitate Camere camera = new Camere();//ne va ajuta pentru update-ul disponibilitatii camerei in timp real DataTable intermediar = new DataTable(); intermediar.Columns.Add("Nr_Camera"); intermediar.Columns.Add("Tip_Camera"); intermediar.Columns.Add("Descriere_Facilitati"); intermediar.Columns.Add("Nr_locuri"); intermediar.Columns.Add("Pret/noapte"); for (int i = 0; i < dataGridView1.Rows.Count; i++) { DataGridViewCheckBoxCell cell = dataGridView1.Rows[i].Cells[0] as DataGridViewCheckBoxCell; if (cell.Value == cell.TrueValue) { //si se face camera indisponibila daca aceasta a fost programata camera.setDisponibilitate(0, (int)dataGridView1.Rows[i].Cells[1].Value); DataRow row = intermediar.NewRow(); row["Nr_camera"] = (int)dataGridView1.Rows[i].Cells[1].Value; row["Tip_Camera"] = dataGridView1.Rows[i].Cells[2].Value; row["Descriere_Facilitati"] = dataGridView1.Rows[i].Cells[3].Value; row["Nr_locuri"] = dataGridView1.Rows[i].Cells[4].Value; row["Pret/noapte"] = dataGridView1.Rows[i].Cells[6].Value; intermediar.Rows.Add(row); } } //memorez intr-un datatable camerele selectate pentru programari de catre client //urmeaza posinbilitatea stergerii unei comenzi in cazul in care a aparut o greseala dataGridView2.DataSource = intermediar; string connstring = "Data Source=(localDb)\\Databases;Initial Catalog=BD_Proiect;Integrated Security=True"; DataTable dt = new DataTable(); string query = "SELECT ID_Camera,Tip_camera,Descriere_Facilitati,Nr_Locuri,Disponibilitate,Pret_camera FROM Camere WHERE Disponibilitate = 1;"; SqlDataAdapter adt = new SqlDataAdapter(query, connstring); adt.Fill(dt); dataGridView1.DataSource = dt; }
private void button2_Click(object sender, EventArgs e) { Camere camera1 = new Camere(); for (int i = 0; i < dataGridView2.Rows.Count; i++) { DataGridViewCheckBoxCell cell = dataGridView2.Rows[i].Cells[0] as DataGridViewCheckBoxCell; if (cell.Value == cell.TrueValue) { camera1.setDisponibilitate(1, Convert.ToInt32(dataGridView2.Rows[i].Cells[1].Value)); dataGridView2.Rows.RemoveAt(i); //DELETE DIN Facturi } } //preiau din baza de date string query = "SELECT ID_Camera,Tip_camera,Descriere_Facilitati,Nr_Locuri,Disponibilitate,Pret_camera FROM Camere WHERE Disponibilitate = 1;"; string connstring = "Data Source=(localDb)\\Databases;Initial Catalog=BD_Proiect;Integrated Security=True"; DataTable dt = new DataTable(); SqlDataAdapter adt = new SqlDataAdapter(query, connstring); adt.Fill(dt); dataGridView1.DataSource = dt; }