using System; using System.Collections.Generic; using Datalib.EntityClasses; using Datalib.HelperClasses; using System.Linq; using Datalib.Linq; using System.Windows.Forms; namespace PatientMan.Forms { public partial class frmTreatment : PatientMan.BasicForms.frmCommon { public EntityCollection TreatmentInfo = new EntityCollection(); public frmTreatment() { InitializeComponent(); } private void frmTreatment_Load(object sender, EventArgs e) { LinqMetaData MetaData = new LinqMetaData(); MetaData.AdapterToUse = adapter; //var pro = new EntityCollection(); //var Agency = new EntityCollection(); var regimen = (from q in MetaData.TblRegimen select new { q.Regimenid, RegimenName = SettingInfo.Language == 0 ? q.VRegimenname : q.ERegimenName }).ToList(); //var tests = new EntityCollection(); var treatments = (from q in MetaData.TblTreatment select new { q.TreatmentId, TreatmentDes = SettingInfo.Language == 0 ? q.VTreatmentDes : q.ETreatmentDes }).ToList(); var Patients = (from q in MetaData.TblPatient select new { q.PatientId, PatientName=strUtil.Decrypt(q.PatientName) }).ToList(); //adapter.FetchEntityCollection(pro, null); //adapter.FetchEntityCollection(Agency, null); //adapter.FetchEntityCollection(regimen, null); //adapter.FetchEntityCollection(tests, null); //adapter.FetchEntityCollection(treatments, null); //adapter.FetchEntityCollection(Patients, null); //_province.DataSource = pro; //_AgencyType.DataSource = Agency; _regimen.DataSource = regimen; //_test.DataSource = tests; _treatment.DataSource = treatments; _Patients.DataSource = Patients; adapter.FetchEntityCollection(TreatmentInfo, null); LoadData(); } public override void LoadData() { usrTreatment.TreatmentInfos = TreatmentInfo; grdTreatmentInfo.DataSource = TreatmentInfo; usrTreatment.BindingData(); usrTreatment.LoadLibrary(); } private void gridView_DoubleClick(object sender, EventArgs e) { if (TreatmentInfo.Count == 0) { return; } var PatientId = TreatmentInfo[BindingContext[TreatmentInfo].Position].PatientId; var frm = new frmPatientInfo(); frm.PatientsCollection = new EntityCollection(); var PatientInfo = new TblPatientEntity(PatientId); adapter.FetchEntity(PatientInfo); frm.PatientsCollection.Add(PatientInfo); frm.PatientInfo = PatientInfo; frm.LoadData(); frm.gotoTreatment(); frm.ShowDialog(); } private void barPrint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { grdTreatmentInfo.ShowPrintPreview(); } private void barButtonView_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (TreatmentInfo.Count == 0) { return; } var PatientId = TreatmentInfo[BindingContext[TreatmentInfo].Position].PatientId; var frm = new frmPatientInfo(); frm.PatientsCollection = new EntityCollection(); var PatientInfo = new TblPatientEntity(PatientId); adapter.FetchEntity(PatientInfo); frm.PatientsCollection.Add(PatientInfo); frm.PatientInfo = PatientInfo; frm.LoadData(); frm.gotoTreatment(); frm.ShowDialog(); } private void barAutoUpdate_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { (new PatientMan.Classes.Actions.clsUpdateReferralArv()).UpdateArv(); var Treats = TreatmentInfo.Where(m => m.TreatmentId == "01").GroupBy(m => m.PatientId).Select(m => m.First()).ToList(); foreach( TblTreatmentInfoEntity tr in Treats) { string PatientId = tr.PatientId; DateTime ArvDate = tr.TreatmentSdate.Value; TblPatientEntity patient = new TblPatientEntity(PatientId); adapter.FetchEntity(patient); if(patient.HaveArvBefore!=1) { patient.DateofArv = ArvDate; patient.Regimenid = tr.Regimenid; adapter.SaveEntity(patient); } } MessageBox.Show("Task is completed"); } } }