예제 #1
0
        protected void guardarButton_Click(object sender, EventArgs e)
        {
            BLL.Repositorio <Usuario> repositorio = new BLL.Repositorio <Usuario>();
            Usuario usuario = new Usuario();
            bool    paso    = false;

            if (HayErrores())
            {
                Response.Write("<script>alert('Contraseñas no concuerdan');</script>");
            }
            else
            {
                //todo: validaciones adicionales
                usuario = LlenaClase();

                if (usuario.UsuarioId == 0)
                {
                    paso = repositorio.Guardar(usuario);
                    Response.Write("<script>alert('Guardado');</script>");
                    Limpiar();
                }
                else
                {
                    Usuario user = new Usuario();
                    int     id   = ToInt(usuarioIdTextBox.Text);
                    BLL.Repositorio <Usuario> repository = new BLL.Repositorio <Usuario>();
                    usuario = repository.Buscar(id);

                    if (user != null)
                    {
                        paso = repositorio.Modificar(LlenaClase());
                        Response.Write("<script>alert('Modificado');</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Id no existe');</script>");
                    }
                }

                if (paso)
                {
                    Limpiar();
                }
                else
                {
                    Response.Write("<script>alert('No se pudo guardar');</script>");
                }
            }
        }
예제 #2
0
        protected void guadarButton_Click(object sender, EventArgs e)
        {
            BLL.Repositorio <Categoria> repositorio = new BLL.Repositorio <Categoria>();
            Categoria categoria = new Categoria();
            bool      paso      = false;

            if (HayErrores())
            {
                return;
            }
            else
            {
                //todo: validaciones adicionales
                categoria = LlenaClase();

                if (categoria.CategoriaId == 0)
                {
                    paso = repositorio.Guardar(categoria);
                    Utils.ShowToastr(this, "Guardado", "Correcto", "success");
                    Limpiar();
                }
                else
                {
                    Categoria category = new Categoria();
                    BLL.Repositorio <Categoria> repository = new BLL.Repositorio <Categoria>();
                    int id = ToInt(categoriaIdTextBox.Text);
                    category = repository.Buscar(id);

                    if (category != null)
                    {
                        paso = repository.Modificar(LlenaClase());
                        Utils.ShowToastr(this, "Modificado", "Correcto", "success");
                    }
                    else
                    {
                        Utils.ShowToastr(this, "Id no existe", "Error", "error");
                    }
                }

                if (paso)
                {
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
                }
            }
        }
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            BLL.Repositorio <CuentaBancaria> repositorio = new BLL.Repositorio <CuentaBancaria>();
            CuentaBancaria cuenta = new CuentaBancaria();
            bool           paso   = false;

            //todo: validaciones adicionales
            cuenta = LlenaClase();

            if (cuenta.CuentaBancariaId == 0)
            {
                paso = repositorio.Guardar(cuenta);
                Utils.ShowToastr(this, "Guardado", "Exito", "success");
                Limpiar();
            }
            else
            {
                int id = Utils.ToInt(cuentaBancariaIdTextBox.Text);
                BLL.Repositorio <CuentaBancaria> repository = new BLL.Repositorio <CuentaBancaria>();
                cuenta = repository.Buscar(id);

                if (cuenta != null)
                {
                    paso = repositorio.Modificar(LlenaClase());
                    Utils.ShowToastr(this, "Modificado", "Exito", "success");
                }
                else
                {
                    Utils.ShowToastr(this, "Id no existe", "Error", "error");
                }
            }

            if (paso)
            {
                Limpiar();
            }
            else
            {
                Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
            }
        }