示例#1
0
        public List <QI_USER_REC> GetQiUsersCollection(Guid facilityId)
        {
            List <QI_USER_REC> userCollection = new List <QI_USER_REC>();

            userCollection.Clear();
            using (SqlConnection dbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString))
            {
                string     sqlText = "usp_SelectUserRecsByFacID";
                SqlCommand sqlCmd  = new SqlCommand(sqlText, dbConn);
                sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@FacilityId", facilityId);
                SqlDataReader dr = sqlCmd.ExecuteReader();
                while (dr.Read())
                {
                    QI_USER_REC rec = new QI_USER_REC();
                    try
                    {
                        rec.UserID = dr.GetGuid(0);
                        try{ rec.UserName = dr.GetString(1); }
                        catch (SqlNullValueException ex) { rec.UserName = string.Empty; }
                        try { rec.FacilityId = dr.GetGuid(2); }
                        catch (SqlNullValueException ex) { rec.FacilityId = new Guid(); }

                        userCollection.Add(rec);
                    }
                    catch (InvalidCastException ex)
                    {
                    }
                }
                dr.Close();
                dbConn.Close();
            }

            return(userCollection);
        }
示例#2
0
 public void UpdateUser(ref QI_USER_REC userRec)
 {
     using (SqlConnection awareDbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString))
     {
         HAR_StringEncrypter encrypter = new HAR_StringEncrypter();
         string     sqlText            = "usp_UpdateUser";
         SqlCommand sqlCmd             = new SqlCommand(sqlText, awareDbConn);
         sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         sqlCmd.Parameters.AddWithValue("@UserName", userRec.UserName);
         sqlCmd.Parameters.AddWithValue("@FacilityId", userRec.FacilityId);
         sqlCmd.Parameters.AddWithValue("@VerifyCode", encrypter.EncryptString(userRec.VerifyCode));
         sqlCmd.Parameters.AddWithValue("@UserId", userRec.UserID);
         sqlCmd.ExecuteNonQuery();
         awareDbConn.Close();
     }
 }
示例#3
0
        public QI_USER_REC GetUserRecordById(Guid UserId)
        {
            QI_USER_REC user = new QI_USER_REC();

            using (SqlConnection awareDbConn = m_SqlHelpers.GetDbConnection(m_AwareDbConnString))
            {
                HAR_StringEncrypter m_Encrypter = new HAR_StringEncrypter();
                string sqlText = "usp_SelectUserRecsByUserID";

                SqlCommand sqlCmd = new SqlCommand(sqlText, awareDbConn);
                sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
                sqlCmd.Parameters.AddWithValue("@UserId", UserId);
                SqlDataReader dr = sqlCmd.ExecuteReader();

                while (dr.Read())
                {
                    try
                    {
                        try { user.UserID = dr.GetGuid(0); }
                        catch (SqlNullValueException Exception) { user.UserID = new Guid(); }
                        try { user.UserName = dr.GetString(1); }
                        catch (SqlNullValueException ex) { user.UserName = string.Empty; }
                        try { user.FacilityId = dr.GetGuid(2); }
                        catch (SqlNullValueException ex) { user.FacilityId = new Guid(); }
                        try { user.VerifyCode = m_Encrypter.DecryptString(dr.GetString(3)); }
                        catch (SqlNullValueException ex) { user.VerifyCode = string.Empty; }
                    }
                    catch (InvalidCastException ex)
                    {
                    }
                }
                dr.Close();
                awareDbConn.Close();
            }
            return(user);
        }