private void toolStripBtExtension_Click(object sender, EventArgs e) { if (tbSurnameDriver.Text == "" || tbNameDriver.Text == "" || tbPatronimycDriver.Text == "" || tbBrandCar.Text == "" || tbModelCar.Text == "" || cbYearCreated.Text == "" || tbNumberSTSCar.Text == "") { MessageBox.Show("Сначала заполните/сохраните информацию о клиенте", "Ошибка"); return; } if (clbRepairs.Items.Count == 0) { MessageBox.Show("Добавьте хотя-бы одну ремонтную работу", "Ошибка"); return; } List <int> idCurrentRepairs = db.SearchIdCurrentRepairs(idClient); List <int> idEmployees = new List <int>(); List <string[]> strEmployees = new List <string[]>(); List <int> idWorkHours = new List <int>(); List <int> idRepairs = new List <int>(); for (int i = 0; i < lbEmployeesRepairs.Items.Count; i++) { strEmployees.Add(lbEmployeesRepairs.Items[i].ToString().Split(new char[] { ' ' })); idEmployees.Add(Convert.ToInt32(strEmployees[i][strEmployees[i].Length - 1])); idWorkHours.Add(db.SearchIdWorkHours(idEmployees[i], DateTime.Today.ToString("yyyy-MM-dd"))); idRepairs.Add(db.SearchIdRepairs(clbRepairs.Items[i].ToString())); } string timeFinish = ""; int oldIdExtentionRepair = db.SearchIdExtensionRepair(idCurrentRepairs[0], quantityDays); if (toolStripComboBoxQuantityDays.Text != "Количество дней" && Convert.ToInt32(toolStripComboBoxQuantityDays.Text) <= 15) { quantityDays += Convert.ToInt32(toolStripComboBoxQuantityDays.Text); } else { quantityDays++; } for (int i = 0; i < idCurrentRepairs.Count; i++) { db.AddExtentionRepairs(oldIdExtentionRepair, idCurrentRepairs[i], quantityDays); db.UpdateOrInsertCurrentRepairs(idCurrentRepairs[i], idWorkHours[i], idRepairs[i], idClient, timeStartRepair, timeFinish, "Продлено"); } toolStripStatusLabelInfoClient.Text = "Всего дней работы: " + quantityDays; }