Пример #1
0
 private void OKButton_Click(object sender, EventArgs e)
 {
     if (nameTypeTB.Text.Trim(' ') == "")
     {
         MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         string nameCostumeType = nameTypeTB.Text;
         string query           = String.Format(@"INSERT INTO `carnaval`.`costume_type`
                         (`name`)
                         VALUES
                        ('{0}');", nameCostumeType);
         long   inserted_id     = DB.SetNoResultQuery(query);
         if (inserted_id > 0)
         {
             hide();
             refreshData();
         }
         else
         {
             MessageBox.Show("При добавлении костюма произошла ошибка, \nобратитесь к системному администратору!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #2
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (fioTB.Text.Trim(' ') == "" && phoneTB.Text.Trim(' ') == "")
            {
                MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string adress, numPass, datePass, departPass, fio = fioTB.Text.Replace("'", "\'"), phone = phoneTB.Text.Replace("'", "\'");
                adress = numPass = datePass = departPass = "******";
                if (adressTB.Text.Trim(' ') != "")
                {
                    adress = "'" + adressTB.Text + "'";
                }
                if (passDateDTP.Value != null)
                {
                    datePass = "******" + DB.DateToMysql(passDateDTP.Value, true, false) + "'";
                }
                if (passNumTB.Text.Trim(' ') != "")
                {
                    numPass = "******" + passNumTB.Text + "'";
                }
                if (passDepartRTB.Text.Trim(' ') != "")
                {
                    departPass = "******" + passDepartRTB.Text + "'";
                }

                string query       = String.Format(@"INSERT INTO `carnaval`.`client`
                                (`name`,
                                `telephone`,
                                `address`,
                                `id_passport`,
                                `passport_issue`,
                                `passport_depart`)
                                VALUES
                                (
                                '{0}',
                                '{1}',
                                 {2},
                                 {3},
                                 {4},
                                 {5});", fio, phone, adress, numPass, datePass, departPass);
                long   inserted_id = DB.SetNoResultQuery(query);
                if (inserted_id > 0)
                {
                    hide();
                    //  mainDGV.Rows.Add(fio, phone);
                    //focusOnRowDGV();
                    refreshData();
                }
                else
                {
                    MessageBox.Show("При добавлении клиента произошла ошибка, \nобратитесь к системному администратору!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
 private void notPaidButton_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in mainDGV.SelectedRows)
     {
         int    bill_id = (int)DB.GetRowCol(row, "id_bill");
         string query   = string.Format("UPDATE `bill` SET `paid` = 0 WHERE `id_bill` = {0}", bill_id);
         DB.SetNoResultQuery(query);
     }
     SetMainDGV(searchTB.Text);
 }
Пример #4
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (costumeDT.Rows.Count == 0)
            {
                MessageBox.Show("Выберите костюмы для выдачи");
                return;
            }
            if ((from DataRow x in costumeDT.Rows where x["vendor"] == "" select x).ToList().Count > 0)
            {
                MessageBox.Show("Введите артикул для каждого костюма");
                return;
            }
            string date      = DB.DateToMysql(dateDTP.Value, true, false);
            int    client_id = (int)clientCB.SelectedValue;
            string query     = "";

            if (CurState == State.Add)
            {
                foreach (DataRow x in costumeDT.Rows)
                {
                    query = string.Format("INSERT INTO `order` (`date`, `client_id`, `costume_size_id`, " +
                                          "`vendor`, `costume_price`, `costume_daily_price`, `returndate_shedule`) " +
                                          "VALUES ('{0}', {1}, {2}, '{3}', {4}, {5}, '{6}')",
                                          date, client_id, x["costume_size_id"], x["vendor"],
                                          x["costume_price"], x["costume_daily_price"],
                                          DB.DateToMysql((DateTime)x["returndate_shedule"], true, false));
                    int    order_id   = DB.SetNoResultQuery(query);
                    string bill_query = string.Format("INSERT INTO `bill` (`date`, `bill_type_id`, `order_id`, " +
                                                      "`employee_id`, `price`, `paid`) VALUES ('{0}', 1, {1}, {2}, {3}, 1)",
                                                      date, order_id, Program.employee_id, x["costume_price"]);
                    DB.SetNoResultQuery(bill_query);
                }
            }
            else
            {
                foreach (DataRow x in costumeDT.Rows)
                {
                    query = string.Format("UPDATE `order` SET `date` = '{0}', `client_id` = {1}, " +
                                          "`costume_size_id` = {2}, `vendor` = '{3}', `returndate_shedule` = '{4}', " +
                                          "`costume_price` = {5}, `costume_daily_price` = {6} WHERE `id_order` = {7}",
                                          date, client_id, x["costume_size_id"], x["vendor"],
                                          DB.DateToMysql((DateTime)x["returndate_shedule"], true, false),
                                          x["costume_price"], x["costume_daily_price"], x["id_order"]);
                    DB.SetNoResultQuery(query);
                    string bill_query = string.Format("UPDATE `bill` SET `date` = '{0}', `price` = {1} WHERE " +
                                                      "`order_id` = {2} AND `bill_type_id` = 1", date, x["rent_price"], x["id_order"]);
                    DB.SetNoResultQuery(bill_query);
                }
            }
            // -----
            SetMainDGV(searchTB.Text);
            CurState = State.Table;
        }
Пример #5
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rows = mainDGV.SelectedRows;
            int    n = rows.Count;
            string text;
            string caption;

            if (n == 1)
            {
                text = string.Format("Вы уверены, что хотите удалить размер костюма \n{0}?",
                                     DB.GetRowCol(rows[0], "costume_name"));
                caption = "Удаление размера костюма";
            }
            else
            {
                Func <string> GetWordForm = () =>
                {
                    if (n % 100 >= 11 && n % 100 <= 19)
                    {
                        return("размеров костюмов");
                    }
                    if (n % 10 == 1)
                    {
                        return("размер костюма");
                    }
                    if (n % 10 >= 2 && n % 10 <= 4)
                    {
                        return("размера костюма");
                    }
                    return("размеров костюмов");
                };

                text = string.Format("Вы уверены, что хотите удалить {0} {1}?",
                                     n, GetWordForm());
                caption = "Удаление размеров костюмов";
            }
            DialogResult answer = MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (answer == DialogResult.No)
            {
                return;
            }

            var ids = from DataGridViewRow x in rows
                      select DB.GetRowCol(x, "id_costume_size");

            string query = string.Format("DELETE FROM `costume_size` WHERE `id_costume_size` IN ({0})",
                                         string.Join(", ", ids));

            DB.SetNoResultQuery(query);
            SetMainDGV(searchTB.Text);
        }
Пример #6
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (nameTB.Text.Trim(' ') == "" || priceTB.Text.Trim(' ') == "" || typeCB.SelectedText.ToString() == null || daily_priceTB.Text.Trim(' ') == "")
            {
                MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string priceCostume = priceTB.Text, daily_priceCostume = daily_priceTB.Text, typeCostume = typeCB.SelectedValue.ToString(), nameCostume = nameTB.Text.Replace("'", "\'");

                string query;
                if (state == "add")
                {
                    query = String.Format(@"INSERT INTO `carnaval`.`costume`
                                (`name`,
                                `costume_type_id`,
                                `price`,
                                `daily_price`)
                                VALUES
                               ('{0}',
                                 {1},
                                 {2},
                                 {3});", nameCostume, typeCostume, priceCostume, daily_priceCostume);
                }
                else
                {
                    query = String.Format(@"UPDATE `carnaval`.`costume`
                                            SET
                                            `name` = '{0}',
                                            `costume_type_id` = '{1}',
                                            `price` = '{2}',
                                            `daily_price` = '{3}'
                                            WHERE `id_costume` = '{4}';
                                            ", nameCostume, typeCostume, priceCostume, daily_priceCostume, DB.GetRowCol(mainDGV.SelectedRows[0], "id_costume").ToString());
                }
                int inserted_id = DB.SetNoResultQuery(query);
                hide();
                //  mainDGV.Rows.Add(fio, phone);
                //focusOnRowDGV();
                refreshData();
                if (callerForm != null && callerForm.GetType() == typeof(CostumeSizeForm))
                {
                    CostumeSizeForm CSForm = (CostumeSizeForm)callerForm;
                    DB.FillCB(CSForm.costumeCB, Properties.Resources.CostumeQuery, "id_costume", "name");
                    if (inserted_id != 0)
                    {
                        CSForm.costumeCB.SelectedValue = inserted_id;
                    }
                    Close();
                }
            }
        }
Пример #7
0
        private void deleteButton_Click(object sender, EventArgs e) //не доделал
        {
            DataGridViewSelectedRowCollection rows = mainDGV.SelectedRows;
            int    n = rows.Count;
            string text;
            string caption;

            if (n == 1)
            {
                if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить запись о костюме\n{0}?",
                                                  mainDGV[0, mainDGV.CurrentRow.Index].Value.ToString()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    string query = String.Format(@"
                                        DELETE FROM `carnaval`.`costume`
                                        WHERE id_costume={0};", DB.GetRowCol(mainDGV.Rows[mainDGV.SelectedCells[0].RowIndex], "id_costume"));
                    DB.SetNoResultQuery(query);
                }
                refreshData();
            }
            else
            {
                Func <string> GetWordForm = () =>
                {
                    if (n % 100 >= 11 && n % 100 <= 19)
                    {
                        return("записей");
                    }
                    if (n % 10 == 1)
                    {
                        return("запись");
                    }
                    if (n % 10 >= 2 && n % 10 <= 4)
                    {
                        return("записи");
                    }
                    return("записей");
                };
                if (MessageBox.Show(String.Format("Вы уверены, что хотите удалить {0} {1} о клиентах?",
                                                  n, GetWordForm()), "Внимание", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.OK)
                {
                    var ids = from DataGridViewRow x in rows
                              select DB.GetRowCol(x, "id_costume");

                    string query = string.Format("DELETE FROM `costume` WHERE `id_costume` IN ({0})", string.Join(", ", ids));
                    DB.SetNoResultQuery(query);
                    refreshData();
                }
            }
        }
Пример #8
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            returndateDTP.Value = new DateTime
                                      (returndateDTP.Value.Year, returndateDTP.Value.Month, returndateDTP.Value.Day);
            int dept;

            if (!Int32.TryParse(deptTB.Text, out dept))
            {
                MessageBox.Show("Поля заполнены некорректно");
                return;
            }
            string dt            = DB.DateToMysql(returndateDTP.Value, true, false);
            var    return_filter = from DataGridViewRow x in rows
                                   select(int) DB.GetRowCol(x, "id_order");

            string return_query = string.Format("UPDATE `order` SET `returndate_actual` = '{0}' " +
                                                "WHERE `id_order` IN ({1})", dt, string.Join(", ", return_filter));

            DB.SetNoResultQuery(return_query);
            // ИСПРАВИТЬ ВЫЧИСЛЕНИЕ СЧЕТА НА ВОЗВРАТ ДЕПОЗИТА
            var bill_return_filter =
                from DataGridViewRow x in rows
                select string.Format("('{0}', 2, {1}, {2}, {3}, 0)",
                                     dt, DB.GetRowCol(x, "id_order"), Program.employee_id,
                                     DB.GetRowCol(x, "costume_price"));

            string bill_return_query = string.Format("INSERT INTO `bill` (`date`, `bill_type_id`, `order_id`, " +
                                                     "`employee_id`, `price`, `paid`) VALUES {0}", string.Join(", ", bill_return_filter));

            DB.SetNoResultQuery(bill_return_query);
            var bill_filter =
                from DataGridViewRow x in rows
                where returndateDTP.Value > (DateTime)DB.GetRowCol(x, "returndate_shedule")
                select string.Format("('{0}', 3, {1}, {2}, {3}, 0)",
                                     dt, DB.GetRowCol(x, "id_order"), Program.employee_id,
                                     Controller.GetRentPrice((DateTime)DB.GetRowCol(x, "returndate_shedule"), returndateDTP.Value, dept));

            if (bill_filter.Count() > 0)
            {
                string bill_query = string.Format("INSERT INTO `bill` (`date`, `bill_type_id`, `order_id`, " +
                                                  "`employee_id`, `price`, `paid`) VALUES {0}", string.Join(", ", bill_filter));
                DB.SetNoResultQuery(bill_query);
            }
            new BillForm(DB.GetRowCol(rows[0], "client_name").ToString()).Show();
            Close();
        }
Пример #9
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            string query;
            int    amount;

            try
            {
                amount = Convert.ToInt32(amountTB.Text);
            }
            catch
            {
                MessageBox.Show("Заполните поля корректно");
                return;
            }
            if (CurState == State.Add)
            {
                query = string.Format("INSERT INTO `costume_size` (`costume_id`, `size_id`, `amount`) " +
                                      "VALUES ({0}, {1}, {2})", costumeCB.SelectedValue, sizeCB.SelectedValue, amount);
            }
            else
            {
                query = string.Format("UPDATE `costume_size` SET `costume_id` = {0}, `size_id` = {1}, " +
                                      "`amount` = {2} WHERE `id_costume_size` = {3}",
                                      costumeCB.SelectedValue, sizeCB.SelectedValue, amount, curCS_id);
            }
            if (CurState == State.Add)
            {
                curCS_id = DB.SetNoResultQuery(query);
            }
            else
            {
                DB.SetNoResultQuery(query);
            }
            SetMainDGV(searchTB.Text);
            if (orderForm != null && orderForm.CurState == OrderForm.State.Add)
            {
                AddOrderCostume();
            }
            CurState = State.Table;
        }
Пример #10
0
 private void OKButton_Click(object sender, EventArgs e)
 {
     if (sizeTB.Text.Trim(' ') == "" || altSizeTB.Text.Trim(' ') == "")
     {
         MessageBox.Show("Заполните все обязательные поля!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         string query;
         string size = sizeTB.Text, altSize = altSizeTB.Text;
         if (state == "add")
         {
             query = String.Format(@"INSERT INTO `carnaval`.`size`
                         (`name`,
                          `numeric`)
                         VALUES
                        ('{0}',
                         '{1}');", size, altSize);
         }
         else
         {
             query = String.Format(@"UPDATE `carnaval`.`size`
                                     SET
                                     `name` = '{0}',
                                     `numeric` = '{1}'
                                     WHERE `id_size` = {2};", size, altSize, DB.GetRowCol(mainDGV.SelectedRows[0], "id_size").ToString());
         }
         long inserted_id = DB.SetNoResultQuery(query);
         if (inserted_id > 0)
         {
             hide();
             refreshData();
         }
         else
         {
             MessageBox.Show("При добавлении размера произошла ошибка, \nобратитесь к системному администратору!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }