//Отмена действующих фильтров в таблице с менеджерами private void filterCancelBtn_Click(object sender, EventArgs e) { try { fullName.Text = ""; managersTable.DataSource = null; DBConnection.GetManagers(); managersTable.DataSource = DBConnection.dtManagers; if (DBConnection.dtManagers.Rows.Count > 0) { ReadManagersTableRow(0); } } catch (Exception ex) { exceptPanel.Visible = true; richTextBox1.Text = ex.ToString(); } }
//Выполняется при загрузке формы, заполнение таблицы данными из БД, настройка элементов управления private void Managers_Load(object sender, EventArgs e) { try { formDescriptor = this; reconnectBtn.Font = new Font(reconnectBtn.Font.Name, 10, FontStyle.Regular | FontStyle.Underline); managersTable.RowsDefaultCellStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#f1f2f6"); managersTable.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#ffffff"); DBConnection.GetManagers(); managersTable.DataSource = DBConnection.dtManagers; //managersTable.CurrentCell = managersTable[0, 0]; managersTable.Rows[0].Selected = true; ReadManagersTableRow(0); } catch (Exception ex) { exceptPanel.Visible = true; richTextBox1.Text = ex.ToString(); } }
//Редактирование менеджера, обновление данных в связанных таблицах private void saveManagerBtn_Click(object sender, EventArgs e) { try { if (fullName.Text == "" || adress.Text == "" || phone.Text == "" || login.Text == "" || password.Text == "") { MessageBox.Show("Заполните все поля!"); return; } DBConnection.EditManager(Managers.managerID, fullName.Text, adress.Text, phone.Text, dateBirth.Value.ToString("yyyy-MM-dd"), dateStartWork.Value.ToString("yyyy-MM-dd"), login.Text, password.Text); DBConnection.GetManagers(); Managers.formDescriptor.managersTable.DataSource = DBConnection.dtManagers; Managers.ReadManagersTableRow(0); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//Происходит при загрузке формы, настройка элементов управления private void EditRequest_Load(object sender, EventArgs e) { try { loadingPanel.Visible = false; DBConnection.GetManagers(); manager.DataSource = DBConnection.dtManagers; manager.DisplayMember = "ФИО"; manager.ValueMember = "ID"; DBConnection.GetClients(); client.DataSource = DBConnection.dtClients; client.DisplayMember = "Название"; client.ValueMember = "ID"; dateRequest.Value = Convert.ToDateTime(date_request); dateContract.Value = Convert.ToDateTime(date_contract); client.SelectedValue = client_num; manager.SelectedValue = manager_num; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//Происходит при загрузке формы, настройка элементов управления private void AddRequest_Load(object sender, EventArgs e) { try { loadingPanel.Visible = false; DBConnection.GetClients(); client.DataSource = DBConnection.dtClients; client.DisplayMember = "Название"; client.ValueMember = "ID"; DBConnection.GetManagers(); manager.DataSource = DBConnection.dtManagers; manager.DisplayMember = "ФИО"; manager.ValueMember = "ID"; status.Text = "Новый"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//Удаление выбранного менеджера private void delManagerBtn_Click(object sender, EventArgs e) { try { if (managersTable.Rows.Count == 0) { MessageBox.Show("Нет записей для удаления!"); return; } managersTable.DataSource = null; DBConnection.DeleteManager(managerID); DBConnection.GetManagers(); managersTable.DataSource = DBConnection.dtManagers; if (DBConnection.dtManagers.Rows.Count > 0) { ReadManagersTableRow(0); } } catch (Exception ex) { exceptPanel.Visible = true; richTextBox1.Text = ex.ToString(); } }