private void GetLoginDetails() { secureData objSecure = new secureData(); SqlDataReader objDr = null; //var UserType = Convert.ToInt32(hfvUserType.Value); var Sautation = ""; var UserName = txtAccessCode.Text; var Password = objSecure.DESEncrypt(txtPassword.Text); objSecure = null; string selectQry = "SP_CheckLogin"; SqlParameter[] objParameter = new SqlParameter[2]; //objParameter[0] = new SqlParameter("@userType", UserType); objParameter[0] = new SqlParameter("@loginID", UserName); objParameter[1] = new SqlParameter("@password", Password); try { objDr = DBL.ExecuteReader(ConnectionString, CommandType.StoredProcedure, selectQry, objParameter); if (objDr.HasRows) { objDr.Read(); Session["AccessCode"] = Convert.ToInt32(objDr["user_ID_PK"]); Session["DealerID"] = null; Session["UserType"] = Convert.ToString(objDr["user_ROLE"]); if (objDr["user_GENDER"] != DBNull.Value) { if (Convert.ToInt32(objDr["user_GENDER"]) == 0) { Sautation = "Mr."; } else { Sautation = "Ms."; } } Session["LoginName"] = Convert.ToString(objDr["user_FIRST_NAME"]) + " " + Convert.ToString(objDr["user_LAST_NAME"]); int iRole = Convert.ToInt32(objDr["user_ROLE"]); Session["AdminRole"] = Convert.ToString(objDr["user_ROLE"]); if (objDr.IsClosed == false) { objDr.Close(); Response.Redirect("~/Modules/DTC/Vehicle_DTC.aspx?MnuID=DSsID"); } if (objDr.IsClosed == false) { objDr.Close(); objDr.Dispose(); } } else { Response.Redirect("default.aspx?err=EUP"); } } catch (Exception ex) { Response.Write(ex.Message); } finally { if (objDr != null) { if (!objDr.IsClosed) { objDr.Close(); } objDr.Dispose(); } } }
protected void btnSavePassword_OnClick(object sender, EventArgs e) { lblMsg.Text = ""; if (Page.IsValid) { string _sReadPass = "", _sEncOldPass = "", _sEncNewPass = ""; secureData _objSecure = new secureData(); _sEncOldPass = _objSecure.DESEncrypt(txtOldPwd.Text); _sEncNewPass = _objSecure.DESEncrypt(txtNewPwd.Text); _objSecure = null; string _sCommandText = "select user_PASSWORD from tab_m_ADMIN_USER where user_PASSWORD ='******' and user_ID_PK=" + Convert.ToInt32(Session["AccessCode"]); object _oRes = DBL.executeScalar(Connectionstring, CommandType.Text, _sCommandText); if (_oRes != DBNull.Value) { _sReadPass = Convert.ToString(_oRes); } bool _bValidatePwd = true; if (_bValidatePwd == true) { if (_sReadPass == _sEncOldPass) { string _sQuery = "Update tab_m_ADMIN_USER set user_PASSWORD='******' where user_ID_PK=" + Convert.ToInt32(Session["AccessCode"]); int _iSuccess = 0; SqlConnection _objCon = new SqlConnection(Connectionstring); try { if (_objCon.State != ConnectionState.Open) { _objCon.Open(); } _iSuccess = DBL.executeNonQuery(_objCon, CommandType.Text, _sQuery, null); } catch { } finally { if (_objCon.State != ConnectionState.Closed) { _objCon.Close(); } _objCon.Dispose(); } if (_iSuccess > 0) { Session.Abandon(); Response.Redirect("~/default.aspx?err=SPC"); } else { Response.Redirect("~/default.aspx?err=E00A"); } } else { lblMsg.Text = "Old Password is wrong"; } } } }