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 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); }
} // 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); } } } } }
private void richTextBoxExPostit_Leave(object sender, EventArgs e) { _therapist.Postit = richTextBoxExPostit.Rtf; using (var db = new Db.PhisioDB()) { db.Update(_therapist); } }
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); } } }
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); } }