示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         try
         {
             if (Session["Username"] != null && Session["Token"] != null)
             {
                 student       = new Student();
                 student.Email = Session["Username"].ToString();
                 ReadAllClassMeetingCommand cmd = new ReadAllClassMeetingCommand();
                 cmd.Execute();
                 list_class = cmd.ClassMeetings;
                 foreach (ClassMeeting classMeeting in list_class)
                 {
                     ReadClasslistCommand cmd_ = new ReadClasslistCommand(classMeeting);
                     cmd_.Execute();
                     clase_aux = cmd_.Classlist;
                     foreach (Classlist classlist in clase_aux)
                     {
                         if (classlist.Student.Email == Session["Username"].ToString())
                         {
                             list_class_aux.Add(classMeeting);
                             class_data.DataSource = list_class_aux;
                             class_data.DataBind();
                         }
                     }
                 }
             }
             else
             {
                 Response.Redirect("/site/student/login.aspx");
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
示例#2
0
        protected void mat_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ImageButton action       = (ImageButton)e.CommandSource;
            string      actionString = action.ID;

            if (action.ID.Equals("join"))
            {
                try
                {
                    clase = new ClassMeeting();
                    string date = ((Label)class_data.Items[e.Item.ItemIndex].FindControl("starttime")).Text;
                    clase.StartTime = Convert.ToDateTime(date);
                    if (clase.StartTime.ToShortDateString() == DateTime.Now.ToShortDateString())
                    {
                        string joinurl = ((Label)class_data.Items[e.Item.ItemIndex].FindControl("joinurl")).Text;
                        Response.Redirect(joinurl);
                    }
                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme()", true);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else if (action.ID.Equals("cancel"))
            {
                try
                {
                    clase     = new ClassMeeting();
                    clase_aux = new List <Classlist>();
                    string id = ((Label)class_data.Items[e.Item.ItemIndex].FindControl("Id")).Text;
                    clase.Id = id;
                    ReadClasslistCommand cmd__ = new ReadClasslistCommand(clase);
                    cmd__.Execute();
                    clase_aux = cmd__.Classlist;
                    foreach (Classlist classlist in clase_aux)
                    {
                        if (classlist.Student.Email == Session["Username"].ToString())
                        {
                            DeleteClasslistCommand __cmd__ = new DeleteClasslistCommand(classlist);
                            __cmd__.Execute();
                        }
                    }
                    student       = new Student();
                    student.Email = Session["Username"].ToString();
                    string sectionid = ((Label)class_data.Items[e.Item.ItemIndex].FindControl("sectionId")).Text;
                    payment = new List <AraPayment>();
                    ReadAllPaymentByStudentCommand _cmd_ = new ReadAllPaymentByStudentCommand(student);
                    _cmd_.Execute();
                    payment = _cmd_.Payments;
                    foreach (AraPayment Payment in payment)
                    {
                        if (Payment.Section.Id == Int32.Parse(sectionid))
                        {
                            Payment.Id = Payment.Id;
                            Payment.RemainingClasses = Payment.RemainingClasses + 1;
                            UpdateRemainingClassesCommand __cmd_ = new UpdateRemainingClassesCommand(Payment);
                            __cmd_.Execute();
                        }
                    }
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme_del()", true);
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (Session["Username"] != null && Session["Token"] != null)
                    {
                        student       = new Student();
                        sections      = new List <Section>();
                        student.Email = Session["Username"].ToString();
                        ReadAllPaymentByStudentCommand cmd_ = new ReadAllPaymentByStudentCommand(student);
                        cmd_.Execute();
                        payment = cmd_.Payments;
                        foreach (AraPayment araPayment in payment)
                        {
                            section    = new Section();
                            section.Id = araPayment.Section.Id;
                            ReadSectionCommand cmd = new ReadSectionCommand(section);
                            cmd.Execute();
                            sections.Add(cmd.Section);
                        }

                        ReadAllClassMeetingCommand _cmd_ = new ReadAllClassMeetingCommand();
                        _cmd_.Execute();
                        list_class = _cmd_.ClassMeetings;
                        foreach (Section section in sections)
                        {
                            foreach (ClassMeeting classMeeting in list_class)
                            {
                                if (section.Id == classMeeting.Section.Id)
                                {
                                    list_class_aux.Add(classMeeting);
                                }
                            }
                        }

                        foreach (ClassMeeting classMeeting1 in list_class_aux)
                        {
                            ReadClasslistCommand cmd2 = new ReadClasslistCommand(classMeeting1);
                            cmd2.Execute();
                            class_list = cmd2.Classlist;
                            if (class_list.Count == 0)
                            {
                                class_aux.Add(classMeeting1);
                            }
                        }
                        class_data.DataSource = class_aux;
                        class_data.DataBind();
                        int i;
                        list_data = new List <object>();
                        for (i = 0; i < class_aux.Count; i++)
                        {
                            var myData = new
                            {
                                title = list_class_aux[i].Agenda,
                                start = new DateTime(list_class_aux[i].StartTime.Year, list_class_aux[i].StartTime.Month, list_class_aux[i].StartTime.Day).ToString("yyyy-MM-dd")
                            };

                            list_data.Add(myData);
                        }
                        //Tranform it to Json object
                        jsonData = JsonConvert.SerializeObject(list_data);
                    }
                    else
                    {
                        Response.Redirect("login.aspx");
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }