private void SaveButton_Click(object sender, EventArgs e)
        {
            int flag = 1;

            //validation
            string email = textBox3.Text;

            if (textBox1.Text.Length < 3)
            {
                errorProvider1.SetError(textBox1, "Please enter a valid Name");
                flag = 0;
            }
            else
            {
                errorProvider1.Clear();
            }
            if (textBox2.Text.Length < 11 || textBox2.Text.Length > 11)
            {
                errorProvider1.SetError(textBox2, "Please Enter a Valid Phone Number");
                flag = 0;
            }
            else
            {
                errorProvider1.Clear();
            }

            if (!IsValidEmail(email))
            {
                errorProvider1.SetError(textBox3, "Email No must have @ and it`s must be Valid");
                flag = 0;
            }
            else
            {
                errorProvider1.Clear();
            }

            if (flag == 0)
            {
                return;
            }



            //**************


            try
            {
                StudentInfo student = new StudentInfo();

                DateTime date  = DateTime.Now;
                DateTime idate = Convert.ToDateTime(date);
                int      datey = Convert.ToInt32(idate.Year) / 1000;
                int      datem = Convert.ToInt32(idate.Month);

                //student.Id = datev.ToString()+"-000-"+"7"+student.Code;



                student.Name    = textBox1.Text;
                student.Contact = textBox2.Text;
                student.Email   = textBox3.Text;
                student.Code    = Convert.ToInt32(codeTextBox.Text);

                student.Id = datey.ToString() + "-" + student.Code + "-" + datem;

                if (maleRadioButton.Checked == true)
                {
                    student.Gender = "Male";
                }
                else if (femaleRadioButton.Checked == true)
                {
                    student.Gender = "Female";
                }
                else if (othersRadioButton.Checked == true)
                {
                    student.Gender = "Others";
                }
                else
                {
                    genderLabel.Text = "*Please Select Gender First!";
                }

                //select recedient
                if (recidentCheckBox.Checked == true)
                {
                    student.Resident = "Yes";
                }
                else
                {
                    student.Resident = "No";
                }

                bool isStudentAdded = student.Add(student);



                if (isStudentAdded)
                {
                    MessageBox.Show("Done!");
                    //return;
                }
                else
                {
                    MessageBox.Show("Failed");
                }
                string connectionstring = "server=DWIP\\SQLEXPRESS; database=Entry;integrated security=true";

                SqlConnection con   = new SqlConnection(connectionstring);
                string        query = @"SELECT StudentId,Name,Contact,Email,Gender,Recident FROM Students";

                SqlCommand command = new SqlCommand(query, con);

                con.Open();
                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(command);
                da.Fill(dt);
                studentsDataGridView.DataSource = dt;

                con.Close();
            }

            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }