public InvoiceListCtrl(DataModels.Customer customer) { Customer = customer; InitializeComponent(); _proformaInvoices = new List <DataModels.ProformaInvoice>(); dateTimePickerfrom.ValueChanged -= dateTimePickerfrom_ValueChanged; dateTimePickerfrom.Format = DateTimePickerFormat.Custom; dateTimePickerfrom.Value = Helper.Global.FilterFromData; dateTimePickerfrom.CustomFormat = "dd/MM/yyyy"; dateTimePickerfrom.ValueChanged += dateTimePickerfrom_ValueChanged; dateTimePickerTo.Format = DateTimePickerFormat.Custom; dateTimePickerTo.Value = Helper.Global.FilterToData; dateTimePickerTo.CustomFormat = "dd/MM/yyyy"; comboBoxPayed.Items.AddRange(_comboBoxValues); comboBoxPayed.SelectedItem = _comboBoxValues[0]; var col = this.dataGridView1.Columns[1]; col.DefaultCellStyle.Format = "dd.MM.yyyy"; using (var db = new Db.PhisioDB()) { _therapist = db.Therapists.FirstOrDefault(); } }
public VisitCtrl(DataModels.Customer customer, DataModels.Visit visit) { InitializeComponent(); _visit = visit; _customer = customer; if (_visit == null || _visit.Id == null || _visit.Id == Guid.Empty) { button1.Visible = false; } else { button1.Visible = true; } using (var db = new Db.PhisioDB()) { _therapist = db.Therapists.FirstOrDefault(); _treatments = db.Treatments.ToList(); foreach (var treatment in _treatments) { this.checkedListBox1.DisplayMember = "DescriptionIt"; if (_customer.Language == "german") { this.checkedListBox1.DisplayMember = "DescriptionDe"; } this.checkedListBox1.Items.Add(treatment, false); } } FillVisitFields(); }
public static void SetBackupTimer(DataModels.Therapist terapist) { invoiceBackupTimer = new Timer(1000 * 60 * 60); invoiceBackupTimer.Elapsed += (sender, e) => { OnBackupTimerEvent(terapist); }; invoiceBackupTimer.AutoReset = true; invoiceBackupTimer.Enabled = true; }
private static void OnBackupTimerEvent(DataModels.Therapist terapist) { if (_begin > 0) { _begin--; return; } _begin = 100; BackupPdf(terapist.InvoicesFolder, "Invoice"); BackupPdf(terapist.PrivacyFolder, "Privacy"); _begin = 0; }
public InvoiceCtrl(DataModels.ProformaInvoice proformaInvoice, bool edit = false) { InitializeComponent(); ProformaInvoice = proformaInvoice; _edit = edit; _printProInvoiceTT.SetToolTip(this.buttonPrintProformaInvoice, "Stampa la fattura proforma"); _printInvoiceTT.SetToolTip(this.buttonPrintInvoice, "Stampa la fattura"); ProformaInvoice.Visitsproformainvoiceidfkeys = ProformaInvoice.Visitsproformainvoiceidfkeys.Where(x => x.Deleted == false).ToList(); using (var db = new Db.PhisioDB()) { ProformaInvoice.Invoice = db.Invoices.LoadWith(e1 => e1.Visitsinvoiceidfkeys.First().Treatmentsvisitidfkeys.First().Treatment).LoadWith(e1 => e1.Visitsinvoiceidfkeys.First().Customer.Address).FirstOrDefault(inv => inv.ProformaInvoiceId == ProformaInvoice.Id); if (ProformaInvoice.Invoice?.Visitsinvoiceidfkeys != null) { ProformaInvoice.Invoice.Visitsinvoiceidfkeys = ProformaInvoice.Invoice.Visitsinvoiceidfkeys.Where(x => x.Deleted == false); } _therapist = db.Therapists.FirstOrDefault(); } }
public MultipleVisits(DataModels.Customer customer) { InitializeComponent(); using (var db = new Db.PhisioDB()) { _visitNr = 10; _therapist = db.Therapists.FirstOrDefault(); _treatments = db.Treatments.ToList(); _customer = customer; foreach (var treatment in _treatments) { this.checkedListBox1.DisplayMember = "DescriptionIt"; if (_customer.Language == "german") { this.checkedListBox1.DisplayMember = "DescriptionDe"; } this.checkedListBox1.Items.Add(treatment, false); } } ChangeVisitiTot(); }
private void PrintProforma(DataModels.ProformaInvoice invoice) { if (invoice.Id == null || invoice.Id == Guid.Empty) { invoice.TaxStamp = checkBox1.Checked; if (double.TryParse(textBoxDiscount.Text, out double disc)) { invoice.Discount = disc; } MessageBox.Show("Si sta visualizzando un anteprima, ricordarsi di salvare la fattura!", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Information); } DataModels.Therapist therapist = null; using (var db = new Db.PhisioDB()) { therapist = db.Therapists.FirstOrDefault(); } if (therapist == null) { MessageBox.Show("Qualcosa è andato storto non trovo i parametri generali", "Stampa", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(therapist.InvoicesFolder)) { MessageBox.Show("Prima di proseguire bisogna impostare la cartella di salvataggio delle fatture", "Salvataggio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string html = ""; if (_customer.Language == "german") { html = File.ReadAllText("Template/templateProformaInvoice_de.html"); } else { html = File.ReadAllText("Template/templateProformaInvoice_it.html"); } var groupVisits = checkBoxGroup.Checked; html = Helper.Helper.ReplaceProformaInvoicePlaceHolder(html, _customer, invoice, groupVisits); var basePath = therapist.InvoicesFolder + "_Proforma"; var date = $"{ProformaInvoice.Date.Year}{ProformaInvoice.Date.Month}"; basePath = Path.Combine(basePath, date); Directory.CreateDirectory(basePath); var pdfPath = $@"{basePath}\{invoice.Title.Replace(@"/", "_")}_{_customer.FullName.Replace(" ", "_").Replace("'", "")}.pdf"; var htmlPath = $@"{basePath}\{invoice.Title.Replace("/", "_")}_{_customer.FullName.Replace(" ", "_").Replace("'", "")}.html"; try { File.WriteAllText(htmlPath, html); Helper.PdfManager.CreatePdf(pdfPath, htmlPath); } catch (Exception ee) { MessageBox.Show("Il file è già aperto, chiuderlo", "Stampa", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Helper.DriveManagement.InsertFilePdf(pdfPath, new List<string> { "Invoice", date }); File.Delete(htmlPath); if (File.Exists(pdfPath)) { System.Diagnostics.Process.Start(pdfPath); } else { MessageBox.Show("ERRORE! Non risco a visualizzare il PDF per il file: " + Environment.NewLine + pdfPath + Environment.NewLine + "Dillo a Davide"); } }