99 lines
2.6 KiB
C#
99 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
|
|
namespace PWAPPv2.Source.DataObjects
|
|
{
|
|
class ReferToBox : ComboBoxData
|
|
{
|
|
List<int> PractieID;
|
|
List<string> ToName;
|
|
List<int> DoctorID;
|
|
|
|
public ReferToBox(ComboBox box, string data) : base(box)
|
|
{
|
|
this.Add("Choose Refer To");
|
|
ToName = new List<string>();
|
|
DoctorID = new List<int>();
|
|
PractieID = new List<int>();
|
|
data = data.Replace("\\n", "");
|
|
data = data.Replace("\"", "");
|
|
string[] split = data.Split('|');
|
|
for (int i = 0; i < split.Length; i = i + 3)
|
|
{
|
|
try
|
|
{
|
|
PractieID.Add(int.Parse(split[i]));
|
|
ToName.Add(split[i + 1]);
|
|
DoctorID.Add(int.Parse(split[i + 2]));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw new DataInvalidException();
|
|
}
|
|
}
|
|
foreach (string name in ToName)
|
|
{
|
|
this.Add(name);
|
|
}
|
|
Box.SelectedItem = "Choose Refer To";
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override int GetSelectedID()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
|
|
public int GetSelectedPracticeID()
|
|
{
|
|
string selected = GetSelectedData();
|
|
if (selected == "Choose Refer To")
|
|
{
|
|
throw new ReferToDefaultException();
|
|
}
|
|
for (int i = 0; i < ToName.Count; i++)
|
|
{
|
|
if (ToName[i] == selected)
|
|
{
|
|
return PractieID[i];
|
|
}
|
|
}
|
|
throw new InvalidReferToException();
|
|
}
|
|
|
|
public int GetSelectedDoctorID()
|
|
{
|
|
string selected = GetSelectedData();
|
|
if (selected == "Choose Refer To")
|
|
{
|
|
throw new ReferToDefaultException();
|
|
}
|
|
for (int i = 0; i < ToName.Count; i++)
|
|
{
|
|
if (ToName[i] == selected)
|
|
{
|
|
return DoctorID[i];
|
|
}
|
|
}
|
|
throw new InvalidReferToException();
|
|
}
|
|
|
|
public override int GetSelectedIndex(string content)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class ReferToDefaultException : Exception
|
|
{ }
|
|
|
|
public class InvalidReferToException : Exception
|
|
{ }
|
|
}
|