IList <ALRD_SecurityUserEntity> IALRD_SecurityUserDao.GetAll(ALRD_SecurityUserEntity entity) { try { const string SP = "alrd_securityuser_GetAll"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddSortExpressionParameter(cmd, entity.SortExpression); FillParameters(entity, cmd, Database); IList <ALRD_SecurityUserEntity> itemList = new List <ALRD_SecurityUserEntity>(); using (IDataReader reader = Database.ExecuteReader(cmd)) { while (reader.Read()) { itemList.Add(new ALRD_SecurityUserEntity(reader)); } } return(itemList); } } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("GetAll")); } }
long IALRD_SecurityUserDao.Update(ALRD_SecurityUserEntity entity, bool isPertial = false) { long returnCode = -99; string SP; if (!isPertial) { SP = "alrd_securityuser_Update"; } else { SP = "alrd_securityuser_PertialUpdate"; } using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { FillParameters(entity, cmd, Database); //FillSequrityParameters(securityCapsule, cmd, OparationType.Update, Database); AddOutputParameter(cmd); try { returnCode = Database.ExecuteNonQuery(cmd); } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("Update")); } } return(returnCode); }
long IALRD_SecurityUserDao.Add(ALRD_SecurityUserEntity entity) { long returnCode = -99; const string SP = "alrd_securityuser_Insert"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { FillParameters(entity, cmd, Database); //FillSequrityParameters(securityCapsule, cmd, OparationType.Save, Database); AddOutputParameter(cmd); try { returnCode = Database.ExecuteNonQuery(cmd); // GetReturnCodeFromParameter(cmd); if (returnCode == 1) { returnCode = Convert.ToInt64(cmd.Parameters["@RETURN_KEY"].Value); } else { returnCode = -99; } } catch (Exception ex) { throw GetDataAccessException(ex, SourceOfException("Add")); } } return(returnCode); }
private void LoadEntityList(ALRD_SecurityUserEntity entity) { try { if (entity.PageSize < 0) { entity.PageSize = 10; } if (entity.SortExpression == string.Empty) { entity.SortExpression = "UserName ASC"; } LocalEntityList = ALRD_SecurityUserService.GetService().GetAll(entity).ToList(); //lsvUserList.Items.Clear(); if (LocalEntityList != null && LocalEntityList.Count > 0) { lsvUserList.DataSource = LocalEntityList; lsvUserList.DataBind(); } else { lsvUserList.DataSource = null; lsvUserList.DataBind(); } } catch (Exception ex) { Error = ex.Message; } }
private bool CheckUser(ALRD_SecurityUserEntity entity) { try { ALRD_SecurityUserEntity objEntity = new ALRD_SecurityUserEntity(); objEntity = ALRD_SecurityUserService.GetService().GetAll(entity).FirstOrDefault(); if (objEntity != null && objEntity.COMPID.HasValue) { GlobalClass.IsLogin = true; GlobalClass.UserID = (long)objEntity.COMPID; //GlobalClass.PublicUserID = objEntity.Public_User_ID.HasValue ? (long)objEntity.Public_User_ID : -99; GlobalClass.UserRoleID = objEntity.RoleID.HasValue ? (long)objEntity.RoleID : -99; GlobalClass.Email = objEntity.Email; GlobalClass.UserName = objEntity.UserName; GlobalClass.UserFullName = objEntity.FullName; GlobalClass.BlockIPAccess = objEntity.BlockIPAccess != null?objEntity.BlockIPAccess.Trim() : string.Empty; GlobalClass.BlockMacAccess = objEntity.BlockMacAccess != null?objEntity.BlockMacAccess.Trim() : string.Empty; GlobalClass.UserRolePermission = ALRD_SecurityRoleDetailService.GetService().GetAll(new ALRD_SecurityRoleDetailEntity { RoleID = GlobalClass.UserRoleID, IsVisible = true }).ToList(); return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { this.CheckFormPermission(this.FormID); LoadCombo(); SearchEntity = new ALRD_SecurityUserEntity(); //if (Request.QueryString["hid"] != null && !string.IsNullOrEmpty(Request.QueryString["hid"].ToString())) if (GlobalClass.FormUserID > 0) { SearchEntity.COMPID = GlobalClass.FormUserID; } else { SearchEntity.COMPID = -99; } LoadEntity(SearchEntity); } } catch (Exception ex) { Error = ex.Message; } }
protected void btnFilter_Click(object sender, EventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { SearchEntity = BuiltEntity(); LoadEntityList(SearchEntity); } catch (Exception ex) { Error = ex.Message; } }
protected void btnSave_Click(object sender, EventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { if (btnSave.Text == "Save") { ALRD_SecurityUserEntity entity = BuiltEntity(); long i = ALRD_SecurityUserService.GetService().Add(entity); if (i > 0) { SuccessMessage = "Information Saved Successfully"; LoadEntity(new ALRD_SecurityUserEntity { COMPID = i }); } } else { ALRD_SecurityUserEntity entity = BuiltEntity(); clsStringEnc cls = new clsStringEnc(); ALRD_SecurityUserEntity objEnt = ALRD_SecurityUserService.GetService().GetAll(new ALRD_SecurityUserEntity { COMPID = GlobalClass.UserID }).FirstOrDefault(); if (objEnt != null && cls.decryptSimple(objEnt.Password) == entity.PasswordPrevious) { long i = ALRD_SecurityUserService.GetService().Update(entity); if (i > 0) { SuccessMessage = "Information Updated Successfully"; LoadEntity(new ALRD_SecurityUserEntity { COMPID = entity.COMPID }); } } else { SuccessMessage = "Previous password does not match."; } } } catch (Exception ex) { Error = ex.Message; } }
private ALRD_SecurityUserEntity BuiltEntity(ALRD_SecurityUserEntity entity = null) { try { if (entity == null) { entity = new ALRD_SecurityUserEntity(); } entity.UserNameLike = txtUserName.Text.Trim() != string.Empty ? txtUserName.Text.Trim() : string.Empty; entity.Status = ddlStatus.SelectedIndex > 0 ? bool.Parse(ddlStatus.SelectedValue) : (bool?)null; entity.RoleID = ddlRoleType.SelectedIndex > 0 ? long.Parse(ddlRoleType.SelectedValue) : (long?)null; } catch (Exception ex) { throw ex; } return(entity); }
private ALRD_SecurityUserEntity BuiltEntity(ALRD_SecurityUserEntity entity = null) { try { if (entity == null) { entity = new ALRD_SecurityUserEntity(); } entity.COMPID = hdnUserID.Value.Trim() != string.Empty ? long.Parse(hdnUserID.Value.Trim()) : (long?)null; entity.UserName = txtUserName.Text.Trim() != string.Empty ? txtUserName.Text.Trim() : string.Empty; entity.FullName = txtFullName.Text.Trim() != string.Empty ? txtFullName.Text.Trim() : string.Empty; entity.Password = txtPassword.Text.Trim() != string.Empty ? txtPassword.Text.Trim() : string.Empty; entity.AlternateEmail = txtAlternateEmail.Text.Trim() != string.Empty ? txtAlternateEmail.Text.Trim() : string.Empty; entity.BlockIPAccess = txtIPAddress.Text.Trim() != string.Empty ? txtIPAddress.Text.Trim() : string.Empty; entity.BlockMacAccess = txtMACAddress.Text.Trim() != string.Empty ? txtMACAddress.Text.Trim() : string.Empty; //entity.Public_User_ID = ddlPublicUser.SelectedIndex > 0 ? long.Parse(ddlPublicUser.SelectedValue) : (long?)null; entity.RoleID = ddlRoleType.SelectedIndex > 0 ? long.Parse(ddlRoleType.SelectedValue) : (long?)null; entity.Status = chkStatus.Checked; entity.ActivationKey = hdnActivationKey.Value.Trim() != string.Empty ? hdnActivationKey.Value.Trim() : string.Empty; entity.IsActivated = chkIsActivated.Checked; clsStringEnc cls = new clsStringEnc(); entity.Password = entity.Password != string.Empty ? cls.encryptSimple(entity.Password) : string.Empty; if (entity.COMPID.HasValue) { entity.UpdatedBy = GlobalClass.UserID; entity.UpdatedOn = DateTime.Now; entity.CreatedBy = hdnCreatedBy.Value.Trim() != string.Empty ? long.Parse(hdnCreatedBy.Value.Trim()) : (long?)null; entity.CreatedOn = GetDateFromString(hdnCreatedOn.Value.Trim()); } else { entity.CreatedBy = GlobalClass.UserID; entity.CreatedOn = DateTime.Now; } } catch (Exception ex) { throw ex; } return(entity); }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { GlobalClass.FormUserID = -99; this.CheckFormPermission(this.FormID); this.CheckButtonPermission(null, null, null, lnkAddNew); LoadCombo(); SearchEntity = new ALRD_SecurityUserEntity(); SearchEntity.CurrentPage = 1; SearchEntity.PageSize = 10; LoadEntityList(SearchEntity); } } catch (Exception ex) { Error = ex.Message; } }
protected void btnGoLogin_Click(object sender, EventArgs e) { ALRD_SecurityUserEntity entity = new ALRD_SecurityUserEntity(); clsStringEnc cls = new clsStringEnc(); entity.UserName = txtUseName.Text != null && txtUseName.Text.Trim() != string.Empty ? txtUseName.Text.Trim() : "-!@#$%^&*()9999"; entity.Password = txtPassword.Text != null && txtPassword.Text.Trim() != string.Empty ? cls.encryptSimple(txtPassword.Text.Trim()) : "-!@#$%^&*()9999"; entity.Status = true; if (CheckUser(entity)) { //MenuPermission(); //Response.Redirect(Request.RawUrl); Response.Redirect("~/Default.aspx", false); } else { System.Web.UI.ScriptManager.RegisterStartupScript(Page, this.GetType(), "click", "alert('" + "Yor username or password is invalid." + "')", true); } }
protected void lsvUserList_ItemCommand(object sender, ListViewCommandEventArgs e) { this.lblException.Text = ""; this.lblResult.Text = ""; try { string CommandName = e.CommandName.ToString(); string CommandArgument = e.CommandArgument.ToString(); if (CommandArgument.ToString() != "") { long Value = long.Parse(CommandArgument.ToString()); if (CommandName == "edit") { GlobalClass.FormUserID = Value; Response.Redirect("SecurityUserInfo.aspx", true); } else if (CommandName == "delete") { ALRD_SecurityUserEntity entity = new ALRD_SecurityUserEntity { COMPID = Value }; //LoadEntityList(entity); long i = ALRD_SecurityUserService.GetService().Delete(entity); LoadEntityList(new ALRD_SecurityUserEntity()); Error = "Information Deleted Successfully"; } } } catch (Exception ex) { Error = ex.Message; } }
public static void FillParameters(ALRD_SecurityUserEntity entity, DbCommand cmd, Database Database, bool forDelete = false) { if (entity.COMPID.HasValue) { Database.AddInParameter(cmd, "@COMPID", DbType.Int64, entity.COMPID); } if (forDelete) { return; } if (entity.RoleID.HasValue) { Database.AddInParameter(cmd, "@RoleID", DbType.Int64, entity.RoleID); } if (entity.ProfileID.HasValue) { Database.AddInParameter(cmd, "@ProfileID", DbType.Int64, entity.ProfileID); } if (!(string.IsNullOrEmpty(entity.FullName))) { Database.AddInParameter(cmd, "@FullName", DbType.String, entity.FullName); } if (!(string.IsNullOrEmpty(entity.UserName))) { Database.AddInParameter(cmd, "@UserName", DbType.String, entity.UserName); } if (!(string.IsNullOrEmpty(entity.Password))) { Database.AddInParameter(cmd, "@Password", DbType.String, entity.Password); } if (!(string.IsNullOrEmpty(entity.BlockIPAccess))) { Database.AddInParameter(cmd, "@BlockIPAccess", DbType.String, entity.BlockIPAccess); } if (!(string.IsNullOrEmpty(entity.BlockMacAccess))) { Database.AddInParameter(cmd, "@BlockMacAccess", DbType.String, entity.BlockMacAccess); } if (!(string.IsNullOrEmpty(entity.AlternateEmail))) { Database.AddInParameter(cmd, "@AlternateEmail", DbType.String, entity.AlternateEmail); } if (entity.Status.HasValue) { Database.AddInParameter(cmd, "@Status", DbType.Boolean, entity.Status); } if (!(string.IsNullOrEmpty(entity.UserNameLike))) { Database.AddInParameter(cmd, "@UserNameLike", DbType.String, entity.UserNameLike); } if (entity.IsActivated.HasValue) { Database.AddInParameter(cmd, "@IsActivated", DbType.Boolean, entity.IsActivated); } if (!(string.IsNullOrEmpty(entity.ActivationKey))) { Database.AddInParameter(cmd, "@ActivationKey", DbType.String, entity.ActivationKey); } if (entity.CreatedBy.HasValue) { Database.AddInParameter(cmd, "@CreatedBy", DbType.Int64, entity.CreatedBy); } if (entity.CreatedOn.HasValue) { Database.AddInParameter(cmd, "@CreatedOn", DbType.DateTime, entity.CreatedOn); } if (entity.UpdatedBy.HasValue) { Database.AddInParameter(cmd, "@UpdatedBy", DbType.Int64, entity.UpdatedBy); } if (entity.UpdatedOn.HasValue) { Database.AddInParameter(cmd, "@UpdatedOn", DbType.DateTime, entity.UpdatedOn); } }
private void LoadEntity(ALRD_SecurityUserEntity entity) { try { ALRD_SecurityUserEntity objEntity = ALRD_SecurityUserService.GetService().GetAll(entity).FirstOrDefault(); ClearControlStates(pnlForm); if (objEntity != null && objEntity.COMPID != null && objEntity.COMPID > 0) { lblPrePassword.Visible = true; txtPrePassword.Visible = true; txtPrePassword.CssClass = "w250px required txtPrePassword"; atcPrePassword.Visible = true; GlobalClass.FormUserID = (long)objEntity.COMPID; txtUserName.Text = objEntity.UserName; txtFullName.Text = objEntity.FullName; hdnUserID.Value = objEntity.COMPID.ToString(); if (objEntity.RoleID.HasValue) { ddlRoleType.Text = objEntity.RoleID.ToString(); } //if (objEntity.Public_User_ID.HasValue) // ddlPublicUser.SelectedValue = objEntity.Public_User_ID.ToString(); //txtPassword.Text = objEntity.Password; //txtRePassword.Text = objEntity.Password; txtIPAddress.Text = objEntity.BlockIPAccess; txtMACAddress.Text = objEntity.BlockMacAccess; txtAlternateEmail.Text = objEntity.AlternateEmail; hdnActivationKey.Value = objEntity.ActivationKey; if (objEntity.IsActivated.HasValue) { chkIsActivated.Checked = (bool)objEntity.IsActivated; } if (objEntity.Status.HasValue) { chkStatus.Checked = (bool)objEntity.Status; } if (objEntity.CreatedBy.HasValue) { hdnCreatedBy.Value = objEntity.CreatedBy.ToString(); } hdnCreatedOn.Value = GetStringFromDate(objEntity.CreatedOn); btnSave.Text = "Update"; btnSave.OnClientClick = "javascript:return checkValidation('Do you want to update this information?');"; this.CheckButtonPermission(null, btnSave, null); } else { GlobalClass.FormUserID = -99; btnSave.Text = "Save"; btnSave.OnClientClick = "javascript:return checkValidation('Do you want to save this information?');"; this.CheckButtonPermission(btnSave, null, null); lblPrePassword.Visible = false; txtPrePassword.Visible = false; txtPrePassword.CssClass = "w250px txtPrePassword"; atcPrePassword.Visible = false; } } catch (Exception ex) { Error = ex.Message; } }