Beispiel #1
0
 private void ADD_Click(object sender, EventArgs e)
 {
     try
     {
         if (FirstName.Text != "" && Email.Text != "" && RegistrationNumber.Text != "")
         {
             StudentClass Stu  = new StudentClass();
             int          temp = 0;
             if (IsValidEmail(Email.Text) == false)
             {
                 Email.Text = " ";
                 MessageBox.Show("please enter Valid Email Address");
                 Email_TextChanged(sender, e);
             }
             if (Contact.Text.Length > 11 || Contact.Text.Length < 9)
             {
                 Contact.Text = " ";
                 MessageBox.Show("Please enter valid Contact Number");
                 Contact_TextChanged(sender, e);
             }
             else
             {
                 if (Active.Checked == true)
                 {
                     temp = 5;
                 }
                 if (InActive.Checked == true)
                 {
                     temp = 6;
                 }
                 if (Stu.Check(RegistrationNumber.Text.Trim()))
                 {
                     Stu.ADD_student(FirstName.Text.Trim(), LastName.Text.Trim(), Contact.Text.Trim(), Email.Text.Trim(), RegistrationNumber.Text.Trim(), temp);
                     FirstName.Text          = " ";
                     LastName.Text           = " ";
                     Contact.Text            = " ";
                     Email.Text              = " ";
                     RegistrationNumber.Text = " ";
                     StudentForm_Load(sender, e);
                     MessageBox.Show("Data inserted Successfully");
                 }
                 else
                 {
                     MessageBox.Show("This registration Number already Exit");
                     RegistrationNumber.Text = " ";
                     RegistrationNumber_TextChanged(sender, e);
                 }
             }
         }
         else
         {
             MessageBox.Show("FirstName ,Email,RegistrationNumber,Status are required fields.please fill these fields");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Data Can't be added,please fill valid and new data");
         return;
     }
 }
 /// <summary>
 /// This function insert the student record in the StudentRecordList
 /// </summary>
 /// <param name="query">Query to retrieve the data from database</param>
 public void Show_Record(string query)
 {
     try
     {
         SqlCommand command = new SqlCommand(query, conn);
         conn.Open();
         SqlDataReader reader;
         reader = command.ExecuteReader();
         if (reader.HasRows)
         {
             ListofClasses Lt1 = new ListofClasses();
             Lt1.StudentList.Clear();
             while (reader.Read())
             {
                 StudentClass st1 = new StudentClass();
                 st1.Id1                = Convert.ToInt32(reader[0]);
                 st1.FirstName          = reader[1].ToString();
                 st1.LastName           = reader[2].ToString();
                 st1.Contact            = reader[3].ToString();
                 st1.Email              = reader[4].ToString();
                 st1.RegistrationNumber = reader[5].ToString();
                 st1.Status             = Convert.ToInt32(reader[6]);
                 Lt1.addIntolist(st1);
             }
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
     finally
     {
         conn.Close();
     }
 }
Beispiel #3
0
        private void StudentForm_Load(object sender, EventArgs e)
        {
            StudentClass  st1 = new StudentClass();
            ListofClasses lt1 = new ListofClasses();

            st1.StudentRecord();
            StudentRecord.DataSource = null;
            StudentRecord.DataSource = lt1.StudentList;
        }
Beispiel #4
0
        private void StudentRecord_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            StudentClass    sc    = new StudentClass();
            ListofClasses   lt    = new ListofClasses();
            int             index = StudentRecord.CurrentCell.RowIndex;
            DataGridViewRow r     = StudentRecord.Rows[index];
            int             id    = Convert.ToInt32(r.Cells[0].Value);

            if (StudentRecord.Columns[e.ColumnIndex].Name == "Delete")
            {
                DialogResult result = MessageBox.Show("Do You Want to delete adainst id ?" + id, "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (result.Equals(DialogResult.OK))
                {
                    sc.Delete(id);
                    StudentRecord.DataSource = null;
                    StudentForm_Load(sender, e);
                }
                else
                {
                    return;
                }
            }
            if (StudentRecord.Columns[e.ColumnIndex].Name == "Edit")
            {
                FirstName.Text          = r.Cells[1].Value.ToString();
                LastName.Text           = r.Cells[2].Value.ToString();
                Contact.Text            = r.Cells[3].Value.ToString();
                Email.Text              = r.Cells[4].Value.ToString();
                RegistrationNumber.Text = r.Cells[5].Value.ToString();
                int temp = Convert.ToInt32(r.Cells[6].Value);
                if (temp == 5)
                {
                    Active.Checked = true;
                }
                if (temp == 6)
                {
                    InActive.Checked = true;
                }
                globalindex = id;
            }
        }
Beispiel #5
0
 private void Save_Click(object sender, EventArgs e)
 {
     try
     {
         int          temp = 0;
         StudentClass Stu  = new StudentClass();
         if (IsValidEmail(Email.Text) == false)
         {
             MessageBox.Show("input should be in email format");
             Email.Text = " ";
             Email_TextChanged(sender, e);
         }
         else
         {
             if (Active.Checked == true)
             {
                 temp = 5;
             }
             if (InActive.Checked == true)
             {
                 temp = 6;
             }
             Stu.Edit(globalindex, FirstName.Text, LastName.Text, Contact.Text, Email.Text, RegistrationNumber.Text, temp);
             FirstName.Text           = " ";
             LastName.Text            = " ";
             Contact.Text             = " ";
             Email.Text               = " ";
             RegistrationNumber.Text  = " ";
             StudentRecord.DataSource = null;
             StudentForm_Load(sender, e);
         }
     }catch (Exception ex)
     {
         MessageBox.Show("Data can,t Update,please enter valid data");
         return;
     }
 }
 /// <summary>
 /// this function used to add student in the studentList
 /// </summary>
 /// <param name="st">student of type StudentClass</param>
 public void addIntolist(StudentClass st)
 {
     studentList.Add(st);
 }