コード例 #1
0
        protected void btnAddSession_Click(object sender, EventArgs e)
        {
            if (IsLoggedIn)
            {
                Session newSession = new Session();

                if (string.IsNullOrEmpty(hfTutorID.Value))
                {
                    newSession.TutorID = CurrentUser.ID;
                }
                else
                {
                    newSession.TutorID = int.Parse(hfTutorID.Value);
                }

                if (!string.IsNullOrEmpty(hfSeesionID.Value))
                {
                    newSession.ID        = int.Parse(hfSeesionID.Value);
                    newSession.UpdatedBy = CurrentUser.Email;
                }

                newSession.MaxStudents = int.Parse(txtMaxNumber.Text);
                newSession.CourseID    = int.Parse(ddlCourses.SelectedItem.Value);

                newSession.StartDateTime = DateTimeUtility.ConcatinateDateTime(txtDate.Text, txtStartTime.Text);
                newSession.EndDateTime   = DateTimeUtility.ConcatinateDateTime(txtDate.Text, txtEndTime.Text);
                newSession.Campus        = ddlCampus.SelectedValue;
                newSession.Location      = txtLocation.Text;
                newSession.CreatedBy     = CurrentUser.Email;
                /* Create session in result object */
                Result <Session> result = sms.CreateOrUpdateSession(newSession);

                /* If session is added sucessfully */
                if (result.isSuccess)
                {
                    txtMaxNumber.Text        = "1";
                    ddlCourses.SelectedIndex = 0;

                    ddlCampus.SelectedIndex = 0;
                    txtLocation.Text        = string.Empty;


                    LoadSessions();
                }
                else
                {
                    //Display errror message
                }
                ShowMessage(result.message);
            }
        }
コード例 #2
0
 protected void cvStartEndTimeCompare_ServerValidate(object source, ServerValidateEventArgs args)
 {
     try
     {
         // parse & compare dates
         string   randomDt = "01/01/2000 ";
         DateTime start    = DateTimeUtility.ConcatinateDateTime(randomDt, txtStartTime.Text);
         DateTime end      = DateTimeUtility.ConcatinateDateTime(randomDt, txtEndTime.Text);
         args.IsValid = end.CompareTo(start) > 0;
     }
     catch (Exception /*ex*/)
     {
         // exception is assumed to be invalid times entered
         args.IsValid = false;
     }
 }