コード例 #1
0
        public UserPaswordHistoryBO GetCurrentPaswordDetails(DBEgine dbEngine,int userID)
        {
            UserPaswordHistoryBO hs = null;

            try
            {
                SqlParameter[] parms = new SqlParameter[1];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "@UserID";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.Input;
                p1.Value = userID;
                parms[0] = p1;

                DataTable dtHistry = dbEngine.ExecuteDataTable("UserManagement.UM_GetCurrentPasswordDetails", parms);
                if (dtHistry.Rows.Count > 0)
                {

                    foreach (DataRow r in dtHistry.Rows)
                    {
                        hs = new UserPaswordHistoryBO();

                        if (r.Table.Columns.Contains("UserPaswordHistoryID"))
                            if (r["UserPaswordHistoryID"] != DBNull.Value)
                                hs.UserPaswordHistoryID = (int)r["UserPaswordHistoryID"];

                        if (r.Table.Columns.Contains("UserID"))
                            if (r["UserID"] != DBNull.Value)
                                hs.UserID = (int)r["UserID"];

                        if (r.Table.Columns.Contains("Password"))
                            if (r["Password"] != DBNull.Value)
                                hs.Password = r["Password"].ToString();

                        if (r.Table.Columns.Contains("CreatedBy"))
                            if (r["CreatedBy"] != DBNull.Value)
                                hs.CreatedBy = (int)r["CreatedBy"];

                        if (r.Table.Columns.Contains("CreatedDate"))
                            if (r["CreatedDate"] != DBNull.Value)
                                hs.CreatedDate = DateTime.Parse(r["CreatedDate"].ToString());

                        if (r.Table.Columns.Contains("DayProcessID"))
                            if (r["DayProcessID"] != DBNull.Value)
                                hs.DayProcessID = r["DayProcessID"].ToString();

                        if (r.Table.Columns.Contains("IsCurrent"))
                            if (r["IsCurrent"] != DBNull.Value)
                                hs.IsCurrent = (bool)r["IsCurrent"];
                    }

                }
                return hs;
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        public int SaveUserPaswordHistory(DBEgine dbEngine, UserPaswordHistoryBO upHistry)
        {
            int ID = -1;
            try
            {
                SqlParameter[] arrSqlParam = GetFDUpLiftmentParameters(upHistry);
                dbEngine.ExecNonQueryStoredProc("UserManagement.UM_SaveUserPasswordHistory", arrSqlParam);

            }
            catch
            {
                throw;
            }

            return ID;
        }
コード例 #3
0
        private SqlParameter[] GetFDUpLiftmentParameters(UserPaswordHistoryBO upHistry)
        {
            SqlParameter[] arrSqlParam = new SqlParameter[3];

            SqlParameter param_UserID = new SqlParameter();
            param_UserID.ParameterName = "@UserID";
            param_UserID.SqlDbType = SqlDbType.Int;
            param_UserID.Value = upHistry.UserID;
            arrSqlParam[0] = param_UserID;

            SqlParameter param_Password = new SqlParameter();
            param_Password.ParameterName = "@Password";
            param_Password.SqlDbType = SqlDbType.NVarChar;
            param_Password.Value = upHistry.Password;
            arrSqlParam[1] = param_Password;

            SqlParameter param_CreatedBy = new SqlParameter();
            param_CreatedBy.ParameterName = "@CreatedBy";
            param_CreatedBy.SqlDbType = SqlDbType.Int;
            param_CreatedBy.Value = upHistry.CreatedBy;
            arrSqlParam[2] = param_CreatedBy;

            return arrSqlParam;
        }
コード例 #4
0
ファイル: UserDAL.cs プロジェクト: anushkaD/AnushkaPrivate
        public bool ChangePasswordByUserId(int userId, string userPassword, int createdBy)
        {
            bool isChange = false;

            DBEgine dbEgine = new DBEgine();
            SqlTransaction trnx = null;

            try
            {

                dbEgine.DBOpen(trnx);
                SqlParameter[] parms = new SqlParameter[2];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "UserId";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.Input;
                p1.Value = userId;
                parms[0] = p1;

                SqlParameter p2 = new SqlParameter();
                p2.ParameterName = "password";
                p2.SqlDbType = SqlDbType.NVarChar;
                p2.Size = 500;
                p2.Direction = ParameterDirection.Input;
                p2.Value = userPassword;
                parms[1] = p2;

                dbEgine.ExecNonQueryStoredProc("UserManagement.UM_changePasswordByUserId", parms);
                isChange = true;
                UserPaswordHistoryBO histry = new UserPaswordHistoryBO();
                histry.UserID = userId;
                histry.Password = userPassword;
                histry.CreatedBy = createdBy;

                new UserPaswordHistoryDAL().SaveUserPaswordHistory(dbEgine, histry);

                dbEgine.DBTransAction.Commit();

            }

            catch
            {
                throw;
            }

            finally
            {
                dbEgine.DBClose();
            }

            return isChange;
        }