Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            String n        = txtName.Text;
            String dob      = dobTxt.Text;
            String addres   = AddrsTxt.Text;
            String phoneNum = phoneTxt.Text;
            int    t        = 0; //check our input

            if (string.IsNullOrWhiteSpace(txtName.Text))
            {
                ePro.SetError(txtName, "Vui lòng nhập tên");
                return;
            }

            else
            {
                ePro.SetError(txtName, "");
                if (GenderTxt.SelectedIndex == -1)
                {
                    ePro.SetError(GenderTxt, "Vui lòng chon giới tính");
                    return;
                }
                else

                {
                    ePro.SetError(GenderTxt, "");

                    if (!((phoneTxt.Text).Length == 10 && phoneTxt.Text[0] == '0'))
                    {
                        ePro.SetError(phoneTxt, "Kiểm tra thông tin có '0' ở đầu và đủ 10 chữ số");
                        return;
                    }

                    else
                    {
                        ePro.SetError(phoneTxt, "");
                        if (string.IsNullOrWhiteSpace(AddrsTxt.Text))
                        {
                            ePro.SetError(AddrsTxt, "Vui lòng nhập địa chỉ");
                            return;
                        }
                        else
                        {
                            ePro.SetError(AddrsTxt, "");
                        }
                    }
                }
            }



            switch (function_check)
            {
            case 1:
                //Check privacy

                currentPatient = patient.Insert(n, dob, gender, addres, phoneNum);

                break;

            case 2:
                //Check privacy
                currentPatient.Update(n, dob, gender, addres, phoneNum);

                break;
            }

            currentPatient          = null;
            txtName.Text            = "";
            dobTxt.Text             = "";
            AddrsTxt.Text           = "";
            phoneTxt.Text           = "0";
            GenderTxt.SelectedIndex = -1;

            //
            Enable_Uneable_Function(true);
            Hide_Buttons();
            Block_or_Unlock_Textbox(false);

            //Set Error Provider to False



            //
            LoadAll();
        }