1018 lines
36 KiB
C#
1018 lines
36 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using System.Collections.Generic;
|
|
using Datalib.EntityClasses;
|
|
using Datalib.HelperClasses;
|
|
using System.Linq;
|
|
using Datalib.Linq;
|
|
using Datalib.FactoryClasses;
|
|
using SD.LLBLGen.Pro.ORMSupportClasses.Miscellaneous;
|
|
using SD.LLBLGen.Pro.ORMSupportClasses;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraGrid;
|
|
namespace PatientMan.Forms
|
|
{
|
|
public partial class frmPatientInfo : PatientMan.BasicForms.frmCommon
|
|
{
|
|
public TblPatientEntity PatientInfo { get; set; }
|
|
private EntityCollection<TblChildEntity> Children { get; set; }
|
|
|
|
|
|
public EntityCollection<TblPatientEntity> PatientsCollection { get; set; }
|
|
private int TabNo = 0;
|
|
public frmPatientInfo()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public override void SaveRecord()
|
|
{
|
|
|
|
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
usrPatientInfo.SaveRecord();
|
|
|
|
usrPatientInfo.ControlEnabled = false;
|
|
break;
|
|
case 1:
|
|
usrExamInfo.SaveRecord();
|
|
usrExamInfo.ControlEnabled = false;
|
|
grdExam.Enabled = true;
|
|
break;
|
|
case 2:
|
|
usrClinlicInfo.SaveRecord();
|
|
usrClinlicInfo.ControlEnabled = false;
|
|
grdClinicInfo.Enabled = true;
|
|
break;
|
|
case 3:
|
|
usrPreClinicInfo.SaveRecord();
|
|
usrPreClinicInfo.ControlEnabled = false;
|
|
grdPreClinicInfo.Enabled = true;
|
|
break;
|
|
case 4:
|
|
usrTreatment.SaveRecord();
|
|
usrTreatment.ControlEnabled = false;
|
|
grdTreatmentInfo.Enabled = true;
|
|
break;
|
|
case 5:
|
|
usrReferralInfo.SaveRecord();
|
|
usrReferralInfo.ControlEnabled = false;
|
|
grdReferralInfo.Enabled = true;
|
|
break;
|
|
case 6:
|
|
usrReferralService.SaveRecord();
|
|
usrReferralService.ControlEnabled = false;
|
|
grdReferralService.Enabled = true;
|
|
break;
|
|
case 7:
|
|
var frm = new frmShowSaveInfo();
|
|
frm.Show();
|
|
savePregnance();
|
|
break;
|
|
case 8:
|
|
usrDiary.SaveRecord();
|
|
usrDiary.ControlEnabled = false;
|
|
grdDiary.Enabled = true;
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void savePregnance()
|
|
{
|
|
foreach( TblPregnanceInfoEntity Preg in PatientInfo .TblPregnanceInfos)
|
|
{
|
|
foreach (TblChildEntity Child in Preg.TblChildren)
|
|
{
|
|
|
|
if (Child.UniqueKey==string.Empty)
|
|
{
|
|
Child.UniqueKey = Guid.NewGuid().ToString("N");
|
|
|
|
}
|
|
}
|
|
adapter.SaveEntityCollection(PatientInfo.TblPregnanceInfos, true, true);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
public override void NewRecord()
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
NewPatient();
|
|
break;
|
|
case 1:
|
|
NewExam();
|
|
break;
|
|
case 2:
|
|
NewClinic();
|
|
break;
|
|
case 3:
|
|
NewPreClinic();
|
|
break;
|
|
case 4:
|
|
NewTreatment();
|
|
break;
|
|
case 5:
|
|
NewReferral();
|
|
break;
|
|
case 6:
|
|
NewReferralService();
|
|
break;
|
|
case 7:
|
|
NewPregnance();
|
|
break;
|
|
case 8:
|
|
NewDiary();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void PatientTab_Selected(object sender, DevExpress.XtraTab.TabPageEventArgs e)
|
|
{
|
|
TabNo = e.PageIndex;
|
|
}
|
|
|
|
public void NewPatient ()
|
|
{
|
|
Delete.Enabled = false;
|
|
r.Enabled = false;
|
|
Adnew.Enabled = false;
|
|
Print.Enabled = false;
|
|
Cancel.Enabled = true;
|
|
Save.Enabled = true;
|
|
BindingContext[PatientsCollection].AddNew();
|
|
usrPatientInfo.PatientsCollection = PatientsCollection;
|
|
PatientInfo = PatientsCollection[BindingContext[PatientsCollection].Position];
|
|
if (((TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position]).PatientId.Length == 0)
|
|
{
|
|
// ((TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position]).PatientId = (new Utility()).GetDefaultPatientID();
|
|
}
|
|
//PatientInfo.PatientId = (new Utility()).GetDefaultPatientID();
|
|
usrPatientInfo.PatientInfor = PatientInfo;
|
|
usrExamInfo.ExamInfos = PatientInfo.TblExaminationInfos;
|
|
usrPreClinicInfo.PreClinicsInfos = PatientInfo.TblPreClinicsInfos;
|
|
usrClinlicInfo.ClinicInfos = PatientInfo.TblExaminationInfos;
|
|
usrTreatment.TreatmentInfos = PatientInfo.TblTreatmentInfos;
|
|
usrReferralInfo.ReferralInfos = PatientInfo.TblReferralsTos;
|
|
usrReferralService.ReferralService = PatientInfo.TblReferraltoServices;
|
|
usrDiary.Diary = PatientInfo.TblDiaries;
|
|
usrPatientInfo.BindingData();
|
|
usrExamInfo.BindingData();
|
|
usrClinlicInfo.BindingData();
|
|
usrPreClinicInfo.BindingData();
|
|
usrTreatment.BindingData();
|
|
usrReferralInfo.BindingData();
|
|
usrDiary.BindingData();
|
|
usrPreClinicInfo.LoadLibrary();
|
|
usrPatientInfo.LoadLibrary();
|
|
usrTreatment.LoadLibrary();
|
|
usrReferralInfo.LoadLibrary();
|
|
usrReferralService.LoadLibrary();
|
|
usrPreClinicInfo.LoadLibrary();
|
|
usrExamInfo.LoadLibrary();
|
|
usrDiary.LoadLibrary();
|
|
grdExam.DataSource = PatientInfo.TblExaminationInfos;
|
|
grdPreClinicInfo.DataSource = PatientInfo.TblPreClinicsInfos;
|
|
grdClinicInfo.DataSource = PatientInfo.TblExaminationInfos;
|
|
grdTreatmentInfo.DataSource = PatientInfo.TblTreatmentInfos;
|
|
grdReferralInfo.DataSource = PatientInfo.TblReferralsTos;
|
|
grdReferralService.DataSource = PatientInfo.TblReferraltoServices;
|
|
grdDiary.DataSource = PatientInfo.TblDiaries;
|
|
usrPatientInfo.ControlEnabled = true;
|
|
}
|
|
public override void LoadData()
|
|
{
|
|
usrPatientInfo.PatientsCollection = PatientsCollection;
|
|
PatientInfo.PatientName = strUtil.Decrypt(PatientInfo.PatientName);
|
|
usrPatientInfo.PatientInfor = PatientInfo;
|
|
usrExamInfo.PatientInfor = PatientInfo;
|
|
usrExamInfo.LoadData();
|
|
usrPreClinicInfo.PatientInfor = PatientInfo;
|
|
usrPreClinicInfo.LoadData();
|
|
usrClinlicInfo.PatientInfor = PatientInfo;
|
|
usrClinlicInfo.LoadData();
|
|
usrTreatment.PatientInfor = PatientInfo;
|
|
usrTreatment.LoadData();
|
|
usrReferralInfo.PatientInfor = PatientInfo;
|
|
usrReferralInfo.LoadData();
|
|
usrReferralService.PatientInfor = PatientInfo;
|
|
usrReferralService.LoadData();
|
|
usrDiary.PatientInfor = PatientInfo;
|
|
usrDiary.LoadData();
|
|
loadPregance();
|
|
grdExam.DataSource = PatientInfo.TblExaminationInfos;
|
|
grdPreClinicInfo.DataSource = PatientInfo.TblPreClinicsInfos;
|
|
grdClinicInfo.DataSource = PatientInfo.TblExaminationInfos;
|
|
grdTreatmentInfo.DataSource = PatientInfo.TblTreatmentInfos;
|
|
grdReferralInfo.DataSource = PatientInfo.TblReferralsTos;
|
|
grdPregnance.DataSource = PatientInfo.TblPregnanceInfos;
|
|
|
|
grdDiary.DataSource = PatientInfo.TblDiaries;
|
|
grdReferralService.DataSource = PatientInfo.TblReferraltoServices;
|
|
|
|
|
|
usrPatientInfo.BindingData();
|
|
usrExamInfo.BindingData();
|
|
usrClinlicInfo.BindingData();
|
|
usrPreClinicInfo.BindingData();
|
|
usrTreatment.BindingData();
|
|
usrReferralInfo.BindingData();
|
|
usrDiary.BindingData();
|
|
usrReferralService.BindingData();
|
|
|
|
usrPatientInfo.LoadLibrary();
|
|
usrTreatment.LoadLibrary();
|
|
usrReferralInfo.LoadLibrary();
|
|
usrReferralService.LoadLibrary();
|
|
usrPreClinicInfo.LoadLibrary();
|
|
usrExamInfo.LoadLibrary();
|
|
usrDiary.LoadLibrary();
|
|
usrPreClinicInfo.LoadLibrary();
|
|
}
|
|
private void NewExam()
|
|
{
|
|
usrExamInfo.ControlEnabled = true;
|
|
grdExam.Enabled = false;
|
|
BindingContext[PatientInfo.TblExaminationInfos].AddNew();
|
|
((TblExaminationInfoEntity)PatientInfo.TblExaminationInfos[BindingContext[PatientInfo.TblExaminationInfos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void loadPregance()
|
|
{
|
|
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)Datalib.EntityType.TblPregnanceInfoEntity);
|
|
prefetchPath.Add(TblPregnanceInfoEntity.PrefetchPathTblChildren);
|
|
adapter.FetchEntityCollection(PatientInfo.TblPregnanceInfos, PatientInfo.GetRelationInfoTblPregnanceInfos(), prefetchPath);
|
|
|
|
|
|
}
|
|
private void NewPreClinic()
|
|
{
|
|
grdPreClinicInfo.Enabled = false;
|
|
usrPreClinicInfo.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblPreClinicsInfos].AddNew();
|
|
((TblPreClinicsInfoEntity)PatientInfo.TblPreClinicsInfos[BindingContext[PatientInfo.TblPreClinicsInfos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
((TblPreClinicsInfoEntity)PatientInfo.TblPreClinicsInfos[BindingContext[PatientInfo.TblPreClinicsInfos].Position]).TestDate = common.testdate;
|
|
usrPreClinicInfo.TestDate.DateTime = common.testdate;
|
|
}
|
|
private void NewClinic()
|
|
{
|
|
grdClinicInfo.Enabled = false;
|
|
usrClinlicInfo.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblClinicInfos].AddNew();
|
|
((TblClinicInfoEntity)PatientInfo.TblClinicInfos[BindingContext[PatientInfo.TblClinicInfos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
((TblClinicInfoEntity)PatientInfo.TblClinicInfos[BindingContext[PatientInfo.TblClinicInfos].Position]).ClinicDate = common.visitdate.Date;
|
|
usrClinlicInfo.ClinicDate.DateTime = common.visitdate;
|
|
}
|
|
private void NewTreatment()
|
|
{
|
|
usrTreatment.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblTreatmentInfos].AddNew();
|
|
((TblTreatmentInfoEntity)PatientInfo.TblTreatmentInfos[BindingContext[PatientInfo.TblTreatmentInfos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
private void NewReferral()
|
|
{
|
|
grdReferralInfo.Enabled = false;
|
|
usrReferralInfo.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblReferralsTos].AddNew();
|
|
|
|
((TblReferralsToEntity)PatientInfo.TblReferralsTos[BindingContext[PatientInfo.TblReferralsTos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void NewReferralService()
|
|
{
|
|
|
|
grdReferralService.Enabled = false;
|
|
usrReferralService.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblReferraltoServices].AddNew();
|
|
((TblReferraltoServiceEntity)PatientInfo.TblReferraltoServices[BindingContext[PatientInfo.TblReferraltoServices].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void NewDiary()
|
|
{
|
|
grdDiary.Enabled = false;
|
|
usrDiary.ControlEnabled = true;
|
|
BindingContext[PatientInfo.TblDiaries].AddNew();
|
|
|
|
((TblDiaryEntity)PatientInfo.TblDiaries[BindingContext[PatientInfo.TblDiaries].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void NewPregnance ()
|
|
{
|
|
grdPregnance.Enabled = true;
|
|
BindingContext[PatientInfo.TblPregnanceInfos].AddNew();
|
|
|
|
((TblPregnanceInfoEntity)PatientInfo.TblPregnanceInfos[BindingContext[PatientInfo.TblPregnanceInfos].Position]).UniqueKey = System.Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void frmPatientInfo_Load(object sender, EventArgs e)
|
|
{
|
|
LinqMetaData MetaData = new LinqMetaData();
|
|
MetaData.AdapterToUse = adapter;
|
|
|
|
var pro = (from q in MetaData.TblProvince select new { q.Provinceid, q.Provincename }).ToList();
|
|
var Agency = (from q in MetaData.TblAgency select new { q.AgencyTypeId, AgencyTypeName= SettingInfo.Language==0?q.EAgencyTypeName:q.EAgencyTypeName }).ToList();
|
|
var regimen = (from q in MetaData.TblRegimen select new { q.Regimenid, RegimenName = SettingInfo.Language == 0 ? q.VRegimenname : q.ERegimenName }).ToList();
|
|
var tests = (from q in MetaData.TblTest select new { q.Testid, TestName = SettingInfo.Language == 0 ? q.VTestName : q.ETestName }).ToList();
|
|
var treatments = (from q in MetaData.TblTreatment select new { q.TreatmentId, TreatmentDes = SettingInfo.Language == 0 ? q.VTreatmentDes : q.ETreatmentDes }).ToList();
|
|
|
|
_province.DataSource = pro;
|
|
_AgencyType.DataSource = Agency;
|
|
_regimen.DataSource = regimen;
|
|
_test.DataSource = tests;
|
|
_treatment.DataSource = treatments;
|
|
}
|
|
|
|
|
|
|
|
private void First_Click(object sender, EventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
PatientFirst();
|
|
break;
|
|
case 1:
|
|
ExamFirst();
|
|
break;
|
|
case 2:
|
|
ClinicFirst();
|
|
break;
|
|
case 3:
|
|
PreClinicFirst();
|
|
break;
|
|
case 4:
|
|
TreatmentFirst();
|
|
break;
|
|
case 5:
|
|
ReferralFirst();
|
|
break;
|
|
case 6:
|
|
PregnanceFirst();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Prev_Click(object sender, EventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
PatientPrev();
|
|
break;
|
|
case 1:
|
|
ExamPrev();
|
|
break;
|
|
case 2:
|
|
ClinicPrev();
|
|
break;
|
|
case 3:
|
|
PreClinicPrev();
|
|
break;
|
|
case 4:
|
|
TreatmentPrev();
|
|
break;
|
|
case 5:
|
|
ReferralPrev();
|
|
break;
|
|
case 6:
|
|
PregnancePrev();
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Next_Click(object sender, EventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
PatientNext();
|
|
break;
|
|
case 1:
|
|
ExamNext();
|
|
break;
|
|
case 2:
|
|
ClinicFirst();
|
|
break;
|
|
case 3:
|
|
PreClinicFirst();
|
|
break;
|
|
case 4:
|
|
TreatmentFirst();
|
|
break;
|
|
case 5:
|
|
ReferralFirst();
|
|
break;
|
|
case 6:
|
|
PregnanceFirst();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Last_Click(object sender, EventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
PatientLast();
|
|
break;
|
|
case 1:
|
|
ExamLast();
|
|
break;
|
|
case 2:
|
|
ClinicLast();
|
|
break;
|
|
case 3:
|
|
PreClinicLast();
|
|
break;
|
|
case 4:
|
|
TreatmentLast();
|
|
break;
|
|
case 5:
|
|
ReferralLast();
|
|
break;
|
|
case 6:
|
|
PregnanceLast();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void PatientLast()
|
|
{
|
|
if (BindingContext[PatientsCollection].Count > 0)
|
|
{
|
|
BindingContext[PatientsCollection].Position = BindingContext[PatientsCollection].Count - 1;
|
|
PatientInfo = (TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position];
|
|
}
|
|
LoadData();
|
|
}
|
|
|
|
public void PatientFirst()
|
|
{
|
|
if (BindingContext[PatientsCollection].Count > 0)
|
|
{
|
|
BindingContext[PatientsCollection].Position = 0;
|
|
PatientInfo = (TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position];
|
|
}
|
|
LoadData();
|
|
}
|
|
public void PatientNext()
|
|
{
|
|
if (BindingContext[PatientsCollection].Count > 0 && BindingContext[PatientsCollection].Position != BindingContext[PatientsCollection].Count - 1)
|
|
{
|
|
BindingContext[PatientsCollection].Position = BindingContext[PatientsCollection].Position + 1;
|
|
PatientInfo = (TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position];
|
|
}
|
|
LoadData();
|
|
}
|
|
public void PatientPrev()
|
|
{
|
|
if (BindingContext[PatientsCollection].Count > 0)
|
|
{
|
|
BindingContext[PatientsCollection].Position = BindingContext[PatientsCollection].Position - 1;
|
|
PatientInfo = (TblPatientEntity)PatientsCollection[BindingContext[PatientsCollection].Position];
|
|
}
|
|
LoadData();
|
|
}
|
|
|
|
|
|
public void ExamLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblExaminationInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblExaminationInfos].Position = BindingContext[PatientInfo.TblExaminationInfos].Count - 1;
|
|
}
|
|
}
|
|
|
|
public void ExamFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblExaminationInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblExaminationInfos].Position = 0;
|
|
}
|
|
}
|
|
public void ExamNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblExaminationInfos].Count > 0 && BindingContext[PatientInfo.TblExaminationInfos].Position != BindingContext[PatientInfo.TblExaminationInfos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblExaminationInfos].Position = BindingContext[PatientInfo.TblExaminationInfos].Position + 1;
|
|
}
|
|
}
|
|
public void ExamPrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblExaminationInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblExaminationInfos].Position = BindingContext[PatientInfo.TblExaminationInfos].Position - 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void PreClinicLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblExaminationInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPreClinicsInfos].Position = BindingContext[PatientInfo.TblPreClinicsInfos].Count - 1;
|
|
}
|
|
}
|
|
|
|
public void PreClinicFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPreClinicsInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPreClinicsInfos].Position = 0;
|
|
}
|
|
}
|
|
public void PreClinicNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPreClinicsInfos].Count > 0 && BindingContext[PatientInfo.TblPreClinicsInfos].Position != BindingContext[PatientInfo.TblPreClinicsInfos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblPreClinicsInfos].Position = BindingContext[PatientInfo.TblPreClinicsInfos].Position + 1;
|
|
}
|
|
}
|
|
public void PreClinicPrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPreClinicsInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPreClinicsInfos].Position = BindingContext[PatientInfo.TblPreClinicsInfos].Position - 1;
|
|
}
|
|
}
|
|
|
|
|
|
public void ClinicLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblClinicInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblClinicInfos].Position = BindingContext[PatientInfo.TblClinicInfos].Count - 1;
|
|
}
|
|
}
|
|
public void ClinicFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblClinicInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblClinicInfos].Position = 0;
|
|
}
|
|
}
|
|
public void ClinicNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblClinicInfos].Count > 0 && BindingContext[PatientInfo.TblClinicInfos].Position != BindingContext[PatientInfo.TblClinicInfos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblClinicInfos].Position = BindingContext[PatientInfo.TblClinicInfos].Position + 1;
|
|
}
|
|
}
|
|
public void ClinicPrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblClinicInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblClinicInfos].Position = BindingContext[PatientInfo.TblClinicInfos].Position - 1;
|
|
}
|
|
}
|
|
public void TreatmentLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblTreatmentInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblTreatmentInfos].Position = BindingContext[PatientInfo.TblTreatmentInfos].Count - 1;
|
|
}
|
|
}
|
|
public void TreatmentFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblTreatmentInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblTreatmentInfos].Position = 0;
|
|
}
|
|
}
|
|
public void TreatmentNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblTreatmentInfos].Count > 0 && BindingContext[PatientInfo.TblTreatmentInfos].Position != BindingContext[PatientInfo.TblTreatmentInfos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblTreatmentInfos].Position = BindingContext[PatientInfo.TblTreatmentInfos].Position + 1;
|
|
}
|
|
}
|
|
public void TreatmentPrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblTreatmentInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblTreatmentInfos].Position = BindingContext[PatientInfo.TblTreatmentInfos].Position - 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void ReferralLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblReferralsTos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblReferralsTos].Position = BindingContext[PatientInfo.TblReferralsTos].Count - 1;
|
|
}
|
|
}
|
|
public void ReferralFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblReferralsTos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblReferralsTos].Position = 0;
|
|
}
|
|
}
|
|
public void ReferralNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblReferralsTos].Count > 0 && BindingContext[PatientInfo.TblReferralsTos].Position != BindingContext[PatientInfo.TblReferralsTos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblReferralsTos].Position = BindingContext[PatientInfo.TblReferralsTos].Position + 1;
|
|
}
|
|
}
|
|
public void ReferralPrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblReferralsTos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblReferralsTos].Position = BindingContext[PatientInfo.TblReferralsTos].Position - 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void PregnanceLast()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPregnanceInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPregnanceInfos].Position = BindingContext[PatientInfo.TblPregnanceInfos].Count - 1;
|
|
}
|
|
}
|
|
public void PregnanceFirst()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPregnanceInfos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPregnanceInfos].Position = 0;
|
|
}
|
|
}
|
|
public void PregnanceNext()
|
|
{
|
|
if (BindingContext[PatientInfo.TblPregnanceInfos].Count > 0 && BindingContext[PatientInfo.TblPregnanceInfos].Position != BindingContext[PatientInfo.TblPregnanceInfos].Count - 1)
|
|
{
|
|
BindingContext[PatientInfo.TblPregnanceInfos].Position = BindingContext[PatientInfo.TblPregnanceInfos].Position + 1;
|
|
}
|
|
}
|
|
public void PregnancePrev()
|
|
{
|
|
if (BindingContext[PatientInfo.TblReferralsTos].Count > 0)
|
|
{
|
|
BindingContext[PatientInfo.TblPregnanceInfos].Position = BindingContext[PatientInfo.TblPregnanceInfos].Position - 1;
|
|
}
|
|
}
|
|
|
|
|
|
public void gotoPreclinic()
|
|
{
|
|
PatientTab.SelectedTabPage = PagePreClinic;
|
|
}
|
|
public void gotoClinic()
|
|
{
|
|
PatientTab.SelectedTabPage = PageVisitInfo;
|
|
}
|
|
public void gotoReferral()
|
|
{
|
|
PatientTab.SelectedTabPage = PageReferral;
|
|
}
|
|
|
|
public void gotoTreatment()
|
|
{
|
|
PatientTab.SelectedTabPage = PageTreatment;
|
|
}
|
|
public void gotoExam()
|
|
{
|
|
PatientTab.SelectedTabPage = PageVisitInfo;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Adnew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
Delete.Enabled = false;
|
|
r.Enabled = false;
|
|
Adnew.Enabled = false;
|
|
Print.Enabled = false;
|
|
Cancel.Enabled = true;
|
|
Save.Enabled = true;
|
|
NewRecord();
|
|
}
|
|
|
|
private void Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
usrPatientInfo.ControlEnabled = true;
|
|
break;
|
|
case 1:
|
|
if (PatientInfo.TblExaminationInfos.Count > 0)
|
|
{
|
|
usrExamInfo.ControlEnabled = true;
|
|
usrExamInfo.ControlArange();
|
|
grdExam.Enabled = false;
|
|
}
|
|
break;
|
|
case 2:
|
|
if (PatientInfo.TblClinicInfos.Count > 0)
|
|
{
|
|
usrClinlicInfo.ControlEnabled = true;
|
|
grdClinicInfo.Enabled = false;
|
|
}
|
|
break;
|
|
case 3:
|
|
if (PatientInfo.TblPreClinicsInfos.Count > 0)
|
|
{
|
|
usrPreClinicInfo.ControlEnabled = true;
|
|
grdPreClinicInfo.Enabled = false;
|
|
}
|
|
break;
|
|
case 4:
|
|
if (PatientInfo.TblTreatmentInfos.Count > 0)
|
|
{
|
|
usrTreatment.ControlEnabled = (PatientInfo.TblTreatmentInfos.Count > 0);
|
|
grdTreatmentInfo.Enabled = false;
|
|
}
|
|
break;
|
|
case 5:
|
|
if (PatientInfo.TblReferralsTos.Count > 0)
|
|
{
|
|
usrReferralInfo.ControlEnabled = true;
|
|
grdReferralInfo.Enabled = false;
|
|
}
|
|
break;
|
|
|
|
case 6:
|
|
if (PatientInfo.TblReferraltoServices.Count > 0)
|
|
{
|
|
|
|
usrReferralService.ControlEnabled = true;
|
|
grdReferralService.Enabled = false;
|
|
}
|
|
break;
|
|
case 7:
|
|
grdPregnance.Enabled = (PatientInfo.TblPregnanceInfos.Count > 0);
|
|
break;
|
|
|
|
case 8:
|
|
if (PatientInfo.TblDiaries.Count > 0)
|
|
{
|
|
usrDiary.ControlEnabled = true;
|
|
grdDiary.Enabled = false;
|
|
}
|
|
break;
|
|
}
|
|
Delete.Enabled = false;
|
|
Adnew.Enabled = false;
|
|
r.Enabled = false;
|
|
Cancel.Enabled = true;
|
|
Save.Enabled = true;
|
|
Delete.Enabled = false;
|
|
r.Enabled = false;
|
|
}
|
|
|
|
private void Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
SaveRecord();
|
|
Delete.Enabled = true;
|
|
r.Enabled = true;
|
|
Adnew.Enabled = true;
|
|
Cancel.Enabled = false;
|
|
Save.Enabled = false;
|
|
}
|
|
|
|
private void Print_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
break;
|
|
case 2:
|
|
|
|
break;
|
|
case 3:
|
|
|
|
break;
|
|
case 4:
|
|
|
|
break;
|
|
case 5:
|
|
if (PatientInfo.TblReferralsTos.Count > 0)
|
|
{
|
|
usrReferralInfo.Print();
|
|
}
|
|
break;
|
|
case 6:
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Cancel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
usrPatientInfo.Cancel();
|
|
usrPatientInfo.ControlEnabled = false;
|
|
break;
|
|
case 1:
|
|
usrExamInfo.Cancel();
|
|
usrExamInfo.ControlEnabled = false;
|
|
grdExam.Enabled = true;
|
|
break;
|
|
case 2:
|
|
usrClinlicInfo.Cancel();
|
|
usrClinlicInfo.ControlEnabled = false;
|
|
grdClinicInfo.Enabled = true;
|
|
break;
|
|
case 3:
|
|
usrPreClinicInfo.Cancel();
|
|
usrPreClinicInfo.ControlEnabled = false;
|
|
grdPreClinicInfo.Enabled = true;
|
|
break;
|
|
case 4:
|
|
usrTreatment.Cancel();
|
|
usrTreatment.ControlEnabled = false;
|
|
grdTreatmentInfo.Enabled = true;
|
|
break;
|
|
case 5:
|
|
usrReferralInfo.Cancel();
|
|
usrReferralInfo.ControlEnabled = false;
|
|
grdReferralInfo.Enabled = true;
|
|
break;
|
|
|
|
case 6:
|
|
usrReferralService.Cancel();
|
|
usrReferralService.ControlEnabled = false;
|
|
grdReferralService.Enabled = true;
|
|
break;
|
|
case 7:
|
|
BindingContext[PatientInfo.TblPregnanceInfos].CancelCurrentEdit();
|
|
grdPregnance.Enabled = false;
|
|
break;
|
|
case 8:
|
|
usrDiary.Cancel();
|
|
usrDiary.ControlEnabled = false;
|
|
grdDiary.Enabled = true;
|
|
break;
|
|
}
|
|
Delete.Enabled = true;
|
|
r.Enabled = true;
|
|
Cancel.Enabled = false;
|
|
Print.Enabled = true;
|
|
Save.Enabled = false;
|
|
Adnew.Enabled = true;
|
|
}
|
|
|
|
private void Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
{
|
|
if (MessageBox.Show("Do you realy want to delete this record?", "Delete Confirmation", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
{
|
|
return;
|
|
}
|
|
switch (TabNo)
|
|
{
|
|
case 0:
|
|
usrPatientInfo.DeleteRecord();
|
|
r.Enabled = (usrPatientInfo.PatientsCollection.Count > 0);
|
|
break;
|
|
case 1:
|
|
usrExamInfo.DeleteRecord();
|
|
r.Enabled = (usrExamInfo.ExamInfos.Count > 0);
|
|
break;
|
|
case 2:
|
|
usrClinlicInfo.DeleteRecord();
|
|
r.Enabled = (usrClinlicInfo.ClinicInfos.Count > 0);
|
|
|
|
break;
|
|
case 3:
|
|
usrPreClinicInfo.DeleteRecord();
|
|
r.Enabled = (usrPreClinicInfo.PreClinicsInfos.Count > 0);
|
|
break;
|
|
case 4:
|
|
usrTreatment.DeleteRecord();
|
|
r.Enabled = (usrTreatment.TreatmentInfos.Count > 0);
|
|
break;
|
|
case 5:
|
|
usrReferralInfo.DeleteRecord();
|
|
r.Enabled = (usrReferralInfo.ReferralInfos.Count > 0);
|
|
break;
|
|
|
|
|
|
case 6:
|
|
usrReferralService.DeleteRecord();
|
|
r.Enabled = (usrReferralService.ReferralService.Count > 0);
|
|
break;
|
|
case 7:
|
|
TblPregnanceInfoEntity PregDeleted;
|
|
|
|
|
|
PregDeleted = PatientInfo.TblPregnanceInfos[BindingContext[PatientInfo.TblPregnanceInfos].Position];
|
|
PatientInfo.TblPregnanceInfos.Remove(PregDeleted);
|
|
adapter.DeleteEntity(PregDeleted);
|
|
break;
|
|
case 8:
|
|
usrDiary.DeleteRecord();
|
|
r.Enabled = (usrDiary.Diary.Count > 0);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void cardView_RowDeleting(object sender, DevExpress.Data.RowDeletingEventArgs e)
|
|
{
|
|
|
|
int PregPos= BindingContext[PatientInfo.TblPregnanceInfos].Position;
|
|
EntityCollection <TblPregnanceInfoEntity> PregSet = PatientInfo.TblPregnanceInfos;
|
|
TblPregnanceInfoEntity Preg = PatientInfo.TblPregnanceInfos[PregPos];
|
|
EntityCollection <TblChildEntity> ChildSet = Preg.TblChildren;
|
|
int ChildPos= BindingContext[ChildSet].Position;
|
|
TblChildEntity DeletedChild = ChildSet[ChildPos];
|
|
adapter.DeleteEntity(DeletedChild);
|
|
|
|
}
|
|
|
|
private void btnExpand_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
GridView View = this.grdPregnance.FocusedView as GridView;
|
|
int rHandle = View.FocusedRowHandle;
|
|
View.SetMasterRowExpanded(rHandle, !View.GetMasterRowExpanded(rHandle));
|
|
}
|
|
|
|
|
|
|
|
private void gridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
|
{
|
|
|
|
if (e.FocusedRowHandle >= 0)
|
|
{
|
|
Children = PatientInfo.TblPregnanceInfos[e.FocusedRowHandle].TblChildren;
|
|
this.grdChildren.DataSource =Children;
|
|
this.grdChildren.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
Children = null;
|
|
this.grdChildren.DataSource = null;
|
|
this.grdChildren.Enabled = false;
|
|
}
|
|
}
|
|
|
|
private void btnChildAdnew_Click(object sender, EventArgs e)
|
|
{
|
|
TblChildEntity newChild = Children.AddNew();
|
|
newChild.UniqueKey = Guid.NewGuid().ToString("N");
|
|
}
|
|
|
|
private void btnChildDel_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (MessageBox.Show("Bạn có muốn xóa bản hồ sơ đứa trẻ này?", "Confirm deletion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
TblChildEntity DeletedChild;
|
|
|
|
DeletedChild = Children[BindingContext[Children].Position];
|
|
Children.Remove(DeletedChild);
|
|
adapter.DeleteEntity(DeletedChild);
|
|
}
|
|
}
|
|
|
|
private void usrPatientInfo_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|