protected void EliminarButton_Click(object sender, EventArgs e) { int id = textboxId.Text.ToInt(); if (id < 0) { Utils.ShowToastr(this, "Id invalido", "Advertencia", "warning"); return; } BLL.RepositorioBase <Prestamo> repositorio = new BLL.RepositorioBase <Prestamo>(); if (repositorio.Get(id) == null) { Utils.ShowToastr(this, "Registro no encontrado", "Advertencia", "warning"); return; } bool paso = repositorio.Delete(id); if (!paso) { Utils.ShowToastr(this, "Error al intentar eliminar el registro", "Error", "error"); return; } Utils.ShowToastr(this, "Registro eliminado correctamente!", "exito", "success"); return; }
protected void Page_Load(object sender, EventArgs e) { Utils.VerificarAccesoEmpresa(this); LabelFecha.Text = DateTime.Now.Date.ToString("dd/MM/yy"); this.textboxId.ReadOnly = true; if (!IsPostBack) { int idCliente = HttpContext.Current.Request.Cookies.Get("EmpresaId").Value.ToInt(); System.Linq.Expressions.Expression <Func <Cliente, bool> > filtro = x => x.Id_Empresa == idCliente; Utils.LlenarDropDownList <Cliente>(dropdownlistClientes, new RepositorioBase <Cliente>(), filtro, "Id_Cliente", "Nombre"); if (dropdownlistClientes.Items.Count <= 0) { Response.Redirect("~/privatef/Registros/rClientes.aspx"); } ViewState["data"] = new Prestamo(); int id = Request.QueryString["id"].ToInt(); if (id > 0) { BLL.RepositorioBase <Prestamo> repositorio = new BLL.RepositorioBase <Prestamo>(); Prestamo data = repositorio.Get(id); if (data == null) { Utils.ShowToastr(this, "Prestamo no encontrada!", "Advertencia", "warning"); return; } LlenaCampos(data); Utils.ShowToastr(this, "Prestamo Encontrada", "Exito!"); textboxId.ReadOnly = true; } } else { Prestamo data = (Prestamo)ViewState["data"]; } }