private void Rooms_Click(object sender, EventArgs e) { Form form = OwnedForms.FirstOrDefault(f => f is Rooms); if (form != null) { form.WindowState = FormWindowState.Normal; form.Activate(); return; } form = new Rooms(); form.Show(this); }
private void Save_btn_Click(object sender, EventArgs e) { sql.Open(); string check_name = "UPDATE AdditionalService SET Name = '" + Convert.ToString(Name_tb.Text) + "', Description = '" + Convert.ToString(Description_tb.Text) + "', Price = " + Convert.ToDouble(Price_tb.Text) + " WHERE AdditionalServiceID LIKE " + ID + ""; SQLiteCommand check = new SQLiteCommand(check_name, sql); check.ExecuteNonQuery(); sql.Close(); if (MessageBox.Show("Изменения были успешно сохранены!") == DialogResult.OK) { this.Close(); Rooms room = new Rooms(); room.Show(); } }
private void roomsToolStripMenuItem_Click(object sender, EventArgs e) { if (rm == null) { rm = new Rooms(); rm.MdiParent = this; rm.Dock = DockStyle.Fill; rm.Show(); } else { rm.Show(); rm.Activate(); } }
private void SaveBtn_Click(object sender, EventArgs e) { string c = " "; sql.Open(); string sql_request = "SELECT Name FROM Room WHERE Name ='" + Nametb.Text + "' "; SQLiteCommand add = new SQLiteCommand(sql_request, sql); add.ExecuteNonQuery(); SQLiteDataReader reader = add.ExecuteReader(); while (reader.Read()) { c = reader[0] + ""; } sql.Close(); if (Nametb.Text.Trim() == c) { MessageBox.Show("Номер с таким именем уже существует!"); } else { var stop_array = new[] { ".", ",", ";", ":", "?", "!", "<", ">", "-", "=" }; if ((Nametb.Text.Equals("")) || (Descriptioncmb.Text.Equals("")) || (PricemaskedTextBox.Text.Equals("")) || (Typecmbb.Text.Equals(""))) { MessageBox.Show("Одно или несколько полей не заполнены"); } else { var flag = true; if (Nametb.Text != "") { foreach (string t in stop_array) { if (Nametb.Text.Contains(t)) { flag = false; break; } } if (flag == false) { MessageBox.Show("Название номера введено не верно!"); } if (flag == true) { sql.Open(); string check_name = @"UPDATE Room SET Name = '" + Convert.ToString(Nametb.Text) + "', Description = '" + Convert.ToString(Descriptioncmb.Text) + "', Price = '" + Convert.ToDouble(PricemaskedTextBox.Text) + "', TypeName = '" + Convert.ToString(Typecmbb.Text) + "' WHERE Name LIKE '" + Current_Name + "'"; SQLiteCommand check = new SQLiteCommand(check_name, sql); check.ExecuteNonQuery(); sql.Close(); if (MessageBox.Show("Изменения были успешно сохранены!") == DialogResult.OK) { this.Close(); Rooms room = new Rooms(); room.Show(); } sql.Close(); } } } } }
private void BackBtn_Click(object sender, EventArgs e) { Hide(); //Rooms rm = new Rooms(); rm.Show(); }
private void SaveBtn_Click(object sender, EventArgs e) { string c = " "; sql.Open(); string sql_request = "SELECT Name FROM Room WHERE Name ='" + NametextBox.Text + "' "; SQLiteCommand add = new SQLiteCommand(sql_request, sql); add.ExecuteNonQuery(); SQLiteDataReader reader = add.ExecuteReader(); while (reader.Read()) { c = reader[0] + ""; } sql.Close(); if (NametextBox.Text.Trim() == c) { MessageBox.Show("Номер с таким именем уже существует!"); } else { var stop_array = new[] { ".", ",", ";", ":", "?", "!", "<", ">", "-", "=" }; if ((NametextBox.Text.Equals("")) || (Descriptioncmb.Text.Equals("")) || (PricemaskedTextBox.Text.Equals("")) || (Typecmbb.Text.Equals(""))) { MessageBox.Show("Одно или несколько полей не заполнены"); } else { var flag = true; if (NametextBox.Text != "") { foreach (string t in stop_array) { if (NametextBox.Text.Contains(t)) { flag = false; break; } } if (flag == false) { MessageBox.Show("Название номера введено не верно!"); } if (flag == true) { sql.Open(); SQLiteCommand sqlcon = new SQLiteCommand(sql); sqlcon.CommandText = @"insert into room(roomID, Name, Description, Status, Price, TypeName) values(null, '" + Convert.ToString(NametextBox.Text) + "', '" + Convert.ToString(Descriptioncmb.Text) + "', 'свободен','" + Convert.ToDouble(PricemaskedTextBox.Text) + "', '" + Convert.ToString(Typecmbb.Text) + "');"; SQLiteDataReader srd = sqlcon.ExecuteReader(); MessageBox.Show("Номер добавлен"); sql.Close(); Close(); Rooms r = new Rooms(); r.Show(); } } } } }