Esempio n. 1
0
        private void CreateProformaInvoice()
        {
            if (MessageBox.Show("Una volta salvata la fattura non potrà essere modificata!", "Salvataggio", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            if (ProformaInvoice.Id != null && ProformaInvoice.Id != Guid.Empty)
            {
                MessageBox.Show("Fattura già salvata", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ProformaInvoice.TaxStamp    = checkBox1.Checked;
            ProformaInvoice.GroupVisits = checkBoxGroup.Checked;

            if (double.TryParse(textBoxDiscount.Text, out double disc))
            {
                ProformaInvoice.Discount = disc;
            }

            using (var db = new Db.PhisioDB())
            {
                ProformaInvoice.TherapistId = _therapist.Id;
                var proformaInvoiceID = ProformaInvoice.SaveToDB();
                foreach (var visit in ProformaInvoice.Visitsproformainvoiceidfkeys)
                {
                    visit.ProformaInvoiced  = true;
                    visit.ProformaInvoiceId = proformaInvoiceID;
                    visit.SaveToDB();
                }
                MessageBox.Show("Salvato Correttamente", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SavedInvoice?.Invoke(this, new EventArgs());
            }
        }
Esempio n. 2
0
        private void CreateInvoice()
        {
            if (MessageBox.Show("Una volta salvata la fattura non potrà essere modificata!", "Salvataggio", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            if (ProformaInvoice.Invoice != null && ProformaInvoice.Invoice.Id != null && ProformaInvoice.Invoice.Id != Guid.Empty)
            {
                MessageBox.Show("Fattura già salvata", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            if (ProformaInvoice.Payed == false)
            {
                if (MessageBox.Show("La fattura proforma non è ancora stata pagata, continuare?", "Salvataggio", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                {
                    return;
                }
            }

            var invoice = Helper.Helper.CreateNewInvoice(ProformaInvoice.Visitsproformainvoiceidfkeys.ToList(), out string errors);

            if (!string.IsNullOrEmpty(errors))
            {
                MessageBox.Show("errors", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            invoice.TaxStamp = ProformaInvoice.TaxStamp;
            invoice.Discount = ProformaInvoice.Discount;

            using (var db = new Db.PhisioDB())
            {
                invoice.TherapistId       = ProformaInvoice.TherapistId;
                invoice.ProformaInvoiceId = ProformaInvoice.Id;
                ProformaInvoice.Invoice   = invoice;
                ProformaInvoice.InvoiceId = invoice.SaveToDB();
                ProformaInvoice.SaveToDB();
                foreach (var visit in ProformaInvoice.Visitsproformainvoiceidfkeys)
                {
                    visit.Invoiced  = true;
                    visit.InvoiceId = ProformaInvoice.Invoice.Id;
                    visit.SaveToDB();
                }
                MessageBox.Show("Salvato Correttamente", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SavedInvoice?.Invoke(this, new EventArgs());
            }
        }