<%@ Page Language="C#" MasterPageFile="~/masterpages/eDashboard.master" AutoEventWireup="true" Inherits="site_HITS_Reports_Default" Title="Brightstar Device Protection: Report Administration Page" Theme="eMain" Culture="auto" UICulture="auto" Codebehind="Default.aspx.cs" %>
<%@ Register Assembly="eSecuritel.HITS.UI.Components" Namespace="eSecuritel.HITS.UI.Components" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="eContent" Runat="Server">
   <h1><asp:Label runat="server" Text="<%$ Resources: AdministrationManagement, LabelHeaderReportAdministration %>" /></h1>
   
   <h2><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelExistingReports %>" /></h2>
   
   <cc1:ExtendedValidationSummary runat="server" ID="extValidationSummaryTop" HeaderText="<%$ Resources: ReportsManagement, HeaderTextFollowingItemsReviewedContinuing %>" ></cc1:ExtendedValidationSummary>

    <asp:GridView ID="dgReports" runat="server" Width = "100%" AutoGenerateColumns="False" 
    DataKeyNames="ReportId" DataSourceID="odsReports" AllowPaging="True"
         OnPageIndexChanged = "dgReports_PageIndexChanged" 
         OnPageIndexChanging = "dgReports_PageIndexChanging"
          OnRowDataBound = "dgReports_RowDataBound"
          OnRowUpdating="dgReports_RowUpdating" OnSelectedIndexChanging="dgReports_SelectedIndexChanging">
    
    <Columns>
        <asp:BoundField DataField="CategoryName" HeaderText="<%$ Resources: ReportsManagement, HeaderTextCategoryName %>" />
        <asp:BoundField DataField="ReportName" HeaderText="<%$ Resources: ReportsManagement, HeaderTextReportName %>" />
        <asp:CheckBoxField DataField="Active" HeaderText="<%$ Resources: ReportsManagement, HeaderTextActiveQuestion %>" />
        <asp:BoundField DataField="CategoryColumnIndex" HeaderText="<%$ Resources: ReportsManagement, HeaderTextColIndex %>" >
            <ControlStyle Width="20px" />
        </asp:BoundField>
        <asp:BoundField DataField="CategoryRowIndex" HeaderText="<%$ Resources: ReportsManagement, HeaderTextRowIndex %>" >
            <ControlStyle Width="20px" />
        </asp:BoundField>
        <asp:BoundField DataField="ItemRowIndex" HeaderText="<%$ Resources: ReportsManagement, HeaderTextItemIndex %>" >
            <ControlStyle Width="20px" />
        </asp:BoundField>
        <asp:BoundField DataField="URL" HeaderText="<%$ Resources: ReportsManagement, HeaderTextLink %>" >
            <ControlStyle Width="320px" />
        </asp:BoundField>
            
           
         <asp:TemplateField HeaderText = "<%$ Resources: OrganizationManagement, OrganizationTypeTableHeader %>">
            <ItemTemplate>
                <asp:Label ID = "lblOrganizationTypes" runat = "server" />
            </ItemTemplate>
            <EditItemTemplate>                                
                <center>
                        <asp:DropDownList ID = "ddlOrganizationType" runat = "server" Width = "150px" />
                       
                        <div style="margin-top:5px;margin-bottom:5px;"> 
                            <asp:Button ID = "btnAddOrganizationType" runat = "server" Text = "<%$ Resources: Default, ButtonAdd %>"  OnClick = "btnAddOrganizationType_Click" />
                            <asp:Button ID = "btnRemoveOrganizationType" runat = "server" Text = "<%$ Resources: Default, ButtonRemove %>"  OnClick = "btnRemoveOrganizationType_Click" />
                        </div>
                        
                        <div style="margin-top:5px;margin-bottom:5px;"> 
                            <asp:ListBox ID = "lstOrganizationTypes" runat = "server" Width = "150px" />
                            <asp:Label ID = "lblAllOrgTypes" runat = "server" Text = "<%$ Resources: OrganizationManagement, LabelAllOrgTypes %>" />
                        </div>
                </center>                
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowEditButton="True" EditText="<%$ Resources: ReportsManagement, LabelEdit %>" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton CommandName="Delete" ID="btnDeleteLink" runat="server"  OnClientClick="<%$ Resources: ReportsManagement, ConfirmContinueWithDelete %>" Text="<%$ Resources: Default, DeleteButtonLabel %>"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowSelectButton="true" SelectText="<%$ Resources: ReportsManagement, LabelInsertCopyBelow %>" ItemStyle-Wrap="false" />
    </Columns>    
   
    <PagerSettings Mode="NumericFirstLast" />
    </asp:GridView>
    
    <asp:ObjectDataSource ID="odsReports" runat="server"
        TypeName="ReportManagement"
        SelectMethod="SelectAllReportDataWithInactive"
        SelectCountMethod = "SelectAllReportsCount"
        UpdateMethod="UpdateReportData"
        DeleteMethod="DeleteReportData"
        InsertMethod="InsertReportData"
        DataObjectTypeName="HITSWebService.ReportData">
    </asp:ObjectDataSource>
    &nbsp;
    <div>
        <asp:LinkButton ID="btnAddNew" runat="server" OnClick="btnAddNew_Click" Text="<%$ Resources: Default, ButtonAddNew %>"></asp:LinkButton>
    </div>
    
    <asp:Panel ID = "pnlNewReport" runat = "server" Visible = "False">
    <h2><asp:label runat="server" Text="<%$ Resources: ReportsManagement, LabelEnterNewReport %>" /></h2>
   <div class="greyblock">
   <b><span style="color: #ff0000">* </span></b>
        <asp:Literal ID="m_litRequiredFieldIndicator" runat="server" Text="<%$ Resources: Default, LabelIndicatesRequiredField %>" />
    <asp:FormView runat="server" ID="frmNewRow" DataSourceID="odsReports" OnItemCommand = "frmNewRow_ItemCommand"  OnItemInserted="frmNewRow_ItemInserted" DefaultMode="Insert">
        <InsertItemTemplate>
            <table>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelCategoryName %>" />&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtCategoryName" Text='<%# Bind("CategoryName") %>' />
                    <asp:RequiredFieldValidator ID = "RequiredFieldValidator1" runat = "server" ControlToValidate = "txtCategoryName" ValidationGroup = "NewReport"  Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    </td>
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelReportName %> "/>&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtReportName" Text='<%# Bind("ReportName") %>' />
                    <asp:RequiredFieldValidator ID = "RequiredFieldValidator2" runat = "server" ControlToValidate = "txtReportName" ValidationGroup = "NewReport" Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    </td>
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelColIndex %>" />&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtCategoryColumnIndex" Text='<%# Bind("CategoryColumnIndex") %>' />
                    <asp:RequiredFieldValidator ID = "RequiredFieldValidator3" runat = "server" ControlToValidate = "txtCategoryColumnIndex" ValidationGroup = "NewReport" Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    <asp:CompareValidator ID = "CompareValidator1" runat = "server" Operator = "DataTypeCheck"  Text = "Value must be numeric" ControlToValidate = "txtCategoryColumnIndex" Type="Integer" />
                    </td>
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelRowIndex %>" />&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtCategoryRowIndex" Text='<%# Bind("CategoryRowIndex") %>' />
                    <asp:RequiredFieldValidator ID = "RequiredFieldValidator4" runat = "server" ControlToValidate = "txtCategoryRowIndex" ValidationGroup = "NewReport" Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    <asp:CompareValidator ID = "CompareValidator2" runat = "server" Operator = "DataTypeCheck"  Text = "Value must be numeric" ControlToValidate = "txtCategoryRowIndex" Type="Integer" />
                    </td>
                    
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelItemIndex %>" />&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtItemRowIndex" Text='<%# Bind("ItemRowIndex") %>' />
                    <asp:RequiredFieldValidator ID = "RequiredFieldValidator5" runat = "server" ControlToValidate = "txtItemRowIndex" ValidationGroup = "NewReport" Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    <asp:CompareValidator ID = "CompareValidator3" runat = "server" Operator = "DataTypeCheck" Text = "Value must be numeric" ControlToValidate = "txtItemRowIndex" Type="Integer" />
                    </td>
                    
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: ReportsManagement, LabelActiveQuestion %>" /></td>
                    <td><asp:CheckBox runat="server" ID="ckActive" Checked='<%# Bind("Active") %>' /></td>                    
                </tr>
                <tr>
                    <td><asp:Label ID="Label1" runat="server" Text="<%$ Resources: ReportsManagement, LabelLink %>" />&nbsp;<b><span style="color: #ff0000">* </span></b></td>
                    <td><asp:TextBox runat="server" ID="txtURL" Text='<%# Bind("URL") %>' Width="400px" />
                        <asp:RequiredFieldValidator ID = "RequiredFieldValidator6" runat = "server" ControlToValidate = "txtURL" ValidationGroup = "NewReport" Text="<%$ Resources:Default, RequiredValidatorText %>" />
                    </td>
                </tr>
                <tr>
                    <td><asp:Label runat="server" Text="<%$ Resources: OrganizationManagement, OrganizationTypeLabel %>" /></td> 
                    <td>
                        <asp:ListBox ID = "lstOrganizationTypes" runat = "server" SelectionMode = "Multiple" Rows = "7" Width = "150px" OnDataBinding = "lstOrganizationTypes_DataBinding" />
                    </td>
                </tr>                
            </table>
           <div style="padding-left:12%">
                    <asp:Button runat="server" ID="btnInsert" CommandName="Insert" CssClass="pagebutton" Text="<%$ Resources: Default, ButtonInsert %>" ValidationGroup = "NewReport" />
                    <asp:Button runat="server" ID="btnCancel" CommandName="Cancel" CssClass="pagebutton" Text="<%$ Resources: Default, ButtonCancel %>" />
                    </div> 
        </InsertItemTemplate>        
    </asp:FormView>
    </div> 
    </asp:Panel>
</asp:Content>

