<%@ page language="C#" masterpagefile="~/MasterPage.master" autoeventwireup="true" CodeFile="Department.aspx.cs" inherits="Maintenance_HR_Department" title="<%$ Resources: SiteMapLocalizations, Maintenance_DepartmentEdit %>" theme="white" %>
<%@ Import Namespace="System.Data" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script runat="server">

    
    protected void GridView1_Init(object sender, EventArgs e) {
    }

    protected void GridView1_Load(object sender, EventArgs e) {

    }
    protected void GridView1_PreRender(object sender, EventArgs e) {
    }
    protected void GridView1_DataBound(object sender, EventArgs e) {

    }



</script>


<center>
<p class="masterpageContentTop" >

<%--<asp:Label ID="txtTitle" runat="server" CssClass="PageTitle" Text="<%$ resources:Universal,Title_Department %>"></asp:Label>
--%><br />
<asp:Button ID="btnAddNew" runat="Server" Width="100px" Text="<%$ resources:Universal,Data_AddNew %>" OnClick="AddButton1_Click" />
    &nbsp; &nbsp;
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" PageSize="20"
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="DeptID" DataSourceID="ObjectDataSource1" EmptyDataText="null"
        ForeColor="#333333" GridLines="None" OnInit="GridView1_Init" OnRowCommand="GridView1_RowCommand" 
        OnRowCreated="GridView1_RowCreated" OnDataBound="GridView1_DataBound" OnLoad="GridView1_Load" OnPreRender="GridView1_PreRender" >
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

        <Columns>
            <asp:CommandField UpdateText="<%$ resources:Universal,Data_Update %>"
            CancelText="<%$ resources:Universal,Data_Cancel %>" EditText="<%$ resources:Universal,Data_Edit %>"
            DeleteText="<%$ resources:Universal,Data_Delete %>"  />

            <asp:TemplateField HeaderText="<%$ resources:Universal,Department_DeptID %>" SortExpression="DeptID">
                <EditItemTemplate>
                    <asp:TextBox ID="txtEditDeptID" runat="server" Text='<%# Bind("DeptID") %>' MaxLength="10" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEditDeptID"
                        ErrorMessage="<%$ resources:Universal, Msg_Remind_DepartmentID %>" ValidationGroup="EditValidationControls">*</asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="DeptIDLabel" runat="server" Text='<%# Eval("DeptID") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtAddDeptID" runat="server" Text='<%# Bind("DeptID") %>' MaxLength="3" />
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtAddDeptID"
                        ErrorMessage="<%$ resources:Universal, Msg_Remind_DepartmentID %>" ValidationGroup="AddValidationControls">*</asp:RequiredFieldValidator>
               </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal,Department_Name %>" SortExpression="Name">
                <EditItemTemplate>
                    <asp:TextBox ID="txtEditName" runat="server" Text='<%# Bind("Name") %>' />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtEditName"
                        ErrorMessage="<%$ resources:Universal, Msg_Remind_DepartmentName %>" ValidationGroup="EditValidationControls">*</asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtAddName" runat="server" Text='<%# Bind("Name") %>' />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAddName"
                        ErrorMessage="<%$ resources:Universal, Msg_Remind_DepartmentName %>" ValidationGroup="AddValidationControls">*</asp:RequiredFieldValidator>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal,Organizational %>" SortExpression="Organization">
                <EditItemTemplate>
                    <asp:TextBox ID="txtEditGrade" runat="server" Text='<%# Bind("Organization") %>' />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblGrade" runat="server" Text='<%# Eval("Organization") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtAddGrade" runat="server" Text='<%# Bind("Organization") %>' />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal,Comm_Description %>">
                <EditItemTemplate>
                    <asp:TextBox ID="DescriptionBox" runat="server" Text='<%# Bind("Description") %>' />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="DescriptionBox" runat="server" Text='<%# Bind("Description") %>' />
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButtonUpdate" runat="server" ValidationGroup="EditValidationControls" CausesValidation="true" CommandName="Update"
                        Text="<%$ resources:Universal,Data_Update %>" />
                    <asp:LinkButton ID="LinkButtonCancel" runat="server" CommandName="Cancel"
                        Text="<%$ resources:Universal,Data_Cancel %>" />
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButtonEdit" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="<%$ resources:Universal,Data_Edit %>" />
                    <asp:LinkButton ID="LinkButtonDelete" runat="server" CausesValidation="False" CommandName="Delete"
                        OnClientClick="<%$ resources: Universal, Msg_DelConfirm %>" Text="<%$ resources:Universal,Data_Delete %>" />
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Button ID="btnSave" runat="server" ValidationGroup="AddValidationControls" CausesValidation="true" 
                        Text="<%$ resources:Universal,Data_Save %>"  CommandName="Save" OnClick="btnSave_Click" />
                    <asp:Button ID="btnInsertCancel" runat="server" Text="<%$ resources:Universal,Data_Cancel %>" OnClick="btnInsertCancel_Click" />
               </FooterTemplate>
            </asp:TemplateField>
        </Columns>
     
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <EditRowStyle BackColor="#999999" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
</p>
    <p class="masterpageContentTop">
<%--    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDepartment"
        TypeName="DepartmentsTableAdapters.HR_DepartmentsTableAdapter" DeleteMethod="Delete" UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="Original_DeptID" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="DeptID" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Original_DeptID" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="DeptID" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>
--%>    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="HR_DepartmentsData"
        SelectMethod="Select" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" 
        UpdateMethod="Update" DeleteMethod="Delete"
        OnSelected="ObjectDataSourceMain_Selected">
        <InsertParameters>
            <asp:Parameter Name="DeptID" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="DeptID" Type="String" />
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="original_DeptID" Type="String" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:Parameter Name="original_DeptID" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>



    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
         ShowSummary="False" ValidationGroup="EditValidationControls" />
    <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="True"
         ShowSummary="False" ValidationGroup="AddValidationControls" />
    </p>
</center>
</asp:Content>