Exemple #1
0
        private void buttonStampa_Click(object sender, RoutedEventArgs e)
        {
            //controllo selezione clienti
            if (cmbClienti.SelectedIndex == -1)
            {
                MessageBox.Show("selezionare un cliente");
                return;
            }

            if (cmbData.SelectedIndex == -1)
            {
                MessageBox.Show("selezionare una sessione");
                return;
            }

            if (rdbVerbale.IsChecked == false && rdbMemorandum.IsChecked == false)
            {
                MessageBox.Show("selezionare verbale o memorandum");
                return;
            }

            if (rdbDescrittiva.IsChecked != true && rdbCompleta.IsChecked != true)
            {
                MessageBox.Show("Scegliere il tipo di stampa");
                return;
            }

            //Process wait - START
            //ProgressWindow pw = new ProgressWindow();

            MasterFile mf = MasterFile.Create();

            string IDCliente = htClienti[cmbClienti.SelectedIndex].ToString();

            this.selectedCliente = IDCliente;


            string anno = cmbData.SelectedValue.ToString().Split('/')[2];

            Hashtable cliente = mf.GetAnagrafica(Convert.ToInt32(IDCliente));

            XmlDataProviderManager _t = null;

            Hashtable valueshere = new Hashtable();

            //WordLib wl = new WordLib();
            RTFLib wl = new RTFLib();

            //wl.Verbali = true;

            #region Dati da revisione

            //XmlDataProviderManager _y = null;

            string FileRevisione = mf.GetRevisioneFromEsercizio(IDCliente, anno);



            string RagioneSociale  = "Dato Mancante: Compilare Carta di Lavoro 2.1.1";
            string Indirizzo       = "";
            string REA             = "";
            string CapitaleSociale = "Dato Mancante: Compilare Carta di Lavoro 2.1.5";
            string ids             = "";
            foreach (Hashtable item in mf.GetVerifiche(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                {
                    ids = item["ID"].ToString();
                }
            }
            this.selectedSession = ids;

            cBusinessObjects.idcliente = int.Parse(IDCliente);
            RagioneSociale             = cBusinessObjects.GetRagioneSociale();
            Indirizzo       = cBusinessObjects.GetIndirizzo();
            REA             = cBusinessObjects.GetREA();
            CapitaleSociale = cBusinessObjects.GetCapitaleSociale();

            #endregion

            wl.Watermark = false;
            wl.TabelleSenzaRigheVuote = true;
            wl.SenzaStampareTitoli    = true;
            wl.TitoloVerbale          = false;

            if (rdbDescrittiva.IsChecked == true)
            {
                wl.StampaDescrittiva = true;
            }

            wl.TemplateFileCompletePath = App.AppTemplateStampaNoLogo;
            wl.Open(new Hashtable(), cliente["RagioneSociale"].ToString(), cliente["CodiceFiscale"].ToString(), cmbData.SelectedValue.ToString(), "", true, true, IDCliente);

            if (rdbVerbale.IsChecked == true)
            {
                //if ( chk4.IsChecked == false && Chk5.IsChecked == false )
                //{
                //    MessageBox.Show( "selezionare almeno una tra l'area 4 o 5" );
                //    pw.Close();
                //    return;
                //}

                //if ( chk4.IsChecked == true)
                //{
                string partial_rtf_text = "";

                if (rdbMemorandum.IsChecked == false)
                {
                    foreach (Hashtable item in mf.GetVerifiche(IDCliente))
                    {
                        if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                        {
                            valueshere = item;
                            _t         = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                        }
                    }

                    bool notfoundv = false;
                    if (valueshere.Count == 0)
                    {
                        notfoundv = true;
                    }
                    else
                    {
                        valueshere.Add("PeriodoPianificato", "");
                        DateTime dti_o = Convert.ToDateTime(valueshere["Data"]);

                        foreach (Hashtable item in mf.GetPianificazioniVerifiche(IDCliente))
                        {
                            DateTime dti = Convert.ToDateTime(item["DataInizio"]);
                            DateTime dtf = Convert.ToDateTime(item["DataFine"]);

                            if (dti_o.CompareTo(dti) > 0 && dti_o.CompareTo(dtf) < 0)
                            {
                                valueshere["PeriodoPianificato"] = item["DataInizio"] + " - " + item["DataFine"];
                                break;
                            }
                        }

                        partial_rtf_text = "\\pard\\keepn\\f0 ";

                        string titolohere = "VERBALE DELLA VERIFICA PERIODICA DEL ";
                        try
                        {
                            //if (_t.Document.SelectSingleNode("/Tree//Node[@ID='614']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2" || _t.Document.SelectSingleNode("/Tree//Node[@ID='615']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2" || _t.Document.SelectSingleNode("/Tree//Node[@ID='616']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2" || _t.Document.SelectSingleNode("/Tree//Node[@ID='617']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2" || _t.Document.SelectSingleNode("/Tree//Node[@ID='618']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2")
                            //{
                            //  titolohere = "VERBALE DI INSEDIAMENTO DEL ";
                            //}
                            XmlNode node6;
                            string  selection, strNode;
                            int     i;

                            selection = "/Tree//Node[@ID='<idnode>']/Sessioni/Sessione[@Selected='#AA82BDE4']";
                            for (i = 0; i < 5; i++)
                            {
                                strNode = string.Format("{0}", 614 + i);
                                strNode = selection.Replace("<idnode>", strNode);
                                node6   = _t.Document.SelectSingleNode(strNode);
                                if (node6 == null)
                                {
                                    continue;
                                }
                                if (node6.Attributes["Stato"].Value == "2")
                                {
                                    titolohere = "VERBALE DI INSEDIAMENTO DEL ";
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            string log = ex.Message;
                        }

                        wl.SetIntestazione(RagioneSociale, Indirizzo, CapitaleSociale, REA, titolohere, valueshere);

                        partial_rtf_text += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI CONTROLLO CONTABILE \\b0\\cell\\row";

                        string TestoHere = "L'organo di revisione procede alla verifica secondo la previsione dell'art.14, primo comma, lettera b), del D. Lgs. 27 Gennaio 2010 n° 39, in conformità al Principio di revisione SA Italia 250B.";

                        partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                        TestoHere         = "Per lo svolgimento delle attività di revisione e controllo viene utilizzata una procedura informatica che produce carte di lavoro, nelle quali vengono inseriti i dati tabellari raccolti nel corso della sessione, i commenti e le osservazioni annotati, nonché vengono allegati documenti in qualsiasi formato immateriale.";
                        partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                        bool      esistepianificazione = false;
                        ArrayList al = mf.GetPianificazioniVerifiche(IDCliente);
                        foreach (Hashtable itemHT in al)
                        {
                            string filedata = App.AppDataDataFolder + "\\" + itemHT["FileData"].ToString();
                            //if ((new FileInfo(filedata)).Exists)
                            //{
                            //  XmlDataProviderManager ALXTPP = new XmlDataProviderManager(filedata);

                            //  foreach (XmlNode itemXPP in ALXTPP.Document.SelectNodes("//Dato[@ID=\"100013\"]/Valore/Pianificazione"))
                            //  {
                            //    if (itemXPP.Attributes["Data"].Value == cmbData.SelectedValue.ToString())
                            //    {
                            //      esistepianificazione = true;
                            //      break;
                            //    }
                            //  }
                            //}
                            XmlDataProviderManager ALXTPP = new XmlDataProviderManager(filedata);
                            if (ALXTPP.Document != null)
                            {
                                foreach (XmlNode itemXPP in ALXTPP.Document.SelectNodes("//Dato[@ID=\"100013\"]/Valore/Pianificazione"))
                                {
                                    if (itemXPP.Attributes["Data"].Value == cmbData.SelectedValue.ToString())
                                    {
                                        esistepianificazione = true;
                                        break;
                                    }
                                }
                            }

                            if (esistepianificazione == true)
                            {
                                break;
                            }
                        }

                        if (esistepianificazione == true)
                        {
                            //Inserisco il testo per la pianificazione
                            TestoHere         = "L'attività di controllo è stata pianificata con la carta di lavoro denominata Pianificazione; la sessione avviata rientra fra quelle pianificate.";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\line \\cell\\row";
                        }

                        if (rdbDescrittiva.IsChecked == true)
                        {
                            TestoHere         = "Per economia di lavoro nel presente verbale verrà dato conto delle carte di lavoro utilizzate dalle quali verranno estrapolati le sole osservazioni e i commenti; per i dati raccolti ed inseriti anche in forma tabellare si farà riferimento alle carte di lavoro, conservate con modalità informatica, che si intendono parte integrante del presente verbale. Parimenti i documenti raccolti vengono associati alle carte di lavoro e conservati in modalità informatiche.";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\line \\cell\\row";
                        }

                        TestoHere         = "Vengono eseguite le seguenti verifiche: \\line ";
                        partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                        // partial_rtf_text += "\\par\n";

                        wl.InsertRtf(partial_rtf_text);



                        printsingle(cliente, _t, (Convert.ToInt32(App.TipoFile.Verifica)).ToString(), wl, valueshere["ID"].ToString(), IDCliente, "", valueshere["FileData"].ToString());
                    }

                    valueshere.Clear();

                    foreach (Hashtable item in mf.GetVigilanze(IDCliente))
                    {
                        if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                        {
                            valueshere = item;
                            _t         = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                        }
                    }

                    if (valueshere.Count > 0)
                    {
                        if (notfoundv == false)
                        {
                            partial_rtf_text  = "\\pard\\keepn\\f0 ";
                            partial_rtf_text += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI VIGILANZA \\b0\\cell\\row";

                            string TestoHere = "L’organo di controllo di cui agli artt. 2397 e seguenti Cod. Civ. procede alla verifica prescritta dall'articolo 2404 Cod. Civ.; l'attività da svolgere concernerà i doveri indicati nel primo comma dell'articolo 2403 Cod. Civ., esercitando i poteri di cui all'art. 2404 bis Cod. Civ.";

                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj \\line \\cell\\row";

                            partial_rtf_text += "\n";
                        }
                        else
                        {
                            string titolohere2 = "VERBALE DELLA VERIFICA DEL ";
                            try
                            {
                                if (_t.Document.SelectSingleNode("/Tree//Node[@ID='614']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2")
                                {
                                    titolohere2 = "VERBALE DI INSEDIAMENTO DEL ";
                                }
                            }
                            catch (Exception ex)
                            {
                                string log = ex.Message;
                            }

                            wl.SetIntestazione(RagioneSociale, Indirizzo, CapitaleSociale, REA, titolohere2, valueshere);

                            partial_rtf_text += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI VIGILANZA \\b0\\cell\\row";

                            string TestoHere = "L’organo di controllo di cui agli artt. 2397 e seguenti Cod. Civ. procede alla verifica prescritta dall'articolo 2404 Cod. Civ.; l'attività da svolgere concernerà i doveri indicati nel primo comma dell'articolo 2403 Cod. Civ., esercitando i poteri di cui all'art. 2404 bis Cod. Civ.";

                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj \\line \\cell\\row";

                            partial_rtf_text += "\n";
                        }


                        wl.InsertRtf(partial_rtf_text);

                        printsingle(cliente, _t, (Convert.ToInt32(App.TipoFile.Vigilanza)).ToString(), wl, valueshere["ID"].ToString(), IDCliente, "", valueshere["FileData"].ToString());
                    }
                    else
                    {
                        MessageBox.Show("Verifica per attività di vigilanza non trovata");
                    }
                }
                else
                {
                    foreach (Hashtable item in mf.GetVigilanze(IDCliente))
                    {
                        if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                        {
                            valueshere = item;
                            _t         = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                        }
                    }

                    if (valueshere.Count > 0)
                    {
                        valueshere.Add("PeriodoPianificato", "");
                        DateTime dti_o = Convert.ToDateTime(valueshere["Data"]);

                        foreach (Hashtable item in mf.GetPianificazioniVigilanze(IDCliente))
                        {
                            DateTime dti = Convert.ToDateTime(item["DataInizio"]);
                            DateTime dtf = Convert.ToDateTime(item["DataFine"]);

                            if (dti_o.CompareTo(dti) > 0 && dti_o.CompareTo(dtf) < 0)
                            {
                                valueshere["PeriodoPianificato"] = item["DataInizio"] + " - " + item["DataFine"];
                                break;
                            }
                        }

                        partial_rtf_text = "\\pard\\keepn\\f0 ";

                        if (valueshere.Count == 0)
                        {
                            MessageBox.Show("Verifica per attività di vigilanza non trovata");
                        }
                        else
                        {
                            string titolohere3 = "VERBALE DELLA VERIFICA DEL ";
                            try
                            {
                                if (_t.Document.SelectSingleNode("/Tree//Node[@ID='614']/Sessioni/Sessione[@Selected='#AA82BDE4']").Attributes["Stato"].Value == "2")
                                {
                                    titolohere3 = "VERBALE DI INSEDIAMENTO DEL ";
                                }
                            }
                            catch (Exception ex)
                            {
                                string log = ex.Message;
                            }

                            wl.SetIntestazione(RagioneSociale, Indirizzo, CapitaleSociale, REA, titolohere3, valueshere);

                            partial_rtf_text += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI VIGILANZA \\b0\\cell\\row";

                            string TestoHere = "L’organo di controllo di cui agli artt. 2397 e seguenti Cod. Civ. procede alla verifica prescritta dall'articolo 2404 Cod. Civ.; l'attività da svolgere concernerà i doveri indicati nel primo comma dell'articolo 2403 Cod. Civ., esercitando i poteri di cui all'art. 2404 bis Cod. Civ.";

                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj \\line \\cell\\row";

                            bool      esistepianificazione = false;
                            ArrayList al = mf.GetPianificazioniVigilanze(IDCliente);
                            foreach (Hashtable itemHT in al)
                            {
                                string filedata = App.AppDataDataFolder + "\\" + itemHT["FileData"].ToString();
                                if ((new FileInfo(filedata)).Exists)
                                {
                                    XmlDataProviderManager ALXTPP = new XmlDataProviderManager(filedata);

                                    foreach (XmlNode itemXPP in ALXTPP.Document.SelectNodes("//Dato[@ID=\"100003\"]/Valore/Pianificazione"))
                                    {
                                        if (itemXPP.Attributes["Data"].Value == cmbData.SelectedValue.ToString())
                                        {
                                            esistepianificazione = true;
                                            break;
                                        }
                                    }
                                }

                                if (esistepianificazione == true)
                                {
                                    break;
                                }
                            }

                            //partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                            TestoHere         = "Vengono eseguite le seguenti verifiche: \\line ";
                            partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                            //   partial_rtf_text += "\\par\n";

                            wl.InsertRtf(partial_rtf_text);

                            printsingle(cliente, _t, (Convert.ToInt32(App.TipoFile.Vigilanza)).ToString(), wl, valueshere["ID"].ToString(), IDCliente, "", valueshere["FileData"].ToString());
                        }
                    }

                    #region memorandum contemporaneo
                    RTFLib wl2 = new RTFLib();
                    wl2.Watermark = false;
                    wl2.TabelleSenzaRigheVuote = true;
                    wl2.SenzaStampareTitoli    = true;
                    wl2.TitoloVerbale          = false;

                    if (rdbDescrittiva.IsChecked == true)
                    {
                        wl2.StampaDescrittiva = true;
                    }

                    wl2.TemplateFileCompletePath = App.AppTemplateStampaNoLogo;
                    wl2.Open(new Hashtable(), cliente["RagioneSociale"].ToString(), cliente["CodiceFiscale"].ToString(), cmbData.SelectedValue.ToString(), "", true, true, IDCliente);
                    foreach (Hashtable item in mf.GetVerifiche(IDCliente))
                    {
                        if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                        {
                            valueshere = item;
                            _t         = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                        }
                    }

                    if (!valueshere.Contains("PeriodoPianificato"))
                    {
                        valueshere.Add("PeriodoPianificato", "");
                    }
                    DateTime dti_o2 = Convert.ToDateTime(valueshere["Data"]);

                    foreach (Hashtable item in mf.GetPianificazioniVerifiche(IDCliente))
                    {
                        DateTime dti = Convert.ToDateTime(item["DataInizio"]);
                        DateTime dtf = Convert.ToDateTime(item["DataFine"]);

                        if (dti_o2.CompareTo(dti) > 0 && dti_o2.CompareTo(dtf) < 0)
                        {
                            valueshere["PeriodoPianificato"] = item["DataInizio"] + " - " + item["DataFine"];
                            break;
                        }
                    }

                    if (valueshere.Count == 0)
                    {
                        MessageBox.Show("Verifica per controllo contabile non trovata");
                    }
                    else
                    {
                        wl2.SetIntestazione(RagioneSociale, Indirizzo, CapitaleSociale, REA, "MEMORANDUM DELLA VERIFICA PERIODICA DEL ", valueshere);

                        string partial_rtf_text2 = "\\pard\\keepn\\f0 ";

                        partial_rtf_text2 += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI CONTROLLO CONTABILE \\b0\\cell\\row";

                        string TestoHere2 = "L'organo di revisione procede alla verifica secondo la previsione dell'art.14, primo comma, lettera b), del D. Lgs. 27 Gennaio 2010 n° 39, in conformità al Principio di revisione SA Italia 250B.";

                        partial_rtf_text2 += "\\trowd\\cellx9900 \\qj " + TestoHere2 + " \\cell\\row";

                        TestoHere2         = "Per lo svolgimento delle attività di revisione e controllo viene utilizzata una procedura informatica che produce carte di lavoro, nelle quali vengono inseriti i dati tabellari raccolti nel corso della sessione, i commenti e le osservazioni annotati, nonché vengono allegati documenti in qualsiasi formato immateriale.";
                        partial_rtf_text2 += "\\trowd\\cellx9900 \\qj " + TestoHere2 + " \\cell\\row";

                        bool      esistepianificazione2 = false;
                        ArrayList al2 = mf.GetPianificazioniVerifiche(IDCliente);
                        foreach (Hashtable itemHT in al2)
                        {
                            string filedata = App.AppDataDataFolder + "\\" + itemHT["FileData"].ToString();
                            if ((new FileInfo(filedata)).Exists)
                            {
                                XmlDataProviderManager ALXTPP = new XmlDataProviderManager(filedata);

                                foreach (XmlNode itemXPP in ALXTPP.Document.SelectNodes("//Dato[@ID=\"100013\"]/Valore/Pianificazione"))
                                {
                                    if (itemXPP.Attributes["Data"].Value == cmbData.SelectedValue.ToString())
                                    {
                                        esistepianificazione2 = true;
                                        break;
                                    }
                                }
                            }

                            if (esistepianificazione2 == true)
                            {
                                break;
                            }
                        }

                        if (esistepianificazione2 == true)
                        {
                            //Inserisco il testo per la pianificazione
                            TestoHere2         = "L'attività di controllo è stata pianificata con la carta di lavoro denominata Pianificazione; la sessione avviata rientra fra quelle pianificate.";
                            partial_rtf_text2 += "\\trowd\\cellx9900 \\qj " + TestoHere2 + " \\line \\cell\\row";
                        }

                        if (rdbDescrittiva.IsChecked == true)
                        {
                            TestoHere2         = "Per economia di lavoro nel presente memorandum verrà dato conto delle carte di lavoro utilizzate dalle quali verranno estrapolati le sole osservazioni e i commenti; per i dati raccolti ed inseriti anche in forma tabellare si farà riferimento alle carte di lavoro, conservate con modalità informatica, che si intendono parte integrante del presente verbale. Parimenti i documenti raccolti vengono associati alle carte di lavoro e conservati in modalità informatiche.";
                            partial_rtf_text2 += "\\trowd\\cellx9900 \\qj " + TestoHere2 + " \\line \\cell\\row";
                        }

                        TestoHere2         = "Vengono eseguite le seguenti verifiche: \\line ";
                        partial_rtf_text2 += "\\trowd\\cellx9900 \\qj " + TestoHere2 + " \\cell\\row";

                        //   partial_rtf_text2 += "\\par\n";

                        wl2.InsertRtf(partial_rtf_text2);

                        printsingle(cliente, _t, (Convert.ToInt32(App.TipoFile.Verifica)).ToString(), wl2, valueshere["ID"].ToString(), IDCliente, "", valueshere["FileData"].ToString());
                    }

                    wl2.LastParagraph(valueshere);
                    wl2.SetFilename(App.AppTempFolder + "\\" + cliente["RagioneSociale"].ToString() + "_Memorandum_" + cmbData.SelectedValue.ToString().Replace("/", ""));
                    wl2.Save("");
                    wl2.Close();
                    #endregion
                }
            }
            else if (rdbMemorandum.IsChecked == true)
            {
                foreach (Hashtable item in mf.GetVerifiche(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == (item["Data"].ToString()))
                    {
                        valueshere = item;
                        _t         = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    }
                }

                valueshere.Add("PeriodoPianificato", "");
                DateTime dti_o = Convert.ToDateTime(valueshere["Data"]);

                foreach (Hashtable item in mf.GetPianificazioniVerifiche(IDCliente))
                {
                    DateTime dti = Convert.ToDateTime(item["DataInizio"]);
                    DateTime dtf = Convert.ToDateTime(item["DataFine"]);

                    if (dti_o.CompareTo(dti) > 0 && dti_o.CompareTo(dtf) < 0)
                    {
                        valueshere["PeriodoPianificato"] = item["DataInizio"] + " - " + item["DataFine"];
                        break;
                    }
                }

                if (valueshere.Count == 0)
                {
                    MessageBox.Show("Verifica per controllo contabile non trovata");
                }
                else
                {
                    wl.SetIntestazione(RagioneSociale, Indirizzo, CapitaleSociale, REA, "MEMORANDUM DELLA VERIFICA PERIODICA DEL ", valueshere);

                    string partial_rtf_text = "\\pard\\keepn\\f0 ";

                    partial_rtf_text += "\\trowd\\cellx9900 \\fs24 \\qc\\b ATTIVITA' DI CONTROLLO CONTABILE \\b0\\cell\\row";

                    string TestoHere = "L'organo di revisione procede alla verifica secondo la previsione dell'art.14, primo comma, lettera b), del D. Lgs. 27 Gennaio 2010 n° 39, in conformità al Principio di revisione SA Italia 250B.";

                    partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                    TestoHere         = "Per lo svolgimento delle attività di revisione e controllo viene utilizzata una procedura informatica che produce carte di lavoro, nelle quali vengono inseriti i dati tabellari raccolti nel corso della sessione, i commenti e le osservazioni annotati, nonché vengono allegati documenti in qualsiasi formato immateriale.";
                    partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                    bool      esistepianificazione = false;
                    ArrayList al = mf.GetPianificazioniVerifiche(IDCliente);
                    foreach (Hashtable itemHT in al)
                    {
                        string filedata = App.AppDataDataFolder + "\\" + itemHT["FileData"].ToString();
                        if ((new FileInfo(filedata)).Exists)
                        {
                            XmlDataProviderManager ALXTPP = new XmlDataProviderManager(filedata);

                            foreach (XmlNode itemXPP in ALXTPP.Document.SelectNodes("//Dato[@ID=\"100013\"]/Valore/Pianificazione"))
                            {
                                if (itemXPP.Attributes["Data"].Value == cmbData.SelectedValue.ToString())
                                {
                                    esistepianificazione = true;
                                    break;
                                }
                            }
                        }

                        if (esistepianificazione == true)
                        {
                            break;
                        }
                    }

                    if (esistepianificazione == true)
                    {
                        //Inserisco il testo per la pianificazione
                        TestoHere         = "L'attività di controllo è stata pianificata con la carta di lavoro denominata Pianificazione; la sessione avviata rientra fra quelle pianificate.";
                        partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\line \\cell\\row";
                    }

                    if (rdbDescrittiva.IsChecked == true)
                    {
                        TestoHere         = "Per economia di lavoro nel presente memorandum verrà dato conto delle carte di lavoro utilizzate dalle quali verranno estrapolati le sole osservazioni e i commenti; per i dati raccolti ed inseriti anche in forma tabellare si farà riferimento alle carte di lavoro, conservate con modalità informatica, che si intendono parte integrante del presente verbale. Parimenti i documenti raccolti vengono associati alle carte di lavoro e conservati in modalità informatiche.";
                        partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\line \\cell\\row";
                    }

                    TestoHere         = "Vengono eseguite le seguenti verifiche: \\line ";
                    partial_rtf_text += "\\trowd\\cellx9900 \\qj " + TestoHere + " \\cell\\row";

                    // partial_rtf_text += "\\par\n";

                    wl.InsertRtf(partial_rtf_text);

                    printsingle(cliente, _t, (Convert.ToInt32(App.TipoFile.Verifica)).ToString(), wl, valueshere["ID"].ToString(), IDCliente, "", valueshere["FileData"].ToString());
                }
            }
            else
            {
                //pw.Close();
                return;
            }

            wl.LastParagraph(valueshere);
            string str;
            str = App.AppTempFolder + "\\" + cliente["RagioneSociale"].ToString() + "_VerbaleVerificaPeriodica_" + cmbData.SelectedValue.ToString().Replace("/", "");
            str = str.Replace("*", "_");
            wl.SetFilename(str);
            wl.Save("");
            wl.Close();

            //Process wait - STOP
            //pw.Close();
        }
        public void LoadDataSource(string ID, string IDCliente, string IDSessione)
        {
            id = int.Parse(ID.ToString());
            cBusinessObjects.idcliente  = int.Parse(IDCliente.ToString());
            cBusinessObjects.idsessione = int.Parse(IDSessione.ToString());



            dati = cBusinessObjects.GetData(id, typeof(TempiCorrispettivi));
            if (dati.Rows.Count == 0)
            {
                dati.Rows.Add(id, cBusinessObjects.idcliente, cBusinessObjects.idsessione);
            }
            datiVigilanza = cBusinessObjects.GetData(id, typeof(TempiCorrispettiviVigilanza));

            foreach (DataRow dtrow in dati.Rows)
            {
                if (String.IsNullOrEmpty(dtrow["Incipit"].ToString()))
                {
                    txtIncipit.Text = "";
                }
                else
                {
                    txtIncipit.Text = dtrow["Incipit"].ToString();
                }
            }

            Binding b = new Binding();

            b.Source = dati;
            dtgTempiCorrispettivi.SetBinding(ItemsControl.ItemsSourceProperty, b);

            if (datiVigilanza.Rows.Count == 0)
            {
                MasterFile mf = MasterFile.Create();
                Hashtable  n  = mf.GetAnagrafica(Convert.ToInt32(Owner.IDCliente));

                if (n.Contains("OrganoDiRevisione") && n.Contains("RevisoreAutonomo") && n.Contains("OrganoDiControllo"))
                {
                    if (n["OrganoDiRevisione"].ToString() == "2" || n["OrganoDiRevisione"].ToString() == "3")
                    {
                        AggiungiNodoVigilanza(n["RevisoreAutonomo"].ToString(), "Revisore");
                    }
                    else
                    {
                        if (n["OrganoDiControllo"].ToString() == "2")
                        {
                            if (ID == "2016161")
                            {
                                MessageBox.Show("Composizione Organo diverso da quello presente nel Cliente.", "Attenzione");
                                this.Owner.ConsentiChiusuraFinestra = true;

                                this.Owner.Close();
                                return;
                            }
                            else
                            {
                                AggiungiNodoVigilanza(n["Presidente"].ToString(), "Sindaco Unico");
                            }
                        }

                        if (n["OrganoDiControllo"].ToString() == "1")
                        {
                            if (ID == "161")
                            {
                                MessageBox.Show("Composizione Organo diverso da quello presente nel Cliente.", "Attenzione");
                                this.Owner.ConsentiChiusuraFinestra = true;

                                this.Owner.Close();
                                return;
                            }
                            else
                            {
                                AggiungiNodoVigilanza(n["Presidente"].ToString(), "Presidente");
                                AggiungiNodoVigilanza(n["MembroEffettivo"].ToString(), "Membro Effettivo");
                                AggiungiNodoVigilanza(n["MembroEffettivo2"].ToString(), "Membro Effettivo");
                            }
                        }
                    }
                }
            }

            Binding c = new Binding();

            c.Source = datiVigilanza;
            dtgTempiCorrispettiviVigilanza.SetBinding(ItemsControl.ItemsSourceProperty, c);
        }
Exemple #3
0
        //private void functionCmbClientiChanged(ComboBox cmb)
        //{
        //	cmbData.SelectedIndex = -1;

        //	if (cmb.SelectedIndex != -1)
        //	{
        //		try
        //		{
        //			string IDCliente = htClienti[cmb.SelectedIndex].ToString();

        //			OldSelectedCmbClienti = Convert.ToInt32(IDCliente);

        //			MasterFile mf = MasterFile.Create();

        //			int index = 0;
        //			htDate.Clear();
        //			cmbData.Items.Clear();

        //			List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>();

        //			ArrayList alreadydone = new ArrayList();

        //			foreach (Hashtable item in mf.GetBilanci(IDCliente))
        //			{
        //				myList.Add(new KeyValuePair<string, string>(item["ID"].ToString(), ConvertDataToEsercizio(item["Data"].ToString())));
        //				alreadydone.Add(ConvertDataToEsercizio(item["Data"].ToString()));
        //			}

        //			foreach (Hashtable item in mf.GetRevisioni(IDCliente))
        //			{
        //				if (!alreadydone.Contains(ConvertDataToEsercizio(item["Data"].ToString())))
        //				{
        //					myList.Add(new KeyValuePair<string, string>(item["ID"].ToString(), ConvertDataToEsercizio(item["Data"].ToString())));
        //                          alreadydone.Add( ConvertDataToEsercizio( item["Data"].ToString() ) );
        //				}
        //			}

        //                  foreach ( Hashtable item in mf.GetConclusioni( IDCliente ) )
        //                  {
        //                      if ( !alreadydone.Contains( ConvertDataToEsercizio( item["Data"].ToString() ) ) )
        //                      {
        //                          myList.Add( new KeyValuePair<string, string>( item["ID"].ToString(), ConvertDataToEsercizio( item["Data"].ToString() ) ) );
        //                      }
        //                  }

        //			myList.Sort
        //			(
        //				delegate(KeyValuePair<string, string> firstPair, KeyValuePair<string, string> nextPair)
        //				{
        //					try
        //					{
        //						return nextPair.Value.ToString().CompareTo(firstPair.Value.ToString());
        //					}
        //					catch (Exception ex)
        //					{
        //						string log = ex.Message;
        //						return 1;
        //					}
        //				}
        //			);

        //			foreach (KeyValuePair<string, string> item in myList)
        //			{
        //				cmbData.Items.Add(item.Value);
        //				htDate.Add(index, item.Key);
        //				index++;
        //			}
        //		}
        //		catch (Exception ex)
        //		{
        //			string log = ex.Message;
        //			cmbData.IsEnabled = false;
        //		}
        //	}
        //}

        private void buttonStampa_Click(object sender, RoutedEventArgs e)
        {
            //controllo selezione clienti
            if (cmbClienti.SelectedIndex == -1)
            {
                MessageBox.Show("selezionare un cliente");
                return;
            }

            //Adesso stampa selettivamente o 1/ISQC o 2/3/9 (Borelli 11/12/2017)
            //if (cmbData.SelectedIndex == -1)
            //{
            //    MessageBox.Show("selezionare un anno");
            //    return;
            //}
            Hide();
            ArrayList TBD1 = new ArrayList();

#pragma warning disable CS0219 // La variabile è assegnata, ma il suo valore non viene mai usato
            bool atleastone = false;
#pragma warning restore CS0219 // La variabile è assegnata, ma il suo valore non viene mai usato

            foreach (object item in stpSessioni1.Children)
            {
                if (item.GetType().Name == "CheckBox")
                {
                    if (((CheckBox)(item)).Tag.ToString() == "-1")
                    {
                        continue;
                    }

                    if (((CheckBox)(item)).IsChecked == true)
                    {
                        atleastone = true;
                        TBD1.Add(((CheckBox)(item)).Tag.ToString());
                    }
                }
            }

            //if (cmbData.SelectedIndex == -1 && atleastone == false)
            //{
            //    MessageBox.Show("selezionare almeno un incarico o esercizio");
            //    return;
            //}



            try
            {
                MasterFile mf = MasterFile.Create();

                string IDCliente = htClienti[cmbClienti.SelectedIndex].ToString();

                string anno = "";
                if (cmbData.SelectedIndex != -1)
                {
                    anno = cmbData.SelectedValue.ToString().Split(' ')[0];
                }
                selectedCliente = IDCliente;
                Hashtable cliente = mf.GetAnagrafica(Convert.ToInt32(IDCliente));

                //WordLib wl = new WordLib();
                RTFLib wl = new RTFLib();

                wl.Fascicolo = true;
                wl.StampaLetteraAttestazione         = false;
                wl.StampaManagementLetter            = false;
                wl.StampaLetteraIncarico             = false;
                wl.StampaRelazioneBilancioeVigilanza = false;
                wl.StampaRelazioneBilancio           = false;
                wl.StampaRelazioneVigilanza          = false;
                wl.StampaRelazioneGenerica           = false;
                wl.Utente = txtRevisore.Text;

                Hashtable hthere = new Hashtable();
                hthere.Add("ID", IDCliente);
                hthere.Add("anno", anno);

                wl.TemplateFileCompletePath = App.AppTemplateStampa;
                if (cmbData.SelectedIndex != -1)
                {
                    wl.Open(hthere, cliente["RagioneSociale"].ToString(), cliente["CodiceFiscale"].ToString(), cmbData.SelectedValue.ToString(), "Fascicolo della Revisione \\line\\line esercizio " + cmbData.SelectedValue.ToString() + " \\line\\line\\line\\line\\line\\line\\line\\line ", true, true, IDCliente);
                }
                else
                {
                    wl.Open(hthere, cliente["RagioneSociale"].ToString(), cliente["CodiceFiscale"].ToString(), "", "Fascicolo della Revisione \\line\\line Accettazione Incarico \\line\\line\\line\\line\\line\\line\\line\\line ", true, true, IDCliente);
                }

                foreach (Hashtable htTBD in alIncarichi)
                {
                    if (TBD1.Contains(htTBD["ID"].ToString()))
                    {
                        XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + htTBD["File"].ToString());
                        XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + htTBD["FileData"].ToString());

                        printsingle(cliente, _t, _x, (Convert.ToInt32(App.TipoFile.Incarico)).ToString(), wl, htTBD["ID"].ToString(), IDCliente, " ( Sessione: " + htTBD["DataNomina"].ToString() + " )", htTBD["FileData"].ToString());
                    }
                }

                foreach (Hashtable htTBD in alISQCs)
                {
                    if (TBD1.Contains(htTBD["ID"].ToString()))
                    {
                        XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + htTBD["File"].ToString());
                        XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + htTBD["FileData"].ToString());

                        printsingle(cliente, _t, _x, (Convert.ToInt32(App.TipoFile.ISQC)).ToString(), wl, htTBD["ID"].ToString(), IDCliente, " ( Sessione: " + htTBD["DataNomina"].ToString() + " )", htTBD["FileData"].ToString());
                    }
                }

                if (cmbData.SelectedIndex == -1)// && atleastone == false)
                {
                    ;
                }
                else
                {
                    foreach (Hashtable item in mf.GetRevisioni(IDCliente))
                    {
                        try
                        {
                            if (cmbData.SelectedValue != null && item != null && item["Data"] != null && cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                            {
                                XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                                XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                                printsingle(cliente, _t, _x, (Convert.ToInt32(App.TipoFile.Revisione)).ToString(), wl, item["ID"].ToString(), IDCliente, "", item["FileData"].ToString());
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            cBusinessObjects.logger.Error(ex, "wStampaFascicolo.buttonStampa_Click1 exception");
                            MessageBox.Show("Attenzione, errore nei dati sulle revisioni verificare la stampa");
                            break;
                        }
                    }

                    foreach (Hashtable item in mf.GetBilanci(IDCliente))
                    {
                        try
                        {
                            if (cmbData.SelectedValue != null && item != null && item["Data"] != null && cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                            {
                                XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                                XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                                printsingle(cliente, _t, _x, (Convert.ToInt32(App.TipoFile.Bilancio)).ToString(), wl, item["ID"].ToString(), IDCliente, "", item["FileData"].ToString());
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            cBusinessObjects.logger.Error(ex, "wStampaFascicolo.buttonStampa_Click2 exception");
                            MessageBox.Show("Attenzione, errore nei dati sui bilanci verificare la stampa");
                            break;
                        }
                    }

                    foreach (Hashtable item in mf.GetConclusioni(IDCliente))
                    {
                        try
                        {
                            if (cmbData.SelectedValue != null && item != null && item["Data"] != null && cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                            {
                                XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                                XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                                printsingle(cliente, _t, _x, (Convert.ToInt32(App.TipoFile.Conclusione)).ToString(), wl, item["ID"].ToString(), IDCliente, "", item["FileData"].ToString());
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            cBusinessObjects.logger.Error(ex, "wStampaFascicolo.buttonStampa_Click3 exception");
                            MessageBox.Show("Attenzione, errore nei dati sulle conclusioni verificare la stampa");
                            break;
                        }
                    }
                }

                wl.SetFilename(App.AppTempFolder + "\\" + cliente["RagioneSociale"].ToString() + "_Fascicolo_" + anno);
                wl.SavePDF("", this);
                wl.Close();
            }
            catch (Exception ex)
            {
                cBusinessObjects.logger.Error(ex, "wStampaFascicolo.buttonStampa_Click4 exception");
                string log = ex.Message;
                MessageBox.Show("Attenzione, il processo ha riscontrato un errore: " + log);
            }
        }
Exemple #4
0
        //----------------------------------------------------------------------------+
        //                                   accedi                                   |
        //----------------------------------------------------------------------------+
        public void accedi(string ID, bool ReadOnly)
        {
            MasterFile mf         = MasterFile.Create();
            Hashtable  htSelected = mf.GetRelazioneB(ID);

            if (htSelected.Count == 0)
            {
                return;
            }
            WindowWorkAreaTree wWorkArea = new WindowWorkAreaTree();

            //Prisc
            try
            {
                wWorkArea.Owner = this;
            }
            catch (Exception ex)
            {
                cBusinessObjects.logger.Error(ex, "wSchedaRelazioneB.accedi exception");
                string log = ex.Message;
            }
            wWorkArea.SelectedTreeSource = App.AppDataDataFolder + "\\" + htSelected["File"].ToString();
            wWorkArea.SelectedDataSource = App.AppDataDataFolder + "\\" + htSelected["FileData"].ToString();
            if (htSelected["Sigillo"] != null && htSelected["Sigillo"].ToString() != "")
            {
                wWorkArea.ReadOnly = true;
            }
            else
            {
                wWorkArea.ReadOnly = ReadOnly;
            }
            wWorkArea.TipoAttivita            = App.TipoAttivita.RelazioneB;
            wWorkArea.Cliente                 = (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["RagioneSociale"].ToString()) + " (C.F. " + (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["CodiceFiscale"].ToString()) + ")";
            wWorkArea.SessioneAlias           = "";
            wWorkArea.SessioneFile            = "";
            wWorkArea.SessioneSigillo         = null;
            wWorkArea.SessioneSigilloData     = null;
            wWorkArea.SessioneSigilloPassword = null;
            wWorkArea.IDTree     = (Convert.ToInt32(App.TipoFile.RelazioneB)).ToString();
            wWorkArea.IDCliente  = htSelected["Cliente"].ToString();
            wWorkArea.IDSessione = ID;
            foreach (Hashtable item in ((ArrayList)(mf.GetRelazioniB(htSelected["Cliente"].ToString()))))
            {
                wWorkArea.SessioneFile            += ((wWorkArea.SessioneFile == "") ? "" : "|") + App.AppDataDataFolder + "\\" + item["FileData"].ToString();
                wWorkArea.SessioneAlias           += ((wWorkArea.SessioneAlias == "") ? "" : "|") + item["Data"].ToString();// ConvertDataToEsercizio(item["Data"].ToString());
                wWorkArea.SessioneID              += ((wWorkArea.SessioneID == "") ? "" : "|") + item["ID"].ToString();
                wWorkArea.SessioneSigillo         += ((wWorkArea.SessioneSigillo == null) ? "" : "|") + ((item["Sigillo"] != null) ? item["Sigillo"].ToString() : "");
                wWorkArea.SessioneSigilloData     += ((wWorkArea.SessioneSigilloData == null) ? "" : "|") + ((item["Sigillo_Data"] != null) ? item["Sigillo_Data"].ToString() : "");
                wWorkArea.SessioneSigilloPassword += ((wWorkArea.SessioneSigilloPassword == null) ? "" : "|") + ((item["Sigillo_Password"] != null) ? item["Sigillo_Password"].ToString() : "");
            }
            //aperto in sola lettura
            wWorkArea.ApertoInSolaLettura = TipologiaAttivita == App.TipoAttivitaScheda.View;
            wWorkArea.LoadTreeSource();
            Hide();
            wWorkArea.ShowDialog();
            if (TipologiaAttivita != App.TipoAttivitaScheda.View)
            {
                int IDCliente = Convert.ToInt32(htClienti[cmbClienti.SelectedIndex].ToString());
                mf.SetAnafraficaStato(Convert.ToInt32(IDCliente), App.TipoAnagraficaStato.Disponibile);
            }
            Close();
        }
Exemple #5
0
        private void functionCmbClientiChanged(ComboBox cmb)
        {
            if (_cmbInCaricamento)
            {
                return;
            }

            if (oldTipologiaAttivita != App.TipoAttivitaScheda.View)
            {
                TipologiaAttivita = oldTipologiaAttivita;
            }

            _InCaricamento              = true;
            cmbData.SelectedIndex       = -1;
            dtpDataNomina.SelectedIndex = -1;
            txtNota.Text          = "";
            imageStato.Visibility = System.Windows.Visibility.Hidden;

            if (cmb.SelectedIndex != -1)
            {
                try
                {
                    string IDCliente = htClienti[cmb.SelectedIndex].ToString();

                    OldSelectedCmbClienti = Convert.ToInt32(IDCliente);

                    MasterFile mf = MasterFile.Create();

                    int index = 0;
                    htDate.Clear();
                    cmbData.Items.Clear();

                    List <KeyValuePair <string, string> > myList = new List <KeyValuePair <string, string> >();

                    foreach (Hashtable item in mf.GetRelazioniB(IDCliente))
                    {
                        myList.Add(new KeyValuePair <string, string>(item["ID"].ToString(), ConvertDataToEsercizio(item["Data"].ToString(), item)));
                    }

                    myList.Sort
                    (
                        delegate(KeyValuePair <string, string> firstPair, KeyValuePair <string, string> nextPair)
                    {
                        try
                        {
                            return(Convert.ToInt32(nextPair.Value).CompareTo(Convert.ToInt32(firstPair.Value)));
                        }
                        catch (Exception ex)
                        {
                            cBusinessObjects.logger.Error(ex, "wSchedaRelazioneB.functionCmbClientiChanged1 exception");
                            string log = ex.Message;
                            return(1);
                        }
                    }
                    );

                    foreach (KeyValuePair <string, string> item in myList)
                    {
                        cmbData.Items.Add(item.Value);
                        htDate.Add(index, item.Key);
                        index++;
                    }

                    index = 0;
                    htSelectedDate.Clear();
                    dtpDataNomina.Items.Clear();

                    for (int i = 2009; i <= (DateTime.Now.Year + 1); i++)
                    {
                        Hashtable clientetmp = mf.GetAnagrafica(Convert.ToInt32(IDCliente));

                        string datatmp = "";

                        switch ((App.TipoAnagraficaEsercizio)(Convert.ToInt32(clientetmp["Esercizio"].ToString())))
                        {
                        case App.TipoAnagraficaEsercizio.ACavallo:
                            datatmp = "31/12/" + i.ToString();
                            break;

                        case App.TipoAnagraficaEsercizio.AnnoSolare:
                        case App.TipoAnagraficaEsercizio.Sconosciuto:
                        default:
                            datatmp = "01/01/" + i.ToString();
                            break;
                        }

                        if (!cmbData.Items.Contains(ConvertDataToEsercizio(datatmp)))
                        {
                            dtpDataNomina.Items.Add(ConvertDataToEsercizio(datatmp));
                            htSelectedDate.Add(index, datatmp);
                            index++;
                        }
                    }

                    //stato
                    if (IDClienteImport == "-1")
                    {
                        App.TipoAnagraficaStato anaStato = mf.GetAnafraficaStato(Convert.ToInt32(IDCliente));

                        //non disponibile: configuro interfaccia
                        if (anaStato != App.TipoAnagraficaStato.Disponibile)
                        {
                            oldTipologiaAttivita = TipologiaAttivita;
                            TipologiaAttivita    = App.TipoAttivitaScheda.View;
                        }
                    }


                    if (TipologiaAttivita != App.TipoAttivitaScheda.New)
                    {
                        cmbData.IsEnabled        = true;
                        dtpDataNomina.IsEnabled  = false;
                        label2.Visibility        = System.Windows.Visibility.Collapsed;
                        dtpDataNomina.Visibility = System.Windows.Visibility.Collapsed;
                        label3.Visibility        = System.Windows.Visibility.Visible;
                        cmbData.Visibility       = System.Windows.Visibility.Visible;
                        txtNota.IsEnabled        = false;
                    }
                    else
                    {
                        cmbData.IsEnabled        = false;
                        dtpDataNomina.IsEnabled  = true;
                        label2.Visibility        = System.Windows.Visibility.Visible;
                        dtpDataNomina.Visibility = System.Windows.Visibility.Visible;
                        label3.Visibility        = System.Windows.Visibility.Collapsed;
                        cmbData.Visibility       = System.Windows.Visibility.Collapsed;
                        txtNota.IsEnabled        = true;
                    }
                }
                catch (Exception ex)
                {
                    cBusinessObjects.logger.Error(ex, "wSchedaRelazioneB.functionCmbClientiChanged2 exception");
                    string log = ex.Message;

                    cmbData.IsEnabled       = false;
                    dtpDataNomina.IsEnabled = false;
                    txtNota.IsEnabled       = false;
                }
            }
        }
Exemple #6
0
        //----------------------------------------------------------------------------+
        //                                   accedi                                   |
        //----------------------------------------------------------------------------+
        public void accedi(string ID, bool ReadOnly)
        {
            MasterFile mf         = MasterFile.Create();
            Hashtable  htSelected = mf.GetIncarico(ID);

            if (htSelected.Count == 0)
            {
                //MessageBox.Show("wSchedaIncarico.xaml.cs, accedi(): incarico non trovato");
                return;
            }
            WindowWorkAreaTree wWorkArea = new WindowWorkAreaTree();

            //Prisc
            try
            {
                wWorkArea.Owner = this;
            }
            catch (Exception ex)
            {
                cBusinessObjects.logger.Error(ex, "wSchedaIncarico.accedi exception");
                string log = ex.Message;
            }
            wWorkArea.SelectedTreeSource = App.AppDataDataFolder + "\\" + htSelected["File"].ToString();
            wWorkArea.SelectedDataSource = App.AppDataDataFolder + "\\" + htSelected["FileData"].ToString();
            if (htSelected["Sigillo"] != null && htSelected["Sigillo"].ToString() != "")
            {
                wWorkArea.ReadOnly = true;
            }
            else
            {
                wWorkArea.ReadOnly = ReadOnly;
            }
            foreach (var Window in App.Current.Windows)
            {
                if (Window.GetType().Name == "MainWindow")
                {
                    if (((RevisoftApplication.MainWindow)Window).Area1CS.IsChecked == true)
                    {
                        wWorkArea.TipoAttivita = App.TipoAttivita.IncaricoCS;
                    }
                    if (((RevisoftApplication.MainWindow)Window).Area1SU.IsChecked == true)
                    {
                        wWorkArea.TipoAttivita = App.TipoAttivita.IncaricoSU;
                    }
                    if (((RevisoftApplication.MainWindow)Window).Area1REV.IsChecked == true)
                    {
                        wWorkArea.TipoAttivita = App.TipoAttivita.IncaricoREV;
                    }
                }
            }


            wWorkArea.Cliente                 = (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["RagioneSociale"].ToString()) + " (C.F. " + (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["CodiceFiscale"].ToString()) + ")";
            wWorkArea.SessioneAlias           = "";
            wWorkArea.SessioneFile            = "";
            wWorkArea.SessioneSigillo         = null;
            wWorkArea.SessioneSigilloData     = null;
            wWorkArea.SessioneSigilloPassword = null;
            if (area1 == "CS")
            {
                wWorkArea.IDTree = (Convert.ToInt32(App.TipoFile.IncaricoCS)).ToString();
            }
            if (area1 == "SU")
            {
                wWorkArea.IDTree = (Convert.ToInt32(App.TipoFile.IncaricoSU)).ToString();
            }
            if (area1 == "REV")
            {
                wWorkArea.IDTree = (Convert.ToInt32(App.TipoFile.IncaricoREV)).ToString();
            }


            wWorkArea.IDCliente  = htSelected["Cliente"].ToString();
            wWorkArea.IDSessione = ID;
            foreach (Hashtable item in ((ArrayList)(mf.GetIncarichi(htSelected["Cliente"].ToString(), area1))))
            {
                wWorkArea.SessioneFile += ((wWorkArea.SessioneFile == "") ? "" : "|") + App.AppDataDataFolder + "\\" + item["FileData"].ToString();
                switch ((App.TipoIncaricoAttivita)(Convert.ToInt32(item["Attivita"].ToString())))
                {
                case App.TipoIncaricoAttivita.Nomina:
                    wWorkArea.SessioneAliasAdditivo += ((wWorkArea.SessioneAliasAdditivo == "") ? "" : "|") + "Incarico";
                    break;

                case App.TipoIncaricoAttivita.Riesame:
                    wWorkArea.SessioneAliasAdditivo += ((wWorkArea.SessioneAliasAdditivo == "") ? "" : "|") + "Riesame";
                    break;

                case App.TipoIncaricoAttivita.Sconosciuto:
                default:
                    wWorkArea.SessioneAliasAdditivo += ((wWorkArea.SessioneAliasAdditivo == "") ? "" : "|") + "";
                    break;
                }
                //wWorkArea.SessioneAlias += ((wWorkArea.SessioneAlias == "") ? "" : "|") + ((item["DataNomina"].ToString().Split('/')[2].Length == 2) ? item["DataNomina"].ToString().Split('/')[0] + "/" + item["DataNomina"].ToString().Split('/')[1] + "/20" + item["DataNomina"].ToString().Split('/')[2] : item["DataNomina"].ToString());
                wWorkArea.SessioneAlias           += ((wWorkArea.SessioneAlias == "") ? "" : "|") + item["DataNomina"].ToString();
                wWorkArea.SessioneID              += ((wWorkArea.SessioneID == "") ? "" : "|") + item["ID"].ToString();
                wWorkArea.SessioneSigillo         += ((wWorkArea.SessioneSigillo == null) ? "" : "|") + ((item["Sigillo"] != null) ? item["Sigillo"].ToString() : "");
                wWorkArea.SessioneSigilloData     += ((wWorkArea.SessioneSigilloData == null) ? "" : "|") + ((item["Sigillo_Data"] != null) ? item["Sigillo_Data"].ToString() : "");
                wWorkArea.SessioneSigilloPassword += ((wWorkArea.SessioneSigilloPassword == null) ? "" : "|") + ((item["Sigillo_Password"] != null) ? item["Sigillo_Password"].ToString() : "");
            }
            //aperto in sola lettura
            wWorkArea.ApertoInSolaLettura = TipologiaAttivita == App.TipoAttivitaScheda.View;
            wWorkArea.LoadTreeSource();
            Hide();
            cBusinessObjects.hide_workinprogress();
            wWorkArea.ShowDialog();
            if (TipologiaAttivita != App.TipoAttivitaScheda.View)
            {
                int IDCliente = Convert.ToInt32(htClienti[cmbClienti.SelectedIndex].ToString());
                mf.SetAnafraficaStato(Convert.ToInt32(IDCliente), App.TipoAnagraficaStato.Disponibile);
            }

            Close(); // new LC
        }
Exemple #7
0
        public void accedi(string ID, bool ReadOnly, bool tobeclosed)
        {
            MasterFile mf         = MasterFile.Create();
            Hashtable  htSelected = mf.GetPianificazioniVigilanza(ID);

            if (htSelected.Count == 0)
            {
                return;
            }

            WindowWorkAreaTree wWorkArea = new WindowWorkAreaTree();

            //Prisc
            try
            {
                wWorkArea.Owner = this;
            }
            catch (Exception ex)
            {
                cBusinessObjects.logger.Error(ex, "wSchedaPianificazioneVigilanzaOLD.accedi exception");
                string log = ex.Message;
            }
            wWorkArea.SelectedTreeSource = App.AppDataDataFolder + "\\" + htSelected["File"].ToString();
            wWorkArea.SelectedDataSource = App.AppDataDataFolder + "\\" + htSelected["FileData"].ToString();
            wWorkArea.ReadOnly           = ReadOnly;
            wWorkArea.TipoAttivita       = App.TipoAttivita.PianificazioniVigilanza;
            wWorkArea.Cliente            = (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["RagioneSociale"].ToString()) + " (C.F. " + (((Hashtable)(mf.GetAnagrafica(Convert.ToInt32(htSelected["Cliente"].ToString()))))["CodiceFiscale"].ToString()) + ")";
            wWorkArea.SessioneAlias      = "";
            wWorkArea.SessioneFile       = "";

            wWorkArea.IDTree     = (Convert.ToInt32(App.TipoFile.PianificazioniVigilanza)).ToString();
            wWorkArea.IDCliente  = htSelected["Cliente"].ToString();
            wWorkArea.IDSessione = ID;

            foreach (Hashtable item in ((ArrayList)(mf.GetPianificazioniVigilanze(htSelected["Cliente"].ToString()))))
            {
                wWorkArea.SessioneAliasAdditivo += ((wWorkArea.SessioneAliasAdditivo == "") ? "" : "|") + item["DataFine"].ToString();
                wWorkArea.SessioneFile          += ((wWorkArea.SessioneFile == "") ? "" : "|") + App.AppDataDataFolder + "\\" + item["FileData"].ToString();
                wWorkArea.SessioneAlias         += ((wWorkArea.SessioneAlias == "") ? "" : "|") + item["DataInizio"].ToString();
                wWorkArea.SessioneID            += ((wWorkArea.SessioneID == "") ? "" : "|") + item["ID"].ToString();
            }


            //aperto in sola lettura
            wWorkArea.ApertoInSolaLettura = TipologiaAttivita == App.TipoAttivitaScheda.View;

            wWorkArea.LoadTreeSource();
            wWorkArea.ShowDialog();

            //setto dati
            Hashtable ht = new Hashtable();

            ht.Add("Cliente", Convert.ToInt32(htSelected["Cliente"].ToString()));


            ht.Add("DataInizio", dtpDataInizio.SelectedDate.Value.ToShortDateString());
            ht.Add("DataFine", dtpDataFine.SelectedDate.Value.ToShortDateString());

            mf.SetPianificazioniVigilanza(ht, Convert.ToInt32(ID), Convert.ToInt32(htSelected["Cliente"].ToString()));

            if (TipologiaAttivita != App.TipoAttivitaScheda.View)
            {
                int IDCliente = Convert.ToInt32(htClienti[cmbClienti.SelectedIndex].ToString());
                mf.SetAnafraficaStato(Convert.ToInt32(IDCliente), App.TipoAnagraficaStato.Disponibile);
            }

            functionCmbDataChanged(cmbData);

            if (tobeclosed == true)
            {
                base.Close();
            }
        }
Exemple #8
0
        private void buttonStampa_Click(object sender, RoutedEventArgs e)
        {
            //controllo selezione clienti
            if (cmbClienti.SelectedIndex == -1)
            {
                MessageBox.Show("selezionare un cliente");
                return;
            }

            if (cmbData.SelectedIndex == -1)
            {
                MessageBox.Show("selezionare un esercizio");
                return;
            }

            MasterFile mf = MasterFile.Create();

            string IDCliente = htClienti[cmbClienti.SelectedIndex].ToString();

            string anno = cmbData.SelectedValue.ToString().Split(' ')[0];

            Hashtable cliente = mf.GetAnagrafica(Convert.ToInt32(IDCliente));

            ArrayList NodiDaCompletare = new ArrayList();

            foreach (Hashtable item in mf.GetIncarichi(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                {
                    XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                    XmlNodeList NodeList = _x.Document.SelectNodes("/Dati//Dato");

                    foreach (XmlNode nodo in NodeList)
                    {
                        if (nodo.Attributes["Stato"] != null && nodo.Attributes["Stato"].Value == (Convert.ToInt32(App.TipoTreeNodeStato.DaCompletare)).ToString())
                        {
                            XmlNode nodotree = _t.Document.SelectSingleNode("/Tree//Node[@ID='" + nodo.Attributes["ID"].Value + "']");
                            NodiDaCompletare.Add(nodotree.Attributes["Codice"].Value);
                        }
                    }
                }
            }

            foreach (Hashtable item in mf.GetISQCs(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                {
                    XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                    XmlNodeList NodeList = _x.Document.SelectNodes("/Dati//Dato");

                    foreach (XmlNode nodo in NodeList)
                    {
                        if (nodo.Attributes["Stato"] != null && nodo.Attributes["Stato"].Value == (Convert.ToInt32(App.TipoTreeNodeStato.DaCompletare)).ToString())
                        {
                            XmlNode nodotree = _t.Document.SelectSingleNode("/Tree//Node[@ID='" + nodo.Attributes["ID"].Value + "']");
                            NodiDaCompletare.Add(nodotree.Attributes["Codice"].Value);
                        }
                    }
                }
            }

            foreach (Hashtable item in mf.GetRevisioni(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                {
                    XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                    XmlNodeList NodeList = _x.Document.SelectNodes("/Dati//Dato");

                    foreach (XmlNode nodo in NodeList)
                    {
                        if (nodo.Attributes["Stato"] != null && nodo.Attributes["Stato"].Value == (Convert.ToInt32(App.TipoTreeNodeStato.DaCompletare)).ToString() && nodo.Attributes["ID"].Value != "22")
                        {
                            XmlNode nodotree = _t.Document.SelectSingleNode("/Tree//Node[@ID='" + nodo.Attributes["ID"].Value + "']");
                            NodiDaCompletare.Add(nodotree.Attributes["Codice"].Value);
                        }
                    }
                }
            }

            foreach (Hashtable item in mf.GetBilanci(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                {
                    XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                    XmlNodeList NodeList = _x.Document.SelectNodes("/Dati//Dato");

                    foreach (XmlNode nodo in NodeList)
                    {
                        if (nodo.Attributes["Stato"] != null && nodo.Attributes["Stato"].Value == (Convert.ToInt32(App.TipoTreeNodeStato.DaCompletare)).ToString())
                        {
                            XmlNode nodotree = _t.Document.SelectSingleNode("/Tree//Node[@ID='" + nodo.Attributes["ID"].Value + "']");
                            NodiDaCompletare.Add(nodotree.Attributes["Codice"].Value);
                        }
                    }
                }
            }

            foreach (Hashtable item in mf.GetConclusioni(IDCliente))
            {
                if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                {
                    XmlDataProviderManager _t = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["File"].ToString());
                    XmlDataProviderManager _x = new XmlDataProviderManager(App.AppDataDataFolder + "\\" + item["FileData"].ToString());

                    XmlNodeList NodeList = _x.Document.SelectNodes("/Dati//Dato");

                    foreach (XmlNode nodo in NodeList)
                    {
                        if (nodo.Attributes["Stato"] != null && nodo.Attributes["Stato"].Value == (Convert.ToInt32(App.TipoTreeNodeStato.DaCompletare)).ToString())
                        {
                            XmlNode nodotree = _t.Document.SelectSingleNode("/Tree//Node[@ID='" + nodo.Attributes["ID"].Value + "']");
                            NodiDaCompletare.Add(nodotree.Attributes["Codice"].Value);
                        }
                    }
                }
            }

            if (NodiDaCompletare.Count > 0)
            {
                string daCompletare = "Attenzione, per questo esercizio risultano 'DA COMPLETARE' le seguenti voci: ";
                foreach (string ndc in NodiDaCompletare)
                {
                    daCompletare += ndc + ", ";
                }

                MessageBox.Show(daCompletare);
                return;
            }
            else
            {
                string sigillo = "";

                GestioneLicenza gl           = new GestioneLicenza();
                string          intestatario = gl.Utente;// UtenteSigillo;
                foreach (Hashtable item in mf.GetIncarichi(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                    {
                        sigillo = (item["Sigillo"] == null) ? "" : item["Sigillo"].ToString();

                        if (sigillo != "")
                        {
                            MessageBox.Show("ATTENZIONE: sigillo già applicato a questa sessione");
                            return;
                        }
                    }
                }

                foreach (Hashtable item in mf.GetISQCs(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                    {
                        sigillo = (item["Sigillo"] == null) ? "" : item["Sigillo"].ToString();

                        if (sigillo != "")
                        {
                            MessageBox.Show("ATTENZIONE: sigillo già applicato a questa sessione");
                            return;
                        }
                    }
                }

                foreach (Hashtable item in mf.GetBilanci(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        sigillo = (item["Sigillo"] == null) ? "" : item["Sigillo"].ToString();

                        if (sigillo != "")
                        {
                            MessageBox.Show("ATTENZIONE: sigillo già applicato a questa sessione");
                            return;
                        }
                    }
                }

                foreach (Hashtable item in mf.GetConclusioni(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        sigillo = (item["Sigillo"] == null) ? "" : item["Sigillo"].ToString();

                        if (sigillo != "")
                        {
                            MessageBox.Show("ATTENZIONE: sigillo già applicato a questa sessione");
                            return;
                        }
                    }
                }

                foreach (Hashtable item in mf.GetRevisioni(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        sigillo = (item["Sigillo"] == null) ? "" : item["Sigillo"].ToString();

                        if (sigillo != "")
                        {
                            MessageBox.Show("ATTENZIONE: sigillo già applicato a questa sessione");
                            return;
                        }
                    }
                }

                if ((cliente["Presidente"] == null || cliente["Presidente"].ToString() != intestatario) &&
                    (cliente["MembroEffettivo"] == null || cliente["MembroEffettivo"].ToString() != intestatario) &&
                    (cliente["MembroEffettivo2"] == null || cliente["MembroEffettivo2"].ToString() != intestatario) &&
                    (cliente["RevisoreAutonomo"] == null || cliente["RevisoreAutonomo"].ToString() != intestatario))
                {
                    MessageBox.Show("ATTENZIONE: l'intestatario di questa licenza non risulta uno dei revisori abilitati per questo cliente");
                    return;
                }

                wSigilloPassword SP = new wSigilloPassword();
                SP.ShowDialog();
                SP.Activate();

                if (!SP.PasswordOK)
                {
                    return;
                }

                string password = SP.Password;

                foreach (Hashtable item in mf.GetIncarichi(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                    {
                        mf.SetSigilloIncarico(Convert.ToInt32(item["ID"].ToString()), intestatario, password);
                    }
                }

                foreach (Hashtable item in mf.GetISQCs(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["DataNomina"].ToString()))
                    {
                        mf.SetSigilloISQC(Convert.ToInt32(item["ID"].ToString()), intestatario, password);
                    }
                }

                foreach (Hashtable item in mf.GetRevisioni(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        mf.SetSigilloRevisione(Convert.ToInt32(item["ID"].ToString()), intestatario, password);
                    }
                }

                foreach (Hashtable item in mf.GetBilanci(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        mf.SetSigilloBilancio(Convert.ToInt32(item["ID"].ToString()), intestatario, password);
                    }
                }

                foreach (Hashtable item in mf.GetConclusioni(IDCliente))
                {
                    if (cmbData.SelectedValue.ToString() == ConvertDataToEsercizio(item["Data"].ToString()))
                    {
                        mf.SetSigilloConclusione(Convert.ToInt32(item["ID"].ToString()), intestatario, password);
                    }
                }

                MessageBox.Show("Sigillo applicato con successo");
                base.Close();
            }
        }