<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocumentoCad.aspx.cs" Inherits="PortalTransparencia.Admin.DocumentoCad"
    MasterPageFile="Admin.Master" %>

<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script src="jquery-toastmessage/src/main/javascript/jquery.toastmessage.js" type="text/javascript"></script>
    <link href="jquery-toastmessage/src/main/resources/css/jquery.toastmessage.css" rel="stylesheet"
        type="text/css" />
    <script type="text/javascript">

        function showSuccessToast() {
            $().toastmessage('showSuccessToast', "Dialogo Exibido com Sucesso...");
        }
        function showStickySuccessToast() {
            $().toastmessage('showToast', {
                text: 'Dialogo Exibido com Sucesso - Dialogo Fixo',
                sticky: true,
                position: 'top-right',
                type: 'success',
                closeText: '',
                close: function () {
                    console.log("toast is closed ...");
                }
            });

        }
        function showNoticeToast() {
            $().toastmessage('showNoticeToast', "Notice  Dialog ");
        }
        function showStickyNoticeToast() {
            $().toastmessage('showToast', {
                text: 'Notice Dialog Fixo',
                sticky: true,
                position: 'top-left',
                type: 'notice',
                closeText: '',
                close: function () { console.log("toast is closed ..."); }
            });
        }
        function showWarningToast() {
            $().toastmessage('showWarningToast', "Warning Dialog ");
        }
        function showStickyWarningToast() {
            $().toastmessage('showToast', {
                text: 'Warning Dialog Fixo',
                sticky: true,
                position: 'middle-right',
                type: 'warning',
                closeText: '',
                close: function () {
                    console.log("toast is closed ...");
                }
            });
        }
        function showErrorToast() {
            $().toastmessage('showErrorToast', "Error Dialog  ...");
        }
        function showStickyErrorToast() {
            $().toastmessage('showToast', {
                text: 'Error Dialog Fixo',
                sticky: true,
                position: 'center',
                type: 'error',
                closeText: '',
                close: function () {
                    console.log("toast is closed ...");
                }
            });
        }

    </script>
    <script type="text/javascript">
    // <![CDATA[
        function Uploader_OnUploadStart() {
            btnUpload.SetEnabled(false);
            alert('Upload realizado com sucesso');
        }
        function Uploader_OnFileUploadComplete(args) {
            //var imgSrc = aspxPreviewImgSrc;
            //if (args.isValid) {
            //  var date = new Date();
            //imgSrc = "UploadImages/" + args.callbackData + "?dx=" + date.getTime();
            //}
            //getPreviewImageElement().src = imgSrc;
            //UpdateUploadButton();

            //chamar metodo para dar refresh
            //pegar arquivo  file e tirar a visible dele
            //var url = window.location;
            //window.location = url;
        }
        function Uploader_OnFilesUploadComplete(args) {
            UpdateUploadButton();
        }
        function UpdateUploadButton() {
            btnUpload.SetEnabled(uploader.GetText(0) != "");
        }
        function getPreviewImageElement() {
            return document.getElementById("previewImage");
        }

    // ]]> 
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager runat="server" ID="ScriptManagerMaster1" EnableScriptGlobalization="true"
        AsyncPostBackTimeout="900" EnableScriptLocalization="true" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upnCadastro">
        <ProgressTemplate>
            <%--<ldg:ucLoading ID="ucLoading1" runat="server" />--%>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel runat="server" ID="upnCadastro" ClientIDMode="Static">
        <ContentTemplate>
            <asp:MultiView runat="server" ID="mltCadatro" ActiveViewIndex="0">
                <asp:View runat="server" ID="viewGrid">
                    <div id="hosme" class="meio">
                        <div class="container">
                            <div class="limite">
                                <div class="esquerda">
                                    <div class="box">
                                        <h2 class="titulo">
                                            Cadastrar</h2>
                                        <ul class="form">
                                            <li><span class="titulo">Código:</span>
                                                <dx:ASPxTextBox ID="txtCodigo" ClientInstanceName="txtCodigo" Text="0" ReadOnly="true"
                                                    runat="server" Width="50%">
                                                </dx:ASPxTextBox>
                                            </li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                            <li><span class="titulo">* Tipo de Documento:</span>
                                                <dx:ASPxComboBox ID="ddlTipoDocumento" ClientInstanceName="ddlTipoDocumento" ValueField="id_DocumentoTipo"
                                                    runat="server" Width="50%" SkinID="cmbValidator" AutoPostBack="true" OnSelectedIndexChanged="ddlTipoDocumento_OnSelectedIndexChanged">
                                                    <Columns>
                                                        <dx:ListBoxColumn FieldName="id_DocumentoTipo" Visible="false" />
                                                        <dx:ListBoxColumn Caption="Documento" FieldName="ds_DocumentoTipo" Width="100%" />
                                                    </Columns>
                                                </dx:ASPxComboBox>
                                            </li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                            <li><span class="titulo">* Nome Documento:</span>
                                                <dx:ASPxTextBox ID="txtNmDoc" ClientInstanceName="txtNmDoc" runat="server" Width="50%">
                                                </dx:ASPxTextBox>
                                            </li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                            <li><span class="titulo">* Data Documento:</span>
                                                <dx:ASPxDateEdit ID="ddlDataDoc" ClientInstanceName="ddlDataDoc" runat="server" EditFormat="Date"
                                                    EditFormatString="dd/MM/yyyy" MinDate="1900-01-01" Width="50%" DateOnError="Today"
                                                    DisplayFormatString="dd/MM/yyyy" AllowNull="False" UseMaskBehavior="true" ClientEnabled="true">
                                                </dx:ASPxDateEdit>
                                            </li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                            <li><span class="titulo">* Upload (PDF):</span>
                                                <dx:ASPxUploadControl ID="uplImage" runat="server" ClientInstanceName="uploader"
                                                    ShowProgressPanel="True" NullText="Click here to browse files..." Size="35" OnFileUploadComplete="uplImage_FileUploadComplete">
                                                    <ClientSideEvents FileUploadComplete="function(s, e) { Uploader_OnFileUploadComplete(e); }"
                                                        FilesUploadComplete="function(s, e) { Uploader_OnFilesUploadComplete(e); }" FileUploadStart="function(s, e) { Uploader_OnUploadStart(); }"
                                                        TextChanged="function(s, e) { UpdateUploadButton(); }"></ClientSideEvents>
                                                    <ValidationSettings MaxFileSize="4194304" AllowedFileExtensions=".pdf">
                                                    </ValidationSettings>
                                                </dx:ASPxUploadControl>    
                                                <dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Upload" ClientInstanceName="btnUpload"
                                                    Width="100px" ClientEnabled="False">
                                                    <ClientSideEvents Click="function(s, e) { uploader.Upload(); }" />
                                                </dx:ASPxButton>                                            
                                            </li>     
                                            <li><span class="titulo">
                                                <br /><br />
                                            </span></li>
                                            <li>
                                            <span class="titulo">
                                                <br />
                                            </span></li>
                                            </li>     
                                            <li>
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Preencha o campo Tipo de Documento!"
                                                    ControlToValidate="ddlTipoDocumento" ValidationGroup="valid" ForeColor="Red">
                                                </asp:RequiredFieldValidator>
                                                <br />
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="* Preencha o campo Nome do Documento!"
                                                    ControlToValidate="txtNmDoc" ValidationGroup="valid" ForeColor="Red">
                                                </asp:RequiredFieldValidator>
                                                <br />
                                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="* Preencha o campo Data do Documento!"
                                                    ControlToValidate="ddlDataDoc" ValidationGroup="valid" ForeColor="Red">
                                                </asp:RequiredFieldValidator>
                                                <br />
                                                <asp:Label ID="lbl" runat="server" ForeColor="Red" Text="" Visible="false"></asp:Label>
                                                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="* Preencha o campo Upload (PDF)!"
                                                    ControlToValidate="uplImage" ValidationGroup="valid" ForeColor="Red">
                                                </asp:RequiredFieldValidator>--%>
                                            </li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                            <li><span class="titulo">
                                                <br />
                                            </span></li>
                                        </ul>
                                        <ul class="form">
                                            <li class="botoes">
                                                <asp:Button runat="server" ID="btnSalvar" CssClass="btazul" Text="Salvar" OnClick="btnSalvar_OnClick"
                                                    ValidationGroup="valid" CausesValidation="true"/>
                                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                                <asp:Button runat="server" ID="btnVoltar" CssClass="btazul" Text="Voltar" OnClick="btnVoltar_OnClick"
                                                    CausesValidation="false" />
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </asp:View>
                <asp:View runat="server" ID="viewCadastro">
                </asp:View>
            </asp:MultiView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
