Beispiel #1
0
        //methods
        void OpenRoomForm()
        {
            this.Hide();
            RoomForm roomForm = new RoomForm(room, guest, staff);

            roomForm.Show();
        }
Beispiel #2
0
        private void EditButton_Click(object sender, EventArgs e)
        {
            RoomForm form = new RoomForm();

            form.Text         = "Изменить номер";
            form.button1.Text = "Применить";

            form.Tag               = dataGridView.SelectedRows[0].Cells[0].Value.ToString();
            form.number.Value      = int.Parse(dataGridView.SelectedRows[0].Cells[1].Value.ToString());
            form.type.SelectedItem = dataGridView.SelectedRows[0].Cells[2].Value.ToString();
            form.places.Value      = int.Parse(dataGridView.SelectedRows[0].Cells[3].Value.ToString());

            if (form.ShowDialog() == DialogResult.OK)
            {
                using (var sql = new SqlConnection(Program.sql.ConnectionString))
                {
                    sql.Open();
                    var com = sql.CreateCommand();
                    com.CommandText = String.Format("update Номера set [Номер комнаты]='{0}',[Тип номера]='{1}'," +
                                                    "[Количество мест]='{2}' where Id={3}",
                                                    form.number.Value, form.type.SelectedItem, form.places.Value, form.Tag);
                    com.ExecuteNonQuery();
                    sql.Close();
                }
                RefreshDB();
                Owner.OwnedForms.OfType <IRefreshable>().ToList().ForEach(f => f.RefreshDB());
            }
        }
Beispiel #3
0
        //Обработка нажатия на кнопки
        private void AddBtn_Click(object sender, EventArgs e)
        {
            CreateGuest CreateGuestForm = new CreateGuest();
            RoomForm    CreateRoomForm  = new RoomForm();

            if (dataGridView1.Visible)
            {
                CreateGuestForm.Show();
            }

            if (dataGridView2.Visible)
            {
                CreateRoomForm.Show();
            }
        }
Beispiel #4
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            RoomForm form = new RoomForm();

            form.Text         = "Добавить номер";
            form.button1.Text = "Добавить";
            if (form.ShowDialog() == DialogResult.OK)
            {
                using (var sql = new SqlConnection(Program.sql.ConnectionString))
                {
                    sql.Open();
                    var com = sql.CreateCommand();
                    com.CommandText = String.Format("insert into Номера values('{0}','{1}','{2}')",
                                                    form.number.Value, form.type.SelectedItem, form.places.Value);
                    com.ExecuteNonQuery();
                    sql.Close();
                }
                RefreshDB();
                Owner.OwnedForms.OfType <IRefreshable>().ToList().ForEach(f => f.RefreshDB());
            }
        }
Beispiel #5
0
        public void createRoom()
        {
            string[] room = RoomForm.Create();

            string query = "INSERT INTO номер (`Номер`,`Состояние`,`Цена за ночь`,`Оценка номера`,`id_набора особенностей`) VALUES ('" + room[0] + "','" + room[1] + "','" + room[2] + "','" + room[3] + "','" + room[4] + "')";

            MySqlCommand command = new MySqlCommand(query, connection);

            command.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                connection.Open();
                reader = command.ExecuteReader();
                // Succesfully deleted
                connection.Close();
            }
            catch (Exception ex)
            {
                // Ops, maybe the id doesn't exists ?
                MessageBox.Show(ex.Message);
            }
        }