From: <ro...@us...> - 2006-08-11 19:46:21
|
Revision: 309 Author: rouquin Date: 2006-08-11 12:46:14 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=309&view=rev Log Message: ----------- The Version page is working as much as I can get it to right now. (don't press the update button. :-) Modified Paths: -------------- Website/App_Code/Versions.cs Website/Includes/AdministrationTree.ascx.cs Website/Includes/Versions.ascx Website/Includes/Versions.ascx.cs Modified: Website/App_Code/Versions.cs =================================================================== --- Website/App_Code/Versions.cs 2006-08-11 18:37:56 UTC (rev 308) +++ Website/App_Code/Versions.cs 2006-08-11 19:46:14 UTC (rev 309) @@ -16,10 +16,10 @@ /// </summary> public class VersionDB : Page { - public static Release GetVersion(int VersionID) + public static Release GetVersion(int versionID) { tcdbDataSetTableAdapters.db_versionTableAdapter versionAdapter = new tcdbDataSetTableAdapters.db_versionTableAdapter(); - tcdbDataSet.db_versionDataTable versionTable = versionAdapter.GetData(VersionID, null, true); + tcdbDataSet.db_versionDataTable versionTable = versionAdapter.GetData(versionID, null, null); Release version = new Release(); if (versionTable.Count > 0) @@ -27,7 +27,6 @@ return version; } - public static List<Release> GetVersionList(Nullable<int> ProductID, Nullable<bool> active) { tcdbDataSetTableAdapters.db_versionTableAdapter versionAdapter = new tcdbDataSetTableAdapters.db_versionTableAdapter(); @@ -39,6 +38,11 @@ return versionList; } + public static void SaveVersion(String number, String code, int productID) + { + tcdbDataSetTableAdapters.db_versionTableAdapter vAdapter = new tcdbDataSetTableAdapters.db_versionTableAdapter(); + vAdapter.Insert(productID, number, code); + } public static Build GetBuild(int buildID) { @@ -51,7 +55,6 @@ return build; } - public static List<Build> GetBuildList(Nullable<int> versionID, Nullable<bool> active) { tcdbDataSetTableAdapters.db_buildTableAdapter bAdapter = new tcdbDataSetTableAdapters.db_buildTableAdapter(); @@ -63,6 +66,11 @@ return buildList; } + public static void SaveBuild(String number, int versionID) + { + tcdbDataSetTableAdapters.db_buildTableAdapter bAdapter = new tcdbDataSetTableAdapters.db_buildTableAdapter(); + bAdapter.Insert(versionID, number); + } } public class Release Modified: Website/Includes/AdministrationTree.ascx.cs =================================================================== --- Website/Includes/AdministrationTree.ascx.cs 2006-08-11 18:37:56 UTC (rev 308) +++ Website/Includes/AdministrationTree.ascx.cs 2006-08-11 19:46:14 UTC (rev 309) @@ -177,7 +177,7 @@ // Set additional properties for the node. newNode.SelectAction = TreeNodeSelectAction.Expand; - newNode.NavigateUrl = "~/Version.aspx?" + Constants.CODE_VERSION + "=" + newNode.Value; + newNode.NavigateUrl = "~/Version.aspx?"+Constants.CODE_PRODUCT+"="+productID+"&" + Constants.CODE_VERSION + "=" + newNode.Value; if (!version.ACTIVE) newNode.Text = "<font class='deleted'>" + newNode.Text + "</font>"; @@ -847,6 +847,5 @@ break; } } - } } Modified: Website/Includes/Versions.ascx =================================================================== --- Website/Includes/Versions.ascx 2006-08-11 18:37:56 UTC (rev 308) +++ Website/Includes/Versions.ascx 2006-08-11 19:46:14 UTC (rev 309) @@ -1,6 +1,6 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Versions.ascx.cs" Inherits="TCDB.Versions" %> <asp:FormView ID="FormView1" runat="server" DataKeyNames="versionID" DataSourceID="VersionDataSource" - OnDataBound="FormView1_DataBound" OnItemDeleted="FormView1_ItemDeleted" OnItemInserted="FormView1_ItemInserted" + OnDataBound="FormView1_DataBound" OnItemInserted="FormView1_ItemInserted" OnItemUpdated="FormView1_ItemUpdated"> <HeaderTemplate> <table width="100%"> @@ -14,9 +14,10 @@ OnCommand="newTestPass">New Test Pass</asp:LinkButton><strong> </strong> <asp:LinkButton ID="newBuild" runat="server" CommandArgument='<%# Eval("versionID") %>' OnCommand="newBuild" PostBackUrl="~/Build.aspx?mode=new">New Build</asp:LinkButton> - <asp:LinkButton ID="newPlatform" runat="server" CommandName="newPlatform" PostBackUrl="~/Platform.aspx?mode=new">New Platform</asp:LinkButton> - <strong>Active:</strong> - <asp:CheckBox ID="activeBox" runat="server" AutoPostBack="True" OnCheckedChanged="activeBox_CheckedChanged" /> + <asp:LinkButton ID="newPlatform" runat="server" CommandName="newPlatform" PostBackUrl="~/Platform.aspx?mode=new">New Platform</asp:LinkButton><br /> + <asp:Label ID="activeLbl" runat="server" Text="Hidden:"></asp:Label> + <asp:CheckBox ID="activeBox" runat="server" AutoPostBack="True" OnCheckedChanged="activeBox_CheckedChanged" + OnInit="activeBox_Init" /> </td> </tr> </table> @@ -45,7 +46,8 @@ <strong>Product:</strong> <asp:Label ID="productName" runat="server" Text='<%# Eval("productName") %>'></asp:Label></td> <td align="left" colspan="2" valign="top"> - <strong>Platforms: </strong><br /> + <strong>Platforms: </strong> + <br /> <asp:ListBox ID="platformList" runat="server" Height="150px" Width="150px"></asp:ListBox> </td> </tr> @@ -56,13 +58,9 @@ <tr> <td align="left" colspan="1" style="height: 34px" width="25%"> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" - Text="New"></asp:LinkButton> - | - <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" - Text="Edit"></asp:LinkButton> - | - <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" - Text="Delete"></asp:LinkButton> + Text="New" OnInit="NewButton_Init"></asp:LinkButton><asp:Label ID="newLbl" runat="server"> | </asp:Label><asp:LinkButton + ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" + OnInit="EditButton_Init"></asp:LinkButton> </td> <td colspan="3" style="height: 34px"> </td> @@ -81,8 +79,10 @@ <table width="700"> <tr> <td align="left" colspan="3" width="60%"> - <strong>Version #: </strong> <asp:TextBox ID="numberBox" runat="server" - Text='<%# Bind("number") %>'></asp:TextBox></td> + <strong> + <asp:CheckBox ID="Active" runat="server" Checked='<%# Bind("active") %>' Enabled="False" + Visible="False" />Version #: </strong> + <asp:TextBox ID="numberBox" runat="server" Text='<%# Bind("number") %>'></asp:TextBox></td> <td align="right" colspan="1" width="40%"> <strong>Date Created: <asp:Label ID="dateCreatedLbl" runat="server" Font-Bold="False" Text='<%# Eval("dateCreated") %>'></asp:Label> @@ -95,14 +95,15 @@ <tr> <td align="left" colspan="2"> <strong>Product:</strong> - <asp:DropDownList ID="productList" runat="server" DataSourceID="ProductsDataSource" - DataTextField="name" DataValueField="productID" SelectedValue='<%# Bind("productID") %>'> + <asp:DropDownList ID="productList" runat="server" OnInit="productList_Init"> </asp:DropDownList> </td> <td align="left" colspan="2" valign="top"> <strong>Platform:</strong><br /> - <asp:ListBox ID="platformList" runat="server" OnDataBound="platformList_DataBound" SelectionMode="Multiple" OnInit="platformList_Init" Height="150px" Width="150px"> - </asp:ListBox> </td> + <asp:ListBox ID="platformList" runat="server" OnDataBound="platformList_DataBound" + SelectionMode="Multiple" OnInit="platformList_Init" Height="150px" Width="150px"> + </asp:ListBox> + </td> </tr> <tr> <td class="hr" colspan="4"> @@ -138,7 +139,7 @@ Text='<%# Bind("number") %>'></asp:TextBox></td> <td align="right" colspan="1" width="40%"> <strong>Date Created: - <asp:Label ID="dateCreatedLbl" runat="server" Font-Bold="False" Text='<%# Bind("dateCreated") %>'></asp:Label> </strong></td> + <asp:Label ID="dateCreatedLbl" runat="server" Font-Bold="False" Text='<%# Eval("dateCreated") %>'></asp:Label> </strong></td> </tr> <tr> <td class="hr" colspan="4" style="height: 1px"> @@ -147,13 +148,13 @@ <tr> <td align="left" colspan="2"> <strong>Product:</strong> - <asp:DropDownList ID="productList" runat="server" DataSourceID="ProductsDataSource" - DataTextField="name" DataValueField="productID" SelectedValue='<%# Bind("productID") %>'> + <asp:DropDownList ID="productList" runat="server" OnInit="productList_Init"> </asp:DropDownList> </td> <td align="left" colspan="2" valign="top"> <strong>Platform:</strong><br /> - <asp:ListBox ID="platformList" runat="server" SelectionMode="Multiple"></asp:ListBox> </td> + <asp:ListBox ID="platformList" runat="server" SelectionMode="Multiple"></asp:ListBox> + </td> </tr> <tr> <td class="hr" colspan="4"> @@ -177,7 +178,7 @@ </InsertItemTemplate> </asp:FormView> <asp:ObjectDataSource ID="VersionDataSource" runat="server" InsertMethod="Insert" - OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="tcdbDataSetTableAdapters.db_versionTableAdapter" + OldValuesParameterFormatString="{0}" SelectMethod="GetData" TypeName="tcdbDataSetTableAdapters.db_versionTableAdapter" UpdateMethod="Update"> <UpdateParameters> <asp:Parameter Name="productID" Type="Int32" /> Modified: Website/Includes/Versions.ascx.cs =================================================================== --- Website/Includes/Versions.ascx.cs 2006-08-11 18:37:56 UTC (rev 308) +++ Website/Includes/Versions.ascx.cs 2006-08-11 19:46:14 UTC (rev 309) @@ -16,8 +16,9 @@ { private static Logger m_logg = new Logger("TCDB.Versions"); int versionID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_VERSION]); - String mode = HttpContext.Current.Request.QueryString["mode"]; - String product = HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]; + Release version; + String mode = HttpContext.Current.Request.QueryString[Constants.CODE_MODE]; + int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); protected void Page_Load(object sender, EventArgs e) { @@ -28,46 +29,58 @@ if (mode == null) { m_logg.Debug("Mode not set, redirecting to Test Management page"); - Response.Redirect("TestManagement.aspx"); + Response.Redirect("~/TestManagement.aspx"); } } - - // Check rights - - Session.Add("versionID", versionID); - - if (mode == "new") + if (mode == "new" && m_user.HasRight(Constants.RIGHTS_VERSION_CREATE, Constants.PRODUCT_ANYID)) + { + // New Version + Page.Title = "TCDB: New Version"; FormView1.ChangeMode(FormViewMode.Insert); + } + else + { + version = VersionDB.GetVersion(versionID); + Page.Title = "TCDB: Version #" + version.NUMBER; - Session.Add("tableName", "tcdb_version"); + // Check rights + if (!m_user.HasRight(Constants.RIGHTS_VERSION_VIEW, version.PRODUCT.ID)) + Response.Redirect("~/TestManagement.aspx"); + if (mode == "edit" && m_user.HasRight(Constants.RIGHTS_VERSION_EDIT, version.PRODUCT.ID)) + FormView1.ChangeMode(FormViewMode.Insert); + + Session.Add("tableName", "tcdb_version"); + } } - protected void activeBox_CheckedChanged(object sender, EventArgs e) - { - CheckBox active = (CheckBox)sender; - // TODO: update active value when procedure is created - //SqlCommand cmd = new SqlCommand("UPDATE version SET active='" + active.Checked + "' WHERE versionID=" + versionID, Master.DBConnection); - //cmd.ExecuteNonQuery(); - } - protected void FormView1_ItemDeleted(object sender, FormViewDeletedEventArgs e) + protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) { - // TODO: Update version platforms when possible - // clear current values - //SqlCommand cmd = new SqlCommand("DELETE FROM platformVersion WHERE versionID=" + versionID, Master.DBConnection); - //cmd.ExecuteNonQuery(); + if (e.Exception == null) + { + List<Release> versions = VersionDB.GetVersionList(Convert.ToInt32(e.Values["productID"]), true); - Response.Redirect("Administration.aspx"); + if (versions.Count > 0) + { + updatePlatforms(); + Response.Redirect("Version.aspx?" + Constants.CODE_VERSION + "=" + versions[0].ID); + } + } + else + { + m_logg.Error("Could not insert version"); + } } - protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) + protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { - tcdbDataSetTableAdapters.db_versionTableAdapter versionAdapter = new tcdbDataSetTableAdapters.db_versionTableAdapter(); - tcdbDataSet.db_versionDataTable versionTable = versionAdapter.GetData(null, Convert.ToInt32(e.Values["productID"]), active); - if (versionTable.Count > 0) + if (e.Exception == null) { updatePlatforms(); - Response.Redirect("Version.aspx?" + Constants.CODE_VERSION + "=" + versionTable[versionTable.Count - 1].versionID); } + else + { + m_logg.Error("Could not update version"); + } } protected void FormView1_DataBound(object sender, EventArgs e) { @@ -77,15 +90,16 @@ { Label dateCreated = (Label)FormView1.FindControl("dateCreatedLbl"); dateCreated.Text = DateTime.Today.ToShortDateString(); - active.Checked = true; + active.Checked = false; } else { DataRowView row = (DataRowView)FormView1.DataItem; if (row != null) - active.Checked = Convert.ToBoolean(row["active"].ToString()); + active.Checked = !Convert.ToBoolean(row["active"].ToString()); } } + protected void newTestPass(object sender, CommandEventArgs e) { Response.Redirect("~/TestPass.aspx?mode=new&" + Constants.CODE_VERSION + "=" + e.CommandArgument); @@ -94,18 +108,7 @@ { Response.Redirect("~/Build.aspx?mode=new&" + Constants.CODE_VERSION + "=" + e.CommandArgument); } - protected void productList_DataBound(object sender, EventArgs e) - { - if (FormView1.CurrentMode == FormViewMode.Insert && product != null) - { - DropDownList productList = (DropDownList)sender; - productList.SelectedValue = product; - } - } - protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) - { - updatePlatforms(); - } + protected void updatePlatforms() { ListBox platformList = (ListBox)FormView1.FindControl("platformList"); @@ -147,7 +150,84 @@ } protected void platformList_Init(object sender, EventArgs e) { - + } -} + + protected void activeBox_Init(object sender, EventArgs e) + { + CheckBox activeBox = (CheckBox)sender; + Label activeLbl = (Label)FormView1.FindControl("ActiveLbl"); + if (version == null) version = VersionDB.GetVersion(versionID); + + if (!m_user.HasRight(Constants.RIGHTS_VERSION_HIDE, version.PRODUCT.ID)) + { + activeBox.Visible = false; + activeLbl.Visible = false; + } + } + protected void activeBox_CheckedChanged(object sender, EventArgs e) + { + CheckBox activeBox = (CheckBox)sender; + + if (FormView1.CurrentMode == FormViewMode.Edit) + { + CheckBox active = (CheckBox)FormView1.FindControl("active"); + active.Checked = !activeBox.Checked; + } + else + { + /* TODO: add versionID and enable when bug 9898 + tcdbDataSetTableAdapters.db_versionTableAdapter vAdapter = new tcdbDataSetTableAdapters.db_versionTableAdapter(); + vAdapter.Update(version.PRODUCT.ID, version.NUMBER, version.CODE, !activeBox.Checked); + + Response.Redirect(Request.RawUrl); + */ + } + } + + protected void NewButton_Init(object sender, EventArgs e) + { + LinkButton newBtn = (LinkButton)sender; + Label newLbl = (Label)FormView1.FindControl("newLbl"); + + if (!m_user.HasRight(Constants.RIGHTS_VERSION_CREATE, Constants.PRODUCT_ANYID)) + { + newBtn.Visible = false; + newLbl.Visible = false; + } + } + protected void EditButton_Init(object sender, EventArgs e) + { + LinkButton editBtn = (LinkButton)sender; + Label newLbl = (Label)FormView1.FindControl("newLbl"); + if (version == null) version = VersionDB.GetVersion(versionID); + + if (!m_user.HasRight(Constants.RIGHTS_VERSION_EDIT, version.PRODUCT.ID)) + { + editBtn.Visible = false; + newLbl.Visible = false; + } + } + + protected void productList_Init(object sender, EventArgs e) + { + List<Product> products = ProductDB.GetProductList(active); + DropDownList productList = (DropDownList) sender; + + foreach (Product product in products) + { + if (m_user.HasRight(Constants.RIGHTS_VERSION_CREATE, product.ID) || + (product.ID == productID && m_user.HasRight(Constants.RIGHTS_VERSION_EDIT, productID))) + { + ListItem item = new ListItem(product.NAME, product.ID.ToString()); + if (!product.ACTIVE) + item.Attributes.CssStyle.Add("text-decoration", "line-through"); + if (product.ID == productID) + item.Selected = true; + + productList.Items.Add(item); + } + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |