Ejemplo n.º 1
0
        private void textBox4_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            if (e.KeyCode == Keys.Enter)
            {
                SQLClass.Update(
                    "UPDATE room" +
                    " SET quantity = '" + tb.Text.Replace("штук", "") + "'" +
                    " WHERE id = '" + tb.Tag.ToString() + "'");
            }
        }
Ejemplo n.º 2
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] + ")");
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        private void DeleteRoom(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    y   = btn.Location.Y;

            foreach (Control control in panel2.Controls)
            {
                if (control.Location == new Point(0, y))
                {
                    SQLClass.Update(
                        "DELETE FROM room WHERE id = '" + control.Tag.ToString() + "'");

                    AdminRoomsForm_Load(sender, e);
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        private void DeleteHotel(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    y   = btn.Location.Y;

            foreach (Control control in panel2.Controls)
            {
                if (control.Location == new Point(0, y))
                {
                    SQLClass.Update(
                        "DELETE FROM " + SQLClass.HOTELS + " WHERE Name = '" + control.Text + "'");

                    AdminHotelsForm_Load(sender, e);
                    return;
                }
            }
        }
Ejemplo n.º 8
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 + "')");
            }
        }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
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) { }
        }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
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);
                    }
                }
            }
        }
Ejemplo n.º 13
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;
            }
        }
Ejemplo n.º 14
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
        }
Ejemplo n.º 15
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);
            }
        }