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] + ")");
            }
        }
Exemple #2
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() + "'");
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            panel2.Controls.Clear();

            string command = "SELECT Login, Name, City, Age FROM " + SQLClass.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;
            }
        }
Exemple #4
0
        /// <summary>
        /// Доступность всем или админу
        /// </summary>
        private void ButtonAdminCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            SQLClass.Update("DELETE FROM " + SQLClass.UNIQUE_DESIGN +
                            " WHERE type='" + button1.GetType() + "'" +
                            " AND name='" + btn.Name + "'" +
                            " AND form='" + parent.Name + "'" +
                            " AND parameter='ADMIN'");

            SQLClass.Update("INSERT INTO " + SQLClass.UNIQUE_DESIGN +
                            "(type, parameter, name, form, value) values (" +
                            "'" + button1.GetType() + "', " +
                            "'ADMIN', " +
                            "'" + btn.Name + "', " +
                            "'" + parent.Name + "', " +
                            "'" + ((ButtonAdminCheckBox.Checked) ? "1": "0") + "')");
        }
Exemple #5
0
        public AdminUsersForm()
        {
            InitializeComponent();

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

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

            button1_Click(null, null);
        }
        /// <summary>
        /// Значение параметра
        /// </summary>
        public static string SelectBlockParam(string par, Control ctrl, Control parent)
        {
            string insta = "";

            try
            {
                insta = SQLClass.Select(
                    "SELECT value FROM " + SQLClass.BLOCK_DESIGN +
                    " WHERE parameter='" + par + "'" +
                    " AND name='" + ctrl.Name + "'" +
                    " AND form='" + parent.Name + "'")[0];
            }
            catch (Exception) { }

            return(insta);
        }
        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;
                }
            }
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["action"] != null)
            {
                int cid = int.Parse(Request["cid"]);


                List <Customer> tempList = SQLClass.ReadAllCustomers();

                var userQuery =
                    from n in tempList
                    where n.CustomerID == cid
                    select n.Firstname;

                string name = userQuery.FirstOrDefault();
            }
        }
        /// <summary>
        /// Рисование компонентов
        /// </summary>
        private void AdminHotelsForm_Load(object sender, EventArgs e)
        {
            List <string> hotels_list = SQLClass.Select(
                "SELECT Name, City, Rating, id FROM " + SQLClass.HOTELS);

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

            for (int i = 0; i < hotels_list.Count; i += 4)
            {
                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);

                Button btn2 = new Button();
                btn2.Text     = "Обновить";
                btn2.Tag      = hotels_list[i + 3];
                btn2.Location = new Point(500, y);
                btn2.Size     = new Size(100, 30);
                btn2.Click   += new EventHandler(RefreshHotel);
                panel2.Controls.Add(btn2);

                y += 30;
            }
        }
        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;
                }
            }
        }
        private void LoadStock()
        {
            List <Stock> stock = SQLClass.ReadStockContent();

            if (stock != null)
            {
                string stockTableContent = "";

                foreach (var item in stock)
                {
                    stockTableContent += $"<tr><td>{item.StockID}</td><td>{item.ProductID}</td><td>{item.StockQuantity}</td></tr>";
                    //$ lägger på ToString() på variabler som skrivs mellan måsvingar.
                }

                Stock.Text = stockTableContent;
            }
            //todo - what to do else..?
        }
        protected void ButtonUpdateStock_Click(object sender, EventArgs e)
        {
            int sid = int.Parse(TextBoxStockID.Text);

            List <Stock> stock  = SQLClass.ReadStockContent();
            var          querry = from s in stock
                                  where s.StockID == sid
                                  select s.StockQuantity;

            int cid = querry.First();


            int quantity = int.Parse(TextBoxQuantity.Text);

            SQLClass.UpdateStock(sid, cid + quantity);

            LoadStock();
        }
Exemple #13
0
        public void ButtonClicked(object sender, EventArgs e)
        {
            string UserId = System.Web.HttpContext.Current.User.Identity.Name;

            string[] split = (sender as Button).ID.Split('#');


            DateTime datetime    = DateTime.Parse(split[1]);
            string   SQLDateTime = datetime.ToString("yyyy-MM-dd HH:mm:00").Replace(".", ":");

            //CHECKS TO SEE IF SCHEDULE HAVE BEEN BOOKED ALREADY
            SQLClass      SQL     = new SQLClass();
            string        Query   = $"select [datetime] from dbo.SCHEDULE where [datetime] = '{SQLDateTime}' and [machine_FK] = '{split[0]}'"; //SQLDateTime
            List <string> ListSQL = SQL.ReadSQL(Query);

            if (ListSQL.Count > 0)
            {
                return;
            }                                 //Already have a schedule

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("datetime", typeof(DateTime));
            dataTable.Columns.Add("timeadded", typeof(DateTime));
            dataTable.Columns.Add("status", typeof(int));
            dataTable.Columns.Add("showID", typeof(int));
            dataTable.Columns.Add("username_fk", typeof(string));
            dataTable.Columns.Add("machine_fk", typeof(int));

            //                 DateTimeSQL / Status / showUser / User (email) / Machine
            dataTable.Rows.Add(datetime, DateTime.Now, 1, AdminSettings.showUserInfo, UserId, split[0]);//datetime SQL

            //INSERTS THE SCHEDULE INTO SQL
            SQL.WriteSQLDatatable(@"insert into [dbo].[SCHEDULE] ([datetime], [timeadded], [status], [showID], [username_FK], [machine_FK]) 
SELECT dataTable.datetime, dataTable.timeadded, dataTable.status, dataTable.showID, dataTable.username_FK, dataTable.machine_FK 
FROM @DataTable dataTable", dataTable, "[dbo].[SCHEDULEImport]");

            //SENDS EMAIL
            new MailClass().SendEmail(UserId, datetime);
            Response.Redirect("~/");
            //Response.Redirect(Request.RawUrl);
        }
Exemple #14
0
        private void LoadUser()
        {
            string          CustomerID = (string)Session["CID"];
            List <Customer> customers  = SQLClass.ReadAllCustomers().FindAll(x => x.CustomerID == Convert.ToInt32(CustomerID));

            if (customers != null)
            {
                string stockTableContent = "";

                foreach (var item in customers)
                {
                    if (true)
                    {
                        stockTableContent += $"<tr><td>{item.Firstname}</td><td>{item.Lastname}</td><td>{item.Email}</td><td>{item.Username}</td><td>{item.Password}</td></tr>";
                    }
                }

                Stock.Text = stockTableContent;
            }
        }
Exemple #15
0
        private void ucitavanjeForme()
        {
            zauzetoMemorijeKB = 0;

            SQLClass baza = new SQLClass();

            FTPFile[] fajl;

            /*
             * Pozicioniramo se na lokaciju iznad klijentovog foldera.
             * */
            server.ChangeWorkingDirectory("\\" + Properties.Settings.Default.nazivFoldera[0]);
            fajl = server.GetFileInfos(Properties.Settings.Default.nazivFoldera);

            /*
             * Pozicioniramo se na klijentov folder.
             * */
            server.ChangeWorkingDirectory(Properties.Settings.Default.nazivFoldera);

            for (int i = 0; i < fajl.Length; i++)
            {
                zauzetoMemorijeKB += fajl[i].Size;
            }

            lblMemorija.Text = zauzetoMemorijeKB.ToString();

            cmbMjeraMemorije.Text = "MB";

            server.DownloadFile(Application.StartupPath, "Baza.s3db");

            baza.otovriKonekciju();
            baza.ucitavanjePodataka(dgvTabela, bindingSource);
            baza.zatvoriKonekciju();

            bindingNavigator.BindingSource = bindingSource;

            lblPojedinacniFajloviId.DataBindings.Add(new Binding("Text", bindingSource, "Id"));
            lblPojedinacniFajloviImeFajla.DataBindings.Add(new Binding("Text", bindingSource, "ImeFajla"));
            lblPojedinacniFajloviLokacija.DataBindings.Add(new Binding("Text", bindingSource, "Lokacija"));
            lblPojedinacniFajloviDatumVrijeme.DataBindings.Add(new Binding("Text", bindingSource, "DatumVrijeme"));
        }
Exemple #16
0
        /// <summary>
        /// Цвет кнопок
        /// </summary>
        private void ButtonColorButton_Click(object sender, EventArgs e)
        {
            colorDialog1.Color = BUTTON_COLOR;

            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                BUTTON_COLOR = colorDialog1.Color;

                AdminDesignForm_Load(null, null);

                SQLClass.Update("DELETE FROM defaultDesign" +
                                " WHERE type='" + button1.GetType() + "'" +
                                " AND parameter='COLOR'");

                SQLClass.Update("INSERT INTO defaultDesign" +
                                "(type, parameter, value) values (" +
                                "'" + button1.GetType() + "', " +
                                "'COLOR', " +
                                "'" + BUTTON_COLOR.ToArgb() + "')");
            }
        }
        private void DeleteBooking(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.BOOKING +
                        " WHERE user = '******'" +
                        " AND room_id = '" + control.Tag.ToString() + "'" +
                        " AND dateFrom = '" + Convert.ToDateTime(control.AccessibleName).ToString("yyyy-MM-dd") + "'" +
                        " AND dateTo = '" + Convert.ToDateTime(control.AccessibleDescription).ToString("yyyy-MM-dd") + "'");

                    AdminBookingForm_Load(sender, e);
                    return;
                }
            }
        }
Exemple #18
0
        /// <summary>
        /// Выбор положения картинки
        /// </summary>
        private void ButtonLayoutCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ButtonLayoutCombo.SelectedIndex == 0)
            {
                button1.BackgroundImageLayout = ImageLayout.None;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 1)
            {
                button1.BackgroundImageLayout = ImageLayout.Tile;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 2)
            {
                button1.BackgroundImageLayout = ImageLayout.Stretch;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 3)
            {
                button1.BackgroundImageLayout = ImageLayout.Zoom;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 4)
            {
                button1.BackgroundImageLayout = ImageLayout.Center;
            }

            UniqueButton_Load(null, null);


            SQLClass.Update("DELETE FROM " + SQLClass.UNIQUE_DESIGN +
                            " WHERE type='" + button1.GetType() + "'" +
                            " AND name='" + btn.Name + "'" +
                            " AND form='" + parent.Name + "'" +
                            " AND parameter='LAYOUT'");

            SQLClass.Update("INSERT INTO " + SQLClass.UNIQUE_DESIGN +
                            "(type, parameter, name, form, value) values (" +
                            "'" + button1.GetType() + "', " +
                            "'LAYOUT', " +
                            "'" + btn.Name + "', " +
                            "'" + parent.Name + "', " +
                            "'" + button1.BackgroundImageLayout.ToString() + "')");
        }
Exemple #19
0
        /// <summary>
        /// Шрифт кнопок
        /// </summary>
        private void ButtonFontButton_Click(object sender, EventArgs e)
        {
            fontDialog1.Font  = button1.Font;
            fontDialog1.Color = button1.ForeColor;

            if (fontDialog1.ShowDialog() == DialogResult.OK)
            {
                button1.Font      = fontDialog1.Font;
                button1.ForeColor = fontDialog1.Color;

                UniqueButton_Load(null, null);

                SQLClass.Update("DELETE FROM " + SQLClass.UNIQUE_DESIGN +
                                " WHERE type='" + button1.GetType() + "'" +
                                " AND name='" + btn.Name + "'" +
                                " AND form='" + parent.Name + "'" +
                                " AND parameter='FONT'");
                SQLClass.Update("DELETE FROM " + SQLClass.UNIQUE_DESIGN +
                                " WHERE type='" + button1.GetType() + "'" +
                                " AND name='" + btn.Name + "'" +
                                " AND form='" + parent.Name + "'" +
                                " AND parameter='FONT_COLOR'");

                SQLClass.Update("INSERT INTO " + SQLClass.UNIQUE_DESIGN +
                                "(type, parameter, name, form, value) values (" +
                                "'" + button1.GetType() + "', " +
                                "'FONT', " +
                                "'" + btn.Name + "', " +
                                "'" + parent.Name + "', " +
                                "'" + button1.Font.Name + ";" + button1.Font.Size.ToString() + "')");
                SQLClass.Update("INSERT INTO " + SQLClass.UNIQUE_DESIGN +
                                "(type, parameter, name, form, value) values (" +
                                "'" + button1.GetType() + "', " +
                                "'FONT_COLOR', " +
                                "'" + btn.Name + "', " +
                                "'" + parent.Name + "', " +
                                "'" + button1.ForeColor.ToArgb() + "')");
            }
        }
        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;
            }
        }
Exemple #21
0
        /// <summary>
        /// Выбор положения картинки
        /// </summary>
        private void ButtonLayoutCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ButtonLayoutCombo.SelectedIndex == 0)
            {
                BUTTON_LAYOUT = ImageLayout.None;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 1)
            {
                BUTTON_LAYOUT = ImageLayout.Tile;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 2)
            {
                BUTTON_LAYOUT = ImageLayout.Stretch;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 3)
            {
                BUTTON_LAYOUT = ImageLayout.Zoom;
            }
            else if (ButtonLayoutCombo.SelectedIndex == 4)
            {
                BUTTON_LAYOUT = ImageLayout.Center;
            }

            AdminDesignForm_Load(null, null);


            SQLClass.Update("DELETE FROM defaultDesign" +
                            " WHERE type='" + button1.GetType() + "'" +
                            " AND parameter='LAYOUT'");

            SQLClass.Update("INSERT INTO defaultDesign" +
                            "(type, parameter, value) values (" +
                            "'" + button1.GetType() + "', " +
                            "'LAYOUT', " +
                            "'" + BUTTON_LAYOUT.ToString() + "')");
        }
Exemple #22
0
        private void LoadLastOrder()
        {
            if (Session["CID"] != null)
            {
                string       CustomerID = (string)Session["CID"];
                int          cid        = int.Parse(CustomerID);
                List <Order> orderList  = SQLClass.GetOrders(cid);

                if (orderList != null)
                {
                    string stockTableContent = "";

                    foreach (var item in orderList)
                    {
                        if (true)
                        {
                            stockTableContent += $"<tr><td>{item.OrderDate}</td><td>{item.OrderSum}</td><td>{item.OrderQuantity}</td></tr>";
                        }
                    }

                    OrderLiteral.Text = stockTableContent;
                }
            }
        }
        protected void ButtonRegistration_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                string firstName = TextBoxFirstname.Text;
                string lastName  = TextBoxLastname.Text;
                string email     = TextBoxEmail.Text;
                string username  = TextBoxUsername.Text;
                string password  = TextBoxPassword.Text;
                string role      = "User";
                try
                {
                    SQLClass.AddCustomer(firstName, lastName, username, role, password, email);

                    Session["Name"] = firstName;

                    Response.Redirect("/accountConfirmation.aspx");
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private void AdminBookingForm_Load(object sender, EventArgs e)
        {
            List <string> hotels_list = SQLClass.Select(
                "SELECT  booking.room_id, booking.user, booking.dateFrom, " +
                "booking.dateTo, room.name, hotels.name" +
                " FROM " + SQLClass.BOOKING + " booking" +
                " JOIN " + SQLClass.ROOM + " room ON room.id = booking.room_id" +
                " JOIN " + SQLClass.HOTELS + " hotels ON hotels.id = room.hotel_id" +
                " ORDER BY booking.dateFrom");

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

            for (int i = 0; i < hotels_list.Count; i += 6)
            {
                #region Пользователь
                Label lbl = new Label();
                lbl.Location              = new Point(0, y);
                lbl.Size                  = new Size(200, 30);
                lbl.Text                  = hotels_list[i + 1];
                lbl.Tag                   = hotels_list[i];
                lbl.AccessibleName        = hotels_list[i + 2];
                lbl.AccessibleDescription = hotels_list[i + 3];
                panel2.Controls.Add(lbl);
                #endregion

                #region Даты
                Label lbl2 = new Label();
                lbl2.Location = new Point(200, y);
                lbl2.Size     = new Size(100, 30);
                lbl2.Text     = hotels_list[i + 2];
                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 + 3];
                panel2.Controls.Add(lbl3);
                #endregion

                #region Номера
                Label lbl4 = new Label();
                lbl4.Location = new Point(400, y);
                lbl4.Size     = new Size(200, 30);
                lbl4.Text     = hotels_list[i + 4];
                panel2.Controls.Add(lbl4);

                Label lbl5 = new Label();
                lbl5.Location = new Point(600, y);
                lbl5.Size     = new Size(200, 30);
                lbl5.Text     = hotels_list[i + 5];
                panel2.Controls.Add(lbl5);
                #endregion

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

                y += 30;
            }
        }
Exemple #25
0
        /// <summary>
        /// ФИльтр
        /// </summary>
        private void Filter(object sender, EventArgs e)
        {
            HotelsPanel.Controls.Clear();
            string command =
                "SELECT * FROM" +
                "(SELECT hotels.id hid, hotels.name hname, hotels.image himage, " +
                "hotels.rating hrating, hotels.city hcity, " +
                "room.id, room.name, room.price, room.image" +
                " FROM " + SQLClass.ROOM + " room" +
                " JOIN " + SQLClass.HOTELS + " hotels" +
                " ON room.hotel_id = hotels.id" +
                " WHERE 1";

            #region Поиск
            if (CityComboBox.Text != "")
            {
                command += " AND city = '" + CityComboBox.Text + "'";
            }
            if (RatingComboBox.Text != "")
            {
                command += " AND Rating >= " + RatingComboBox.Text;
            }
            if (CapacityComboBox.Text != "")
            {
                command += " AND Capacity >= " + CapacityComboBox.Text;
            }

            foreach (object item in OptionsCheckedListBox.CheckedItems)
            {
                if (item.ToString() == "Для некурящих")
                {
                    command += " AND NoSmoking = 1";
                }
                if (item.ToString() == "Свой санузел")
                {
                    command += " AND Bath = 1";
                }
                if (item.ToString() == "Отдельный номер")
                {
                    command += " AND IsHostel = 0";
                }
                if (item.ToString() == "Wi-Fi")
                {
                    command += " AND WiFi = 1";
                }
            }
            #endregion

            command += " ORDER BY price ASC) C";

            if (SortComboBox.SelectedIndex == 0)
            {
                command += " GROUP BY hid" +
                           " HAVING price = MIN(price) ORDER BY price ASC";
            }
            else if (SortComboBox.SelectedIndex == 1)
            {
                command += " GROUP BY hid" +
                           " HAVING price = MIN(price) ORDER BY price DESC";
            }
            else if (SortComboBox.SelectedIndex == 2)
            {
                command += " GROUP BY hid" +
                           " HAVING price = MIN(price) ORDER BY hrating DESC";
            }

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

            int x = 15;
            for (int i = 0; i < hotels.Count; i += 9)
            {
                #region Гостиница
                Label lbl = new Label();
                lbl.Location = new Point(x, 10);
                lbl.Size     = new Size(200, 30);
                lbl.Text     = hotels[i + 1];
                lbl.Tag      = hotels[i];
                lbl.Click   += new EventHandler(OpenHotel);
                HotelsPanel.Controls.Add(lbl);
                #endregion

                #region Номер
                PictureBox pb = new PictureBox();
                try
                {
                    pb.Load("../../Pictures/" + hotels[i + 8]);
                }
                catch (Exception)
                {
                    try
                    {
                        pb.Load("../../Pictures/2-Seat.jpg");
                    }
                    catch (Exception) { }
                }
                pb.Location = new Point(x, 40);
                pb.Size     = new Size(190, 120);
                pb.SizeMode = PictureBoxSizeMode.StretchImage;
                pb.Tag      = hotels[i + 5];
                pb.Click   += new EventHandler(OpenRoom);
                HotelsPanel.Controls.Add(pb);

                Label lbl2 = new Label();
                lbl2.Name     = "PriceLabel";
                lbl2.Location = new Point(x, 170);
                lbl2.Size     = new Size(200, 30);
                lbl2.Text     = hotels[i + 7] + " рублей";
                lbl2.Tag      = hotels[i + 5];
                lbl2.Click   += new EventHandler(OpenRoom);
                HotelsPanel.Controls.Add(lbl2);

                Label lbl3 = new Label();
                lbl3.Location = new Point(x, 140);
                lbl3.Size     = new Size(200, 30);
                lbl3.Font     = new Font("Arial", 10);
                lbl3.Text     = hotels[i + 6];
                lbl3.Tag      = hotels[i + 5];
                lbl3.Click   += new EventHandler(OpenRoom);
                HotelsPanel.Controls.Add(lbl3);
                #endregion


                #region Город
                Label city = new Label();
                city.TextAlign = ContentAlignment.MiddleRight;
                city.Location  = new Point(x + 80, 40);
                city.Size      = new Size(120, 30);
                city.Text      = hotels[i + 4];
                city.Tag       = hotels[i];
                city.Click    += new EventHandler(OpenHotel);
                HotelsPanel.Controls.Add(city);
                city.BringToFront();
                #endregion

                x += 205;
            }
        }
Exemple #26
0
        private void deleteToolStripButton_Click(object sender, EventArgs e)
        {
            var odgovor = MessageBox.Show("Da li ste sigurni da želite da izbrišete \"" + lblPojedinacniFajloviImeFajla.Text + "\"?", "Informacije", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            switch (odgovor)
            {
            case DialogResult.No:
                break;

            case DialogResult.Yes:
            {
                try
                {
                    string imeFoldera = Properties.Settings.Default.nazivFoldera[0] + "\\" + Properties.Settings.Default.nazivFoldera + "\\";
                    if (server.DeleteFile("\\" + imeFoldera + lblPojedinacniFajloviImeFajla.Text))
                    {
                        MessageBox.Show("Uspješno ste izvršili brisanje fajla " + lblPojedinacniFajloviImeFajla.Text + ".", "Informacije", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        SQLClass baza = new SQLClass();
                        baza.otovriKonekciju();
                        baza.pobrisiPodatak(lblPojedinacniFajloviId.Text);
                        baza.zatvoriKonekciju();

                        lblPojedinacniFajloviId.DataBindings.Clear();
                        lblPojedinacniFajloviImeFajla.DataBindings.Clear();
                        lblPojedinacniFajloviLokacija.DataBindings.Clear();
                        lblPojedinacniFajloviDatumVrijeme.DataBindings.Clear();

                        int brojDogadjaja = bindingNavigator.BindingSource.Count;

                        if (--brojDogadjaja == 0)
                        {
                            lblPojedinacniFajloviId.Text           = "*********";
                            lblPojedinacniFajloviImeFajla.Text     = "*********";
                            lblPojedinacniFajloviLokacija.Text     = "*********";
                            lblPojedinacniFajloviDatumVrijeme.Text = "*********";

                            dgvTabela.DataSource = null;
                            dgvTabela.Refresh();

                            bindingNavigator.DataBindings.Clear();
                            bindingNavigator.Refresh();

                            deleteToolStripButton.Enabled   = false;
                            downloadToolStripButton.Enabled = false;
                            printToolStripButton.Enabled    = false;

                            server.DeleteFile("\\" + Properties.Settings.Default.nazivFoldera[0] + "\\" + Properties.Settings.Default.nazivFoldera + "\\Baza.s3db");
                            zauzetoMemorijeKB = 0;
                            lblMemorija.Text  = "0";
                        }
                        else
                        {
                            Funkcije.slanjeFajlaNaServer(server, Application.StartupPath + @"\Baza.s3db");
                            ucitavanjeForme();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Desila se greška pri brisanju.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                break;
            }

            default:
                break;
            }
        }
Exemple #27
0
 /// <summary>
 /// Удаление картинки
 /// </summary>
 private void ButtonDeletePictureButton_Click(object sender, EventArgs e)
 {
     SQLClass.Update("DELETE FROM defaultDesign" +
                     " WHERE type='" + button1.GetType() + "'" +
                     " AND parameter='PICTURE_ADDRESS'");
 }
Exemple #28
0
        public List <Button> AddButtons(DateTime date, int m)
        {
            List <Button> Buttonlist = new List <Button>();

            //FILLS DATATABLE WITH SCHEDULES FROM SQL
            string    fromDate = date.ToString("yyyy-MM-dd");
            DataTable DT       = new SQLClass().ReadSQLDatatable($"SELECT * from [dbo].[SCHEDULE] where CONVERT(date, [datetime]) = '{fromDate}' and [machine_FK] = {m}");

            //CREATES THE SCHEDULE BUTTONS
            float amountOfSchedulesPerDay = (AdminSettings.closingTime - AdminSettings.openingTime) * 60 / AdminSettings.scheduleTimeInMinutes;

            for (int i = 0; i < amountOfSchedulesPerDay; i++)
            {
                //ADDS HOURS AND MINUTES TO THE TIME THE BOOKING BUTTON SHOWS
                DateTime showtime      = date.Date.AddHours(AdminSettings.openingTime).AddMinutes(i * AdminSettings.scheduleTimeInMinutes);
                Button   BookingButton = new Button();
                BookingButton.ID   = m + "#" + date.ToString("dd/MM/yyyy ") + showtime.ToShortTimeString();
                BookingButton.Text = showtime.ToShortTimeString() + " - " + showtime.AddMinutes(AdminSettings.scheduleTimeInMinutes).ToShortTimeString();
                BookingButton.ControlStyle.CssClass = "booking-button button-free time";
                //BookingButton.ControlStyle.CssClass = "button large regular green";
                //BookingButton.OnClientClick += new EventHandler(ButtonClicked);
                BookingButton.Click += new EventHandler(ButtonClicked);
                foreach (DataRow row in DT.Rows)
                {
                    if (row["dateTime"].ToString().Contains(showtime.ToString()))
                    {
                        if (row["status"].ToString() == "1")
                        {
                            //IF SCHEDULE IS FOUND IN SQL SET BUTTON AS BOOKED DEPENDING ON USERINFOSETTING A NAME OR ADDRESS MIGHT BE ADDED
                            BookingButton.ControlStyle.CssClass = "booking-button button-booked time";
                            // BookingButton.ControlStyle.CssClass = "button large regular red";
                            switch (AdminSettings.showUserInfo)
                            {
                            case false:
                                BookingButton.Text += " Optaget";
                                break;

                            case true:
                                string SQL = $"select [address] from dbo.[USER] where [email] = '{row["username_FK"]}'";
                                BookingButton.Text += " " + new SQLClass().ReadSQL(SQL)[0];
                                break;

                            //case 2:
                            //    BookingButton.Text += row[];
                            //    break;
                            default:
                                BookingButton.Text += " Optaget";
                                break;
                            }
                        }
                        else if (row["status"].ToString() == "2")
                        {
                            BookingButton.Text = " Maskinen er i stykker";
                        }
                        else if (row["status"].ToString() == "3")
                        {
                            BookingButton.Text = " Tekniker er tilkaldt";
                        }
                    }
                }

                if (DateTime.Now > showtime.AddMinutes(AdminSettings.scheduleTimeInMinutes))
                {
                    BookingButton.ControlStyle.CssClass = "booking-button button-past time";
                    //BookingButton.Click += new EventHandler(ButtonClicked);
                    //BookingButton.OnClientClick += new EventHandler(ButtonClicked);
                }

                //ADDS THE CREATED BUTTON TO THE LIST
                Buttonlist.Add(BookingButton);
            }
            return(Buttonlist);
        }
Exemple #29
0
        /// <summary>
        /// ЧТение дизайна кнопки из БД
        /// </summary>
        public static void ReadUniqueButtonDesign(Button btn)
        {
            //Ищем родительскую форму/UserControl
            Control parent = btn;

            while (!(parent is Form || parent is UserControl))
            {
                parent = parent.Parent;
            }

            //Картинка
            try
            {
                string address =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button' AND parameter='PICTURE_ADDRESS'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];
                btn.BackgroundImage = Image.FromFile(BUTTON_PICS_DIR + "\\" + address);
            }
            catch (Exception) { }

            //Положение
            try
            {
                string location =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button' AND parameter='LOCATION'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];
                string[] parts = location.Split(new char[] { ',' });
                btn.Location = new Point(Convert.ToInt32(parts[0]), Convert.ToInt32(parts[1]));
            }
            catch (Exception) { }

            //Доступность админу
            try
            {
                string admin =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button' AND parameter='ADMIN'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];
                btn.AccessibleDescription = admin;
            }
            catch (Exception) { }

            //Размер
            try
            {
                string location =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button' AND parameter='SIZE'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];
                string[] parts = location.Split(new char[] { ',' });
                btn.Size = new Size(Convert.ToInt32(parts[0]), Convert.ToInt32(parts[1]));
            }
            catch (Exception) { }

            //Шрифт
            try
            {
                string color =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='FONT_COLOR'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];

                btn.ForeColor = Color.FromArgb(Convert.ToInt32(color));

                string font =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='FONT'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];

                string[] parts = font.Split(new char[] { ';' });

                btn.Font = new Font(new FontFamily(parts[0]), (float)Convert.ToDouble(parts[1]));
            }
            catch (Exception) { }

            //Цвет
            try
            {
                string color =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='COLOR'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];

                btn.BackColor = Color.FromArgb(Convert.ToInt32(color));
            }
            catch (Exception) { }

            //Положение картинки
            try
            {
                string layout =
                    SQLClass.Select("SELECT value FROM " + SQLClass.UNIQUE_DESIGN +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='LAYOUT'" +
                                    " AND name='" + btn.Name + "'" +
                                    " AND form='" + parent.Name + "'")[0];

                if (layout == "Center")
                {
                    btn.BackgroundImageLayout = ImageLayout.Center;
                }
                else if (layout == "None")
                {
                    btn.BackgroundImageLayout = ImageLayout.None;
                }
                else if (layout == "Stretch")
                {
                    btn.BackgroundImageLayout = ImageLayout.Stretch;
                }
                else if (layout == "Tile")
                {
                    btn.BackgroundImageLayout = ImageLayout.Tile;
                }
                else if (layout == "Zoom")
                {
                    btn.BackgroundImageLayout = ImageLayout.Zoom;
                }
            }
            catch (Exception) { }
        }
Exemple #30
0
        /// <summary>
        /// Чтение дизайна из БД
        /// </summary>
        public static void ReadDefaultDesign()
        {
            //Картинка
            try
            {
                BUTTON_PICTURE_ADDRESS =
                    SQLClass.Select("SELECT value FROM defaultdesign" +
                                    " WHERE type = 'System.Windows.Forms.Button' AND parameter='PICTURE_ADDRESS'")[0];
                BUTTON_PICTURE = Image.FromFile(BUTTON_PICS_DIR + "\\" + BUTTON_PICTURE_ADDRESS);
            }
            catch (Exception) { }

            //Шрифт
            try
            {
                string color =
                    SQLClass.Select("SELECT value FROM defaultdesign" +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='FONT_COLOR'")[0];

                BUTTON_FONT_COLOR = Color.FromArgb(Convert.ToInt32(color));

                string font =
                    SQLClass.Select("SELECT value FROM defaultdesign" +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='FONT'")[0];

                string[] parts = font.Split(new char[] { ';' });

                BUTTON_FONT = new Font(new FontFamily(parts[0]), (float)Convert.ToDouble(parts[1]));
            }
            catch (Exception) { }

            //Цвет
            try
            {
                string color =
                    SQLClass.Select("SELECT value FROM defaultdesign" +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='COLOR'")[0];

                BUTTON_COLOR = Color.FromArgb(Convert.ToInt32(color));
            }
            catch (Exception) { }

            //Положение картинки
            try
            {
                string layout =
                    SQLClass.Select("SELECT value FROM defaultdesign" +
                                    " WHERE type = 'System.Windows.Forms.Button'" +
                                    " AND parameter='LAYOUT'")[0];

                if (layout == "Center")
                {
                    BUTTON_LAYOUT = ImageLayout.Center;
                }
                else if (layout == "None")
                {
                    BUTTON_LAYOUT = ImageLayout.None;
                }
                else if (layout == "Stretch")
                {
                    BUTTON_LAYOUT = ImageLayout.Stretch;
                }
                else if (layout == "Tile")
                {
                    BUTTON_LAYOUT = ImageLayout.Tile;
                }
                else if (layout == "Zoom")
                {
                    BUTTON_LAYOUT = ImageLayout.Zoom;
                }
            }
            catch (Exception) { }
        }