void DGV_Adver() { dgv_Air.Visible = dgv_Emp.Visible = dgv_Own_Statistic.Visible = panelButtons.Enabled = groupBox_Air.Visible = groupBox_Emp.Visible = groupBoxV_Stat_FIO.Visible = menuStrip1.Visible = false; dgv_Advertisements.Visible = groupBox_Nothing.Visible = true; Advertisements_Class adv = new Advertisements_Class(); adv.Update_DGV(dgv_Advertisements); }
private void butUpdate_Click(object sender, EventArgs e) { if (MessageBox.Show("Вы уверены, что хотите внести изменения?!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // Изменение данных о клиенте: #region if (dgv_Own_Client.Visible) { Clients_Class CL_Class = new Clients_Class(); if (textBoxClientSurname.Text.Trim() != "" && textBoxClientName.Text.Trim() != "" && maskedTextBoxClientBankcard.Text != "0000-0000-0000-0000" && maskedTextBoxClientPassport.Text != "000000000" && maskedTextBoxClientTel.Text != "+79990000000") { Clients_Class CL_Update = new Clients_Class(); CL_Update.Update_clients(Client_Passport, textBoxClientSurname.Text.Trim(), textBoxClientName.Text, textBoxClientLastName.Text.Trim(), maskedTextBoxClientBankcard.Text.Trim(), maskedTextBoxClientTel.Text.Trim(), dgv_Own_Client, Emp_Code); DGV_Own_Clients(); ClearBoxes(); } else { MessageBox.Show("Не все ключевые значения были заполнены", "Невозможно внести изменения", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #endregion // Изменение данных о рекламе if (dgv_Own_Adver.Visible) { Advertisements_Class Adv_Update = new Advertisements_Class(); if (comboBoxTime.SelectedIndex != -1 && comboBoxFIO_Passport.SelectedIndex != -1 && comboBoxBroadcast.SelectedIndex != -1 && textBoxInterval.Text != "") { Adv_Update.Update_Adver(Adver_id, comboBoxFIO_Passport.Text, textBoxReklama.Text, int.Parse(textBoxInterval.Text), comboBoxBroadcast.Text, TimeSpan.Parse(comboBoxTime.Text), dgv_Own_Adver, Emp_Code, TimeSpan.Parse(old_reklama_time)); Adv_Update.Update_DGV(dgv_Own_Adver); Adv_Update.Update_DGV(dgv_Own_Adver, Emp_Code); } else { MessageBox.Show("Не все поля были заполнены", "Невозможно внести изменения", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } ClearBoxes(); Panel_Buttons.Enabled = false; }
// Обновление DGV личного public void Update_DGV(DataGridView DGV, byte code) { Advertisements_Class adv = new Advertisements_Class(); byte[] ArrayEmp_Cl = adv.Emp_Clients(code); List <Clients> list = new List <Clients>(); for (int i = 0; i < ArrayEmp_Cl.Length; i++) { byte k = ArrayEmp_Cl[i]; var cl_list = AD.Clients.Where(c => c.cl_id == k).Single(); list.Add(cl_list); } DGV.AutoGenerateColumns = false; DGV.DataSource = list; }
private void butDel_Click(object sender, EventArgs e) { // Удаление клиента: if (MessageBox.Show("Вы уверены, что хотите внести изменения?!", "Надо сделать выбор", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (dgv_Own_Client.Visible) { if (textBoxClientSurname.Text.Trim() != "" && textBoxClientName.Text.Trim() != "" && maskedTextBoxClientBankcard.Text != "" && maskedTextBoxClientPassport.Text != "") { Clients_Class Cl_Class = new Clients_Class(); Cl_Class.Delete_clients(Client_Passport, dgv_Own_Client); DGV_Client(); MessageBox.Show("Запись удалена"); ClearBoxes(); } else { MessageBox.Show("Поля не должны быть пустыми"); } } // Удаление рекламы: if (dgv_Own_Adver.Visible) { if (comboBoxFIO_Passport.Text != "" && textBoxReklama.Text.Trim() != "" && comboBoxBroadcast.Text != "" && textBoxInterval.Text != "" && comboBoxTime.Text != "") { Advertisements_Class adver_del = new Advertisements_Class(); adver_del.Delete_Adver(Adver_id, textBoxReklama.Text, TimeSpan.Parse(comboBoxTime.Text), dgv_Own_Adver); adver_del.Update_DGV(dgv_Own_Adver); adver_del.Update_DGV(dgv_Own_Adver, Emp_Code); MessageBox.Show("Реклама удалена"); ClearBoxes(); } else { MessageBox.Show("Поля не должны быть пустыми"); } } } Panel_Buttons.Enabled = false; }
// Манипулирование рекламой #region void Reklama() { dgv_Own_Statistic.Visible = dgv_Air.Visible = dgv_Clients.Visible = dgv_Own_Client.Visible = groupBox_Own_Stat.Visible = groupBox_Clients.Visible = but_Update.Enabled = false; Clients_Class client = new Clients_Class(); client.Update_DGV(dgv_Clients); Air_Class air = new Air_Class(); air.Update_DGV(dgv_Air); Advertisements_Class Adver = new Advertisements_Class(); if (dgv_Advertisements.Visible) { groupBox_Nothing.Visible = true; Panel_Buttons.Enabled = groupBox_V_Reklama.Visible = false; Adver.Update_DGV(dgv_Advertisements); } if (dgv_Own_Adver.Visible) { groupBox_Nothing.Visible = false; groupBox_V_Reklama.Visible = true; Adver.Update_DGV(dgv_Own_Adver, Emp_Code); //panelButtons.Enabled = false; if (client.Clients_Count() > comboBoxFIO_Passport.Items.Count) { foreach (DataGridViewRow item in dgv_Clients.Rows) { comboBoxFIO_Passport.Items.Add(client.ChangeFIO(byte.Parse(item.Cells[0].Value.ToString().Trim()))); } } if (dgv_Air.RowCount > comboBoxBroadcast.Items.Count) { foreach (DataGridViewRow item in dgv_Air.Rows) { comboBoxBroadcast.Items.Add(item.Cells[0].Value.ToString()); } } } }
// ДОБАВЛЕНИЕ, УДАЛЕНИЕ И ИЗМЕНЕНИЕ ДАННЫХ #region private void butInsert_Click(object sender, EventArgs e) { if (MessageBox.Show("Вы уверены, что хотите внести изменения?!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // Добавление клиентов: #region if (dgv_Own_Client.Visible) { Clients_Class CL_Class = new Clients_Class(); if (textBoxClientSurname.Text.Trim() != "" && textBoxClientName.Text.Trim() != "" && maskedTextBoxClientBankcard.Text != "0000-0000-0000-0000" && maskedTextBoxClientPassport.Text != "000000000" && maskedTextBoxClientTel.Text != "+79990000000") { // Проверка пасспорта: Check = CL_Class.Check_Passport(maskedTextBoxClientPassport.Text); if (Check == 1) { maskedTextBoxClientPassport.Text = ""; MessageBox.Show("Такой паспорт уже занят, введите другой", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Проверка банковской карточки: Check = CL_Class.Check_BankCard(maskedTextBoxClientBankcard.Text, maskedTextBoxClientPassport.Text, false); if (Check == 1) { maskedTextBoxClientBankcard.Text = ""; MessageBox.Show("Данный номер банковской карточки уже имеется в базе, введите другой", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Проверка телефона: Check = CL_Class.Check_Phone(maskedTextBoxClientTel.Text, maskedTextBoxClientPassport.Text, false); if (Check == 1) { maskedTextBoxClientTel.Text = ""; MessageBox.Show("Данный номер телефона уже имеется в базе, введите другой", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { CL_Class.Insert_clients(textBoxClientSurname.Text.Trim(), textBoxClientName.Text, textBoxClientLastName.Text.Trim(), maskedTextBoxClientPassport.Text.Trim(), maskedTextBoxClientBankcard.Text.Trim(), maskedTextBoxClientTel.Text.Trim(), dgv_Own_Client, Emp_Code); MessageBox.Show("Новый клиент добавлен. Для того, чтобы увидеть его в списке своих клиентов необходимо добавить его рекламу", "", MessageBoxButtons.OK, MessageBoxIcon.Information); CL_Class.Update_DGV(dgv_Own_Client, Emp_Code); CL_Class.Update_DGV(dgv_Clients); ClearBoxes(); } } } } else { MessageBox.Show("Не все ключевые значения были заполнены"); } } #endregion //Добавление рекламы: if (dgv_Own_Adver.Visible) { Advertisements_Class adver = new Advertisements_Class(); if (comboBoxFIO_Passport.Text.Trim() != "" && textBoxReklama.Text.Trim() != "" && comboBoxBroadcast.Text != "" && textBoxInterval.Text != "" && comboBoxTime.Text != "") { if (adver.Check_Count(textBoxReklama.Text, TimeSpan.Parse(comboBoxTime.Text)) != 1) { adver.Insert_Adver(comboBoxFIO_Passport.Text, textBoxReklama.Text, comboBoxBroadcast.Text, int.Parse(textBoxInterval.Text), TimeSpan.Parse(comboBoxTime.Text), dgv_Advertisements, Emp_Code); adver.Update_DGV(dgv_Own_Adver); adver.Update_DGV(dgv_Own_Adver, Emp_Code); MessageBox.Show("Реклама добавлена"); ClearBoxes(); } else { MessageBox.Show("Данная реклама уже имеется", "Невозможно внести изменения", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Не все ключевые значения были заполнены", "Невозможно внести изменения", MessageBoxButtons.OK, MessageBoxIcon.Error); } } ClearBoxes(); Panel_Buttons.Enabled = false; } }