protected void gvUsers_ItemCommand(object sender, GridCommandEventArgs e) { try { lblMessage.Text = string.Empty; var item = (Telerik.Web.UI.GridDataItem)e.Item; int id = int.Parse(gvUsers.Items[item.ItemIndex]["fiid_user"].Text); if (e.CommandName == "editId") { ViewState["IdUsuario"] = id; gvUsers.Items[item.ItemIndex].Selected = true; txtNameUser.Text = gvUsers.Items[item.ItemIndex]["fvuser_name"].Text; txtPassword.Text = string.Empty; comboEmpleado.SelectedValue = gvUsers.Items[item.ItemIndex]["fiid_employed"].Text; comboEmpleado.Items[util.IndexCombo(comboEmpleado, gvUsers.Items[item.ItemIndex]["fiid_employed"].Text)].Selected = true; comboRol.SelectedValue = gvUsers.Items[item.ItemIndex]["fiRol"].Text; comboRol.Items[util.IndexCombo(comboRol, gvUsers.Items[item.ItemIndex]["fiRol"].Text)].Selected = true; } if (e.CommandName == "deleteId") { var bo = new BO.UserManager(); bo.DeleteUser(id); LoadUsuarios(); } } catch (Exception ex) { util.ErroDisplay(1, ex.Message, ref lblMessage); } }
protected void btnAddUserAdd_Click(object sender, EventArgs e) { int iNumber; try { Util.isRequired(txtNameUser.Text.Trim(), "Nombre Usuario"); Util.isRequired(txtPassword.Text.Trim(), "ContraseƱa"); var bo = new BO.UserManager(); byte status = 0; string strUser = ViewState["IdUsuario"] == null ? "0" : ViewState["IdUsuario"].ToString(); string msg = bo.Usuario(strUser, int.Parse(util.DefaultCombo(comboEmpleado, "Empleado")), txtNameUser.Text.Trim(), txtPassword.Text.Trim(), chkStatus.Checked, int.Parse(util.DefaultCombo(comboRol, "Rol")), out status); util.ErroDisplay(status, msg, ref lblMessage); LoadUsuarios(); Usuario(); } catch (ArgumentException ae) { util.ErroDisplay(3, ae.Message, ref lblMessage); } catch (Exception ex) { util.ErroDisplay(1, string.Empty, ref lblMessage); } }