Upload to server
uploading
This commit is contained in:
100
patientman/PatientMan/Forms/frmDuplicates.cs
Normal file
100
patientman/PatientMan/Forms/frmDuplicates.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Datalib.EntityClasses;
|
||||
using Datalib.HelperClasses;
|
||||
using Datalib.RelationClasses;
|
||||
using Datalib.DatabaseSpecific;
|
||||
using System.Linq;
|
||||
using Datalib.Linq;
|
||||
using SD.LLBLGen.Pro.ORMSupportClasses;
|
||||
using PatientMan.Classes.Templates;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PatientMan.Forms
|
||||
{
|
||||
public partial class frmDuplicates : PatientMan.BasicForms.frmCommon
|
||||
{
|
||||
private EntityCollection<TblReferralsToEntity> EndExams = new EntityCollection<TblReferralsToEntity>();
|
||||
public frmReferral callFrm { get; set; }
|
||||
private List<clsEndDuplicates> result;
|
||||
public frmDuplicates()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoadData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
|
||||
}
|
||||
|
||||
private void Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
BindingContext[result].EndCurrentEdit();
|
||||
List<clsEndDuplicates> deleted = result.Where(q => q.Deleted == true).ToList();
|
||||
foreach(var m in deleted)
|
||||
{
|
||||
|
||||
TblReferralsToEntity remove = new TblReferralsToEntity(m.UniqueID);
|
||||
adapter.FetchEntity(remove);
|
||||
adapter.DeleteEntity(remove);
|
||||
result.Remove(m);
|
||||
|
||||
|
||||
}
|
||||
this.grdClients.DataSource = null;
|
||||
this.grdClients.DataSource = result;
|
||||
callFrm.LoadData();
|
||||
}
|
||||
|
||||
private void r_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
if (this.result.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var PatientId = result[BindingContext[result].Position].PatientId;
|
||||
var frm = new frmPatientInfo();
|
||||
frm.PatientsCollection = new EntityCollection<TblPatientEntity>();
|
||||
var PatientInfo = new TblPatientEntity(PatientId);
|
||||
adapter.FetchEntity(PatientInfo);
|
||||
frm.PatientsCollection.Add(PatientInfo);
|
||||
frm.PatientInfo = PatientInfo;
|
||||
frm.LoadData();
|
||||
frm.gotoReferral();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
public override void LoadData()
|
||||
{
|
||||
EndExams.Clear();
|
||||
adapter.FetchEntityCollection(EndExams, null);
|
||||
var Dups = EndExams.OrderBy(q => q.PatientId).ThenBy(q => q.EndDate).GroupBy(q => q.PatientId).Select(g => new { PatientId = g.Key, Num = g.Count() }).ToList().Where(q => q.Num > 1).ToList();
|
||||
|
||||
result = (from p in EndExams
|
||||
join q in Dups on p.PatientId equals q.PatientId
|
||||
select new clsEndDuplicates
|
||||
|
||||
{
|
||||
PatientId = p.PatientId,
|
||||
EndDate = (DateTime)p.EndDate,
|
||||
TypeId = p.TypeId,
|
||||
UniqueID = p.UniqueKey
|
||||
|
||||
|
||||
}).OrderBy(q => q.PatientId).ThenBy(q => q.EndDate).ToList();
|
||||
|
||||
for (int i = 1; i < result.Count - 1; i++)
|
||||
{
|
||||
if (result[i - 1].PatientId == result[i].PatientId && result[i - 1].TypeId == this.barEndType.EditValue.ToString().Trim())
|
||||
{
|
||||
result[i].Deleted = true;
|
||||
}
|
||||
|
||||
}
|
||||
this.grdClients.DataSource = result;
|
||||
|
||||
|
||||
base.LoadData();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user