Ejemplo n.º 1
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            int id_order = Convert.ToInt32(InfoWorks.CurrentRow.Cells[0].Value);        //ID_order

            string queryDelOrder = "DELETE from orders WHERE orders.id_order =" + id_order;

            DialogResult result = MessageBox.Show(
                "Вы действительно хотите удалить выбранный заказ?",
                "Подтверждение",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button1,
                MessageBoxOptions.DefaultDesktopOnly);

            // Проверяем какая кнопка нажата ...
            if (result == DialogResult.Yes)
            {
                QueriesClass.QuerytoTable(queryDelOrder);
                QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
            }
            else
            {
                this.TopMost = true;
            }// Ставим нашу форму по верх всех окон
            this.TopMost = true;
        }
Ejemplo n.º 2
0
        private void LoadChartCount()
        {
            string nameMS = "", surnameMS = "", patronymicMS = "";
            string queryMasters = "SELECT Concat_ws(' ',surname,name,patronymic) FROM masters";
            string queryCountWorks;

            masters = QueriesClass.SelectCombo(queryMasters);  //list of FIO masters
            int count = 0;

            for (int i = 0; i < masters.Count; i++)
            {
                //string text = masters[i].ToString();
                //MessageBox.Show(text);
                string[] FIO = masters[i].ToString().Split(' ');
                surnameMS = FIO[0];
                //MessageBox.Show(surnameMS);
                nameMS = FIO[1];
                //MessageBox.Show(nameMS);
                patronymicMS = FIO[2];
                // MessageBox.Show(patronymicMS);
                queryCountWorks = "SELECT count(*) FROM orders INNER JOIN masters ON orders.id_master=masters.id_master Where masters.surname = '" + surnameMS + "' and masters.Name = '" + nameMS + "' and masters.Patronymic = '" + patronymicMS + "'";
                count           = QueriesClass.SelectOne(queryCountWorks);
                chartCount.Series["Количество работ"].Points.AddXY(masters[i], count);
                chartCount.ChartAreas["ChartArea1"].AxisX.Interval = 1;
                chartCount.ChartAreas[0].AxisX.LabelStyle.Angle    = -30;
            }
        }
Ejemplo n.º 3
0
        /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //private void Filter()
        //{
        //    try
        //    {
        //        string FIO = comboFIO.SelectedItem.ToString();
        //        string[] arrFIO = FIO.Split(' ');
        //        string surname = arrFIO[0];
        //        string name = arrFIO[1];
        //        string patronymic = arrFIO[2];
        //        string date1 = dateTimePicker1.Value.Year.ToString() + dateTimePicker1.Value.Month.ToString() + dateTimePicker1.Value.Day.ToString();
        //        string date2 = dateTimePicker2.Value.Year.ToString() + dateTimePicker2.Value.Month.ToString() + dateTimePicker2.Value.Day.ToString();
        //        if (comboService.SelectedIndex > -1 && comboFIO.SelectedIndex > -1 && firstPrice.Text != "" && secondPrice.Text != "")
        //        {
        //            // comboFIO.SelectedIndex = -1;
        //            string querySelService = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', '), " +
        //                              "sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
        //                " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
        //                " INNER JOIN orders ON orders.id_order= order_service.id_order " +
        //                " INNER JOIN masters ON masters.id_master = orders.id_master" +
        //                " WHERE  (orders.Date BETWEEN '" + date1 + "' AND '" + date2 + "') AND masters.Surname = '" + surname + "'AND masters.Name = '" + name + "'AND masters.Patronymic = '" + patronymic + "'" +
        //                " GROUP BY order_service.id_order" +                 //sosat
        //                " having INSTR(Group_concat(service.name_service SEPARATOR ', '), '" + comboService.Text + "') > 0 AND " +
        //                " (sum(service.Price) BETWEEN " + int.Parse(firstPrice.Text) + " AND " + int.Parse(secondPrice.Text)+")";

        //            QueriesClass.SelectQuery(querySelService, InfoWorks);
        //        }
        //        else
        //        {
        //            QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
        //        }
        //    }
        //    catch { }
        //}

        /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void comboFIO_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Filter();
            if (comboFIO.SelectedIndex > -1)
            {
                comboService.SelectedIndex = -1;
                string   FIO        = comboFIO.SelectedItem.ToString();
                string[] arrFIO     = FIO.Split(' ');
                string   surname    = arrFIO[0];
                string   name       = arrFIO[1];
                string   patronymic = arrFIO[2];
                // MessageBox.Show(FIO);
                string querySelMaster = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', ')," +
                                        " sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                        " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                        " INNER JOIN orders ON orders.id_order= order_service.id_order" +
                                        " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                        " WHERE masters.Surname = '" + surname + "'AND masters.Name = '" + name + "'AND masters.Patronymic = '" + patronymic + "' " +
                                        " GROUP BY order_service.id_order";
                QueriesClass.SelectQuery(querySelMaster, InfoWorks);
            }
            else
            {
                QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
            }
            countWorks.Text = "Количество выполненных работ: " + (InfoWorks.RowCount - 1);
            summLine.Text   = "Сумма: " + Total() + "BYN";
        }
Ejemplo n.º 4
0
        private void DeleteOrders_Click(object sender, EventArgs e)
        {
            string deleteOrders = "DELETE from orders";

            if (InfoWorks.Rows.Count > 1)
            {
                DialogResult result = MessageBox.Show(
                    "Вы действительно хотите очистить весь список выполненных заказов?",
                    "Attention",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                // Проверяем какая кнопка нажата ...
                if (result == DialogResult.Yes)
                {
                    QueriesClass.QuerytoTable(deleteOrders);
                    InfoWorks.Rows.Clear();
                }
                else
                {
                    this.TopMost = true;
                }// Ставим нашу форму по верх всех окон
                this.TopMost = true;
            }
            else
            {
                MessageBox.Show("В таблице нет заказов", "Information");
                return;
            }
        }
Ejemplo n.º 5
0
        private void LoadChartSum(string queryDate)
        {
            string nameMS = "", surnameMS = "", patronymicMS = "";
            string queryMasters = "SELECT Concat_ws(' ',surname,name,patronymic) FROM masters";
            string querySumCurMaster;

            masters = QueriesClass.SelectCombo(queryMasters);      //list of FIO masters
            int Sum = 0;

            for (int i = 0; i < masters.Count; i++)
            {
                //string text = masters[i].ToString();
                //MessageBox.Show(i + "ый " + text);
                string[] FIO = masters[i].ToString().Split(' ');
                surnameMS = FIO[0];
                //MessageBox.Show(surnameMS);
                nameMS = FIO[1];
                //MessageBox.Show(nameMS);
                patronymicMS = FIO[2];
                // MessageBox.Show(patronymicMS);
                querySumCurMaster = querySum + " Where masters.surname = '" + surnameMS + "' and masters.Name = '"
                                    + nameMS + "' and masters.Patronymic = '" + patronymicMS + "'" + queryDate;
                Sum = QueriesClass.SelectOne(querySumCurMaster);
                chartSum.Series["Выручка"].Points.AddXY(masters[i], Sum);
                chartSum.ChartAreas["ChartArea1"].AxisX.Interval = 1;
                chartSum.ChartAreas[0].AxisX.LabelStyle.Angle    = -30;
            }
        }
Ejemplo n.º 6
0
        private void DoneWorks_Load(object sender, EventArgs e)
        {
            QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
            countWorks.Text = "Количество выполненных работ: " + (InfoWorks.RowCount - 1);

            summLine.Text = "Сумма: " + Total() + "BYN";
            ////////////////////////////////////////////////////////////////////////////                          WELL, MY BRAIN IS BROKEN
            string        querycount      = "Select count(*) FROM masters";
            string        querycountser   = "Select count(*) FROM service";
            string        querySelFIO     = "SELECT Concat_ws(' ',surname,name,patronymic )  FROM masters";
            string        querySelService = "SELECT name_service  FROM service";
            int           count           = QueriesClass.SelectOne(querycount);
            int           countser        = QueriesClass.SelectOne(querycountser);
            List <string> pamagite        = new List <string>();
            List <string> pamagi          = new List <string>();

            ///
            pamagite.Clear();
            pamagite = QueriesClass.SelectCombo(querySelFIO);
            for (int i = 0; i < count; i++)
            {
                comboFIO.Items.Add(pamagite[i].ToString());
            }
            ///
            pamagi.Clear();
            pamagi = QueriesClass.SelectCombo(querySelService);
            for (int i = 0; i < countser; i++)
            {
                comboService.Items.Add(pamagi[i].ToString());
            }
        }
Ejemplo n.º 7
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            int id_service = Convert.ToInt32(tableService.CurrentRow.Cells[0].Value);        //ID_service

            string queryDeleteMaster = "DELETE from service WHERE service.id_service =" + id_service;

            DialogResult result = MessageBox.Show(
                "Вы действительно хотите удалить эту услугу?",
                "Подтверждение",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button1,
                MessageBoxOptions.DefaultDesktopOnly);

            // Проверяем какая кнопка нажата ...
            if (result == DialogResult.Yes)
            {
                QueriesClass.QuerytoTable(queryDeleteMaster);
                QueriesClass.SelectQuery(querySelectService, tableService);
            }
            else
            {
                this.TopMost = true;
            }// Ставим нашу форму по верх всех окон
            this.TopMost = true;
        }
Ejemplo n.º 8
0
        public void GetProductsWithNRecentReviewsTest()
        {
            List <Product> list = QueriesClass.GetProductsWithNRecentReviews(1);

            Assert.AreEqual(list.Count, 2);
            Assert.AreEqual(list[0].ProductID, 709);
            Assert.AreEqual(list[1].ProductID, 798);
        }
Ejemplo n.º 9
0
 private void resetFilters_Click(object sender, EventArgs e)
 {
     comboFIO.SelectedIndex     = -1;
     comboService.SelectedIndex = -1;
     dateTimePicker2.Value      = dateTimePicker1.Value;
     QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
     firstPrice.Text  = "";
     secondPrice.Text = "";
 }
Ejemplo n.º 10
0
        public void GetNRecentlyReviewedProducts()
        {
            List <Product> list = QueriesClass.GetNRecentlyReviewedProducts(3);

            Assert.AreEqual(list.Count, 3);
            Assert.AreEqual(list[0].ProductID, 937);
            Assert.AreEqual(list[1].ProductID, 798);
            Assert.AreEqual(list[2].ProductID, 709);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// queries
        /// </summary>


        private void AddOrder_Load(object sender, EventArgs e)
        {
            string querySelMasters = "SELECT id_master, Concat_ws(' ',surname,name,patronymic )  FROM masters";

            QueriesClass.SelectQuery(querySelMasters, TableSelectMasters);
            string querySelService = "SELECT id_service, name_service, service.price  FROM service";

            QueriesClass.SelectQuery(querySelService, TableSelectService);
            Reset();
        }
Ejemplo n.º 12
0
        public void GetTotalStandardCostByCategoryTest()
        {
            ProductCategory category = new ProductCategory
            {
                Name = "Clothing"
            };
            int suma = QueriesClass.GetTotalStandardCostByCategory(category);

            Assert.AreEqual(suma, 868);
        }
Ejemplo n.º 13
0
        private void save_Click(object sender, EventArgs e)
        {
            string ser = nameService.Text;
            int    pr  = int.Parse(price.Text);

            string queryUpdate = "UPDATE service SET name_service = '" + ser + "', price = " + pr + " WHERE (id_service = " + id_service + ");";

            QueriesClass.QuerytoTable(queryUpdate);
            MessageBox.Show("Изменения сохранены!");
            this.Hide();

            MastersServices mas = new MastersServices();

            mas.Show();
        }
Ejemplo n.º 14
0
        public void GetProductNamesByVendorNameTest()
        {
            List <string> list = QueriesClass.GetProductNamesByVendorName("SUPERSALES INC.");

            List <string> productNames = new List <string> {
                "Decal 2", "Decal 1"
            };

            Assert.AreEqual(list.Count, 2);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(productNames[i], list[i]);
            }
        }
Ejemplo n.º 15
0
        private void save_Click(object sender, EventArgs e)
        {
            string sur         = surname.Text;
            string name        = nameTB.Text;
            string patro       = patronymic.Text;
            string adr         = adress.Text;
            string ph          = phoneNumber.Text;
            string queryUpdate = "UPDATE masters SET Surname = '" + sur + "', Name = '" + name + "', Patronymic = '" + patro + "', Adress = '" +
                                 adr + "', Phone = '" + ph + "' WHERE (id_master = " + id_master + ");";

            QueriesClass.QuerytoTable(queryUpdate);
            MessageBox.Show("Изменения сохранены!");
            this.Hide();

            MastersServices mas = new MastersServices();

            mas.Show();
        }
Ejemplo n.º 16
0
        private void ChangeSum()
        {
            string service_name;
            //MessageBox.Show(listBox.Items.Count.ToString());
            string query;

            int[] price = new int[listBox.Items.Count];
            int   sum   = 0;

            for (int i = 0; i < listBox.Items.Count; i++)
            {
                service_name = listBox.Items[i].ToString();
                query        = "SELECT price FROM service WHERE service.name_service = '" + service_name + "';";
                price[i]     = QueriesClass.SelectOne(query);

                sum += price[i];
            }
            OrderSum.Text = sum + "BYN";
        }
Ejemplo n.º 17
0
        private void InsService_Click(object sender, EventArgs e)
        {
            string queryInsertService;

            if (nameService.Text != "")
            {
                if (price.Text != "")
                {
                    if (!price.Text.Contains("."))
                    {
                        queryInsertService = "Insert into service VALUES(0,'" + nameService.Text + "'," + int.Parse(price.Text) + ");";
                        QueriesClass.QuerytoTable(queryInsertService);
                        DialogResult result = MessageBox.Show(
                            "Услуга добавлена!",
                            "Well",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information,
                            MessageBoxDefaultButton.Button1,
                            MessageBoxOptions.DefaultDesktopOnly);
                        this.TopMost = true;
                        Reset();
                    }
                    else
                    {
                        MessageBox.Show("Цена должна быть целочисленным значением!", "Ошибка!");
                        price.Focus();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Введите цену за услугу!", "Ошибка!");
                    price.Focus();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Введите название услуги!", "Ошибка!");
                nameService.Focus();
                return;
            }
        }
Ejemplo n.º 18
0
        public void GetProductsByNameTest()
        {
            List <Product> list = QueriesClass.GetProductsByName("lov");

            List <int> productIDs = new List <int>()
            {
                863, 862, 861, 860, 859, 858
            };
            List <string> productNames = new List <string> {
                "Full-Finger Gloves, L", "Full-Finger Gloves, M",
                "Full-Finger Gloves, S", "Half-Finger Gloves, L", "Half-Finger Gloves, M", "Half-Finger Gloves, S"
            };

            Assert.AreEqual(list.Count, 6);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(productIDs[i], list[i].ProductID);
                Assert.AreEqual(productNames[i], list[i].Name);
            }
        }
Ejemplo n.º 19
0
        public void GetNProductsFromCategoryTest()
        {
            List <Product> list = QueriesClass.GetNProductsFromCategory("Accessories", 7);

            List <int> productIDs = new List <int>()
            {
                879, 877, 843, 878, 847, 848, 876
            };
            List <string> productNames = new List <string> {
                "All-Purpose Bike Stand", "Bike Wash - Dissolver", "Cable Lock",
                "Fender Set - Mountain", "Headlights - Dual-Beam", "Headlights - Weatherproof", "Hitch Rack - 4-Bike"
            };

            Assert.AreEqual(list.Count, 7);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(productIDs[i], list[i].ProductID);
                Assert.AreEqual(productNames[i], list[i].Name);
            }
        }
Ejemplo n.º 20
0
 private void comboService_SelectedIndexChanged(object sender, EventArgs e)
 {
     //  Filter();
     if (comboService.SelectedIndex > -1)
     {
         comboFIO.SelectedIndex = -1;
         string querySelService = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', '), " +
                                  "sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                  " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                  " INNER JOIN orders ON orders.id_order= order_service.id_order " +
                                  " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                  " GROUP BY order_service.id_order" + //sosat
                                  " having INSTR(Group_concat(service.name_service SEPARATOR ', '), '" + comboService.Text + "') > 0 ";
         QueriesClass.SelectQuery(querySelService, InfoWorks);
     }
     else
     {
         QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
     }
     countWorks.Text = "Количество выполненных работ: " + (InfoWorks.RowCount - 1);
     summLine.Text   = "Сумма: " + Total() + "BYN";
 }
Ejemplo n.º 21
0
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            comboFIO.SelectedIndex     = -1;
            comboService.SelectedIndex = -1;
            firstPrice.Text            = "";
            secondPrice.Text           = "";
            string date1 = dateTimePicker1.Value.Year.ToString() + "-" + dateTimePicker1.Value.Month.ToString() + "-" + dateTimePicker1.Value.Day.ToString();
            string date2 = dateTimePicker2.Value.Year.ToString() + "-" + dateTimePicker2.Value.Month.ToString() + "-" + dateTimePicker2.Value.Day.ToString();
            //MessageBox.Show(date1 + "   " + date2);
            string querySeldate = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', ')," +
                                  " sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                  " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                  " INNER JOIN orders ON orders.id_order= order_service.id_order" +
                                  " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                  " WHERE  orders.Date BETWEEN '" + date1 + "' AND '" + date2 + "'" +
                                  " GROUP BY order_service.id_order";

            QueriesClass.SelectQuery(querySeldate, InfoWorks);
            // Filter();
            countWorks.Text = "Количество выполненных работ: " + (InfoWorks.RowCount - 1);
            summLine.Text   = "Сумма: " + Total() + "BYN";
        }
Ejemplo n.º 22
0
        private void InsOrder_Click(object sender, EventArgs e)
        {
            DateTime day = monthCalendar1.SelectionStart;

            int    IdMaster = 0;
            int    IdOrder;
            string queryIDorder;

            foreach (DataGridViewRow dr in TableSelectMasters.SelectedRows)
            {
                IdMaster = Convert.ToInt32(dr.Cells[0].Value);            //ID_master
            }
            // MessageBox.Show("id мастера " + IdMaster.ToString());

            string InsertOrder = "INSERT INTO orders VALUES (0,concat_ws('-', " + day.Year + ", " + day.Month + "," + day.Day + ")," + IdMaster + ")";

            QueriesClass.QuerytoTable(InsertOrder);

            queryIDorder = "SELECT last_insert_id(orders.id_order) FROM orders ORDER BY orders.id_order desc LIMIT 1"; // Get ID of last order
            //MessageBox.Show("Сейчас кину ошибку");
            IdOrder = QueriesClass.SelectOne(queryIDorder);                                                            //ID_order

            string InsertOrder_Service;
            string queryIDservice, service_name;      //field for queries
            int    IdService;

            if (listBox.Items.Count > 0 && TableSelectService.CurrentRow.Index != -1 && TableSelectMasters.CurrentRow.Index != -1)
            {
                for (int i = 0; i < listBox.Items.Count; i++)
                {
                    service_name   = listBox.Items[i].ToString();
                    queryIDservice = "SELECT service.id_service FROM service WHERE service.name_service = '" + service_name + "';"; //Get service ID

                    IdService = QueriesClass.SelectOne(queryIDservice);                                                             //ID_service

                    // MessageBox.Show("id услуги "+IdService.ToString());
                    // MessageBox.Show("id заказа " + IdOrder.ToString());

                    InsertOrder_Service = "INSERT INTO order_service  VALUES (0," + IdOrder + "," + IdService + ")";  //Add fields in Order_service table
                    QueriesClass.QuerytoTable(InsertOrder_Service);
                }
                DialogResult result = MessageBox.Show(
                    "Заказ добавлен!",
                    "Well",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                this.TopMost = true;
                Reset();
            }
            else
            {
                DialogResult result = MessageBox.Show(
                    "Для оформления заказа выберите услуги, мастера и дату проведения!",
                    "Attention",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                this.TopMost = true;
                return;
            }
        }
Ejemplo n.º 23
0
        private void SearchField_TextChanged(object sender, EventArgs e)
        {
            string querySearhM = "SELECT * FROM masters WHERE masters.Surname like '%" + SearchField.Text + "%' or masters.Name like '%" + SearchField.Text + "%' or masters.Patronymic like '%" + SearchField.Text + "%' or masters.Phone like '%" + SearchField.Text + "%'";

            QueriesClass.SelectQuery(querySearhM, MastersTable);
        }
Ejemplo n.º 24
0
        private void searchService_TextChanged(object sender, EventArgs e)
        {
            string querySearhS = "SELECT * FROM service WHERE service.name_service like '%" + searchService.Text + "%'";

            QueriesClass.SelectQuery(querySearhS, tableService);
        }
Ejemplo n.º 25
0
        public void GetProductVendorByProductNameTest()
        {
            string vendorName = QueriesClass.GetProductVendorByProductName("Thin-Jam Hex Nut 1");

            Assert.AreEqual(vendorName, "Advanced Bicycles");
        }
Ejemplo n.º 26
0
        private void firstSecondPrice_TextChanged(object sender, EventArgs e)
        {
            //Filter();
            try
            {
                if (firstPrice.Text != "" && secondPrice.Text != "")
                {
                    string AllPrice = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', ')," +
                                      " sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                      " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                      " INNER JOIN orders ON orders.id_order= order_service.id_order" +
                                      " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                      " GROUP BY order_service.id_order" +
                                      " HAVING sum(service.Price) BETWEEN " + int.Parse(firstPrice.Text) + " AND " + int.Parse(secondPrice.Text);
                    QueriesClass.SelectQuery(AllPrice, InfoWorks);
                }
                else
                {
                    QueriesClass.SelectQuery(querySelectOrders, InfoWorks);
                }

                if (firstPrice.Text != "" && secondPrice.Text == "")
                {
                    string fromPrice = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', ')," +
                                       " sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                       " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                       " INNER JOIN orders ON orders.id_order= order_service.id_order" +
                                       " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                       " GROUP BY order_service.id_order" +
                                       " HAVING sum(service.Price)> " + int.Parse(firstPrice.Text);
                    QueriesClass.SelectQuery(fromPrice, InfoWorks);
                }
                else
                if (firstPrice.Text == "" && secondPrice.Text != "")
                {
                    string toPrice = "SELECT orders.id_order,masters.Surname,masters.Name,masters.Patronymic,Group_concat(service.name_service SEPARATOR ', ')," +
                                     " sum(service.price) ,concat_ws('-',day(orders.Date),month(orders.Date),year(orders.Date))" +
                                     " FROM service INNER JOIN order_service ON service.id_service=order_service.id_service " +
                                     " INNER JOIN orders ON orders.id_order= order_service.id_order" +
                                     " INNER JOIN masters ON masters.id_master = orders.id_master" +
                                     " GROUP BY order_service.id_order" +
                                     " HAVING sum(service.Price)< " + int.Parse(secondPrice.Text);
                    QueriesClass.SelectQuery(toPrice, InfoWorks);
                }
            }
            catch
            {
                DialogResult result = MessageBox.Show(
                    "Цена должна быть целочисленного формата",
                    "Attention",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.DefaultDesktopOnly);
                if (firstPrice.Text.Contains("."))
                {
                    firstPrice.Text = "";
                }
                else
                {
                    secondPrice.Text = "";
                }
                this.TopMost = true;
            }
            countWorks.Text = "Количество выполненных работ: " + (InfoWorks.RowCount - 1);
            summLine.Text   = "Сумма: " + Total() + "BYN";
        }
Ejemplo n.º 27
0
 private void Masters_Load(object sender, EventArgs e)
 {
     QueriesClass.SelectQuery(querySelectMasters, MastersTable);
     QueriesClass.SelectQuery(querySelectService, tableService);
     count.Text = "Количество мастеров: " + (MastersTable.RowCount - 1);
 }
Ejemplo n.º 28
0
        private void InsMaster_Click(object sender, EventArgs e)
        {
            string phone;
            string queryInsertMaster;

            if (surname.Text != "")
            {
                if (nameTB.Text != "")
                {
                    if (patronymic.Text != "")
                    {
                        if (adress.Text != "")
                        {
                            if (phoneNumber.Text != "" && PhoneKod.SelectedIndex != -1)
                            {
                                if (!phoneNumber.Text.Contains("."))
                                {
                                    phone             = PhoneKod.SelectedItem.ToString() + phoneNumber.Text;
                                    queryInsertMaster = "Insert into masters VALUES(0,'" + surname.Text + "','" + nameTB.Text + "','" + patronymic.Text + "','" +
                                                        adress.Text + "','" + phone + "');";
                                    QueriesClass.QuerytoTable(queryInsertMaster);
                                    DialogResult result = MessageBox.Show(
                                        "Мастер добавлен!",
                                        "Well",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information,
                                        MessageBoxDefaultButton.Button1,
                                        MessageBoxOptions.DefaultDesktopOnly);
                                    this.TopMost = true;
                                    Reset();
                                }
                                else
                                {
                                    MessageBox.Show("Номер телефона не должен содержать '.'!", "Ошибка!");
                                    phoneNumber.Focus();
                                    return;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Введите номер телефона!", "Ошибка!");
                                phoneNumber.Focus();
                                return;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Введите адрес!", "Ошибка!");
                            adress.Focus();
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Введите отчество!", "Ошибка!");
                        patronymic.Focus();
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Введите имя!", "Ошибка!");
                    nameTB.Focus();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Введите фамилию!", "Ошибка!");
                surname.Focus();
                return;
            }
        }