コード例 #1
0
        private async void BtnRemove_Click(object sender, EventArgs e)
        {
            Mensajes.MensajePregunta("¿Confirma la inactivación/eliminación del cliente?", "Confirmar", "Cancelar", out DialogResult dialog);
            if (dialog == DialogResult.Yes)
            {
                try
                {
                    string rpta = string.Empty;
                    if (this.Agendamiento != null)
                    {
                        rpta = await NUsuarios.InactivarUsuario(this.Agendamiento.Venta.Id_cliente);

                        if (rpta.Equals("OK"))
                        {
                            Mensajes.MensajeInformacion("Se inactivó correctamente el cliente", "Entendido");
                            this.OnRefresh?.Invoke(sender, e);
                        }
                        else
                        {
                            throw new Exception(rpta);
                        }

                        return;
                    }

                    if (this.Venta != null)
                    {
                        rpta = await NUsuarios.InactivarUsuario(this.Venta.Id_cliente);

                        if (rpta.Equals("OK"))
                        {
                            Mensajes.MensajeInformacion("Se inactivó correctamente el cliente", "Entendido");
                            this.OnRefresh?.Invoke(sender, e);
                        }
                        else
                        {
                            throw new Exception(rpta);
                        }

                        return;
                    }
                }
                catch (Exception ex)
                {
                    Mensajes.MensajeErrorCompleto(this.Name, "BtnRemove_Click",
                                                  "Hubo un error al remover el cliente", ex.Message);
                }
            }
        }