public RoomChangeForm(int _id, MainForm _owner) { id = _id; InitializeComponent(); owner = _owner; if (id != 0) { ConectionDB.Connection("select type_id, price, type_of_number.type from type_of_number ", cmType); cmType.Text = ConectionDB.ReturnResultLikeString(String.Format("select type_of_number.type from type_of_number where type_id = (select type_id from hotel_room where room_id = {0})", id)); tbNum.Text = ConectionDB.ReturnResultLikeString(String.Format("select number_of_room from hotel_room where room_id = {0}", id)); nudSleepPoint.Value = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select amount_of_sleeppoint from hotel_room where room_id = {0}", id))); nupFloor.Value = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select floor_of_room from hotel_room where room_id = {0}", id))); ConectionDB.ConnectionSecondCMB("select name_type from type_of_bed", cbBed); cmType.Text = ConectionDB.ReturnResultLikeString(String.Format("select name_type from type_of_bed where type_id = (select type_of_bed_id from hotel_room where room_id = {0})", id)); } string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\"; DataTable result = ConectionDB.ReturnResult(String.Format("select images_path from rooms_images where rooms_id={0}", id)); int y = result.Rows.Count; foreach (DataRow item in result.Rows) { listOfStr.Add(item[0].ToString()); PictureBox pb = new PictureBox(); pb.Name = count.ToString(); pb.SizeMode = PictureBoxSizeMode.Zoom; pb.Image = new Bitmap(appPath + listOfStr.Last()); flpPhotos.Controls.Add(pb); globalPBList.Add(pb); pb.Click += new EventHandler(pb_Click); count++; } }
public void FillField(int id) { tbClient.Text = ConectionDB.ReturnResultLikeString(String.Format("select surname from clients where clients_id = (select clients_id from final_bill where final_bill_id = {0})", id)) + " " + ConectionDB.ReturnResultLikeString(String.Format("select first_name from clients where clients_id = (select clients_id from final_bill where final_bill_id = {0})", id)); tbDays.Text = ConectionDB.ReturnResultLikeString(String.Format("select number_of_days from final_bill where final_bill_id = {0}", id)); tbRoom.Text = ConectionDB.ReturnResultLikeString(String.Format("select number_of_room from hotel_room where room_id = (select room_id from final_bill where final_bill_id = {0})", id)); tbSum.Text = ConectionDB.ReturnResultLikeString(String.Format("select final_summa from final_bill where final_bill_id = {0}", id)); if (Convert.ToInt32((ConectionDB.ReturnResultLikeString(String.Format("select count(*) from bill where main_bill_id = {0}", id)))) > 0) { DataTable result = ConectionDB.ReturnResult(String.Format("select bill_id from bill where main_bill_id={0}", id)); foreach (DataRow item in result.Rows) { flpServces.Controls.Add(new AddServices(Convert.ToInt32(item[0]), false)); } } }
private void ShowImages() { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\"; List <string> listOfStr = new List <string>(); DataTable result = ConectionDB.ReturnResult(String.Format("select images_path from rooms_images where rooms_id={0}", id)); int y = result.Rows.Count; foreach (DataRow item in result.Rows) { listOfStr.Add(item[0].ToString()); PictureBox pb = new PictureBox(); pb.SizeMode = PictureBoxSizeMode.Zoom; pb.Image = new Bitmap(appPath + listOfStr.Last()); flpPicturesBox.Controls.Add(pb); pb.Click += new EventHandler(pb_Click); } }
private void cbNumber_SelectedValueChanged(object sender, EventArgs e) { ClearCheckedItems(); if (!isFirstSelection) { List <string> ds = new List <string>(); DataTable result = ConectionDB.ReturnResult("select name_services from list_of_free_services where service_id in (select service_id from rooms_services where id in (select id from rooms_services where room_id = (select room_id from hotel_room where number_of_room = '" + cbNumber.Text + "')))"); int y = result.Rows.Count; foreach (DataRow item in result.Rows) { ds.Add(item[0].ToString()); if (listOfString.Contains(ds.Last())) { clbFreeServices.SetItemChecked(listOfString.IndexOf(ds.Last()), true); } } isFirstSelection = false; } else { isFirstSelection = false; } }
private void btChange_Click(object sender, EventArgs e) { ConectionDB.Connection("Delete from rooms_services where room_id = (select room_id from hotel_room where number_of_room = '" + cbNumber.Text + "');"); for (int i = 0; i < clbFreeServices.Items.Count; i++) { if (clbFreeServices.GetItemChecked(i)) { ConectionDB.Connection("Insert into rooms_services (room_id, service_id) values (" + ConectionDB.ReturnResult("select room_id from hotel_room where number_of_room = '" + cbNumber.Text + "';").Rows[0]["room_id"].ToString() + ", " + (i + 1) + ")"); } } }