So do I take out the code in your #2 below that calls the SP so that it is more like your #1 and let them all fall to the new one?
 
Mike Stone
Director of Computer Information Services
Kaskaskia College
27210 College Road
Centralia, IL 62801
618-545-3201
www.kaskaskia.edu

>>> bowenweb@gmail.com 12/30/2004 06:27:32 >>>
Mike,

I think I'm just re-stating what you've said already, but...

I agree that your proposal #1 is the better idea...that you'll end up
with three versions of the AddTab method in TabsDB.cs, as follows:

1.
public int AddTab(int portalID, string tabName, string Roles, int tabOrder)
--This is one of the two original versions, it now will just return a
value from your new version of AddTab (with the 6 params...you just
set the defaults for 'ShowMobile' and 'MobileTabName' before you call
the new one)

2.
public int AddTab(int portalID, string tabName, int tabOrder)
--This is one of the two original versions, and can be left as is...It
will happily call the 4-param version, which will happily call the new
6-param version, and it all works out.  It just sets the default value
for the 'Roles' param before calling.

3.
public int AddTab(int portalID, string tabName, string Roles, int
tabOrder, bool ShowMobile, string MobileTabName)
--This is your new one, and the other two point to it.  The sproc in
the database should be changed to handle all the params this method
will be sending (because this one is the only one that will actually
reach the database...the other two versions come here for their data).

I like this way, it seems the cleanest. 
JB
                             

On Thu, 30 Dec 2004 01:30:57 -0600, Mike Stone <mstone@kc.cc.il.us> wrote:
> I used HTML email format so it was easy to highlight key points. It took
> more time to write this then the code,
> so if I left something out I am sorry, I just wanted to get this out today.

> While working on the AddTabs.aspx page I needed to call the rp_AddTab stored
> procedure in the
> TabsDB.cs file and ran into a couple of small issues that needs to be
> addressed.
>  I will include the code so you don't have to go look at it.
> My PROPOSED Solution is at the bottom and when finalized will be added to
> the  Jira Issue

> The form has the following fields as described in Jira Issue which need to
> be saved/inserted into the
> rb_Tabs table, see Tabs Table  (way below).  Table Name Mapping

>    1) Tab Name - TabName
>    2) Authorized Users that can view tab - AuthorizedRoles
>    3) Location where the new tab should be placed - ParentTabID
>    4) Show to Mobile Uses? checkbox - ShowMobile
>    5) Mobile Tab Name - MobileTabName
>    6) Portal Id - PortalID

> Issue 1)
>     The TabsDB.cs currently doesn't support that many parms being passed in.
> Here are the two options
>      currently in TabsDB.cs. in a) below AllUsers is assumed security role.
>          a)  public int AddTab(int portalID, string tabName, string Roles,
> int tabOrder)  only 4 of the 6 needed parms
>                i)  Missing ShowMobile
>                ii) Missing MobileTabName
>          b)  public int AddTab(int portalID, string tabName, int tabOrder)
> only 3 of the 6 needed parms
>                i)   Missing ShowMobile
>                ii)  Missing MobileTabName
>                iii) Missing AuthorizedRoles

> So of course my first idea was to just add another overload to allow for the
> all 6 parms (which I did) so I went and looked at the
> Stored Procedure rp_AddTab and noticed
> it is missing  ShowMobile and the TabsDB.cs has is passing MobileName but
> not getting the
> value from anyplace so it defaults to blank.

>     @PortalID              int,
>     @TabName            nvarchar(50),
>     @TabOrder            int,
>     @AuthorizedRoles   nvarchar (256),
>     @MobileTabName   nvarchar(50),
>     @TabID                 int OUTPUT



> Issue 2)
>     The
> rb_AddTab Stored Procedure Values clause has hard coded values in it :(.  I
> was thinking this is a bad approach. Shouldn't that value be set by a parm
> passed in? (which of course is why it isn't currently passed in at all.)  I
> am sure this is the ShowMobile value set to false

> VALUES
> (
>     @PortalID,
>     @TabName,
>     @TabOrder,
>     0, /* false */
>     @MobileTabName,
>     @AuthorizedRoles
> )


> So for now, to get my project up and running I created a new SP named
> rb_AddTab2 with the correct number of parms for EACH field. I am sure this
> needs to be addressed in my Proposal below...


> --- Tabs Table ---
> 3 TabID int 4 0
> 0 ParentTabID int 4 1
> 0 TabOrder int 4 0
> 0 PortalID int 4 0
> 0 TabName nvarchar 50 0
> 0 MobileTabName nvarchar 50 0
> 0 AuthorizedRoles nvarchar 256 1
> 0 ShowMobile bit 1 0
> 0 TabLayout int 4 1
> -- End Table ----


> Research Completed

>     I searched the whole project with VS for [ AddTab(  ] and only found it
> in the following files. two of
>     the existing modules seem to call the one with 4 of 6 parms shown in
> issue 1 - a) below.  
>     That was #2 and #3 below. 

>      NOTE:   1 - a is the current one that sets all the SP Parms. The other
> one is just a return
>                  public int AddTab(int portalID, string tabName, int
> tabOrder)
>                 {
>                     return AddTab(portalID, tabName, strAllUsers, tabOrder);
>                 }
>                 I am not sure what the official name is
> (OverRide/Module/Class) but I gather it passes in just those three parms to
> the
>                 other (OverRide/Module/Class) and those with out incoming
> parms somehow get default values. In this case Roles is 
>                 set to "All Users;"

>        
> ------ TabsDB.cs ----
>         Issue 1 - a) public int AddTab(int portalID, string tabName,
> string Roles, int tabOrder)
>         Issue 1 - b) public int AddTab(int portalID, string tabName, int
> tabOrder)
>         ------ End TabsDB.cs -----

>    1)  /DesktopModules/Tabs/AddTab.aspx.cs -> SaveButton_Click - Uses New
> Overload)
>  .AddTab(portalSettings.PortalID, Int32.Parse(parentTab.SelectedItem.Value),
> tabName.Text, 990000, authorizedRoles, showMobile.Checked,
> mobileTabName.Text)
>    2)  /DesktopModules/AddTab/AddTab.ascx.cs -> AddTabButton_Click - Uses
> Issue 1 - a)
> .AddTab(portalSettings.PortalID, t.Name, viewPermissionRoles, t.Order);
>   
>    3) /app_code/Rainbow/DAL/PortalsDB.cs -> CreatePortal - Uses Issue 1 - a
> and 1 - b)
>  // Create a new Tab "home"
>  .AddTab(portalID, "Home",1);
> // Create a new Tab "admin"
> .AddTab(portalID, localizedString, strAdmins, 9999);
>    4)  /DesktopModules/PortalsAdministration/AddNewPortals.aspx.cs ->
> CreatePortal - Uses Issue 1 -b)
>  .AddTab(newPortalID, myReader["TabName"].ToString(),
> Int32.Parse(myReader["TabOrder"].ToString()));        
>    5) /DesktopModules/Tabs/Tabs.ascx.cs -> AddTab_Click - Uses Issue 1 - b)
> .AddTab(portalSettings.PortalID, t.Name, t.Order);


> Proposed Solution

>   This is where each of you come in.  I have listed two options below so
> that I can complete this issue. There may be others I am
>    missing so please chime in with your comments.

>   PS1) After toying with my options this one seems like the correct
> approach, assume I follow the Wiki best practices for SQL db changes.
> Drop the rb_AddTab stored procedure and recreate it as shown in  New
> rb_AddTab below.
> Delete out the current class in TabsDB.cs that sets sp parms and leave the
> new one with all the parms I just created.
> Change the override version in TabsDB.cs so that the return has all the
> needed default values passed in the correct order.
> Modify AddTab.ascx.cs -> AddTabButton_Click to pass in all parms as this
> module will get the same features anyway.
> Modify AddNewPortals.aspx.cs -> CreatePortal so that the Admin Tab passes
> all parms default values.
> Make sure the SP sets correct defaults if blanks are passed in.
> The input fields have been restricted to 50 chars so I didn't put in the
> check length for MobileName.
> Retest on my site.
> Ask for testers from team for QA.
> Make Sure changes in Doc get made
> Make Sure Install is not effected
>          

>   PS2) While thinking this was a cheep way out for me, but it doesn't quite
> seem like the best coding practice.
> Change the AddTab module so that it is the same as the new feature in the
> Tabs module EHN I just made. Then Parms are the same.
> Create a NEW sp rb_AddTab2 that the AddTab module and AddTab.aspx page can
> use leaving the old one there
> The input fields have been restricted to 50 chars so I didn't put in the
> check length for MobileName.
> Retest on my site.
> Ask for testers from team for QA.
> Make Sure changes in Doc get made
> Make Sure Install is not effected

>          

> --------- START rb_AddTab Stored Procedure --------------
> CREATE PROCEDURE rb_AddTab2
> (
>    @PortalID                int,                     /* Required Field  */
>    @ParentTabID         int,                    /*   New Parm - NULL Allowed
>    */
>    @TabName             nvarchar(50),      /* Required Field  */
>    @TabOrder             int,                    /* Required Field  */
>    @AuthorizedRoles    nvarchar (256),   /* NULL Allowed    */
>    @ShowMobile          bit = 0,              /*   New Parm - false by
> default */
>    @MobileTabName    nvarchar(50),      /* Required Field  */
>    @TabID                  int OUTPUT         /* Returned value */

> )

> AS

>   /* Normally set to NULL if in Root so do so here */
>   IF (@ParentTabID = 0)
>   BEGIN 
>     set @ParentTabID = NULL
>   END

> /* Optionally check other fields and set appropriate defaults for them here
> */

>
> INSERT INTO rb_Tabs
> (
>    ParentTabID,        /* New Parm */
>     TabOrder,
>     PortalID,
>     TabName,
>     MobileTabName,   /* New Parm */
>     AuthorizedRoles,
>     ShowMobile         /* New Parm  Not hard coded value 0 any more */
>    
>    
> )

>
> VALUES
> (
>   @ParentTabID,
>   @TabOrder,
>    @PortalID,
>    @TabName,
>    @MobileTabName,
>    @AuthorizedRoles,
>    @ShowMobile
>    
> )

> SELECT
>     @TabID = @@IDENTITY
> GO

> --------- END  rb_AddTab Stored Procedure --------------




> Mike Stone
> Director of Computer Information Services
> Kaskaskia College
> 27210 College Road
> Centralia, IL 62801
> 618-545-3201
> www.kaskaskia.edu


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Rainbowportal-devel mailing list
Rainbowportal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rainbowportal-devel