private void toolStripBtAddRepair_Click(object sender, EventArgs e)
        {
            if (tbSurnameDriver.Text == "" || tbNameDriver.Text == "" || tbPatronimycDriver.Text == "" ||
                tbBrandCar.Text == "" || tbModelCar.Text == "" || cbYearCreated.Text == "" ||
                tbNumberSTSCar.Text == "")
            {
                MessageBox.Show("Сначала заполните/сохраните информацию о клиенте", "Ошибка");
                return;
            }

            FormAddRepairForCurrentClient farfcc = new FormAddRepairForCurrentClient(db);

            farfcc.ShowDialog();

            if (StaticData.DataBufferNameRepair != null && StaticData.DataBufferEmployee != null)
            {
                if (clbRepairs.Items.Contains(StaticData.DataBufferNameRepair))
                {
                    DialogResult dialogResult = MessageBox.Show("Вы уверены что хотите добавить уже запланированную ремонтную работу ещё раз?", "Подтверждение", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.No)
                    {
                        return;
                    }
                }

                //Обновление списка работ после закрытия дочерней формы
                clbRepairs.Items.Add(StaticData.DataBufferNameRepair);
                lbEmployeesRepairs.Items.Add(StaticData.DataBufferEmployee);

                db.SearchCostRepairs(StaticData.DataBufferNameRepair, lbRepairsCosts);

                int totalCost = 0;

                for (int i = 0; i < lbRepairsCosts.Items.Count; i++)
                {
                    totalCost += Convert.ToInt32(lbRepairsCosts.Items[i].ToString());
                }

                lbRepairsTotalCost.Text = "Итоговая\nстоимость:\n" + totalCost + " рублей";

                string[] strEmployee = lbEmployeesRepairs.Items[lbEmployeesRepairs.Items.Count - 1].ToString().Split(new char[] { ' ' });
                int      idEmployee  = Convert.ToInt32(strEmployee[strEmployee.Length - 1]);

                string factQuery;
                factQuery = "(`work_hours_id_work_hours`, `repairs_id_repair`, `clients_id_client`, `time_start`, `status_repair`) VALUES('" +
                            db.SearchIdWorkHours(idEmployee, DateTime.Today.ToString("yyyy-MM-dd")) + "', '" +
                            db.SearchIdRepairs(clbRepairs.Items[clbRepairs.Items.Count - 1].ToString()) +
                            "', '" + idClient + "', '" + timeStartRepair + "', 'Не выполнено');";
                db.Add("current_repairs", factQuery);

                idCurrentRepairs.Add(db.LastIDCurrentRepairs());//Добавляем ID работы в список Id работ по клиенту

                toolStripProgressBarStatusRepairs.Maximum = clbRepairs.Items.Count;
                toolStripProgressBarStatusRepairs.Value   = clbRepairs.CheckedItems.Count;
            }
        }
Esempio n. 2
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            string factQuery;

            if (tbSurname.Text == "" || tbName.Text == "" || tbPatronimyc.Text == "" || tbPhone.Text == "" || cbNumSTS.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Ошибка");
            }
            else
            {
                if (!edit)
                {
                    factQuery = "(surname, name, patronimyc, phone_number, cars_number_sts) VALUES('" +
                                tbSurname.Text + "', '" + tbName.Text + "', '" + tbPatronimyc.Text + "', '" +
                                tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "") + "', '" + cbNumSTS.Text + "');";
                    db.Add("clients", factQuery);
                }
                else
                {
                    factQuery = "surname = '" + tbSurname.Text + "', name = '" + tbName.Text + "', " +
                                "patronimyc = '" + tbPatronimyc.Text + "', phone_number = '" +
                                tbPhone.Text.Replace(" ", "").Replace("(", "").Replace(")", "") +
                                "', cars_number_sts = '" + cbNumSTS.Text + "'";
                    db.Edit("clients", "id_client", idClient, factQuery);
                }

                Hide();
            }
        }