Ejemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Int32.Parse(textBox2.Text) < 50 && Int32.Parse(TextBox2.Text) < 100)
     {
         MessageBox.Show("Значение цены должно быть от 50 до 100", "Сообщение об ошибке!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         using (HotelEntities entities = new HotelEntities())
         {
             foreach (Room r in entities.Rooms)
             {
                 if (r.Number == Int32.Parse(textBox1.Text))
                 {
                     r.Price            = Single.Parse(textBox2.Text);
                     r.CountOfPlaces    = Int32.Parse(textBox3.Text);
                     r.CountOfPartRooms = Int32.Parse(TextBox5.Text);
                     r.Description      = textBox4.Text;
                     r.Statut           = comboBox2.SelectedText;
                     break;
                 }
             }
             entities.SaveChanges();
             MessageBox.Show("Редактирование данных завршено успешно!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Ejemplo n.º 2
0
        private void EditRooms_Load(object sender, EventArgs e)
        {
            roomList = new List <string[]>();
            SortedSet <string> setDescriptions = new SortedSet <string>();

            using (HotelEntities entities = new HotelEntities())
            {
                foreach (Room room in entities.Rooms)
                {
                    roomList.Add(new string[7]);
                    roomList[roomList.Count - 1][0] = room.Id.ToString();
                    roomList[roomList.Count - 1][1] = room.Category.ToString();
                    roomList[roomList.Count - 1][2] = room.Number.ToString();
                    roomList[roomList.Count - 1][3] = room.Price.ToString();
                    //roomList[roomList.Count - 1][0] = room.Id.ToString();
                    //roomList[roomList.Count - 1][1] = room.Category;
                    //roomList[roomList.Count - 1][2] = room.Number.ToString();
                    //roomList[roomList.Count - 1][3] = room.Price.ToString();
                    roomList[roomList.Count - 1][4] = room.CountOfPlaces.ToString();
                    roomList[roomList.Count - 1][5] = room.CountOfPartRooms.ToString();
                    roomList[roomList.Count - 1][6] = room.Statut.ToString();
                    setDescriptions.Add(room.Description);
                }
            }


            List <string> prescriptions = new List <string>();

            foreach (string[] s in roomList)
            {
                dataGridView1.Rows.Add(s);
            }
        }
Ejemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (HotelEntities entities = new HotelEntities())
     {
         foreach (User user in entities.Users)
         {
             if ((textBox1.Text == user.Username) && (textBox2.Text == user.Password))
             {
                 MessageBox.Show("Аутентификация пройдена!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 UserForm userForm = new UserForm();
                 userForm.ShowDialog();
                 break;
             }
             if ((textBox1.Text == user.Username) && (textBox2.Text != user.Password))
             {
                 MessageBox.Show("Неверный логин!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 break;
             }
             if ((textBox2.Text == user.Password) && (textBox1.Text != user.Username))
             {
                 MessageBox.Show("Неверный пароль!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 break;
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //if (comboBox1.SelectedText == "Апартаменты")
            //{
            //    label6.Visible = true;
            //    textBox5.Visible = true;
            //}
            if (Double.Parse(textBox2.Text) <= 0)
            {
                MessageBox.Show("Значение цены номера должно быть больше 0!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (Int32.Parse(textBox1.Text) <= 0)
            {
                MessageBox.Show("Значение номера должно быть больше 0!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (Int32.Parse(textBox3.Text) <= 0)
            {
                MessageBox.Show("Значение количества мест должно быть больше 0!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                if (Int32.Parse(textBox5.Text) <= 0)
                {
                    MessageBox.Show("Значение количества комнат должно быть больше 0!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Room room = new Room
                {
                    Category         = comboBox1.SelectedText,
                    Number           = Int32.Parse(textBox1.Text),
                    Price            = Single.Parse(textBox2.Text),
                    CountOfPlaces    = Int32.Parse(textBox3.Text),
                    Description      = textBox4.Text,
                    CountOfPartRooms = Int32.Parse(textBox5.Text),
                    Statut           = comboBox2.SelectedText,
                };

                HotelEntities h = new HotelEntities();
                h.Rooms.Add(room);
                h.SaveChanges();
                //string connectionString = "Data Source=COMPUTER\\SQLEXPRESS;Initial Catalog=Hotel;Integrated Security=True";
                //SqlConnection sqlConnection = new SqlConnection(connectionString);
                //sqlConnection.Open();
                //SqlCommand sqlCommand = new SqlCommand("Insert into Rooms[Category,Number,Price,CountOfPlaces,Description,CountOfPartRooms,Statut] VALUES (@category,@number,@price,@countOfPlaces,@description,@countOfPartOfRooms,@statut)");
                //sqlCommand.Parameters.AddWithValue("Category", room.Category);
                //sqlCommand.Parameters.AddWithValue("Number", room.Number);
                //sqlCommand.Parameters.AddWithValue("Price", room.Price);
                //sqlCommand.Parameters.AddWithValue("CountOfPlaces", room.CountOfPlaces);
                //sqlCommand.Parameters.AddWithValue("Description", room.Description);
                //sqlCommand.Parameters.AddWithValue("CountOfPartRooms", room.CountOfPartRooms);
                //sqlCommand.Parameters.AddWithValue("Statut", room.Statut);
                //sqlCommand.ExecuteNonQuery();

                MessageBox.Show("Информация о номере успешно добавлена!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 5
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dataGridView1.Rows[e.RowIndex].ToString();
            string c  = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            using (HotelEntities entities = new HotelEntities())
            {
                foreach (Room room in entities.Rooms)
                {
                    if (room.Id.ToString() == c)
                    {
                        richTextBox1.Text = room.Description.ToString();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void button3_Click(object sender, EventArgs e)
        {
            string c = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            using (HotelEntities entities = new HotelEntities())
            {
                foreach (Room r in entities.Rooms)
                {
                    if (r.Id.ToString() == c)
                    {
                        MessageBox.Show("Вы действительно хотите удалить эту путевку?", "Сообщение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        entities.Rooms.Remove(r);
                        break;
                    }
                }
                entities.SaveChanges();
            }
        }
Ejemplo n.º 7
0
        private void UserForm_Load(object sender, EventArgs e)
        {
            List <string[]> roomList = new List <string[]>();


            using (HotelEntities entities = new HotelEntities())
            {
                foreach (Room room in entities.Rooms)
                {
                    roomList.Add(new string[7]);
                    roomList[roomList.Count - 1][0] = room.Id.ToString();
                    roomList[roomList.Count - 1][1] = room.Category.ToString();
                    roomList[roomList.Count - 1][2] = room.Price.ToString();
                    richTextBox1.Text = room.Description;
                }
            }

            foreach (string[] s in roomList)
            {
                dataGridView1.Rows.Add(s);
            }
        }
Ejemplo n.º 8
0
        private void ViewUsers_Load(object sender, EventArgs e)
        {
            List <string[]> data = new List <string[]>();

            using (HotelEntities entities = new HotelEntities())
            {
                foreach (User u in entities.Users)
                {
                    data.Add(new string[6]);
                    data[data.Count - 1][0] = u.Id.ToString();
                    data[data.Count - 1][1] = u.Firstname.ToString();
                    data[data.Count - 1][2] = u.Lastname.ToString();
                    data[data.Count - 1][3] = u.Phone.ToString();
                    data[data.Count - 1][4] = u.Passport.ToString();
                }
            }

            foreach (string[] s in data)
            {
                dataGridView1.Rows.Add(s);
            }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Фамилия должна быть обязательно заполнена!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("Имя должно быть обязательно заполнено!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox3.Text.Length < 3)
            {
                MessageBox.Show("Малое значение длины телефона!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox3.Text == "")
            {
                MessageBox.Show("Телефолн должен быть обязательно заполнен!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (textBox4.Text == "")
            {
                MessageBox.Show("Имя пользователя должно быть обязательно заполнено!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox5.Text == "")
            {
                MessageBox.Show("Пароль должен быть обязательно заполнен!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox6.Text == "")
            {
                MessageBox.Show("Пароль должен быть обязательно подтвержден!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox5.Text != textBox6.Text)
            {
                MessageBox.Show("Не соотвествуют пароли!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox7.Text == "")
            {
                MessageBox.Show("Паспортные данные должны быть обязательно заполнены!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (textBox8.Text == "")
            {
                MessageBox.Show("Почта должна быть обязательно заполнена!", "Сообщение об ошибке", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                User user = new User
                {
                    //Id = Int32.Parse(textBox9.Text),
                    Lastname  = textBox1.Text,
                    Firstname = textBox2.Text,
                    Phone     = textBox3.Text,
                    E_mail    = textBox8.Text,
                    Passport  = textBox7.Text,
                    Username  = textBox4.Text,
                    Password  = textBox6.Text
                };


                //string connectionString = "Data Source=COMPUTER\\SQLEXPRESS;Initial Catalog=Pharmacy;Integrated Security=True";
                //SqlConnection sqlConnection = new SqlConnection(connectionString);
                //sqlConnection.Open();
                //SqlCommand sqlCommand = new SqlCommand("INSERT INTO Users (Id,Lastname,Firstname,Phone,[E-mail],Passport,Username,Password) VALUES (@id,@lName,@fName,@phone,@e_mail,@passport,@username,@password)", sqlConnection);
                //sqlCommand.Parameters.AddWithValue("id", user.Id);
                //sqlCommand.Parameters.AddWithValue("lName", user.Lastname);
                //sqlCommand.Parameters.AddWithValue("fName", user.Firstname);
                //sqlCommand.Parameters.AddWithValue("phone", user.Phone);
                //sqlCommand.Parameters.AddWithValue("e_mail", user.E_mail);
                //sqlCommand.Parameters.AddWithValue("passport", user.Passport);
                //sqlCommand.Parameters.AddWithValue("username", user.Username);
                //sqlCommand.Parameters.AddWithValue("password", user.Password);
                //sqlCommand.ExecuteNonQuery();


                using (HotelEntities entities = new HotelEntities())
                {
                    entities.Users.Add(user);
                    entities.SaveChanges();
                }

                MessageBox.Show("Регистрация завершена успешно!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }