예제 #1
0
 private static SqlParameter[] CreateSqlParameter(ContactsBackup model)
 {
     return(new SqlParameter[]
     {
         new SqlParameter("@Id", model.Id),
         new SqlParameter("@PhoneNumber", model.PhoneNumber),
         new SqlParameter("@ComPort", model.ComPort),
         new SqlParameter("@CreatedDate", model.CreatedDate),
         new SqlParameter("@SimNumber", model.SimNumber),
     });
 }
예제 #2
0
        public static ContactsBackup UpdateItem(ContactsBackup model)
        {
            Int32 result = 0;

            using (var reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ContactsBackup_Update", CreateSqlParameter(model)))
            {
                while (reader.Read())
                {
                    result = (Int32)reader[0];
                }
            }
            return(GetItemByID(result));
        }
예제 #3
0
        public static ContactsBackup GetItemByID(Int32 id)
        {
            ContactsBackup item      = new ContactsBackup();
            var            sqlParams = new SqlParameter[1];

            sqlParams[0] = new SqlParameter("@Id", id);
            using (var reader = SqlHelper.ExecuteReader("ContactsBackup_GetByID", sqlParams))
            {
                while (reader.Read())
                {
                    item = GetItemFromReader(reader);
                }
            }
            return(item);
        }
예제 #4
0
        private static ContactsBackup GetItemFromReader(IDataReader dataReader)
        {
            ContactsBackup objItem = new ContactsBackup();

            objItem.Id = SqlHelper.GetInt(dataReader, "Id");

            objItem.PhoneNumber = SqlHelper.GetString(dataReader, "PhoneNumber");

            objItem.ComPort = SqlHelper.GetString(dataReader, "ComPort");

            objItem.CreatedDate = SqlHelper.GetDateTime(dataReader, "CreatedDate");

            objItem.SimNumber = SqlHelper.GetString(dataReader, "SimNumber");
            return(objItem);
        }
예제 #5
0
        public static ContactsBackupCollection GetSimPort()
        {
            ContactsBackupCollection collection = new ContactsBackupCollection();

            using (var reader = SqlHelper.ExecuteReader("ContactsBackup_GetComPort", null))
            {
                while (reader.Read())
                {
                    ContactsBackup obj = new ContactsBackup();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }