protected void btnSubmit_Click(object sender, EventArgs e) { if (txtUserName.Text != "" && txtPwd.Text != "") { var pwd = EncryptDecrypt.base64Encode(txtPwd.Text); var dt = new DataTable(); dt = BL_Users.GetUsers(2, 0, txtUserName.Text); if (dt.Rows.Count > 0) { var a = EncryptDecrypt.base64Decode(dt.Rows[0]["PWD"].ToString()); if (pwd == dt.Rows[0]["PWD"].ToString()) { var userID = Convert.ToInt32(dt.Rows[0]["ID"].ToString()); var roleId = Convert.ToInt32(dt.Rows[0]["ROLE_ID"].ToString()); var obj = new BK_Session(Convert.ToInt32(userID), roleId, this.PrepareMenu(roleId)); obj.UserName = dt.Rows[0]["USER_NAME"].ToString(); obj.RoleName = dt.Rows[0]["ROLE_NAME"].ToString(); obj.BranchId = Convert.ToInt32(dt.Rows[0]["BRANCH_ID"].ToString()); BK_Session.SetSession(obj); var opdate = DateTime.Parse(GetOperationDate(BK_Session.GetSession().BranchId)); InsertDayOpen(BK_Session.GetSession().BranchId, opdate, BK_Session.GetSession().UserId); obj.OpDate = opdate; obj.Name = dt.Rows[0]["NAME"].ToString(); BK_Session.SetSession(obj); Session["Username"] = dt.Rows[0]["USER_NAME"].ToString(); FormsAuthenticationTicket tkt; string cookiestr; tkt = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, "your custom data"); cookiestr = FormsAuthentication.Encrypt(tkt); // FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false); string strRedirect; strRedirect = Request["ReturnUrl"]; if (strRedirect == null) { strRedirect = "~/DashBoard.aspx"; } Response.Redirect(strRedirect, true); } else { //lblError.Text = "Invalid Password For the Given User..!!"; txtPwd.Text = ""; txtPwd.Focus(); } } else { //lblError.Text = "Invalid User Name..!!"; txtUserName.Text = ""; txtPwd.Text = ""; txtUserName.Focus(); } } }
private void FillgvUsers() { var dt = new DataTable(); dt = BL_Users.GetUsers(1, Convert.ToInt32(BK_Session.GetSession().BranchId), ""); if (dt.Rows.Count > 0) { gvUsers.DataSource = dt; gvUsers.DataBind(); } else { gvUsers.DataSource = new string[] { }; gvUsers.DataBind(); } }
public JsonResult Fill(int UserID) { DataSet ds = new DataSet(); List <Users> Search = new List <Users>(); ds = user.GetUsers(UserID); Users addusers = new Users(); addusers.UserID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"].ToString()); addusers.FullName = ds.Tables[0].Rows[0]["FullName"].ToString(); addusers.LoginName = ds.Tables[0].Rows[0]["LoginName"].ToString(); KeystoneProject.Buisness_Logic.Master.BL_MasterSetting obj4 = new Buisness_Logic.Master.BL_MasterSetting(); DataSet dsMasterSetting = new DataSet(); dsMasterSetting = obj4.GetMasterSetting(); if (Convert.ToBoolean(dsMasterSetting.Tables[0].Rows[0]["ForAuthorization"]) == true) { addusers.chbAuthorizationRights = ds.Tables[0].Rows[0]["AuthorizationRights"].ToString(); } else { addusers.chbAuthorizationRights = "false"; } addusers.Password = ds.Tables[0].Rows[0]["Password"].ToString(); addusers.Password2 = ds.Tables[0].Rows[0]["Password2"].ToString(); addusers.RoleID2 = ds.Tables[0].Rows[0]["RoleID2"].ToString(); addusers.EmailID = ds.Tables[0].Rows[0]["EmailID"].ToString(); addusers.RoleName = ds.Tables[0].Rows[0]["RoleName"].ToString(); addusers.UserDetailsID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserDetailsID"]); if (ds.Tables[1].Rows.Count > 0) { addusers.RoleName2 = ds.Tables[1].Rows[0]["RoleName2"].ToString(); } addusers.RoleID = Convert.ToInt32(ds.Tables[0].Rows[0]["RoleID"].ToString()); addusers.Mode = "Edit"; Search.Add(addusers); return(new JsonResult { Data = Search, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
protected void txtCurrentPwd_TextChanged(object sender, EventArgs e) { if (txtCurrentPwd.Text != "") { DataTable dt = BL_Users.GetUsers(3, 0, Session["UserId"].ToString()); if (dt.Rows.Count > 0) { if (EncryptDecrypt.base64Encode(txtCurrentPwd.Text) != dt.Rows[0]["PWD"].ToString()) { msgbox.ShowWarning("Current Password didnot Match"); btnSave.Enabled = false; txtNewPwd.Focus(); } else { btnSave.Enabled = true; txtNewPwd.Focus(); } } } }