예제 #1
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);
                }
            }
        }
예제 #2
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;
        }
예제 #3
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();
        }