Ejemplo n.º 1
0
 // check if number of preference is greater than 0 allow exit button
 private void btnExit(object sender, EventArgs e)
 {
     if (countPreference > 0)
     {
         frmPreference frm1 = new frmPreference();
         frmMain.SetTopPriorityDepartment();
         //frmMain.sendEmail();
         // close preference form
         this.Close();
     }
     else
     {
         MessageBox.Show("Add some preference");
     }
 }
Ejemplo n.º 2
0
        }// add test event end

        ///////////////////// SUBMIT BUTTON register student////////////////////////////
        private void btnsubmit_Click(object sender, EventArgs e)
        {
            //create object of personDTO for taking information fromthe text feilds
            PersonDTO personInformation = new PersonDTO();


            // check either any feild is empty or not and set values
            if (txtname.Text != "" && txtFathername.Text != "" && txtaddress.Text != "" && txtemail.Text != "" &&
                !comboxgender.SelectedItem.Equals("") && txtphonenumber.Text != "")
            {
                try
                {
                    // validate name
                    if (Regex.IsMatch(txtname.Text, @"^[a-zA-Z]+$"))
                    {
                        personInformation.name = txtname.Text;
                        txtname.Text           = "";
                    }
                    else
                    {
                        MessageBox.Show("Names must be Character");
                        txtname.Text = "";
                        return;
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                try
                {
                    // validate father name
                    if (Regex.IsMatch(txtFathername.Text, @"^[a-zA-Z]+$"))
                    {
                        personInformation.fatherName = txtFathername.Text;
                        txtFathername.Text           = "";
                    }
                    else
                    {
                        MessageBox.Show("Names must be Character");
                        txtname.Text = "";
                        return;
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                try
                {
                    //validat ethe phone number
                    if (Regex.IsMatch(txtphonenumber.Text, @"^[0-9]+$"))
                    {
                        personInformation.phoneNumber = int.Parse(txtphonenumber.Text);
                        txtphonenumber.Text           = "";
                    }
                    else
                    {
                        MessageBox.Show("Phone Number must be Digits");
                        txtname.Text = "";

                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }


                // set the gender
                if (comboxgender.SelectedItem.Equals("Male"))
                {
                    personInformation.gender = true;
                }
                else
                {
                    personInformation.gender = false;
                }
                // validate the email of student
                System.Text.RegularExpressions.Regex expr = new System.Text.RegularExpressions
                                                            .Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                try
                {
                    if (!expr.IsMatch(txtemail.Text))
                    {
                        MessageBox.Show("Invalid Email");
                        txtemail.Text = "";

                        // block controll to move onward
                        return;
                    }
                    else
                    {
                        personInformation.email = txtemail.Text;
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                personInformation.homeAddress = txtaddress.Text;
                txtaddress.Text = "";
                // check either academic record and test record is added then add personal
                //information completely
                if (list.Count == 0)
                {
                    personalStd.addStd(personInformation);
                    //compute ARN
                    key = personInformation.email.GetHashCode();
                    if (key < 0)
                    {
                        key = key * -1;

                        listOFARN.Add(key);
                    }
                    else
                    {
                        listOFARN.Add(key);
                    }
                    // add record in the table of tabRecord
                    tableRecord.Rows.Add(key, personInformation.name, personInformation.fatherName,
                                         personInformation.phoneNumber, personInformation.email);

                    /*
                     * attach email of std to academic records AS ARN KEY
                     */
                    Education.setARNinacademic(key);
                    personalStd.setARNinperson(key);
                    //show preference form
                    frmPreference frm = new frmPreference(personInformation.email);
                    frm.Show();
                }
                else
                {
                    MessageBox.Show("Give 3 Degree Records");
                }
            }
            else
            {
                MessageBox.Show("Invalid Input");
            }
        }// submit event call end here