예제 #1
0
        protected void InitializePage()
        {
            MemoryStream ms           = null;
            StreamReader streamReader = null;

            try
            {
                DocsPaWR.FileRequest   fileReq = (DocsPaWR.FileRequest)DocumentManager.getSelectedRecord().documenti[0];
                DocsPaWR.FileDocumento fileDoc = DocumentManager.DocumentoGetFile(fileReq);

                string xmlString = GetFatturaFromBytes(fileDoc.name, fileDoc.content);

                XmlDocument xml = this.GenerateXMLDocumentFromString(xmlString);

                System.Xml.Xsl.XslCompiledTransform xslt = new System.Xml.Xsl.XslCompiledTransform();
                xslt.Load(System.IO.Path.Combine(Server.MapPath("~/"), "xml\\fatturapa_v1.2.xsl"));

                ms = new MemoryStream();

                System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(ms, new System.Text.UTF8Encoding());
                xslt.Transform(xml, null, writer);
                streamReader = new StreamReader(ms);

                DocsPaWR.FileDocumento pdfInvoice = ImportInvoiceManager.getInvoicePreviewPdf(ms.ToArray());

                if (pdfInvoice != null && pdfInvoice.content != null)
                {
                    pdfInvoice.name                = fileDoc.name + ".pdf";
                    pdfInvoice.fullName            = fileDoc.fullName + ".pdf";
                    pdfInvoice.estensioneFile      = "pdf";
                    this.UpPnlDocumentData.Visible = true;
                    FileManager.setSelectedFileReport(this, pdfInvoice, "../popup");
                    //this.frame.Attributes["src"] = "../Summaries/PDFViewer.aspx";
                    this.frame.Attributes["src"] = "InvoicePDFViewer.aspx";
                    this.UpPnlDocumentData.Update();
                }
                else
                {
                    string msg = "InvoicePreviewError";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');} else {parent.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');}", true);

                    this.UpPnlDocumentData.Visible = false;
                    this.UpPnlDocumentData.Update();
                }
            }
            catch (Exception)
            {
                string msg = "InvoicePreviewError";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');} else {parent.ajaxDialogModal('" + msg.Replace("'", @"\'") + "', 'error', '');}", true);

                this.UpPnlDocumentData.Visible = false;
                this.UpPnlDocumentData.Update();
            }
            finally
            {
                ms.Dispose();
                streamReader.Dispose();
            }
        }
예제 #2
0
        protected void BtnImportInvoiceUpdate_Click(object sender, EventArgs e)
        {
            string rifAmm   = this.TxtRifAmm.Text;
            string strIdDoc = this.TxtIdDoc.Text;
            string strCIG   = this.TxtCIG.Text;
            string posFin   = this.TxtPosFin.Text;

            string optional1  = this.TxtOptional1.Text;
            string optional2  = this.TxtOptional2.Text;
            string optional3  = this.TxtOptional3.Text;
            string optional4  = this.TxtOptional4.Text;
            string optional5  = this.TxtOptional5.Text;
            string optional6  = this.TxtOptional6.Text;
            string optional7  = this.TxtOptional7.Text;
            string optional8  = this.TxtOptional8.Text;
            string optional9  = this.TxtOptional9.Text;
            string optional10 = this.TxtOptional10.Text;

            string strDesc    = this.txtDescrizione.Text;
            string strQuant   = this.txtQuantita.Text;
            string strPrezUni = this.txtPrezzoUnitario.Text;
            string strPrezTot = this.txtPrezzoTotale.Text;
            string strAliquot = this.txtAliquota.Text;

            bool result = ImportInvoiceManager.updateParams(rifAmm, strIdDoc, strCIG, posFin, strDesc, strQuant, strPrezUni, strPrezTot, strAliquot, optional1, optional2, optional3, optional4, optional5, optional6, optional7, optional8, optional9, optional10);

            if (result)
            {
                this.frame.Attributes["src"] = "PreviewInvoice.aspx";
                this.UpPnlDocumentData.Update();
            }
            else
            {
                string msgDesc = "msgImportInvoiceUpdateParamKO";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'error', '');} else {parent.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'error', '');}", true);
            }
        }
예제 #3
0
        protected void BtnImportInvoiceConfirm_Click(object sender, EventArgs e)
        {
            string rifAmm = this.TxtRifAmm.Text;

            string strIdDoc = this.TxtIdDoc.Text;
            string strCIG   = this.TxtCIG.Text;
            string posFin   = this.TxtPosFin.Text;

            string optional1  = this.TxtOptional1.Text;
            string optional2  = this.TxtOptional2.Text;
            string optional3  = this.TxtOptional3.Text;
            string optional4  = this.TxtOptional4.Text;
            string optional5  = this.TxtOptional5.Text;
            string optional6  = this.TxtOptional6.Text;
            string optional7  = this.TxtOptional7.Text;
            string optional8  = this.TxtOptional8.Text;
            string optional9  = this.TxtOptional9.Text;
            string optional10 = this.TxtOptional10.Text;

            string strDesc    = this.txtDescrizione.Text;
            string strQuant   = this.txtQuantita.Text;
            string strPrezUni = this.txtPrezzoUnitario.Text;
            string strPrezTot = this.txtPrezzoTotale.Text;
            string strAliquot = this.txtAliquota.Text;

            string strErrore;

            if (VerificaCampiLinea(strDesc, strQuant, strPrezUni, strPrezTot, strAliquot, out strErrore))
            {
                bool result = ImportInvoiceManager.updateParams(rifAmm, strIdDoc, strCIG, posFin, strDesc, strQuant, strPrezUni, strPrezTot, strAliquot, optional1, optional2, optional3, optional4, optional5, optional6, optional7, optional8, optional9, optional10);

                if (result)
                {
                    result = ImportInvoiceManager.uploadFattura();
                }

                if (!result)
                {
                    string msgDesc = "msgImportInvoiceImportKO";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'error', '');} else {parent.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'error', '');}", true);
                }
                else
                {
                    this.TxtRifAmm.Text = string.Empty;

                    this.TxtIdDoc.Text = string.Empty;
                    this.TxtCIG.Text   = string.Empty;

                    this.TxtImportInvoiceSearch.Text = string.Empty;
                    this.PnlOptionalFields.Visible   = false;
                    this.UpPnlOptionalFields.Update();
                    this.UpPnlSearchInvoice.Update();
                    this.BtnImportInvoiceConfirm.Enabled = false;
                    this.BtnImportInvoiceUpdate.Enabled  = false;
                    this.UpPnlDocumentData.Visible       = false;
                    this.frame.Attributes["src"]         = string.Empty;
                    this.UpPnlSearchInvoice.Update();
                    this.UpPnlDocumentData.Update();
                    this.UpPnlContentDxSx.Update();

                    this.txtDescrizione.Text    = string.Empty;
                    this.txtQuantita.Text       = string.Empty;
                    this.txtPrezzoUnitario.Text = string.Empty;
                    this.txtPrezzoTotale.Text   = string.Empty;
                    this.txtAliquota.Text       = string.Empty;
                    this.PnlNewLine.Visible     = false;
                    this.UpnNewLine.Update();
                    this.btnAddLine.Enabled = true;

                    string msgDesc = "msgImportInvoiceImportOK";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'check', '');} else {parent.ajaxDialogModal('" + msgDesc.Replace("'", @"\'") + "', 'check', '');}", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "if (parent.fra_main) {parent.fra_main.ajaxDialogModal('" + strErrore.Replace("'", @"\'") + "', 'error', '');} else {parent.ajaxDialogModal('" + strErrore.Replace("'", @"\'") + "', 'error', '');}", true);
            }
        }