Esempio n. 1
0
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Student s = obj as Student;

            if (StudentID.Equals(s.StudentID))
            {
                return(true);
            }
            return(false);
        }
        public override bool Equals(object obj)
        {
            var item = obj as Enrollment;

            if (item == null)
            {
                return(false);
            }

            if (CourseID.Equals(item.CourseID) && StudentID.Equals(item.StudentID) && date.Equals(item.date))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        /// <param name="obj"> The object to compare with the current object.</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            SessionResult res = obj as SessionResult;

            if (res == null)
            {
                return(false);
            }

            return(ID.Equals(res.ID) && StudentID.Equals(res.StudentID) &&
                   ExamID.Equals(res.ExamID) && Grade.Equals(res.Grade));
        }
Esempio n. 4
0
        /// <summary>
        /// Add row into the StudentTable
        /// </summary>
        /// <param name="sender"></param>
        private void AddRowMethod(object sender)
        {
            // command that control the connection and table, needed to be initialize every time developer uses command
            OleDbCommand cmd = new OleDbCommand();

            if (theConnection.State != ConnectionState.Open)
            {
                theConnection.Open();
            }
            cmd.Connection = theConnection;

            if (!StudentID.Equals(""))
            {
                if (!StudentGenderOption.Equals(""))
                {
                    if (IsIDEnabled)
                    {
                        cmd.CommandText = "INSERT INTO " + TABLENAME + " (ID, StudentName, Gender, Contact, Address) values (" + StudentID + ",'" + StudentName + "','" + StudentGenderOption + "','" + StudentContact + "','" + StudentAddress + "')";
                        cmd.ExecuteNonQuery();
                        BindGrid();
                        MessageBox.Show("Student information added successfully!");
                        RemoveAllInfo();
                    }
                    else // IsIDEnabled is false only when in Edit mode => Update the value to the selected row
                    {
                        cmd.CommandText = "UPDATE " + TABLENAME + " SET StudentName='" + StudentName + "', Gender='" + StudentGenderOption + "', Contact=" + StudentContact + ", Address='" + StudentAddress + "' where ID=" + StudentID;
                        cmd.ExecuteNonQuery();
                        BindGrid();
                        MessageBox.Show("Student information updated successfully!");
                        AddButtonContent = "Add";
                    }
                }
                else //
                {
                    MessageBox.Show("Please select gender!");
                }
            }
            else
            {
                MessageBox.Show("Please enter student ID");
            }
        }