Ejemplo n.º 1
0
        private void btnGeneraFileIncassi_Click(object sender, EventArgs e)
        {
            int n = CfgFn.GetNoNullInt32(txtNproceedsTransm.Text);

            if (n == 0)
            {
                MessageBox.Show(this, "E' necessario selezionare un numero per la distinta");
                return;
            }
            int    y = CfgFn.GetNoNullInt32(Conn.GetSys("esercizio"));
            string filterProceedsTransmission = QHS.AppAnd(QHS.CmpEq("yproceedstransmission", y),
                                                           QHS.CmpEq("nproceedstransmission", n));
            object idtreasurer             = Conn.DO_READ_VALUE("proceedstransmission", filterProceedsTransmission, "idtreasurer");
            object flagtransmissionenabled = Conn.DO_READ_VALUE("proceedstransmission", filterProceedsTransmission,
                                                                "flagtransmissionenabled");
            object cfgflagenabletransmission = Conn.DO_READ_VALUE("config", QHS.CmpEq("ayear", y),
                                                                  "flagenabletransmission");

            if (cfgflagenabletransmission != DBNull.Value)
            {
                string cfg_flag = cfgflagenabletransmission.ToString().ToUpper();
                if ((cfg_flag == "S") && (flagtransmissionenabled.ToString().ToUpper() != "S"))
                {
                    MessageBox.Show(this, "La trasmissione della distinta non è stata autorizzata");
                    return;
                }
            }
            EsportazioneDistinteIncasso E = new EsportazioneDistinteIncasso(Conn, y, n);
            XmlDocument D = E.GeneraFileXML();

            string filterTreasurer = QHS.CmpEq("idtreasurer", idtreasurer);
            string fname           = "";
            object savepath        = Conn.DO_READ_VALUE("treasurer", filterTreasurer, "savepath");

            if (savepath != DBNull.Value)
            {
                fname = Path.Combine(savepath.ToString(), Meta.GetSys("esercizio") + "_reversali_" + n.ToString());
            }
            else
            {
                saveFileDialog1.FileName = Meta.GetSys("esercizio") + "_reversali_" + n.ToString();
                DialogResult dialogResult = saveFileDialog1.ShowDialog(this);
                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }
                fname = saveFileDialog1.FileName;
            }

            try {
                XmlWriterSettings xs = new XmlWriterSettings();
                xs.Indent      = true;
                xs.CloseOutput = true;
                xs.Encoding    = Encoding.GetEncoding("ISO-8859-15");
                XmlWriter xw = XmlWriter.Create(fname, xs);
                D.WriteTo(xw);
                xw.Flush();
                xw.Close();
                MessageBox.Show("Salvataggio del file " + fname + " effettuato");
                TreasurerPutFile ftp = new TreasurerPutFile(Conn, idtreasurer);
                ftp.putFile(fname, Meta.GetSys("esercizio") + "_reversali_" + n.ToString());
            }

            catch (Exception e1) {
                QueryCreator.ShowException("Errore nel salvataggio del file " + fname, e1);
                return;
            }


            try {
                XslCompiledTransform xsltransform = new XslCompiledTransform();
                xsltransform.Load(AppDomain.CurrentDomain.BaseDirectory + "ORDINATIVI_TAG_UFFICIO_LE_3.02.XSLT");
                // Terzo metodo creazione da stringta XML
                Stream transformedData = new MemoryStream();
                String xmlString       = D.InnerXml;
                //String xmlString1 = ("<flusso_ordinativi genre='novel' ISBN='1-861001-57-5'>" +
                //                     "<informazioni_versante>Pride And Prejudice</informazioni_versante>" +
                //                     "</flusso_ordinativi>");
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xmlString);

                xsltransform.Transform(doc, null, transformedData);
                transformedData.Seek(0, SeekOrigin.Begin);
                webBrowser1.DocumentStream = transformedData;
            }
            catch (Exception e2) {
                QueryCreator.ShowException("Errore cercando di visualizzare il file " + fname, e2);
                return;
            }

            try {
                bool res = XML_XSD_Validator.Validate(fname,
                                                      AppDomain.CurrentDomain.BaseDirectory + "ORDINATIVI_TAG_UFFICIO_LE_3.02.XSD");
                if (!res)
                {
                    QueryCreator.ShowError(this, "Errore nella validazione dell'xml",
                                           XML_XSD_Validator.GetError());
                    return;
                }
            }
            catch (Exception e3) {
                QueryCreator.ShowException("Errore validando il file " + fname, e3);
                return;
            }


            AggiornaStreamDate("PROCEEDSTRANSMISSION", y, n);

            //try
            //{
            //    Process.Start(fname);
            //}
            //catch (Exception E1)
            //{
            //    QueryCreator.ShowException(E1);
            //}
        }
Ejemplo n.º 2
0
        private void btnGeneraFilePagamenti_Click(object sender, EventArgs e)
        {
            int n = CfgFn.GetNoNullInt32(txtNPaymentTransmission.Text);

            if (n == 0)
            {
                MessageBox.Show(this, "E' necessario selezionare un numero per la distinta");
                return;
            }
            int y = CfgFn.GetNoNullInt32(Conn.GetSys("esercizio"));

            string filterPaymentTransmission = QHS.AppAnd(QHS.CmpEq("ypaymenttransmission", y),
                                                          QHS.CmpEq("npaymenttransmission", n));
            object idtreasurer             = Conn.DO_READ_VALUE("paymenttransmission", filterPaymentTransmission, "idtreasurer");
            object flagtransmissionenabled = Conn.DO_READ_VALUE("paymenttransmission", filterPaymentTransmission,
                                                                "flagtransmissionenabled");
            object cfgflagenabletransmission = Conn.DO_READ_VALUE("config", QHS.CmpEq("ayear", y),
                                                                  "flagenabletransmission");

            if (cfgflagenabletransmission != DBNull.Value)
            {
                string cfg_flag = cfgflagenabletransmission.ToString().ToUpper();
                if ((cfg_flag == "S") && (flagtransmissionenabled.ToString().ToUpper() != "S"))
                {
                    MessageBox.Show(this, "La trasmissione della distinta non è stata autorizzata");
                    return;
                }
            }
            EsportazioneDistintePagamento E = new EsportazioneDistintePagamento(Conn, y, n);
            XmlDocument D = E.GeneraFileXML();



            if (D == null)
            {
                return;
            }
            string filterTreasurer = QHS.CmpEq("idtreasurer", idtreasurer);
            string fname           = "";
            object savepath        = Conn.DO_READ_VALUE("treasurer", filterTreasurer, "savepath");

            if (savepath != DBNull.Value)
            {
                fname = Path.Combine(savepath.ToString(), Meta.GetSys("esercizio") + "_mandati_" + n.ToString());
            }
            else
            {
                saveFileDialog1.FileName = Meta.GetSys("esercizio") + "_mandati_" + n.ToString();
                DialogResult dialogResult = saveFileDialog1.ShowDialog(this);
                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }
                fname = saveFileDialog1.FileName;
            }
            try {
                XmlWriterSettings xs = new XmlWriterSettings();
                xs.Indent      = true;
                xs.CloseOutput = true;
                xs.Encoding    = Encoding.GetEncoding("ISO-8859-15");
                XmlWriter xw = XmlWriter.Create(fname, xs);
                D.WriteTo(xw);
                xw.Flush();
                xw.Close();
                MessageBox.Show("Salvataggio del file " + fname + " effettuato");
                TreasurerPutFile ftp = new TreasurerPutFile(Conn, idtreasurer);
                ftp.putFile(fname, Meta.GetSys("esercizio") + "_mandati_" + n.ToString());
            }
            catch (Exception e1) {
                QueryCreator.ShowException("Errore nel salvataggio del file " + fname, e1);
                return;
            }

            try {
                XslCompiledTransform xsltransform = new XslCompiledTransform();
                xsltransform.Load(AppDomain.CurrentDomain.BaseDirectory + "ORDINATIVI_TAG_UFFICIO_LE_3.02.XSLT");

                // Secondo metodo, utilizzo di uno stream
                Stream transformedData = new MemoryStream();
                xsltransform.Transform(D, null, transformedData);
                transformedData.Seek(0, SeekOrigin.Begin);
                webBrowser1.DocumentStream = transformedData;
            }
            catch (Exception e2) {
                QueryCreator.ShowException("Errore cercando di visualizzare il file " + fname, e2);
                return;
            }

            try {
                bool res = XML_XSD_Validator.Validate(fname,
                                                      AppDomain.CurrentDomain.BaseDirectory + "ORDINATIVI_TAG_UFFICIO_LE_3.02.XSD");
                if (!res)
                {
                    QueryCreator.ShowError(this, "Errore nella validazione dell'xml",
                                           XML_XSD_Validator.GetError());
                    return;
                }
            }
            catch (Exception e3) {
                QueryCreator.ShowException("Errore validando il file " + fname, e3);
                return;
            }

            AggiornaStreamDate("PAYMENTTRANSMISSION", y, n);
        }