コード例 #1
0
        protected void EliminarButton_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(entradaIdTextbox.Text);

            if (id != 0)
            {
                RepositorioEntrada repositorio = new RepositorioEntrada();
                if (repositorio.Buscar(id) != null)
                {
                    if (repositorio.Eliminar(id))
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['success']('Eliminado con Exito');", addScriptTags: true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['error']('No se pudo eliminar');", addScriptTags: true);
                    }
                    Limpiar();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['error']('No existe');", addScriptTags: true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['warning']('Seleccione un ID');", addScriptTags: true);
            }
        }
コード例 #2
0
        protected void BuscarButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(entradaIdTextbox.Text))
            {
                int id = Convert.ToInt32(entradaIdTextbox.Text);
                if (id != 0)
                {
                    RepositorioEntrada repositorio = new RepositorioEntrada();
                    EntradaProducto    entrada     = repositorio.Buscar(id);

                    if (entrada != null)
                    {
                        LlenaCampos(entrada);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['error']('No existe');", addScriptTags: true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['warning']('Seleccione un ID');", addScriptTags: true);
                }
            }
        }
コード例 #3
0
        protected void EliminarButton_Click(object sender, EventArgs e)
        {
            GridViewRow        grid        = GridView.SelectedRow;
            RepositorioEntrada repositorio = new RepositorioEntrada();
            int id      = Utils.ToInt(IdTextBox.Text);
            var entrada = repositorio.Buscar(id);

            if (entrada != null)
            {
                if (repositorio.Eliminar(id))
                {
                    Utils.ShowToastr(this.Page, "Exito Eliminado", "error");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this.Page, "No Eliminado", "error");
                }
            }
            else
            {
                Utils.ShowToastr(this, "No existe", "Error", "error");
            }
            repositorio.Dispose();
        }
コード例 #4
0
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int id = Convert.ToInt32(entradaIdTextbox.Text);
                if (!(productoIdTextbox.Text == "0" || cantidadTextbox.Text == "0" || String.IsNullOrEmpty(fechaTextbox.Text)))
                {
                    RepositorioEntrada         repositorio     = new RepositorioEntrada();
                    RepositorioBase <Producto> repositorioBase = new RepositorioBase <Producto>();
                    if (id == 0 && repositorioBase.Buscar(int.Parse(productoIdTextbox.Text)) != null)
                    {
                        repositorio.Guardar(LlenaClase());
                        ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['success']('Guardado con Exito');", addScriptTags: true);
                    }
                    else
                    {
                        if (repositorio.Buscar(id) != null && repositorioBase.Buscar(int.Parse(productoIdTextbox.Text)) != null)
                        {
                            EntradaProducto entrada = repositorio.Buscar(int.Parse(entradaIdTextbox.Text));

                            entrada.ProductoId = int.Parse(entradaIdTextbox.Text);
                            entrada.Fecha      = DateTime.Parse(fechaTextbox.Text);
                            entrada.Cantidad   = int.Parse(cantidadTextbox.Text);

                            repositorio.Modificar(entrada);

                            ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['success']('Modificado con Exito');", addScriptTags: true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['error']('No existe una entrada o un producto con ese ID, no puede modificarse');", addScriptTags: true);
                        }
                    }
                }
                else if (id == 0)
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "toastr_message", script: "toastr['warning']('Debe rellenar todos los campos');", addScriptTags: true);
                }
                Limpiar();
            }
        }
コード例 #5
0
        protected void guardarButton_Click(object sender, EventArgs e)
        {
            bool paso = false;
            RepositorioEntrada repositorio = new RepositorioEntrada();
            Entrada            entrada     = new Entrada();

            if (HayErrores())
            {
                return;
            }
            else
            {
                entrada = LlenaClase();

                if (entradaIdTextBox.Text == "0")
                {
                    paso = repositorio.Guardar(entrada);
                    Utils.ShowToastr(this, "Guardado", "Exito", "success");
                    LimpiaObjetos();
                }
                else
                {
                    RepositorioEntrada repository = new RepositorioEntrada();
                    int id = Utils.ToInt(entradaIdTextBox.Text);
                    entrada = repository.Buscar(id);

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

                if (paso)
                {
                    LimpiaObjetos();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
                }
            }
        }
コード例 #6
0
        //Programación de los Botones
        protected void BuscarLinkButton_Click(object sender, EventArgs e)
        {
            RepositorioEntrada repositorio = new RepositorioEntrada();

            var entrada = repositorio.Buscar(Utils.ToInt(entradaIdTextBox.Text));

            if (entrada != null)
            {
                LlenaCampos(entrada);
                Utils.ShowToastr(this, "Busqueda exitosa", "Exito", "success");
            }
            else
            {
                LimpiaObjetos();
                Utils.ShowToastr(this, "No Hay Resultado", "Error", "error");
            }
        }
コード例 #7
0
        protected void eliminarutton_Click(object sender, EventArgs e)
        {
            RepositorioEntrada repositorio = new RepositorioEntrada();
            int id = Utils.ToInt(entradaIdTextBox.Text);

            var entrada = repositorio.Buscar(id);

            if (entrada != null)
            {
                if (repositorio.Eliminar(id))
                {
                    Utils.ShowToastr(this, "Eliminado", "Exito", "success");
                    LimpiaObjetos();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo eliminar", "Error", "error");
                }
            }
            else
            {
                Utils.ShowToastr(this, "No existe", "Error", "error");
            }
        }
コード例 #8
0
        protected void GuadarButton_Click(object sender, EventArgs e)
        {
            RepositorioEntrada repositorio = new RepositorioEntrada();
            Entrada            factura     = repositorio.Buscar(Utils.ToInt(IdTextBox.Text));

            if (Validar())
            {
                return;
            }
            if (factura == null)
            {
                if (repositorio.Guardar(LlenarClase()))
                {
                    Utils.ShowToastr(this, "Guardado", "Exito", "success");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No existe", "Error", "error");
                    Limpiar();
                }
            }
            else
            {
                if (repositorio.Modificar(LlenarClase()))
                {
                    Utils.ShowToastr(this.Page, "Modificado con exito!!", "Guardado", "success");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this.Page, "No se puede modificar", "Error", "error");
                    Limpiar();
                }
            }
        }