Lots of updates
This commit is contained in:
102
PWAPPv2/Source/DataObjects/ReferToBox.cs
Normal file
102
PWAPPv2/Source/DataObjects/ReferToBox.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
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 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
|
||||
{ }
|
||||
}
|
||||
Reference in New Issue
Block a user