private void misvalOkbut_Click(object sender, RoutedEventArgs e)
{
List<string> mvlist = new List<string>();
string mtyp = "";
bool validentry = true;
if (noMisvalRadio.IsChecked == true)
{
mtyp = "none";
//string[] mvs = { "", "", "" };
//misvals = mvs;
}
if (discreteMisvalRadio.IsChecked == true)
{
mtyp = "three";//+mval1+"-"+mval2+"-"+mval3;
string mval1 = misval1.Text;
string mval2 = misval2.Text;
string mval3 = misval3.Text;
string[] mvs = { mval1, mval2, mval3 };
//misvals = mvs;
if ((misval1.Text.Length < 1 && misval2.Text.Length < 1 && misval3.Text.Length < 1))
{
MessageBox.Show("At Least one Discrete value must be provided.");
validentry = false;
}
else
{
foreach (string s in mvs)//Add non blank values to list
{
if (s.Length > 0)
mvlist.Add(s);
}
}
}
if (rangeMisvalRadio.IsChecked == true)
{
mtyp = "range+1";//+low+"-"+high+"-"+discrete;
string low = rangeLow.Text;
string high = rangeHigh.Text;
string discrete = rangeDiscrete.Text;
string[] mvs = { low, high, discrete };
//misvals = mvs;
if ((rangeLow.Text.Length < 1 || rangeHigh.Text.Length < 1))
{
MessageBox.Show("Range must be provided.");
validentry = false;
}
else
{
foreach (string s in mvs)//Add non blank values to list
{
if (s.Length > 0)
mvlist.Add(s);
}
}
}
_misvaltype = mtyp;
/// Validations ///
foreach (string t in mvlist)//Fields must numeric only
{
Int32 temp;
if (!Int32.TryParse(t, out temp))//can check other data types here in future enhancement
{
validentry = false;
break;
}
}
/// Popup window hides ///
if (validentry)
{
misvals = mvlist;//assigning new missing values. Or say current missing values that user selected
if (isMissingModified())// if missing values or types has been modified.
{
OKClicked = true;
isModified = true;
//MessageBox.Show("Modified!");
}
else
{
OKClicked = false;
isModified = false;
//MessageBox.Show("Not Modified!");
}
MissingValuesDialog.GetWindow(this).Close();
}
else
{
if (mvlist.Count > 0)
MessageBox.Show("Not a valid data type.");
}
}