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)); }
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)); }
public static bool Modify(Residence usr) { if (usr.Id == 0) { return(Insert(usr)); } else { return(Update(usr)); } }
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)); }
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); }