コード例 #1
0
 /// <summary>
 /// This method loads the information from the sqlreader into the Employee object
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="employee"></param>
 private static void LoadObject(SqlDataReader reader, ClientOtherInfo clientOther)
 {
     clientOther.UID            = Convert.ToInt32(reader[FieldName.UID].ToString());
     clientOther.FKClientUID    = Convert.ToInt32(reader[FieldName.FKClientUID]);
     clientOther.RCFieldCode    = reader[FieldName.RCFieldCode].ToString();
     clientOther.FieldValueText = reader[FieldName.FieldValueText].ToString();
 }
コード例 #2
0
        /// <summary>
        /// List employees
        /// </summary>
        /// <param name="clientID"></param>
        public static List <ClientOtherInfo> List(int clientID)
        {
            var clientOtherList = new List <ClientOtherInfo>();

            using (var connection = new SqlConnection(ConnString.ConnectionString))
            {
                var commandString = string.Format(
                    " SELECT           " +
                    " UID,             " +
                    " FKClientUID,     " +
                    " RCFieldCode,     " +
                    " FieldValueText   " +
                    "   FROM [ClientOtherInfo] " +
                    "   WHERE  FKClientUID = {0}",
                    clientID);

                using (var command = new SqlCommand(
                           commandString, connection))
                {
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var clientOther = new ClientOtherInfo();
                            LoadObject(reader, clientOther);

                            clientOtherList.Add(clientOther);
                        }
                    }
                }
            }

            return(clientOtherList);
        }