80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
|
|
namespace PWAPPv2.Source.DataObjects
|
|
{
|
|
class ReferFromBox : ComboBoxData
|
|
{
|
|
List<string> DoctorName;
|
|
List<int> DoctorID;
|
|
public ReferFromBox(ComboBox box, string data) : base(box)
|
|
{
|
|
this.Add("Choose Refer From");
|
|
DoctorName = new List<string>();
|
|
DoctorID = new List<int>();
|
|
data = data.Replace("\\n", "");
|
|
data = data.Replace("\"", "");
|
|
string[] split = data.Split('|');
|
|
for (int i = 0; i < split.Length; i = i + 2)
|
|
{
|
|
try
|
|
{
|
|
int id = int.Parse(split[i]);
|
|
DoctorID.Add(id);
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw new DataInvalidException();
|
|
}
|
|
DoctorName.Add(split[i + 1]);
|
|
|
|
}
|
|
|
|
foreach (string name in DoctorName)
|
|
{
|
|
Add(name);
|
|
}
|
|
|
|
Box.SelectedItem = "Choose Refer From";
|
|
|
|
}
|
|
|
|
public override int GetSelectedID()
|
|
{
|
|
string Selected = GetSelectedData();
|
|
if (Selected == "Choose Refer From")
|
|
{
|
|
throw new ReferFromDefaultException();
|
|
}
|
|
for (int i = 0; i < DoctorName.Count; i++)
|
|
{
|
|
if (DoctorName[i] == Selected)
|
|
{
|
|
return DoctorID[i];
|
|
}
|
|
}
|
|
throw new InvalidReferralTypeException();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override int GetSelectedIndex(string content)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
}
|
|
|
|
public class ReferFromDefaultException : Exception
|
|
{ }
|
|
public class InvalidDoctorException : Exception
|
|
{
|
|
|
|
}
|
|
}
|