public static bool CreateEditCauseRow(TableCauses row, Boolean isCreate, int id) { Conn.Open(); try { string Query; if (isCreate) { Query = "INSERT INTO finished_causes (`id_cause`, `max_term`, `min_term`, `received_term`, `excuses`, `suspended_sentence`, `fines`, `date_cause`, `description`, `id_client`)" + "VALUES (@id_cause, @max_term, @min_term, @received_term, @excuses, @suspended_sentence, @fines, @date_cause, @description, @id_client)"; } else { Query = "UPDATE finished_causes SET id_cause = @id_cause, max_term = @max_term, min_term = @min_term, received_term = @received_term, excuses = @excuses, suspended_sentence = @suspended_sentence, fines = @fines, date_cause = @date_cause, description = @description, id_client = @id_client WHERE id_cause = " + id; } MySqlCommand cmd = new MySqlCommand(Query, Conn); cmd.Parameters.AddWithValue("@id_cause", row.ID); cmd.Parameters.AddWithValue("@max_term", row.MaxTerm); cmd.Parameters.AddWithValue("@min_term", row.MinTerm); cmd.Parameters.AddWithValue("@received_term", row.ResultTerm); cmd.Parameters.AddWithValue("@excuses", row.Excuse); cmd.Parameters.AddWithValue("@suspended_sentence", row.SuspendedSentence); cmd.Parameters.AddWithValue("@fines", row.Fines); cmd.Parameters.AddWithValue("@date_cause", row.Date); cmd.Parameters.AddWithValue("@description", row.Description); cmd.Parameters.AddWithValue("@id_client", row.IDClient); cmd.ExecuteNonQuery(); } catch { Conn.Close(); return(false); } Conn.Close(); return(true); }
int GetCauseRow() { TableCauses row; try { row = new TableCauses(Convert.ToInt32(IDCause.Text), Convert.ToInt32(MaxTerm.Text), Convert.ToInt32(MinTerm.Text), Convert.ToInt32(ReceivedTerm.Text), Excuses.Text, Convert.ToInt32(SuspendedSentence.Text), Convert.ToInt32(Fines.Text), Date.Text.GetValue(), Description.Text, Convert.ToInt32(IDClientCase.Text)); } catch { System.Windows.Forms.MessageBox.Show("Ошибка. Введены некорректные данные", "Результат выполнения запроса", MessageBoxButtons.OK); return(0); } if (DataBaseCreateEditRow.CreateEditCauseRow(row, isCreate, ID)) { System.Windows.Forms.MessageBox.Show("Операция успешно выполнена", "Результат выполнения запроса", MessageBoxButtons.OK); Close(); DataBaseGetRows.QueryCausesTable(); main.admin.IsEnabled = true; } else { System.Windows.Forms.MessageBox.Show("Ошибка при выполнении операции в БД", "Результат выполнения запроса", MessageBoxButtons.OK); } return(0); }
public void GetCauseData(TableCauses row) { IDCause.Text = row.ID.ToString(); MaxTerm.Text = row.MaxTerm.ToString(); MinTerm.Text = row.MinTerm.ToString(); ReceivedTerm.Text = row.ResultTerm.ToString(); Excuses.Text = row.Excuse; SuspendedSentence.Text = row.SuspendedSentence.ToString(); Fines.Text = row.Fines.ToString(); Date.Text = row.Date; Description.Text = row.Description; IDClientCase.Text = row.IDClient.ToString(); }
private void DeleteRowClick(object sender, EventArgs e) { try { if (LawyersTable.Visibility == Visibility.Visible) { TableLawyers row = (TableLawyers)LawyersTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("lawyers", row.ID)) { DataBaseGetRows.QueryLawyersTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (ClientsTable.Visibility == Visibility.Visible) { TableClients row = (TableClients)ClientsTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("clients", row.ID)) { DataBaseGetRows.QueryClientsTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (CausesTable.Visibility == Visibility.Visible) { TableCauses row = (TableCauses)CausesTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("causes", row.ID)) { DataBaseGetRows.QueryCausesTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (EfficiencyTable.Visibility == Visibility.Visible) { TableEfficiency row = (TableEfficiency)EfficiencyTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("success", row.ID)) { DataBaseGetRows.QueryEfficiencyTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (FeesTable.Visibility == Visibility.Visible) { TableFees row = (TableFees)FeesTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("fees", row.ID)) { DataBaseGetRows.QueryFeesTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (ReportsTable.Visibility == Visibility.Visible) { TableReports row = (TableReports)ReportsTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("reports", row.ID)) { DataBaseGetRows.QueryReportsTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else if (PasswordTable.Visibility == Visibility.Visible) { TableAuthorization row = (TableAuthorization)PasswordTable.SelectedItems[0]; if (DataBaseDeleteRow.DeleteRow("authoriz", row.ID)) { DataBaseGetRows.QueryAuthorizTable(); System.Windows.Forms.MessageBox.Show("Запись успешно удалена", "Удаление", MessageBoxButtons.OK); } } else { System.Windows.Forms.MessageBox.Show("Вы не выбрали запись для удаления", "Удаление", MessageBoxButtons.OK); } } catch { System.Windows.Forms.MessageBox.Show("Вы не выбрали запись для удаления", "Удаление", MessageBoxButtons.OK); } }
private void EditRowClick(object sender, EventArgs e) { try { if (LawyersTable.Visibility == Visibility.Visible) { TableLawyers row = (TableLawyers)LawyersTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "lawyers", false, row.ID); cer.GetLawyerData(row); cer.Show(); } } else if (ClientsTable.Visibility == Visibility.Visible) { TableClients row = (TableClients)ClientsTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "clients", false, row.ID); cer.GetClientData(row); cer.Show(); } } else if (CausesTable.Visibility == Visibility.Visible) { TableCauses row = (TableCauses)CausesTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "causes", false, row.ID); cer.GetCauseData(row); cer.Show(); } } else if (EfficiencyTable.Visibility == Visibility.Visible) { TableEfficiency row = (TableEfficiency)EfficiencyTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "success", false, row.ID); cer.GetEfficiencyData(row); cer.Show(); } } else if (FeesTable.Visibility == Visibility.Visible) { TableFees row = (TableFees)FeesTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "fees", false, row.ID); cer.GetFeeData(row); cer.Show(); } } else if (ReportsTable.Visibility == Visibility.Visible) { TableReports row = (TableReports)ReportsTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "reports", false, row.ID); cer.GetReportData(row); cer.Show(); } } else if (PasswordTable.Visibility == Visibility.Visible) { TableAuthorization row = (TableAuthorization)PasswordTable.SelectedItems[0]; if (row != null) { admin.IsEnabled = false; CreateEditRow cer = new CreateEditRow(this, "authoriz", false, row.ID); cer.GetAuthorizData(row); cer.Show(); } } else { System.Windows.Forms.MessageBox.Show("Вы не выбрали запись для редактирования", "Редактирование", MessageBoxButtons.OK); } } catch { System.Windows.Forms.MessageBox.Show("Вы не выбрали запись для редактирования", "Редактирование", MessageBoxButtons.OK); } }