public Index ProcessTextInput(string txtHeight, string txtWeight) { Index index = new Index(); bool checkHeght = true; bool checkWeight = true; double _height = 0; double _weight = 0; if (!txtHeight.Equals("")) { if (txtHeight.Contains(".")) { if (txtHeight.IndexOf(".") == txtHeight.LastIndexOf(".") && txtHeight.Length > 2) { txtHeight = txtHeight.Replace(".", ","); _height = Convert.ToDouble(txtHeight); } else { MessageBox("Nhập lỗi", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } } else _height = Convert.ToDouble(txtHeight); } else checkHeght = false; if (!txtWeight.Equals("")) { if (txtWeight.Contains(".")) { if (txtWeight.IndexOf(".") == txtWeight.LastIndexOf(".") && txtWeight.Length > 2) { txtWeight = txtWeight.Replace(".", ","); _weight = Convert.ToDouble(txtWeight); } else { MessageBox("Nhập lỗi số cân", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } } else _weight = Convert.ToDouble(txtWeight); } else checkWeight = false; if (!checkHeght && !checkWeight) { MessageBox("Chưa nhập số liệu", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } else if (!checkWeight || !checkHeght) { if (!checkHeght) { MessageBox("Chưa nhập chiều cao", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } else MessageBox("Chưa nhập cân nặng", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } else { } index.height = _height; index.weight = _weight; return index; }
private void ResultMama_Click(object sender, RoutedEventArgs e) { Index index = new Index(); index = ProcessTextInput(InputHeightMama.Text, InputWeightMama.Text); string _old = InputOldMama.Text; int old = 0; if (index.height != 0 && index.weight != 0) { if (_old.Equals("")) { MessageBox("Chưa nhập số tuổi", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } else { if (!_old.Contains(".")) { old = Convert.ToInt32(_old); } else { MessageBox("Nhập lỗi ", "Bạn nhập lại không?\r\nOk tiếp tục,Canel thoát"); } } } var localSetting = ApplicationData.Current.LocalSettings; string value = localSetting.Values["CheckBorn"].ToString(); ProcessMamaCheck prMama = new ProcessMamaCheck(MeBe.MainPage._week, old, index.weight, index.height); if (value.Equals("false")) { AdviceForMama.Text = prMama.AdviceForMama(); } else { AdviceForMama.Text = prMama.AdviceMamaBeautiful(); } }
private void ResultBaby_Click(object sender, RoutedEventArgs e) { Index index = new Index(); index = ProcessTextInput(InputHeightBaby.Text, InputWeightBaby.Text); var localSetting = ApplicationData.Current.LocalSettings; Object value = localSetting.Values["CheckSex"]; string sex = (string)value; BabyCheck baby = new BabyCheck(); ProcessBabyCheck prbb = new ProcessBabyCheck(MeBe.MainPage._month, sex, index.weight, index.height); AdviceForBaby.Text = prbb.SmartCheck(); }