Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region Провера ошибок
            if (MainForm.Login == "")
            {
                MessageBox.Show("Вы не авторизованы");
                return;
            }

            DateTime dt = dateTimePicker1.Value;
            while (dt <= dateTimePicker2.Value.AddDays(0.5))
            {
                List <string> existBooking = SQLClass.Select("SELECT COUNT(*) FROM booking " +
                                                             "WHERE dateFrom <= '" + dt.ToString("yyyy-MM-dd") + "'" +
                                                             "AND dateTo >= '" + dt.ToString("yyyy-MM-dd") + "'");

                if (Convert.ToInt32(existBooking[0]) >= qty)
                {
                    MessageBox.Show("Все забронировано. Выберите другие даты!");
                    return;
                }

                dt = dt.AddDays(1);
            }
            #endregion

            SQLClass.Update("INSERT INTO booking(user, datefrom, dateto, room_id) VALUES(" +
                            "'" + MainForm.Login + "', " +
                            "'" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "'," +
                            "'" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "'," +
                            id + ")");
            MessageBox.Show("Успешно");
        }
Beispiel #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            #region Проверка ошибок
            if (LoginTextBox.Text == "")
            {
                return;
            }

            List <string> existUser = SQLClass.Select(
                "SELECT * FROM users WHERE login = '******'");
            if (existUser.Count > 0)
            {
                MessageBox.Show("Пользователь с таким логином существует");
                return;
            }
            #endregion

            SQLClass.Update("UPDATE users SET" +
                            " name = '" + textBox2.Text + "'," +
                            " city = '" + CityComboBox.Text + "'," +
                            " age = '" + textBox1.Text + "'," +
                            " login = '******'," +
                            " password = '******'" +
                            " WHERE login = '******'");

            SQLClass.Update("UPDATE booking SET" +
                            " user = '******'" +
                            " WHERE user = '******'");

            SQLClass.Update("UPDATE rating SET" +
                            " user = '******'" +
                            " WHERE user = '******'");

            MainForm.Login = LoginTextBox.Text;
        }
Beispiel #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            List <string> cities = SQLClass.Select(
                "SELECT DISTINCT name FROM " + SQLClass.CITIES + " ORDER BY name");

            foreach (string city in cities)
            {
                TreeNode node = new TreeNode(city);
                treeView1.Nodes[0].Nodes.Add(node);


                List <string> hotels = SQLClass.Select(
                    "SELECT DISTINCT name, id FROM " + SQLClass.HOTELS +
                    " WHERE city='" + node.Text + "' ORDER BY name");
                for (int i = 0; i < hotels.Count; i += 2)
                {
                    TreeNode node2 = new TreeNode(hotels[i]);
                    node2.Tag = hotels[i + 1];
                    node.Nodes.Add(node2);

                    List <string> rooms = SQLClass.Select(
                        "SELECT DISTINCT name, id FROM " + SQLClass.ROOM +
                        " WHERE hotel_id='" + node2.Tag.ToString() + "' ORDER BY name");
                    for (int j = 0; j < rooms.Count; j += 2)
                    {
                        TreeNode node3 = new TreeNode(rooms[j]);
                        node3.Tag = rooms[j + 1];
                        node2.Nodes.Add(node3);
                    }
                }
            }

            Admin.AdminDesignForm.ApplyDesign(this);
            Admin.AdminDesignForm.ApplyMenu(this);
        }
Beispiel #4
0
        public HotelList(/*string City = ""*/)
        {
            InitializeComponent();

            List <string> cities = SQLClass.Select(
                "SELECT DISTINCT Name FROM cities ORDER BY Name");

            CityComboBox.Items.Clear();
            CityComboBox.Items.Add("");
            foreach (string city in cities)
            {
                CityComboBox.Items.Add(city);
            }

            //Ищем город

            /*for (int i = 0; i < CityComboBox.Items.Count; i++)
             * {
             *  if (CityComboBox.Items[i].ToString() == City)
             *  {
             *      CityComboBox.SelectedIndex = i;
             *  }
             * }*/

            Filter(null, null);
        }
Beispiel #5
0
        public AccountForm()
        {
            InitializeComponent();

            List <string> cities = SQLClass.Select("SELECT DISTINCT Name FROM cities ORDER BY Name");

            CityComboBox.Items.Clear();
            CityComboBox.Items.Add("");
            foreach (string city in cities)
            {
                CityComboBox.Items.Add(city);
            }

            List <string> user_data = SQLClass.Select("SELECT login, name, city, age, password FROM users" +
                                                      " WHERE login = '******'");

            if (user_data.Count > 0)
            {
                LoginTextBox.Text    = user_data[0];
                textBox2.Text        = user_data[1];
                textBox1.Text        = user_data[3];
                PasswordTextBox.Text = user_data[4];

                //Выбор города
                for (int i = 0; i < CityComboBox.Items.Count; i++)
                {
                    if (CityComboBox.Items[i].ToString() == user_data[2])
                    {
                        CityComboBox.SelectedIndex = i;
                    }
                }
            }
        }
Beispiel #6
0
        public AdminRoomsForm()
        {
            InitializeComponent();

            List <string> hotels_list = SQLClass.Select("SELECT Name, city, id FROM " + SQLClass.HOTELS);

            comboBox1.Items.Clear();
            for (int i = 0; i < hotels_list.Count; i += 3)
            {
                comboBox1.Items.Add(hotels_list[i] + /*" " + hotels_list[i + 1] +*/ " (" + hotels_list[i + 2] + ")");
            }
        }
Beispiel #7
0
        public RegisterForm()
        {
            InitializeComponent();

            List <string> cities = SQLClass.Select("SELECT DISTINCT Name FROM cities ORDER BY Name");

            CityComboBox.Items.Clear();
            CityComboBox.Items.Add("");
            foreach (string city in cities)
            {
                CityComboBox.Items.Add(city);
            }
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            panel2.Controls.Clear();

            string command = "SELECT Login, Name, City, Age FROM Users WHERE 1";

            if (CityComboBox.Text != "")
            {
                command += " AND city= '" + CityComboBox.Text + "'";
            }
            if (AgeTextBox.Text != "")
            {
                command += " AND age >= " + AgeTextBox.Text;
            }

            command += " ORDER BY Login";

            List <string> users = SQLClass.Select(command);

            int y = 0;

            for (int i = 0; i < users.Count; i += 4)
            {
                Label lbl = new Label();
                lbl.Location = new Point(0, y);
                lbl.Size     = new Size(100, 30);
                lbl.Text     = users[i];
                panel2.Controls.Add(lbl);

                Label lbl2 = new Label();
                lbl2.Location = new Point(100, y);
                lbl2.Size     = new Size(100, 30);
                lbl2.Text     = users[i + 1];
                panel2.Controls.Add(lbl2);

                Label lbl3 = new Label();
                lbl3.Location = new Point(200, y);
                lbl3.Size     = new Size(100, 30);
                lbl3.Text     = users[i + 2];
                panel2.Controls.Add(lbl3);

                Label lbl4 = new Label();
                lbl4.Location = new Point(300, y);
                lbl4.Size     = new Size(100, 30);
                lbl4.Text     = users[i + 3];
                panel2.Controls.Add(lbl4);

                y += 30;
            }
        }
Beispiel #9
0
        public AdminUsersForm()
        {
            InitializeComponent();

            List <string> cities = SQLClass.Select("SELECT DISTINCT Name FROM cities ORDER BY Name");

            CityComboBox.Items.Clear();
            CityComboBox.Items.Add("");
            foreach (string city in cities)
            {
                CityComboBox.Items.Add(city);
            }

            button1_Click(null, null);
        }
Beispiel #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            List <string> exist = SQLClass.Select("SELECT Login FROM users WHERE login = '******'");

            if (exist.Count > 0)
            {
                MessageBox.Show("Вы уже зарегистрированы");
            }
            else
            {
                SQLClass.Update("INSERT INTO users(login, password, name, age, city) VALUES(" +
                                "'" + LoginTextBox.Text + "'," +
                                "'" + PasswordTextBox.Text + "'," +
                                "'" + textBox1.Text + "'," +
                                "'" + textBox2.Text + "'," +
                                "'" + CityComboBox.Text + "')");
            }
        }
Beispiel #11
0
        /// <summary>
        /// ФИльтр
        /// </summary>
        private void Filter(object sender, EventArgs e)
        {
            HotelsPanel.Controls.Clear();
            string command = "SELECT id, Name, City, Image, Rating FROM  " + SQLClass.HOTELS + "  WHERE 1";

            if (CityComboBox.Text != "")
            {
                command += " AND city = '" + CityComboBox.Text + "'";
            }
            if (RatingComboBox.Text != "")
            {
                command += " AND Rating >= " + RatingComboBox.Text;
            }

            List <string> hotels = SQLClass.Select(command);

            int x = 15;

            for (int i = 0; i < hotels.Count; i += 5)
            {
                PictureBox pb = new PictureBox();
                try
                {
                    pb.Load("../../Pictures/" + hotels[i + 3]);
                }
                catch (Exception) { }
                pb.Location = new Point(x, 10);
                pb.Size     = new Size(190, 120);
                pb.SizeMode = PictureBoxSizeMode.StretchImage;
                pb.Tag      = hotels[i];
                pb.Click   += new EventHandler(pictureBox1_Click);
                HotelsPanel.Controls.Add(pb);

                Label lbl = new Label();
                lbl.Location = new Point(x, 140);
                lbl.Size     = new Size(200, 30);
                lbl.Text     = hotels[i + 1];
                lbl.Tag      = hotels[i];
                lbl.Click   += new EventHandler(label4_Click);
                HotelsPanel.Controls.Add(lbl);

                x += 205;
            }
        }
Beispiel #12
0
        public RoomForm(string RoomId)
        {
            id = RoomId;

            InitializeComponent();

            List <string> room_data = SQLClass.Select(
                "SELECT hotel, name, price, image, quantity FROM room WHERE id = " + RoomId);

            Text        = room_data[0] + ": " + room_data[1];
            qty         = Convert.ToInt32(room_data[4]);
            label2.Text = room_data[1];
            label4.Text = room_data[0];
            label6.Text = room_data[2];

            try
            {
                pictureBox1.Load("../../Pictures/" + room_data[3]);
            }
            catch (Exception) { }
        }
Beispiel #13
0
        private void AdminRoomsForm_Load(object sender, EventArgs e)
        {
            List <string> rooms_list = SQLClass.Select("SELECT Name, hotel, price, id FROM room");

            panel2.Controls.Clear();
            int y = 15;

            for (int i = 0; i < rooms_list.Count; i += 4)
            {
                Label lbl = new Label();
                lbl.Location = new Point(0, y);
                lbl.Size     = new Size(200, 30);
                lbl.Text     = rooms_list[i];
                lbl.Tag      = rooms_list[i + 3];
                panel2.Controls.Add(lbl);

                Label lbl2 = new Label();
                lbl2.Location = new Point(200, y);
                lbl2.Size     = new Size(200, 30);
                lbl2.Text     = rooms_list[i + 1];
                panel2.Controls.Add(lbl2);

                Label lbl3 = new Label();
                lbl3.Location = new Point(400, y);
                lbl3.Size     = new Size(100, 30);
                lbl3.Text     = rooms_list[i + 2];
                panel2.Controls.Add(lbl3);

                Button btn = new Button();
                btn.Text     = "Удалить";
                btn.Location = new Point(500, y);
                btn.Size     = new Size(100, 30);
                btn.Click   += new EventHandler(DeleteRoom);
                panel2.Controls.Add(btn);

                y += 30;
            }
        }
Beispiel #14
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            HotelList hotelList = new HotelList();

            hotelList.Dock = DockStyle.Fill;
            panel1.Controls.Clear();
            panel1.Controls.Add(hotelList);


            List <string> cities = SQLClass.Select("SELECT DISTINCT name FROM cities ORDER BY name");

            foreach (string city in cities)
            {
                TreeNode node = new TreeNode(city);
                treeView1.Nodes[0].Nodes.Add(node);


                List <string> hotels = SQLClass.Select(
                    "SELECT DISTINCT name, id FROM hotels" +
                    " WHERE city='" + node.Text + "' ORDER BY name");
                for (int i = 0; i < hotels.Count; i += 2)
                {
                    TreeNode node2 = new TreeNode(hotels[i]);
                    node2.Tag = hotels[i + 1];
                    node.Nodes.Add(node2);

                    List <string> rooms = SQLClass.Select(
                        "SELECT DISTINCT name, id FROM room" +
                        " WHERE hotel_id='" + node2.Tag.ToString() + "' ORDER BY name");
                    for (int j = 0; j < rooms.Count; j += 2)
                    {
                        TreeNode node3 = new TreeNode(rooms[j]);
                        node3.Tag = rooms[j + 1];
                        node2.Nodes.Add(node3);
                    }
                }
            }
        }
Beispiel #15
0
        private void AdminHotelsForm_Load(object sender, EventArgs e)
        {
            List <string> hotels_list = SQLClass.Select("SELECT Name, City, Rating FROM " + SQLClass.HOTELS);

            panel2.Controls.Clear();
            int y = 15;

            for (int i = 0; i < hotels_list.Count; i += 3)
            {
                Label lbl = new Label();
                lbl.Location = new Point(0, y);
                lbl.Size     = new Size(200, 30);
                lbl.Text     = hotels_list[i];
                panel2.Controls.Add(lbl);

                Label lbl2 = new Label();
                lbl2.Location = new Point(200, y);
                lbl2.Size     = new Size(100, 30);
                lbl2.Text     = hotels_list[i + 1];
                panel2.Controls.Add(lbl2);

                Label lbl3 = new Label();
                lbl3.Location = new Point(300, y);
                lbl3.Size     = new Size(100, 30);
                lbl3.Text     = hotels_list[i + 2];
                panel2.Controls.Add(lbl3);

                Button btn = new Button();
                btn.Text     = "Удалить";
                btn.Location = new Point(400, y);
                btn.Size     = new Size(100, 30);
                btn.Click   += new EventHandler(DeleteHotel);
                panel2.Controls.Add(btn);

                y += 30;
            }
        }
Beispiel #16
0
        private void LoginClick(object sender, EventArgs e)
        {
            //Вход
            if (Login == "")
            {
                List <string> user_data = SQLClass.Select(
                    "SELECT admin FROM " + SQLClass.USERS + " WHERE Login = '******' AND Password = '******'");

                //Авторизация успешна
                if (user_data.Count > 0)
                {
                    //Глобальные переменные
                    Login   = LoginTextBox.Text;
                    IsAdmin = (user_data[0] == "1");

                    //Компоненты на форме
                    AuthPanel.Controls.Clear();

                    AuthPanel.Controls.Add(ValuteComboBox);
                    AuthPanel.Controls.Add(HelloLabel);
                    HelloLabel.Text = "Привет, " + Login;

                    AuthPanel.Controls.Add(LoginButton);
                    LoginButton.Text = "Выход";

                    AuthPanel.Controls.Add(AccountButton);
                    AuthPanel.Controls.Add(buttonDefaultDesign);
                    AccountButton.Visible = true;
                    Admin.AdminDesignForm.ApplyDesign(this);
                    Admin.AdminDesignForm.ApplyMenu(this);
                }
                else
                {
                    user_data = SQLClass.Select(
                        "SELECT * FROM " + SQLClass.USERS + " WHERE Login = '******'");

                    if (user_data.Count > 0)
                    {
                        MessageBox.Show("Неправильный пароль");
                    }
                    else
                    {
                        MessageBox.Show("Вы не зарегистрированы");
                    }
                }
            }
            //Выход
            else
            {
                //Глобальные переменные
                Login   = "";
                IsAdmin = false;

                //Компоненты на форме
                AuthPanel.Controls.Clear();
                AuthPanel.Controls.Add(LoginLabel);
                AuthPanel.Controls.Add(LoginTextBox);
                AuthPanel.Controls.Add(PasswordLabel);
                AuthPanel.Controls.Add(PasswordTextBox);
                AuthPanel.Controls.Add(ValuteComboBox);
                AuthPanel.Controls.Add(LoginButton);
                AuthPanel.Controls.Add(buttonDefaultDesign);
                LoginButton.Text = "Вход";
                Admin.AdminDesignForm.ApplyDesign(this);
                Admin.AdminDesignForm.ApplyMenu(this);
            }
        }
Beispiel #17
0
        public HotelForm(string hotel_id)
        {
            InitializeComponent();

            #region Видимость админских компонент
            OpinionPanel.Visible = (MainForm.Login != "");
            button1.Visible      = MainForm.IsAdmin;
            textBox2.ReadOnly    = !MainForm.IsAdmin;
            textBox2.Enabled     = MainForm.IsAdmin;
            textBox3.ReadOnly    = !MainForm.IsAdmin;
            textBox3.Enabled     = MainForm.IsAdmin;
            #endregion


            List <string> hotels = SQLClass.Select(
                "SELECT Name, City, Image, Rating, id, description FROM " + SQLClass.HOTELS +
                " WHERE id = '" + hotel_id + "'");

            HotelName = hotels[0];
            id        = hotel_id;
            try
            {
                pictureBox1.Load("../../Pictures/" + hotels[2]);
            }
            catch (Exception) { }

            Text          = hotels[0];
            textBox2.Text = hotels[0];
            textBox3.Text = hotels[5];

            #region  исование звезд
            int x = 275;
            for (int i = 0; i < Convert.ToInt32(hotels[3]); i++)
            {
                PictureBox box = new PictureBox();
                box.Location = new Point(x, 80);
                box.Load("../../Pictures/star.png");
                box.Size     = new Size(33, 33);
                box.SizeMode = PictureBoxSizeMode.StretchImage;
                InfoPanel.Controls.Add(box);
                x += 40;
            }
            #endregion

            #region Номера
            List <string> rooms = SQLClass.Select("SELECT id, name, price, image, quantity FROM room WHERE hotel_id = " + id);

            x = 15;
            HotelsPanel.Controls.Clear();
            for (int i = 0; i < rooms.Count; i += 5)
            {
                PictureBox pb = new PictureBox();
                try
                {
                    pb.Load("../../Pictures/" + rooms[i + 3]);
                }
                catch (Exception) { }
                pb.Location = new Point(x, 10);
                pb.Size     = new Size(190, 120);
                pb.SizeMode = PictureBoxSizeMode.StretchImage;
                pb.Tag      = rooms[i];
                pb.Click   += new EventHandler(pictureBox7_Click);
                HotelsPanel.Controls.Add(pb);

                Label lbl = new Label();
                lbl.Font     = new Font("Arial", 10);
                lbl.Location = new Point(x, 140);
                lbl.Size     = new Size(200, 30);
                lbl.Text     = rooms[i + 1] + " (" + rooms[i + 2] + ")";
                lbl.Tag      = rooms[i];
                lbl.Click   += new EventHandler(label3_Click);
                HotelsPanel.Controls.Add(lbl);

                if (MainForm.IsAdmin)
                {
                    TextBox lbl2 = new TextBox();
                    lbl2.Font     = new Font("Arial", 10);
                    lbl2.Location = new Point(x, 170);
                    lbl2.Size     = new Size(200, 30);
                    lbl2.Text     = rooms[i + 4] + " штук";
                    lbl2.Tag      = rooms[i];
                    lbl2.KeyDown += new KeyEventHandler(textBox4_KeyDown);
                    HotelsPanel.Controls.Add(lbl2);
                }

                x += 205;
            }
            #endregion
        }