Ejemplo n.º 1
0
 public UserOrgObject SaveUserOrg(UserOrgObject userOrg)
 {
     if (userOrg.UserOrgId > 0) // Update
     {
         string sql = @"
             UPDATE  dat_UserOrg
             SET     EmployeeId = @EmployeeId,
                     Org = @Org
             WHERE   UserOrgId = @UserOrgId";
         Config.Conn.Execute(sql, userOrg);
     }
     else
     {
         if (GetUserOrg(userOrg.EmployeeId, userOrg.Org) == null)
         {
             string sql = @"
             INSERT INTO dat_UserOrg (
                 EmployeeId,
                 Org
             )
             VALUES (
                 @EmployeeId,
                 @Org
             )
             SELECT CAST(SCOPE_IDENTITY() AS INT)";
             userOrg.UserOrgId = Config.Conn.Query <int>(sql, userOrg).Single();
         }
     }
     return(userOrg);
 }
Ejemplo n.º 2
0
 public bool DeleteUserOrg(UserOrgObject userOrg)
 {
     try
     {
         Config.Conn.Execute("DELETE FROM dat_UserOrg WHERE UserOrgId = @UserOrgId", userOrg);
     }
     catch { return(false); }
     return(true);
 }