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++; } }
private void pb_Click(object sender, EventArgs e) { int idRoomImages = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select images_id from rooms_images where rooms_id = {0} and images_path = '{1}'", id, listOfStr[Convert.ToInt32((sender as PictureBox).Name)]))); int y = globalPBList.IndexOf(sender as PictureBox); PictureForm pf = new PictureForm(idRoomImages, (RoomChangeForm)Application.OpenForms[this.Name], false, y); pf.ShowDialog(); }
private void cmServices_DropDownClosed(object sender, EventArgs e) { if (isNew) { price = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select price_of_service from services where service_name = '{0}'", (cmServices.Text).ToString()))); tbPrice.Text = (price * nudAmount.Value).ToString(); Application.OpenForms["BillForm"].Controls["tbSum"].Text = (priceA + Convert.ToInt32(tbPrice.Text.ToString())).ToString(); } }
public void TakeQueryList() { foreach (AddServices items in flpServces.Controls) { int servId = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select service_id from services where service_name = '{0}'", items.cmServices.Text.ToString()))); ConectionDB.Connection(String.Format("insert into bill (service_id, amount, summa, main_bill_id) values ({0}, {1}, {2}, {3})", servId, items.nudAmount.Value, Convert.ToInt32(items.tbPrice.Text.ToString()), id)); } }
private void FillFields(int id) { labelType.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)); labelFloor.Text += ConectionDB.ReturnResultLikeString(String.Format("select floor_of_room from hotel_room where room_id = {0}", id)); labelNum.Text += ConectionDB.ReturnResultLikeString(String.Format("select number_of_room from hotel_room where room_id = {0}", id)); labelSleep.Text += ConectionDB.ReturnResultLikeString(String.Format("select amount_of_sleeppoint from hotel_room where room_id = {0}", id)) + ", " + 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)); ConectionDB.Connection("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 = " + id.ToString() + "))", lbFreeServices); ShowImages(); }
private void btCreate_Click(object sender, EventArgs e) { if (InformationClass.queryNew != "") { InformationClass.clientId = Convert.ToInt32(ConectionDB.ReturnResultLikeString(InformationClass.queryNew)); } ConectionDB.Connection(String.Format("insert into card_of_registration (clients_id, room_id, data_set, data_out, type_pay_id) values ({0}, {1}, '{2}', '{3}', {4})", InformationClass.clientId, InformationClass.roomId, InformationClass.start.ToShortDateString(), InformationClass.finish.ToShortDateString(), ConectionDB.ReturnResultLikeString(String.Format("select type_id from type_of_pay where name_type = '{0}'", cmPay.Text.ToString())))); ConectionDB.Connection(String.Format("insert into final_bill (clients_id, number_of_days, final_summa, room_id) values ({0}, {1}, {2}, {3})", InformationClass.clientId, Convert.ToInt32(lbDays.Text), Convert.ToInt32(lbSum.Text), InformationClass.roomId)); this.Close(); }
public TypeRoom(int _id, MainForm _owner) { InitializeComponent(); owner = _owner; id = _id; if (id != 0) { cmType.Text = ConectionDB.ReturnResultLikeString(String.Format("select type_of_number.type from type_of_number where type_id = {0}", id)); tbPrice.Text = ConectionDB.ReturnResultLikeString(String.Format("select price from type_of_number where type_id = {0}", id)); } }
public ServicesForm(int _id, MainForm _owner) { InitializeComponent(); id = _id; owner = _owner; label7.Text = "Изменить"; if (id != 0) { tbName.Text = ConectionDB.ReturnResultLikeString(String.Format("select service_name from services where service_id = {0}", id)); tbPrice.Text = ConectionDB.ReturnResultLikeString(String.Format("select price_of_service from services where service_id = {0}", id)); } isNew = false; }
private string GetQueryLikeStringAnd(CheckedListBox _object) { string r = ""; List <string> listOfAnswers = new List <string>(); string finalString = "and room_id in (select room_id from rooms_services group by room_id having"; foreach (var item in _object.CheckedItems) { listOfAnswers.Add(((DataRowView)item)[1].ToString()); r = ConectionDB.ReturnResultLikeString("select service_id from list_of_free_services where name_services = '" + listOfAnswers.Last() + "'"); finalString += " sum(case when service_id = " + Convert.ToInt32(r) + " then 1 else 0 end)>0 and"; } finalString = finalString.Remove(finalString.Length - 4); finalString += ")"; return(finalString); }
public ClientsChangeForm(int _id, MainForm _owner) { id = _id; newClient = false; owner = _owner; InitializeComponent(); if (id != 0) { tbSurname.Text = ConectionDB.ReturnResultLikeString(String.Format("select surname from clients where clients_id = {0}", id)); tbFirstName.Text = ConectionDB.ReturnResultLikeString(String.Format("select first_name from clients where clients_id = {0}", id)); tbLastName.Text = ConectionDB.ReturnResultLikeString(String.Format("select last_name from clients where clients_id = {0}", id)); rtbIdentify.Text = ConectionDB.ReturnResultLikeString(String.Format("select identify from clients where clients_id = {0}", id)); tbEmail.Text = ConectionDB.ReturnResultLikeString(String.Format("select email from clients where clients_id = {0}", id)); tbPhone.Text = ConectionDB.ReturnResultLikeString(String.Format("select phone from clients where clients_id = {0}", id)); } }
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)); } } }
public AddServices(int _id, bool _isNew) { InitializeComponent(); id = _id; isNew = _isNew; if (!isNew) { ConectionDB.ConnectionSecondCMB(String.Format("select service_name from services where service_id = (select service_id from bill where bill_id = {0})", id), cmServices); tbPrice.Text = ConectionDB.ReturnResultLikeString(String.Format("select summa from bill where bill_id = {0}", id)); nudAmount.Value = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select amount from bill where bill_id = {0}", id))); cmServices.Enabled = false; tbPrice.Enabled = false; nudAmount.Enabled = false; btDelete.Visible = false; } else { FillFields(); priceA = Convert.ToInt32(Application.OpenForms["BillForm"].Controls["tbSum"].Text.ToString()); } }
public FinalFormBill(int _roomId) { InitializeComponent(); clientId = InformationClass.clientId; roomId = _roomId; if (InformationClass.queryNew == "") { lbClient.Text = " " + ConectionDB.ReturnResultLikeString(String.Format("select surname from clients where clients_id = {0}", clientId)) + " " + ConectionDB.ReturnResultLikeString(String.Format("select first_name from clients where clients_id = {0}", clientId)); } else { lbClient.Text = " " + InformationClass.surname + " " + InformationClass.firstName; } lbDays.Text = " " + (InformationClass.finish - InformationClass.start).TotalDays.ToString(); lbFrom.Text = " " + InformationClass.start.ToShortDateString().ToString(); lbTo.Text = " " + InformationClass.finish.ToShortDateString().ToString(); lbRoom.Text = " " + ConectionDB.ReturnResultLikeString(String.Format("select number_of_room from hotel_room where room_id = {0}", roomId)); lbType.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})", roomId)); lbSum.Text = " " + Convert.ToInt32(Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select price from type_of_number where type_id = (select type_id from hotel_room where room_id = {0})", roomId))) * Convert.ToInt32(lbDays.Text.ToString())).ToString(); ConectionDB.ConnectionSecondCMB("select name_type from type_of_pay", cmPay); }
private void btChange_Click(object sender, EventArgs e) { int buf = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select type_id from type_of_number where type_of_number.type = '{0}'", cmType.Text.ToString()))); int bufBed = Convert.ToInt32(ConectionDB.ReturnResultLikeString(String.Format("select type_id from type_of_bed where name_type = '{0}'", cbBed.Text.ToString()))); ConectionDB.Connection(String.Format("update hotel_room set type_id = '{0}', number_of_room ='{1}', amount_of_sleeppoint = '{2}', floor_of_room = '{3}', type_of_bed_id = {5} where room_id = {4}", buf, tbNum.Text, nudSleepPoint.Value, nupFloor.Value, id, bufBed)); try { int count = 0; foreach (var item in listOfPB) { Image oldImg = item.Image; // save to a memorystream MemoryStream ms = new MemoryStream(); oldImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // dispose old image oldImg.Dispose(); // save new image to same filename Image newImage = Image.FromStream(ms); newImage.Save(appPath + listOfPaths[count]); //item.Image.Save(appPath + listOfPaths[count], System.Drawing.Imaging.ImageFormat.Jpeg); ConectionDB.Connection(String.Format("insert into rooms_images (rooms_id, images_path) values ({0}, '{1}')", id, listOfPaths[count])); count++; } } catch { MessageBox.Show("Невозможно сохранить изображение", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }