コード例 #1
0
ファイル: Dashboard.cs プロジェクト: zanayr/Appoint-MS
 private void DeleteCustomer(int id)
 {
     string[] message =
     {
         "Are you sure want to delete customer " + id + " from the database?",
         "¿Estás seguro que quieres borrar el cliente " + id + " del database?"
     };
     string[] title =
     {
         "Warning",
         "Aviso"
     };
     if (MessageBox.Show(message[Global.Language], title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         try
         {
             Customers.Remove(Customers.GetCustomerBy(c => c.ID == id));
         }
         catch (UnableToDeleteCustomerException e)
         {
             if (MessageBox.Show(e.Message, title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
             {
                 Appointments.GetBy(a => a.Customer.ID == id).ForEach(a =>
                 {
                     Appointments.Remove(Appointments.GetAppointmentBy(p => p.ID == a.ID));
                 });
                 Customers.Remove(Customers.GetCustomerBy(c => c.ID == id));
                 ResponseLabel.Text = _responsesArray[Convert.ToInt32(Responses.DELETE_CUSTOMER), Global.Language] + Convert.ToString(id);
             }
         }
         finally
         {
             ToggleDashboard();
         }
     }
     else
     {
         ToggleDashboard();
     }
 }
コード例 #2
0
ファイル: Dashboard.cs プロジェクト: zanayr/Appoint-MS
        private void DeleteAppointment(int id)
        {
            string[] message =
            {
                "Are you sure want to delete appointment " + id + " from the database?",
                "¿Estás seguro que quieres borrar la cita " + id + " del database?"
            };
            string[] title =
            {
                "Warning",
                "Aviso"
            };
            if (MessageBox.Show(message[Global.Language], title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                Appointments.Remove(Appointments.GetAppointmentBy(a => a.ID == id));
                ResponseLabel.Text = _responsesArray[Convert.ToInt32(Responses.DELETE_APPOINTMENT), Global.Language] + Convert.ToString(id);

                ToggleDashboard();
            }
            else
            {
                ToggleDashboard();
            }
        }