コード例 #1
0
        private void button_ok_Click(object sender, EventArgs e)
        {
            PATIENT_INFO info = new PATIENT_INFO();

            info.name     = this.textBox_name.Text.Trim();
            info.age      = this.textBox_age.Text.Trim();
            info.gender   = this.radioButton_male.Checked?"男":"女";
            info.height   = this.textBox_height.Text.Trim();
            info.weight   = this.textBox_weight.Text.Trim();
            info.phoneNum = this.textBox_phoneNum.Text.Trim();
            info.adress   = this.textBox_adress.Text.Trim();

            DataMngr.m_old_PatientInfo = info;
            //姓名,年龄,性别为必填
            #region
            string str_errHeight      = "";
            string str_errWeight      = "";
            string str_errPhoneNum    = "";
            bool   b_HeightInfo_Right = true;
            bool   b_WeightInfo_Right = true;
            bool   b_PhoneNum_Right   = true;

            //如果姓名年龄都填了
            if (info.name != "" && info.age != "")
            {
                //判断年龄是否填正确,范围0-300
                #region
                double result          = -1;
                string str_errAge      = "";
                bool   b_AgeInfo_Right = true;
                if (!isNumberic(info.age, ref result))
                {
                    str_errAge      = LanguageMngr.errAge();
                    b_AgeInfo_Right = false;
                }
                else
                {
                    if (result <= 0.0 || result >= 300.0)
                    {
                        str_errAge      = LanguageMngr.errAge();
                        b_AgeInfo_Right = false;
                    }
                }
                #endregion

                //如果年龄填正确了,身高,体重,电话号码,地址都为空
                #region
                if (info.height == "" && info.weight == "" && info.phoneNum == "" && info.adress == "")
                {
                    if (b_HeightInfo_Right && b_WeightInfo_Right && b_PhoneNum_Right && b_AgeInfo_Right)
                    {
                        if (PatientInfo != null) //判断事件是否为空
                        {
                            PatientInfo(info);   //执行委托实例
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                    else
                    {
                        //str_errAge = LanguageMngr.errAge();
                        //str_errHeight = LanguageMngr.errHeight();
                        //str_errWeight = LanguageMngr.errWeight();
                        //str_errPhoneNum = LanguageMngr.errPhoneNum();
                        MessageBox.Show(LanguageMngr.pls_fill_in_right() + str_errAge + " " + str_errHeight + " " + str_errWeight + " " + str_errPhoneNum);
                        return;
                    }
                    #region
                    if (PatientInfo != null) //判断事件是否为空
                    {
                        PatientInfo(info);   //执行委托实例
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    #endregion
                }
                else
                {
                    //如果年龄填正确了,身高,体重,电话号码,地址有一个或多个不为空
                    #region
                    //如果填写了身高,对填写的信息进行判断
                    #region
                    if (info.height != "")
                    {
                        //先校验书写的是否是数字
                        double db_Heihgt_result = -1.0;
                        if (isNumberic(info.height, ref db_Heihgt_result))
                        {
                            //如果为数字,判断范围是否在0-500
                            if (db_Heihgt_result <= 0.0 || db_Heihgt_result >= 500.0)
                            {
                                b_HeightInfo_Right = false;
                                str_errHeight      = LanguageMngr.errHeight();
                            }
                        }
                        else
                        {
                            b_HeightInfo_Right = false;
                            str_errHeight      = LanguageMngr.errHeight();
                        }
                    }
                    #endregion

                    //如果填写了体重,对填写的信息进行判断,0-500kg
                    #region
                    if (info.weight != "")
                    {
                        //先校验书写的是否是数字
                        double db_Weight_result = -1.0;
                        if (isNumberic(info.weight, ref db_Weight_result))
                        {
                            if (db_Weight_result <= 0.0 || db_Weight_result >= 500.0)
                            {
                                b_WeightInfo_Right = false;
                                str_errWeight      = LanguageMngr.errWeight();
                            }
                        }
                        else
                        {
                            b_WeightInfo_Right = false;
                            str_errWeight      = LanguageMngr.errWeight();
                        }
                    }
                    #endregion

                    //如果填写了电话号码,对填写的信息进行判断
                    #region
                    if (info.phoneNum != "")
                    {
                        //先校验书写的是否是数字
                        if (!isPhoneNum(info.phoneNum))
                        {
                            b_PhoneNum_Right = false;
                            str_errPhoneNum  = LanguageMngr.errPhoneNum();
                        }
                    }
                    #endregion

                    //如果身高,体重,年龄都正确,就执行委托
                    #region
                    if (b_HeightInfo_Right && b_WeightInfo_Right && b_PhoneNum_Right && b_AgeInfo_Right)
                    {
                        if (PatientInfo != null) //判断事件是否为空
                        {
                            PatientInfo(info);   //执行委托实例
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                    else
                    {
                        //str_errAge = LanguageMngr.errAge();
                        //str_errHeight = LanguageMngr.errHeight();
                        //str_errWeight = LanguageMngr.errWeight();
                        //str_errPhoneNum = LanguageMngr.errPhoneNum();
                        MessageBox.Show(LanguageMngr.pls_fill_in_right() + str_errAge + " " + str_errHeight + " " + str_errWeight + " " + str_errPhoneNum);
                        return;
                    }
                    #endregion

                    #endregion
                }
                #endregion
            }
            else
            {
                //姓名,年龄没有填完全
                MessageBox.Show(LanguageMngr.pls_fill_up_name_and_age());
            }
            #endregion
        }