コード例 #1
0
        public ActionResult AddStudent(StudentViewModel userInput)
        {
            StudentHelper helper = new StudentHelper();
            string        error  = "";

            Student student = helper.AddStudent(userInput, out error);

            if (student != null)
            {
                TempData["bid"] = student.bid;
                return(JavaScript("window.location='" + Url.Action("HostelTransaction") + "'"));
            }

            return(Content(error));
        }
コード例 #2
0
        /// <summary>
        /// Checks if the student is already in the system.
        /// Sends a message if the student exits.
        /// Adds a new student to the system.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Student student = new Student(null, txtFirstName.Text, txtLastName.Text, dtpDOB.Value.Date.ToString("MM/dd/yyyy"));

            if (StudentHelper.ValidateStudent(student))
            {
                MessageBox.Show("There's another student with duplicate information.", "Duplicate Record", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (StudentHelper.AddStudent(student) > 0)
                {
                    MessageBox.Show("The student: " + student.FirstName + " , " + student.LastName + " has been added.", "Student Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                txtFirstName.Clear();
                txtLastName.Clear();
                dtpDOB.Value = DateTime.Today;
            }
        }