示例#1
0
        public static bool Delete(Residence usr)
        {
            const string GET_DELETE = @"delete [tbResidence] WHERE Id = @Id";

            SqlCommand com = new SqlCommand(GET_DELETE);

            com.Parameters.Add(new SqlParameter("@Id", usr.Id));

            return(SqlManager.ExecuteNonQuery(com));
        }
示例#2
0
        public static bool Insert(Residence usr)
        {
            const string GET_INSERT = @"insert [tbResidence] (OwnerNo,TenantNo) values (@OwnerNo, @TenantNo)";

            SqlCommand com = new SqlCommand(GET_INSERT);

            com.Parameters.Add(new SqlParameter("@OwnerNo", usr.OwnerNo));
            com.Parameters.Add(new SqlParameter("@TenantNo", usr.TenantNo));

            return(SqlManager.ExecuteNonQuery(com));
        }
示例#3
0
 public static bool Modify(Residence usr)
 {
     if (usr.Id == 0)
     {
         return(Insert(usr));
     }
     else
     {
         return(Update(usr));
     }
 }
示例#4
0
        public static bool Update(Residence usr)
        {
            const string GET_UPDATE = @"update [tbResidence] set OwnerNo= @OwnerNo, TenantNo= @TenantNo WHERE Id = @Id";

            SqlCommand com = new SqlCommand(GET_UPDATE);

            com.Parameters.Add(new SqlParameter("@OwnerNo", usr.OwnerNo));
            com.Parameters.Add(new SqlParameter("@TenantNo", usr.TenantNo));
            com.Parameters.Add(new SqlParameter("@Id", usr.Id));

            return(SqlManager.ExecuteNonQuery(com));
        }
示例#5
0
        public static Residence Get(int id)
        {
            const string GET_RECORD = @"SELECT Id,OwnerNo,TenantNo FROM [tbResidence] WHERE Id = @Id";

            Residence  ret = default(Residence);
            SqlCommand com = new SqlCommand(GET_RECORD);

            com.Parameters.Add(new SqlParameter("@Id", id));
            ret = SqlManager.Select <Residence>(com).First();

            return(ret);
        }