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(); }
} // uuid public void SaveToDB(Visit _visit) { using (var db = new Db.PhisioDB()) { if (_visit.Id != null) { db.VisitsTreatments.Where(x => x.VisitId == _visit.Id).Delete(); foreach (var visitTreatment in _visit.Treatmentsvisitidfkeys) { db.Insert(visitTreatment); } db.Update(_visit); } else { _visit.Id = Guid.Parse(db.InsertWithIdentity(_visit).ToString()); if (_visit.Treatmentsvisitidfkeys != null) { foreach (var visitTreatment in _visit.Treatmentsvisitidfkeys) { visitTreatment.Visit = _visit; visitTreatment.VisitId = _visit.Id; db.Insert(visitTreatment); } } } } }
public override Guid SaveToDB() { using (var db = new Db.PhisioDB()) { if (Id != null && Guid.Empty != Id) { db.VisitsTreatments.Where(x => x.VisitId == Id).Delete(); foreach (var visitTreatment in Treatmentsvisitidfkeys) { visitTreatment.VisitId = Id; db.Insert(visitTreatment); } db.Update(this); } else { Id = Guid.NewGuid(); Id = Guid.Parse(db.InsertWithIdentity(this).ToString()); if (Treatmentsvisitidfkeys != null) { foreach (var visitTreatment in Treatmentsvisitidfkeys) { visitTreatment.Visit = this; visitTreatment.VisitId = Id; db.Insert(visitTreatment); } } } } return(Id); }
private void DeleteInvoice() { if (MessageBox.Show("Sei sicura di voler cancellare la fattura?", "Cancellazione", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } if (ProformaInvoice.Id == null) { MessageBox.Show("Errore la fattura non è stata caricata correttamente!", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (var db = new Db.PhisioDB()) { if (ProformaInvoice.Id != null) { //Invoice.Deleted = true; foreach (var visit in ProformaInvoice.Visitsproformainvoiceidfkeys) { visit.Payed = false; visit.InvoiceId = null; visit.Invoice = null; visit.Invoiced = false; visit.SaveToDB(); } ProformaInvoice.SaveToDB(); MessageBox.Show("Fattura Eliminata!", "Cancellazione", MessageBoxButtons.OK, MessageBoxIcon.Information); DeletedInvoice?.Invoke(this, new EventArgs()); } } }
private void checkBox2_CheckedChanged(object sender, EventArgs e) { if (!_loaded) { return; } if (_autoClick) { _autoClick = false; return; } if ((bool)Visit.Invoiced) { _autoClick = true; MessageBox.Show("La visita può essere pagata solo attraverso il pagamento della fattura", "Fatturazione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); checkBox2.Checked = !checkBox2.Checked; return; } using (var db = new Db.PhisioDB()) { if (Visit.Id != null) { Visit.Payed = checkBox2.Checked; db.Update(Visit); ChangePayed?.Invoke(this, e); } } }
public static DataModels.Therapist GetTherapist() { using (var db = new Db.PhisioDB()) { return(db.Therapists.FirstOrDefault()); } }
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()); } }
private void buttonSave_Click(object sender, EventArgs e) { _priceLists.Clear(); _treatMentLists.Clear(); using (var db = new Db.PhisioDB()) { _therapist.FullName = textBoxName.Text; _therapist.Email = textBoxEmail.Text; _therapist.FiscalCode = textBoxCf.Text; _therapist.Iban = textBoxIban.Text; _therapist.TaxNumber = textBoxPiva.Text; _therapist.Address = textBoxAddress.Text; _therapist.AddressDe = textBoxAddressDe.Text; _therapist.Aifi = textBoxAifi.Text; _therapist.SaveToDB(); foreach (var a in priceListBindingSource) { var price = (PriceList)a; price.TherapistId = _therapist.Id; price.SaveToDB(); _priceLists.Add(price); } foreach (var t in treatmentBindingSource) { var treatment = (Treatment)t; treatment.TherapistId = _therapist.Id; treatment.SaveToDB(); _treatMentLists.Add(treatment); } FillDataBindings(); } }
private void richTextBoxExPostit_Leave(object sender, EventArgs e) { _therapist.Postit = richTextBoxExPostit.Rtf; using (var db = new Db.PhisioDB()) { db.Update(_therapist); } }
private void Setting_Load(object sender, EventArgs e) { using (var db = new Db.PhisioDB()) { _priceLists = db.PriceLists.ToList(); _treatMentLists = db.Treatments.ToList(); _therapist = db.Therapists.FirstOrDefault(); } FillDataBindings(); }
public AnamnesysView(Customer customer) { InitializeComponent(); if (customer != null) { using (var db = new Db.PhisioDB()) { _remoteAnamnesy = db.RemoteAnamnesys.FirstOrDefault(ra => ra.CustomerId == customer.Id); _recentAnamnesy = db.RecentAnamnesys.FirstOrDefault(ra => ra.CustomerId == customer.Id); } } }
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()); } }
public static List <string> GetTratmensByIdS(List <Guid> ids, string language) { using (var db = new Db.PhisioDB()) { var treatments = db.Treatments.Where(x => ids.Contains(x.Id)).ToList(); if (language == "german") { return(treatments.Select(x => x.DescriptionDe).ToList()); } return(treatments.Select(x => x.DescriptionIt).ToList()); } }
public Stomatognathic(Customer customer) { _customer = customer; using (var db = new Db.PhisioDB()) { StomatognathicTest = db.StomatognathicTests.FirstOrDefault(ra => ra.CustomerId == customer.Id); } if (StomatognathicTest == null) { StomatognathicTest = new StomatognathicTest(); } InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { //Helper.DriveManagement.DeleteAll(); CreateNameList(); AddDashBoard(); using (var db = new Db.PhisioDB()) { _therapist = db.Therapists.FirstOrDefault(); } if (_therapist != null) { BackupManager.SetBackupTimer(_therapist); } }
private string getDirectory() { Therapist therapist; using (var db = new Db.PhisioDB()) { therapist = db.Therapists.FirstOrDefault(); } var folderBase = Directory.GetParent(therapist.InvoicesFolder); var customersDirectory = Path.Combine(folderBase.FullName, "Customers"); Directory.CreateDirectory(customersDirectory); var customerDirectory = Path.Combine(customersDirectory, _customer.FullName.Replace(" ", "_")); Directory.CreateDirectory(customerDirectory); return(customerDirectory); }
public static List <string> GetATreatment(string language) { using (var db = new Db.PhisioDB()) { var treatment = db.Treatments.FirstOrDefault(); if (language == "german") { return new List <string> { treatment.DescriptionDe } } ; return(new List <string> { treatment.DescriptionIt }); } }
public static Guid SaveToDB <T>(T model) { var propertyInfo = typeof(T).GetProperty("Id"); var id = (Guid)propertyInfo.GetValue(model); using (var db = new Db.PhisioDB()) { if (id != null && id != Guid.Empty) { db.Update(model); } else { propertyInfo.SetValue(model, Guid.NewGuid()); id = Guid.Parse(db.InsertWithIdentity(model).ToString()); } return(id); } }
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(); }
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 RemoteAnamnesys(Customer customer) { InitializeComponent(); if (customer != null) { using (var db = new Db.PhisioDB()) { RemoteAnamnesy = db.RemoteAnamnesys.FirstOrDefault(ra => ra.CustomerId == customer.Id); } if (RemoteAnamnesy == null) { RemoteAnamnesy = new RemoteAnamnesy { Customer = customer, CustomerId = customer.Id }; } } }
public static DataModels.ProformaInvoice CreateNewProformaInvoice(List <DataModels.Visit> visits, out string message) { if (visits.Any(x => x.Invoiced)) { message = "Una delle visite selezionate è già stata fatturata!"; return(null); } if (visits.Any(x => x.Payed) && !visits.All(x => x.Payed)) { message = "Non è possibile fatturare un insieme di visite dove solo alcune sono state già pagate"; return(null); } var invoiceTile = ""; Therapist therapist = null; using (var db = new Db.PhisioDB()) { var proformaInvoices = db.ProformaInvoices.Where(x => x.Date >= new NpgsqlTypes.NpgsqlDate(DateTime.Now.Year, 1, 1)).ToList(); invoiceTile = $"{(proformaInvoices.Count + 1).ToString("0000")}/{DateTime.Now.Year}"; therapist = db.Therapists.FirstOrDefault(); } var newProformaInvoice = new DataModels.ProformaInvoice { Date = new NpgsqlTypes.NpgsqlDate(DateTime.Now), Discount = 0, Payed = false, Text = "", Visitsproformainvoiceidfkeys = visits, Title = invoiceTile, TaxStamp = false, TherapistId = therapist.Id, Deleted = false, GroupVisits = false }; message = ""; return(newProformaInvoice); }
private void GetInvoices() { using (var db = new Db.PhisioDB()) { Guid?custId = Customer?.Id; _proformaInvoices = db.ProformaInvoices.LoadWith(e1 => e1.Visitsproformainvoiceidfkeys.First().Treatmentsvisitidfkeys.First().Treatment).LoadWith(e1 => e1.Visitsproformainvoiceidfkeys.First().Customer.Address).LoadWith(x => x.Invoice) .Where(x => x.Visitsproformainvoiceidfkeys.Any(xx => xx.CustomerId == custId) || custId == null) .Where(x => (x.Date >= new NpgsqlTypes.NpgsqlDate(_dateFromFilter) && x.Date < new NpgsqlTypes.NpgsqlDate(_dateToFilter.AddDays(1)) || x.Invoice.Date >= new NpgsqlTypes.NpgsqlDate(_dateFromFilter) && x.Invoice.Date < new NpgsqlTypes.NpgsqlDate(_dateToFilter.AddDays(1))) && x.Deleted == false) .ToList(); _proformaInvoices = _proformaInvoices.OrderBy(x => x.Date).OrderBy(x => x.Invoice == null).ToList(); //Remove proforma with deleted visits _proformaInvoices = _proformaInvoices.Where(x => x.Visitsproformainvoiceidfkeys.Count() > 0).ToList(); if (_filterPayed > 0) { _proformaInvoices = _proformaInvoices.Where(x => x.Payed == (_filterPayed == 1)).ToList(); } if (checkBox1.Checked) { _proformaInvoices = _proformaInvoices.Where(x => x.Invoice != null).ToList(); } _proformaInvoices = _proformaInvoices.OrderBy(x => x.Invoice?.Title).ThenBy(x => x.Date).ThenBy(x => x.Title).ToList(); /* * var noinvoices = _proformaInvoices.Where(x => x.Invoice == null).ToList(); * foreach (var proformaInvoice in noinvoices) * { * if (proformaInvoice.Invoice == null) * { * _proformaInvoices.Remove(proformaInvoice); * _proformaInvoices.Add(proformaInvoice); * } * }*/ } }
private void Dashboard_Load(object sender, EventArgs e) { using (var db = new Db.PhisioDB()) { var today = DateTime.Today; var todayLstMonth = DateTime.Today.AddMonths(-1); _therapist = db.Therapists.FirstOrDefault(); _visitLatMonth = db.Visits.Where(x => x.Deleted == false && x.Date >= new NpgsqlTypes.NpgsqlDate(today.Year, today.Month, 1)).ToList(); _customerLastMonth = db.Customers.Where(x => x.CreationDate >= new NpgsqlTypes.NpgsqlDate(today.Year, today.Month, 1)).ToList(); _visitPreviousMonth = db.Visits.Where(x => x.Deleted == false && x.Date >= new NpgsqlTypes.NpgsqlDate(todayLstMonth.Year, todayLstMonth.Month, 1) && x.Date <= new NpgsqlTypes.NpgsqlDate(today.Year, today.Month, 1)).ToList(); _customerNoPrivacy = db.Customers.Where(x => x.Privacy == false).ToList(); var visitOpen = db.Visits.LoadWith(e1 => e1.Customer) .Where(v => v.Future && v.Invoiced).ToList(); _visitOpen = visitOpen.GroupBy(v => new { cId = v.Customer.Id, CFn = v.Customer.FullName }) .Select(gv => GetMyObject(gv.Key.CFn, gv.Count())).ToList(); dataGridView1.DefaultCellStyle.Font = new Font("Segoe UI Historic", 10); dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("Segoe UI Historic", 11); } FillFields(); }
private void GetVisits() { using (var db = new Db.PhisioDB()) { Guid?custId = _customer?.Id; _visits = db.Visits.LoadWith(e1 => e1.Treatmentsvisitidfkeys) .LoadWith(e1 => e1.Invoice) .LoadWith(e1 => e1.Customer) .Where(x => x.Customer.Id == custId || custId == null) .Where( x => x.Deleted == false && (x.Date >= new NpgsqlTypes.NpgsqlDate(_dateFromFilter) && x.Date < new NpgsqlTypes.NpgsqlDate(_dateToFilter.AddDays(1)) || x.Future == true)) .ToList(); _visits = _visits.OrderBy(x => x.Date).ToList(); if (_filterInvoiced > 0) { _visits = _visits.Where(x => x.Invoiced == (_filterInvoiced == 1 ? true : false)).ToList(); } if (_filterPayed > 0) { _visits = _visits.Where(x => x.Payed == (_filterPayed == 1 ? true : false)).ToList(); } if (_filterProforma > 0) { _visits = _visits.Where(x => x.ProformaInvoiced == (_filterProforma == 1 ? true : false)).ToList(); } if (_filterProforma > 0) { _visits = _visits.Where(x => x.ProformaInvoiced == (_filterProforma == 1 ? true : false)).ToList(); } if (_filterFuture == false) { _visits = _visits.Where(x => !x.Future).ToList(); } } }
private void CreateNameList() { using (var db = new Db.PhisioDB()) { if (textBoxFilter.Text.Length > 0) { customers = db.Customers.LoadWith(e1 => e1.Address).LoadWith(e1 => e1.Pricelist).Where(x => x.Surname.ToLower().Contains(textBoxFilter.Text.ToLower()) || x.Name.ToLower().Contains(textBoxFilter.Text.ToLower())).ToList(); } else { customers = db.Customers.LoadWith(e1 => e1.Address).LoadWith(e1 => e1.Pricelist).ToList(); } } if (customers != null) { customers = customers.OrderByDescending(x => x.FullName).ToList(); customers.Add(null); this.panel2.Controls.Clear(); var panelHeight = 0; foreach (var customer in customers) { var listItemName = new UI.PatientListItem(customer); listItemName.Dock = System.Windows.Forms.DockStyle.Top; listItemName.Location = new System.Drawing.Point(0, 60); listItemName.Size = new System.Drawing.Size(175, 60); listItemName.TabIndex = 0; listItemName.UserClicked += OnNameClicked; if (customer == null) { listItemName.BackColor = Color.FromArgb(255, 236, 236); } this.panel2.Controls.Add(listItemName); panelHeight += 75; } this.panel2.Size = new Size(this.panel4.Size.Width, panelHeight); } }
private void checkBox2_CheckedChanged(object sender, EventArgs e) { if (!_loaded) { return; } using (var db = new Db.PhisioDB()) { if (ProformaInvoice.Id != null) { ProformaInvoice.Payed = checkBox2.Checked; foreach (var visit in ProformaInvoice.Visitsproformainvoiceidfkeys) { visit.Payed = checkBox2.Checked; db.Update(visit); } db.Update(ProformaInvoice); ChangePayed?.Invoke(this, e); } } }
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"); } }
private void InvoiceCtrl_Load(object sender, EventArgs e) { bool invoiced = ProformaInvoice.Invoice != null; labelInviceName.Text = invoiced ? ProformaInvoice.Invoice.Title : "Non ancora fatturato"; labelInviceDate.Text = invoiced ? $"del {((DateTime)ProformaInvoice.Invoice.Date).ToShortDateString()}" : ""; textBoxDiscount.Text = "0"; labelName.Text = ProformaInvoice.Title; labelProformaData.Text = $"del {((DateTime)ProformaInvoice.Date).ToShortDateString()}"; var aVisit = ProformaInvoice.Visitsproformainvoiceidfkeys.FirstOrDefault(); checkBoxGroup.Checked = ProformaInvoice.GroupVisits; if (_edit) { textBoxDiscount.ReadOnly = true; checkBox1.Enabled = false; checkBoxPayed.Enabled = true; if (invoiced) { buttonSave.Visible = false; } else { buttonSave.Text = "Genera Fattura"; } } else { checkBoxPayed.Enabled = false; } if (aVisit != null) { using (var db = new Db.PhisioDB()) { var cust = db.Customers.LoadWith(e1 => e1.Address).LoadWith(e1 => e1.Pricelist).FirstOrDefault(x => x.Id == aVisit.Customer.Id); aVisit.Customer = cust; } _customer = aVisit.Customer; labelCustomerName.Text = aVisit.Customer.FullName; labelFiscalCode.Text = aVisit.Customer.Fiscalcode; } var y = 0; foreach (var visit in ProformaInvoice.Visitsproformainvoiceidfkeys) { Panel panelIn = new Panel(); panelIn.Dock = DockStyle.Top; panel1.Controls.Add(panelIn); Label labelVisit = new Label(); labelVisit.Location = new Point(0, 0); labelVisit.Font = new System.Drawing.Font("Segoe UI Historic", 11.25F); labelVisit.Text = $"• {((DateTime)visit.Date).ToShortDateString()}"; panelIn.Controls.Add(labelVisit); var treatments = Helper.Helper.GetTratmensByIdS(visit.Treatmentsvisitidfkeys.Select(x => x.TreatmentId).ToList(), aVisit.Customer.Language); if (treatments.Count == 0) { treatments = Helper.Helper.GetATreatment(aVisit.Customer.Language); } Label lableTreatment = new Label(); lableTreatment.Location = new Point((int)(panel1.Width * .2), 0); lableTreatment.AutoSize = false; lableTreatment.Font = new System.Drawing.Font("Segoe UI Historic", 11.25F); lableTreatment.Text = string.Join(Environment.NewLine, treatments); lableTreatment.Size = new Size(panel1.Width - (int)(panel1.Width * .2) - 200, LineHeight * treatments.Count()); lableTreatment.Padding = new Padding(20, 0, 0, 0); panelIn.Controls.Add(lableTreatment); Label labelPrice = new Label(); labelPrice.Location = new Point((int)(panel1.Width - 106), 0); labelPrice.Font = new Font("Segoe UI Historic", 11.25F); labelPrice.Text = $"{visit.Price} €"; labelPrice.AutoSize = false; labelPrice.Anchor = AnchorStyles.Top | AnchorStyles.Right; labelPrice.Size = new Size(60, LineHeight * treatments.Count()); panelIn.Controls.Add(labelPrice); /* * Label labelPriceRivalsa = new Label(); * labelPriceRivalsa.Location = new Point((int)(panel1.Width - 106), 0); * labelPriceRivalsa.Font = new Font("Segoe UI Historic", 11.25F); * labelPriceRivalsa.Text = $"{((double)visit.Price * 1).ToString("#.00")} €"; * labelPriceRivalsa.AutoSize = false; * labelPriceRivalsa.Size = new Size(60, LineHeight * treatments.Count()); * labelPriceRivalsa.Anchor = AnchorStyles.Top | AnchorStyles.Right; * panelIn.Controls.Add(labelPriceRivalsa); */ panelIn.Location = new Point(0, y); panelIn.Size = new Size(panel1.Width, Math.Max(labelVisit.Height, lableTreatment.Height) + 10); checkBox1.Checked = ProformaInvoice.TaxStamp; checkBoxContanti.Checked = ProformaInvoice.Contanti; y += panelIn.Height; } var total = CalculateTotal(false); labelRivalsaSconto.Text = "0"; if (!ProformaInvoice.IsInitialized()) { if (total > 77.47) { checkBox1.Checked = true; } else { checkBox1.Checked = false; } } labelTotal.Text = CalculateTotal(true).ToString(); checkBoxPayed.Checked = ProformaInvoice.Payed; if (ProformaInvoice.Payed == true) { dateTimePickerPayed.Enabled = true; dateTimePickerPayed.Value = (DateTime)ProformaInvoice.PayedDate; dateTimePickerPayed.Format = DateTimePickerFormat.Short; } else { dateTimePickerPayed.Enabled = false; dateTimePickerPayed.Format = DateTimePickerFormat.Custom; dateTimePickerPayed.CustomFormat = " "; } _initialization = false; }