protected void btnReset_Click(object sender, EventArgs e) { Entities.UserSystem oUser = (Entities.UserSystem)Session["User"]; if(txtModalUser.Text == oUser.email && txtModalPassword.Text == oUser.Password) { Int32 records = UserSystemBLL.getInstance().resetPasswordSecurity(resetUserSystem_id, resetUserSystemid_id); userAttempts = 0; ScriptManager.RegisterStartupScript(this, this.GetType(), "closeResetPassword", "$('#ResetPassword').modal('toggle');", true); loadData(); if (records > 0) { Entities.Email oEmail = new Entities.Email(); String body = messageDesignReset(oUser.email); oEmail.correoContacto(oUser.email, body, "Restablecer contraseña"); lblMessage.Text = "Se ha restablecido la contraseña correctamente."; } } else { txtModalUser.Text = ""; txtModalPassword.Text = ""; userAttempts++; if (userAttempts>=3) { Response.Redirect("../../logOut.aspx"); } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = -1; if (validateData()) { Entities.UserSystem oUser = new Entities.UserSystem(); Entities.Program oProgram = new Entities.Program(); Entities.Role oRole = new Entities.Role(); oUser.code = Convert.ToInt32(txtCode.Text); oUser.id = txtId.Text; oUser.name = txtName.Text; oUser.lastName = txtLastName.Text; oUser.homePhone = txtHomePhone.Text; oUser.cellPhone = txtCellPhone.Text; oUser.email = txtEmail.Text; oProgram.code = Convert.ToInt16(cboProgram.SelectedValue); if(oProgram.code == 0) { oProgram.code = 1; } oUser.Password = txtId.Text; oRole.Role_Id = Convert.ToInt16(cboRole.SelectedValue); oUser.oProgram = oProgram; oUser.oRole = oRole; oUser.state = Convert.ToInt16(cboState.SelectedValue); if (BLL.UserSystemBLL.getInstance().exists(oUser.code)) { records = BLL.UserSystemBLL.getInstance().modify(oUser); } else { records = BLL.UserSystemBLL.getInstance().insert(oUser); if (records > 0) { Entities.Email oEmail = new Entities.Email(); String body = messageDesign(oUser.email); oEmail.correoContacto(oUser.email, body, "Bienvenido a Siscape"); } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } //no c para que es esto else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true); } } }
protected void gvUserSystem_RowEditing(object sender, GridViewEditEventArgs e) { Int32 code = Convert.ToInt32(gvUserSystem.Rows[e.NewEditIndex].Cells[0].Text); if (code != 1) { unlockControls(); Entities.UserSystem oUser = UserSystemBLL.getInstance().getUserSystem(code); getProgram(); getRole(); txtCode.Text = oUser.code.ToString(); txtId.Text = oUser.id.ToString(); txtName.Text = oUser.name.ToString(); txtLastName.Text = oUser.lastName.ToString(); txtHomePhone.Text = oUser.homePhone.ToString(); txtCellPhone.Text = oUser.cellPhone.ToString(); txtEmail.Text = oUser.email.ToString(); if (oUser.oProgram.code == 1) { cboProgram.SelectedValue = "0"; }else { cboProgram.SelectedValue = oUser.oProgram.code.ToString(); } cboRole.SelectedValue = oUser.oRole.Role_Id.ToString(); try { cboState.SelectedValue = oUser.state.ToString(); } catch (Exception) { cboState.SelectedValue = "1"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); } else { lblMessage.Text = "Este usuario no se puede modificar."; } }