コード例 #1
0
        protected void btn_addpatient_Click( object sender, EventArgs e )
        {
            //defaultstatus();
            string pid = this.txtbox_patientid.Text;
            string name = this.txtbox_name.Text;
            string gender = this.txtbox_gender.Text;
            string tempdate = this.txtbox_birthday.Text;
            string tempage = this.txtbox_age.Text;
            string medical = this.txtbox_medical.Text;

            if ( pid.Length > 0 && name.Length > 0 && gender.Length > 0 && tempdate.Length > 0 && tempage.Length > 0 && medical.Length > 0 )
            {
                BusinessTier.Admin admin = new BusinessTier.Admin();
                Data.DataBase.patientsDataTable table = new Data.DataBase.patientsDataTable();
                table = admin.SearchPatientByID(pid);
                if ( table.Rows.Count > 0 )
                {
                    this.lbl_idwarning.Text = "This ID is already exsit";
                    this.lbl_idwarning.BackColor = System.Drawing.Color.Red;
                }
                else
                {
                    try
                    {
                        int age = int.Parse(tempage);
                        DateTime date = DateTime.Parse(tempdate);
                        admin.AddPatient(pid, name, gender, date.Date, age, medical);
                    }
                    catch ( Exception ex )
                    {
                        this.lbl_agewarning.Text = ex.Message.ToString();
                        this.lbl_birthdaywarning.Text = ex.Message.ToString();
                    }
                }
            }
            else
            {
                errorWarning();
            }
        }