Lots of updates
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user