public static bool CreateEditLawyerRow(TableLawyers row, Boolean isCreate, int id)
 {
     Conn.Open();
     try
     {
         string Query;
         if (isCreate)
         {
             Query = "INSERT INTO lawyers (id_lawyer, surname, name, second_name, phone)" + "VALUES (@id_lawyer, @surname, @name, @second_name, @phone)";
         }
         else
         {
             Query = "UPDATE lawyers SET id_lawyer = @id_lawyer, surname = @surname, name = @name, second_name = @second_name, phone = @phone WHERE id_lawyer = " + id;
         }
         MySqlCommand cmd = new MySqlCommand(Query, Conn);
         cmd.Parameters.AddWithValue("@id_lawyer", row.ID);
         cmd.Parameters.AddWithValue("@surname", row.Surname);
         cmd.Parameters.AddWithValue("@name", row.Name);
         cmd.Parameters.AddWithValue("@second_name", row.SecondName);
         cmd.Parameters.AddWithValue("@phone", row.Phone);
         cmd.ExecuteNonQuery();
     }
     catch
     {
         Conn.Close();
         return(false);
     }
     Conn.Close();
     return(true);
 }
        int GetLawyerRow()
        {
            TableLawyers row;

            try
            {
                row = new TableLawyers(Convert.ToInt32(IDLawyer.Text), SurnameLawyer.Text.GetValue(), NameLawyer.Text.GetValue(), SecondNameLawyer.Text, PhoneLawyer.Text);
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("Ошибка. Введены некорректные данные", "Результат выполнения запроса", MessageBoxButtons.OK);
                return(0);
            }
            if (DataBaseCreateEditRow.CreateEditLawyerRow(row, isCreate, ID))
            {
                System.Windows.Forms.MessageBox.Show("Операция успешно выполнена", "Результат выполнения запроса", MessageBoxButtons.OK);
                Close();
                DataBaseGetRows.QueryLawyersTable();
                main.admin.IsEnabled = true;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Ошибка при выполнении операции в БД", "Результат выполнения запроса", MessageBoxButtons.OK);
            }
            return(0);
        }
 public void GetLawyerData(TableLawyers row)
 {
     IDLawyer.Text         = row.ID.ToString();
     SurnameLawyer.Text    = row.Surname;
     NameLawyer.Text       = row.Name;
     SecondNameLawyer.Text = row.SecondName;
     PhoneLawyer.Text      = row.Phone;
 }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
 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);
     }
 }