コード例 #1
0
        public IActionResult Edit(Cliente cliente)
        {
            if (service.ActualizarCliente(cliente))
            {
                return(RedirectToAction("Index"));
            }

            return(View(cliente));
        }
コード例 #2
0
        private void BtnAceptar_Click(object sender, EventArgs e)
        {
            switch (formMode)
            {
            case FormMode.insert:
            {
                if (ValidarCamposObl())
                {
                    if (ValidarDNICliente())
                    {
                        Cliente oCliente = new Cliente();
                        LlenarDatosCliente(oCliente);

                        clienteService.CargarCliente(oCliente);

                        MessageBox.Show("Usuario cargado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //this.Close(); Deshabilitado temporalmente

                        this.clienteSeleccionado  = oCliente;
                        tabFrmCliente.SelectedTab = tabVehiculos;
                        this.HabilitarTxtVeh(true);
                        this.btnInfo.Enabled        = false;
                        this.btnVehiculos.Enabled   = true;
                        this.btnEliminar.Visible    = false;
                        this.btnEditar.Visible      = false;
                        this.btnNuevo.Visible       = false;
                        this.btnAceptarVeh.Enabled  = true;
                        this.btnCancelarVeh.Visible = false;
                    }
                    else
                    {
                        MessageBox.Show("Ya existe un cliente con el número de DNI ingresado. Por favor, ingrese un DNI diferente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("No se han completado uno o más campos obligatorios.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                break;
            }

            case FormMode.update:
            {
                if (ValidarCamposObl())
                {
                    LlenarDatosCliente(clienteSeleccionado);

                    clienteService.ActualizarCliente(clienteSeleccionado);

                    MessageBox.Show("Usuario actualizado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //this.Dispose();
                }
                else
                {
                    MessageBox.Show("No se han completado uno o más campos obligatorios.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                break;
            }

            case FormMode.details:

                MostrarDatos(clienteSeleccionado);
                this.Close();
                break;
            }
        }
コード例 #3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            switch (formMode)
            {
            case FormMode.insert:
            {
                if (ValidarCampos())
                {
                    var oCliente = new Cliente();
                    oCliente.Apellido = txtapellido.Text;
                    oCliente.Nombre   = txtnombre.Text;
                    oCliente.Cuit     = txtcuit.Text;

                    if (oClienteService.CrearCliente(oCliente))
                    {
                        MessageBox.Show("Cliente creado", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
                break;
            }

            case FormMode.update:
            {
                if (ValidarCampos())
                {
                    oClienteSelected.Apellido = txtapellido.Text;
                    oClienteSelected.Nombre   = txtnombre.Text;
                    oClienteSelected.Cuit     = txtcuit.Text;


                    if (oClienteService.ActualizarCliente(oClienteSelected))
                    {
                        MessageBox.Show("Cliente actualizado!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar el cliente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                break;
            }

            case FormMode.delete:
            {
                if (MessageBox.Show("Seguro que desea habilitar/deshabilitar el producto seleccionado?", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    if (oClienteService.ModificarBorradoCliente(oClienteSelected))
                    {
                        MessageBox.Show("Cliente Habilitado/Deshabilitado!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    //   else
                    //       MessageBox.Show("Error al actualizar el cliente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                break;
            }
            }
        }
コード例 #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            switch (formMode)
            {
            case FormMode.insert:
            {
                if (ExisteCliente() == false)
                {
                    if (ValidarCampos())
                    {
                        var oClientes = new BugTracker.Entities.Clientes();
                        oClientes.RazonSocial     = txtRazonSocial.Text;
                        oClientes.Cuit            = (int)Convert.ToUInt32(txtCuit.Text);
                        oClientes.Calle           = txtCalle.Text;
                        oClientes.Barrio          = new Barrio();
                        oClientes.Barrio.IDBarrio = (int)cboBarrio.SelectedValue;
                        oClientes.FechaAlta       = Convert.ToDateTime(txtFechaAlta.Text);
                        oClientes.NumeroCalle     = Convert.ToInt32(txtNumeroCalle.Text);
                        oClientes.Borrado         = 0;

                        if (oClienteService.CrearCliente(oClientes))
                        {
                            MessageBox.Show("Cliente Insertado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Cliente encontrado! Ingrese un cliente distinto", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;
            }

            case FormMode.update:
            {
                if (ValidarCampos())
                {
                    oClienteSelected.RazonSocial     = txtRazonSocial.Text;
                    oClienteSelected.Cuit            = Convert.ToInt32(txtCuit.Text);
                    oClienteSelected.FechaAlta       = Convert.ToDateTime(txtFechaAlta.Text);
                    oClienteSelected.Calle           = txtCalle.Text;
                    oClienteSelected.NumeroCalle     = Convert.ToInt32(txtNumeroCalle.Text);
                    oClienteSelected.Barrio          = new Barrio();
                    oClienteSelected.Barrio.IDBarrio = (int)cboBarrio.SelectedValue;

                    if (oClienteService.ActualizarCliente(oClienteSelected))
                    {
                        MessageBox.Show("Cliente actualizado!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Error al actualizar el usuario!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                break;
            }

            case FormMode.delete:
            {
                if (MessageBox.Show("¿Seguro que desea eliminar el cliente seleccionado?", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    if (oClienteService.EliminarCliente(oClienteSelected))
                    {
                        MessageBox.Show("Cliente eliminado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar el cliente!", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                break;
            }
            }
        }