Example #1
0
        protected void gridDados_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var cliente     = new GestionarCliente();
            var objeCliente = new Cliente();
            var id          = Convert.ToInt32(e.CommandArgument);

            hdn.Value = id.ToString();

            switch (e.CommandName)
            {
            case "Eliminar":
                cliente.EliminarCliente(id);
                tablaClientes.DataBind();
                break;

            case "Editar":
                botGuardar.CssClass   = "btn btn-primary disabled";
                botModificar.CssClass = "btn btn-primary";
                CargarDatos(id);
                break;

            default:
                break;
            }
        }
Example #2
0
        protected void botGuardar_Click(object sender, EventArgs e)
        {
            var db = new GestionarCliente();
            var c  = new Cliente();

            c.nombresCliente     = txtNombre.Text;
            c.apellidosCliente   = txtApellidos.Text;
            c.documentoIdentidad = txtDocumento.Text;
            c.direccion          = txtDireccion.Text;
            c.telefono           = txtTelefono.Text;

            if (c.NombreInvalido())
            {
                //Response.Write("<script>alert('Nombre invalido')</script>");

                lblMensajeAlerta.Text = "Nombre invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                //txtNombre.Text = "";
                return;
            }
            if (c.ApellidoInvalido())
            {
                //Response.Write("<script>alert('Nombre invalido')</script>");

                lblMensajeAlerta.Text = "Apellido Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                //txtNombre.Text = "";
                return;
            }
            if (c.DocumentoInvalido())
            {
                lblMensajeAlerta.Text = "Documento Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                return;
            }

            if (c.TelefonoInvalido())
            {
                lblMensajeAlerta.Text = "Telefono Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                return;
            }

            int registrar = db.RegistrarCliente(c);

            if (registrar == 1)
            {
                etiMensaje.Text = "Los datos fueron guardados con Exito";
                tablaClientes.DataBind();
            }
            else
            {
                etiMensaje.Text = "No se pudieron guardar los datos";
            }
            //botGuardar.Enabled = false;
            limpiarCajas();
        }
Example #3
0
        public void CargarDatos(int id)
        {
            var cliente = new GestionarCliente();

            var obj = cliente.BuscarCliente(id);

            txtNombre.Text    = obj.nombresCliente;
            txtApellidos.Text = obj.apellidosCliente;
            txtDocumento.Text = obj.documentoIdentidad;
            txtDireccion.Text = obj.direccion;
            txtTelefono.Text  = obj.telefono;
        }
Example #4
0
        protected void botModificar_Click(object sender, EventArgs e)
        {
            var cliente = new GestionarCliente();
            var c       = new Cliente();

            c.idCliente          = Convert.ToInt32(hdn.Value);
            c.nombresCliente     = txtNombre.Text;
            c.apellidosCliente   = txtApellidos.Text;
            c.documentoIdentidad = txtDocumento.Text;
            c.direccion          = txtDireccion.Text;
            c.telefono           = txtTelefono.Text;


            if (c.NombreInvalido())
            {
                //Response.Write("<script>alert('Nombre invalido')</script>");

                lblMensajeAlerta.Text = "Nombre invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                //txtNombre.Text = "";
                return;
            }
            if (c.ApellidoInvalido())
            {
                //Response.Write("<script>alert('Nombre invalido')</script>");

                lblMensajeAlerta.Text = "Apellido Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                //txtNombre.Text = "";
                return;
            }
            if (c.DocumentoInvalido())
            {
                lblMensajeAlerta.Text = "Documento Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                return;
            }

            if (c.TelefonoInvalido())
            {
                lblMensajeAlerta.Text = "Telefono Invalido";
                ClientScript.RegisterStartupScript(GetType(), "abrirVentanaModalMsjJS", "abrirVentanaModalMsj();", true);
                return;
            }
            cliente.ActualizarCliente(c);
            tablaClientes.DataBind();
            limpiarCajas();
        }
Example #5
0
        public List <Cliente> ListarClientes()
        {
            var db = new GestionarCliente();

            return(db.ListarClientes());
        }