Пример #1
0
        // print
        private void button4_Click(object sender, EventArgs e)
        {
            if (dateInizio.Enabled)
            {
                DialogResult dialogResult = MessageBox.Show("Non hai impostato le date!\nProcedere con la stampa?", "Sei sicuro?", MessageBoxButtons.YesNo);
                if (dialogResult != DialogResult.Yes)
                {
                    return;
                }
            }

            List <Iscrizione> update = new List <Iscrizione>();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                try
                {
                    Guid       id   = (Guid)dataGridView1.Rows[i].Cells["ID"].Value;
                    Iscrizione iscr = DB.instance.getIscrizione(id);

                    update.Add(iscr);
                }
                catch { }
            }

            Printing.printLibroSoci(update, dateTimePicker1.Value, Config.Instance.QuitWordAfterPrintLibroSoci);
        }
Пример #2
0
 public PanelIscrizione()
 {
     InitializeComponent();
     iscrizione   = null;
     mainform     = null;
     panelpersona = null;
 }
Пример #3
0
            public EntryIscrizione(Iscrizione i)
            {
                ID          = i.ID;
                Nome        = i.persona.Nome;
                Cognome     = i.persona.Cognome;
                DataNascita = i.persona.DataNascita;
                DataFine    = i.getLastDate();

                try { DaContare = DataFine.Value.CompareTo(DateTime.Today) >= 0; }
                catch { DaContare = false; }
            }
Пример #4
0
 public EntryIscrizione(Iscrizione i)
 {
     ID             = i.ID;
     Nome           = i.persona.Nome;
     Cognome        = i.persona.Cognome;
     DataIscrizione = i.data_iscrizione;
     //DataNascita = Utils.dateToPrintableString(i.persona.DataNascita);
     //LuogoNascita = i.persona.LuogoNascita;
     //CodiceFiscale = i.persona.CodiceFiscale;
     tesseran  = i.tesseran > 0 ? i.tesseran.ToString() : string.Empty;
     DataSocio = Utils.dateToPrintableString(i.data_socio);
     Corso     = i.corso.Descrizione;
 }
Пример #5
0
        private void dataGridViewIscritti_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Iscrizione isc = DB.instance.getIscrizione((Guid)dataGridViewIscritti.Rows[e.RowIndex].Cells[0].Value);

            if (isc == null)
            {
                return;
            }

            if (isc.persona != null)
            {
                mainform.OpenAnagrafica(isc.persona);
            }
        }
Пример #6
0
        public bool save(Iscrizione iscrizione)
        {
            int idx = iscrizioni.FindIndex(x => x.ID == iscrizione.ID);

            if (idx >= 0)
            {
                iscrizioni[idx] = iscrizione;
            }
            else
            {
                iscrizioni.Add(iscrizione);
            }

            return(DB.saveIscrizione(iscrizione));
        }
Пример #7
0
        public void setNewCorso(object id)
        {
            if (persona == null || persona.ID == null || persona.ID == Guid.Empty)
            {
                MessageBox.Show("Impossibile aggiungere il corso perchè la persona non è stata salvata.\nPremere \"Salva\" in basso a sinistra", "ERRORE");
                return;
            }

            Corso      corso   = DB.instance.getCorso((Guid)id);
            bool       saldato = false;
            Iscrizione iscrz   = new Iscrizione()
            {
                corso = corso, persona = persona, data_iscrizione = DateTime.Today, Saldato = saldato
            };

            bool found = false;

            foreach (Iscrizione vecchieisc in persona.Iscrizioni)
            {
                if (vecchieisc.corso.ID == iscrz.corso.ID)
                {
                    found = true;
                    break;
                }
            }

            if (found == true)
            {
                MessageBox.Show("Questa persona è già iscritta a quel corso!");
            }
            else
            {
                if (!persona.Iscrizioni.Contains(iscrz))
                {
                    persona.Iscrizioni.Add(iscrz);
                }

                if (!corso.Iscrizioni.Contains(iscrz))
                {
                    corso.Iscrizioni.Add(iscrz);
                }

                DB.instance.save(iscrz);
            }

            RefreshIscrizioni();
            mainform.RefreshAnagrafiche();
        }
Пример #8
0
 public static bool deleteIscrizione(Iscrizione p)
 {
     using (NHibernate.ISession session = HibernateHelper.Open())
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
             try
             {
                 session.Delete(p);
                 transaction.Commit();
                 return(true);
             }
             catch (Exception exc)
             {
                 Log.Instance.WriteLine(Log.LogLevel.Error, "deleteIscrizione(" + (p != null ? p.ID.ToString() : "null") + "):" + exc.Message);
                 return(false);
             }
 }
Пример #9
0
        private bool violaCriteriRicercaIscrizioni(Iscrizione i)
        {
            if (i.Saldato)
            {
                if (checkBoxCorsiAttivi.Checked && !Utils.isAttivo(i.corso.Attivo))
                {
                    return(true);
                }

                if (checkBoxCorsiNonSaldati.Checked)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #10
0
        public static void printCartellino(Iscrizione iscrizione)
        {
            String colore = iscrizione.corso.TipoCartellino;

            if (String.IsNullOrEmpty(colore))
            {
                MessageBox.Show("Questo corso non ha un cartellino associato!\nVerrà stampato il cartellino di default");
            }

            string oTemplatePath;

            if (String.IsNullOrEmpty(colore))
            {
                oTemplatePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PathCartellino;
            }
            else
            {
                string fullPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PathCartellino;

                int punto = fullPath.LastIndexOf('.');
                if (punto < 0)
                {
                    oTemplatePath = fullPath;
                }
                else
                {
                    oTemplatePath  = fullPath.Substring(0, punto);
                    oTemplatePath += "-" + colore;
                    oTemplatePath += fullPath.Substring(punto);
                }
            }

            if (!File.Exists(oTemplatePath) && !Directory.Exists(oTemplatePath))
            {
                MessageBox.Show("Impossibile trovare il modello di word associato al cartellino \"" + (colore ?? "null") + "\"");
                return;
            }

            printIscrizione((Object)oTemplatePath, iscrizione, -1, Config.Instance.QuitWordAfterPrintCartellino);
        }
Пример #11
0
        public void Save()
        {
            DateTime settime  = dateTimePicker1.Value;
            int      tesseran = DB.instance.getFirstCartellinoLibero();

            List <Iscrizione> update = new List <Iscrizione>();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                try
                {
                    Guid       id   = (Guid)dataGridView1.Rows[i].Cells["ID"].Value;
                    Iscrizione iscr = DB.instance.getIscrizione(id);

                    iscr.data_socio = settime;
                    iscr.tesseran   = tesseran++;

                    dataGridView1.Rows[i].Cells[4].Value = iscr.tesseran;
                    dataGridView1.Rows[i].Cells[5].Value = settime;

                    update.Add(iscr);
                }
                catch { }
            }

            try
            {
                DB.instance.save(update);
            }
            catch (Exception e)
            {
                MessageBox.Show("Errore assegnando le date socio: " + e.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            RefreshList();
        }
 public async Task Delete(ApplicationDbContext db, Iscrizione i)
 {
     db.Iscrizioni.Remove(i);
     await db.SaveChangesAsync();
 }
 public async Task Update(ApplicationDbContext db, Iscrizione i)
 {
     db.Iscrizioni.Update(i);
     await db.SaveChangesAsync();
 }
Пример #14
0
        public void setIscrizione(Iscrizione i, MainForm mf, ViewAnagrafica pp)
        {
            iscrizione   = i;
            mainform     = mf;
            panelpersona = pp;

            readImporti();
            comboIngressi.Items.Clear();
            foreach (string s in importi.Keys)
            {
                comboIngressi.Items.Add(s);  // #ingressi
            }
            comboPagamento1modalita.Items.Clear();
            comboPagamento2modalita.Items.Clear();
            comboPagamento3modalita.Items.Clear();
            String[] modalitapagamenti = Config.Instance.ModalitaPagamento;
            foreach (String s in modalitapagamenti)
            {
                comboPagamento1modalita.Items.Add(s);
                comboPagamento2modalita.Items.Add(s);
                comboPagamento3modalita.Items.Add(s);
            }

            if (iscrizione != null)
            {
                textBox1.Text = iscrizione.corso.Descrizione;

                if (!String.IsNullOrEmpty(iscrizione.primopagamento_modalita))
                {
                    if (!comboPagamento1modalita.Items.Contains(iscrizione.primopagamento_modalita))
                    {
                        comboPagamento1modalita.Items.Add(iscrizione.primopagamento_modalita);
                    }
                    comboPagamento1modalita.Text = iscrizione.primopagamento_modalita;
                }

                if (!String.IsNullOrEmpty(iscrizione.secondopagamento_modalita))
                {
                    if (!comboPagamento2modalita.Items.Contains(iscrizione.secondopagamento_modalita))
                    {
                        comboPagamento2modalita.Items.Add(iscrizione.secondopagamento_modalita);
                    }
                    comboPagamento2modalita.Text = iscrizione.secondopagamento_modalita;
                }

                if (!String.IsNullOrEmpty(iscrizione.terzopagamento_modalita))
                {
                    if (!comboPagamento3modalita.Items.Contains(iscrizione.terzopagamento_modalita))
                    {
                        comboPagamento3modalita.Items.Add(iscrizione.terzopagamento_modalita);
                    }
                    comboPagamento3modalita.Text = iscrizione.terzopagamento_modalita;
                }

                checkTassaIscrizione.Checked = iscrizione.tassa_iscrizione;
                textPagamento1importo.Text   = Utils.moneylongToString(iscrizione.primopagamento_importo);
                textPagamento2importo.Text   = Utils.moneylongToString(iscrizione.secondopagamento_importo);
                textPagamento3importo.Text   = Utils.moneylongToString(iscrizione.terzopagamento_importo);
                textBox9.Text       = iscrizione.tesseran > 0 ? iscrizione.tesseran.ToString() : String.Empty;
                textCartellino.Text = iscrizione.corso.TipoCartellino ?? string.Empty;

                Utils.SetPickerValidIfEnabled(i.data_iscrizione, ref dateIscrizione);
                Utils.SetPickerValidIfEnabled(i.data_inizio, ref dateInizio);
                Utils.SetPickerValid(dateFine, false);
                Utils.SetPickerValidIfEnabled(i.primopagamento_data, ref datePagamento1);
                Utils.SetPickerValidIfEnabled(i.secondopagamento_data, ref datePagamento2);
                Utils.SetPickerValidIfEnabled(i.terzopagamento_data, ref datePagamento3);
                Utils.SetPickerValidIfEnabled(i.data_socio, ref dateSocio);
                Utils.SetPickerValidIfEnabled(i.data_certificato, ref dateCertificato);
                Utils.SetPickerValidIfEnabled(i.data_rinuncia, ref dateRinuncia);

                comboIngressi.Text = iscrizione.ingressi.ToString(); // questa deve essere settata dopo al datePicker che triggera CalcolaGiornate() !
                //comboIngressi_TextChanged(null, null); // setta dovuto
                comboIngressi.Text = Utils.moneylongToString(iscrizione.importo);

                Colorize();
            }
            else
            {
                // questo non dovrebbe succedere
                textBox1.Text = String.Empty;
                Utils.SetPickerValid(dateCertificato, false);
                Utils.SetPickerValid(dateIscrizione, false);
                Utils.SetPickerValid(dateInizio, false);
                Utils.SetPickerValid(dateFine, false);
                Utils.SetPickerValid(datePagamento1, false);
                Utils.SetPickerValid(datePagamento2, false);
                Utils.SetPickerValid(datePagamento3, false);
                Utils.SetPickerValid(dateRinuncia, false);
                Utils.SetPickerValid(dateSocio, false);
            }

            CalcolaImporto();
        }
Пример #15
0
        public static void printIscrizione(Object oTemplatePath, Iscrizione iscrizione, int npagamento, bool shallclose)
        {
            Microsoft.Office.Interop.Word.Application wordApp = null;

            try
            {
                Object oMissing = System.Reflection.Missing.Value;

                wordApp = new Microsoft.Office.Interop.Word.Application();
                Document wordDoc = new Document();
                wordDoc = wordApp.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);

                foreach (Field myMergeField in wordDoc.Fields)
                {
                    Range  rngFieldCode = myMergeField.Code;
                    String fieldText    = rngFieldCode.Text;
                    if (fieldText.StartsWith(" MERGEFIELD"))
                    {
                        Int32  endMerge        = fieldText.IndexOf("\\");
                        Int32  fieldNameLength = fieldText.Length - endMerge;
                        String fieldName       = fieldText.Substring(11, endMerge - 11);

                        fieldName = fieldName.Trim();

                        if (fieldName == "Nome")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.Nome));
                        }
                        else if (fieldName == "Cognome")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.Cognome));
                        }
                        else if (fieldName == "Nascita")
                        {
                            myMergeField.Select();

                            if (iscrizione.persona.DataNascita != null)
                            {
                                DateTime dt = (DateTime)iscrizione.persona.DataNascita;
                                wordApp.Selection.TypeText(dt.ToString("d"));
                            }
                            else
                            {
                                wordApp.Selection.TypeText("  /  /");
                            }
                        }
                        else if (fieldName == "CF")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.CodiceFiscale));
                        }
                        else if (fieldName == "ComuneNascita")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.LuogoNascita));
                        }
                        else if (fieldName == "Corso")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.corso.Descrizione));
                        }
                        else if (fieldName == "Oggi")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(DateTime.Today.ToString("d"));
                        }
                        else if (fieldName == "Giornate")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(Utils.giornateToString(iscrizione.corso.getGiorniSettimana())));
                        }
                        else if (fieldName == "Orario")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.corso.getOrarioString()));
                        }
                        else if (fieldName == "Dal")
                        {
                            myMergeField.Select();
                            if (iscrizione.data_inizio != null)
                            {
                                wordApp.Selection.TypeText(iscrizione.data_inizio.Value.Date.ToString("d"));
                            }
                        }
                        else if (fieldName == "Al")
                        {
                            myMergeField.Select();
                            //    wordApp.Selection.TypeText(iscrizione.corso.DataFine.ToString("d"));
                            wordApp.Selection.TypeText(Utils.dateToPrintableString(iscrizione.getLastDate()));
                        }
                        else if (fieldName == "Pagato")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(iscrizione.Saldato ? "SI" : "NO");
                        }
                        else if (fieldName == "Indirizzo")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.Indirizzo));
                        }
                        else if (fieldName == "NumeroTelefono")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.NumeroTelefono));
                        }
                        else if (fieldName == "NumeroCellulare")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.NumeroCellulare));
                        }
                        else if (fieldName == "Email")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(iscrizione.persona.Email));
                        }
                        else if (fieldName == "Stagione")
                        {
                            myMergeField.Select();
                            wordApp.Selection.TypeText(stringToWord(DB.instance.stagione_corrente.Descrizione));
                        }

                        else if (fieldName == "Importo")
                        {
                            if (npagamento < 0)
                            {
                                continue;
                            }

                            myMergeField.Select();

                            String importo = Utils.moneylongToString(npagamento == 0 ? iscrizione.primopagamento_importo :
                                                                     npagamento == 1 ? iscrizione.secondopagamento_importo :
                                                                     iscrizione.terzopagamento_importo);

                            wordApp.Selection.TypeText(stringToWord(importo));
                        }
                        else if (fieldName == "ModalitaPagamento")
                        {
                            if (npagamento < 0)
                            {
                                continue;
                            }

                            myMergeField.Select();
                            String modalita = npagamento == 0 ? iscrizione.primopagamento_modalita :
                                              npagamento == 1 ? iscrizione.secondopagamento_modalita :
                                              iscrizione.terzopagamento_modalita;

                            wordApp.Selection.TypeText(stringToWord(modalita));
                        }
                        else if (fieldName == "DataPagamento")
                        {
                            if (npagamento < 0)
                            {
                                continue;
                            }

                            try
                            {
                                myMergeField.Select();
                                DateTime?datapagamento = npagamento == 0 ? iscrizione.primopagamento_data :
                                                         npagamento == 1 ? iscrizione.secondopagamento_data :
                                                         iscrizione.terzopagamento_data;

                                if (datapagamento != null)
                                {
                                    wordApp.Selection.TypeText(datapagamento.Value.ToString("d"));
                                }
                            }
                            catch { }
                        }

                        else if (fieldName.StartsWith("Importo"))
                        {
                            try {
                                int n = Int32.Parse(fieldName.Replace("Importo", String.Empty));

                                myMergeField.Select();
                                String importo = Utils.moneylongToString(n == 0 ? iscrizione.primopagamento_importo :
                                                                         n == 1 ? iscrizione.secondopagamento_importo :
                                                                         iscrizione.terzopagamento_importo);

                                wordApp.Selection.TypeText(stringToWord(importo));
                            }
                            catch { continue; }
                        }
                        else if (fieldName.StartsWith("ModalitaPagamento"))
                        {
                            try
                            {
                                int n = Int32.Parse(fieldName.Replace("ModalitaPagamento", String.Empty));

                                myMergeField.Select();
                                String modalita = n == 0 ? iscrizione.primopagamento_modalita :
                                                  n == 1 ? iscrizione.secondopagamento_modalita :
                                                  iscrizione.terzopagamento_modalita;

                                wordApp.Selection.TypeText(stringToWord(modalita));
                            }
                            catch { continue; }
                        }
                        else if (fieldName.StartsWith("DataPagamento"))
                        {
                            try
                            {
                                int n = Int32.Parse(fieldName.Replace("DataPagamento", String.Empty));

                                myMergeField.Select();
                                DateTime?datapagamento = n == 0 ? iscrizione.primopagamento_data :
                                                         n == 1 ? iscrizione.secondopagamento_data :
                                                         iscrizione.terzopagamento_data;

                                if (datapagamento != null)
                                {
                                    wordApp.Selection.TypeText(datapagamento.Value.ToString("d"));
                                }
                            }
                            catch { continue; }
                        }
                    }
                }

                wordApp.PrintOut();
                if (shallclose)
                {
                    Microsoft.Office.Interop.Word._Document document = wordApp.ActiveDocument;
                    document.Close(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges);
                    ((Microsoft.Office.Interop.Word._Application)wordApp).Quit();
                }
                else
                {
                    wordApp.Visible = true;
                }
            }
            catch (Exception e)
            {
                String errorString = "Errore Stampando un Pagamento:\n" + e.Message;

                if (Config.Instance.ShowErrors)
                {
                    MessageBox.Show(errorString, "Errore ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Log.Instance.WriteLine(Log.LogLevel.Exception, errorString);

                try { ((Microsoft.Office.Interop.Word._Application)wordApp).Quit(); }
                catch (Exception e1)
                {
                    Log.Instance.WriteLine(Log.LogLevel.Exception, "Errore chiudendo Office: " + e1.ToString());
                }
            }
        }
Пример #16
0
        public static void printPagamento(Iscrizione iscrizione, int npagamento)
        {
            Object oTemplatePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + PathPagamento;

            printIscrizione(oTemplatePath, iscrizione, npagamento, Config.Instance.QuitWordAfterPrintPagamento);
        }