Beispiel #1
0
        public int AssignSectionTeacher(Educate educate)
        {
            conn = DAO.getConnection();
            NpgsqlCommand     command     = new NpgsqlCommand(DAOEducateResource.CreateEducateSP, conn);
            NpgsqlTransaction transaction = conn.BeginTransaction();

            NpgsqlParameter fksection = new NpgsqlParameter();
            NpgsqlParameter fkteacher = new NpgsqlParameter();

            fksection.ParameterName = DAOEducateResource.SectionID;
            fkteacher.ParameterName = DAOEducateResource.TeacherID;

            fksection.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;
            fkteacher.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;

            fksection.Direction = ParameterDirection.Input;
            fkteacher.Direction = ParameterDirection.Input;

            fksection.Value = educate.Section.Id;
            fkteacher.Value = educate.Teacher.Email;

            command.Parameters.Add(fksection);
            command.Parameters.Add(fkteacher);

            command.CommandType = CommandType.StoredProcedure;

            int response = 500;

            NpgsqlDataReader dr = command.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    response = dr.GetInt32(0);
                }

                dr.Close();
                transaction.Commit();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(response);
        }
Beispiel #2
0
        protected void sections__SelectedIndexChanged(object sender, EventArgs e)
        {
            Educate educate = new Educate();
            Teacher teacher = new Teacher();

            teacher.Email   = list_prof.SelectedValue;
            educate.Teacher = teacher;
            GetSectionsByTeacherCommand cmd = new GetSectionsByTeacherCommand(educate);

            cmd.Execute();
            educateList = cmd.EducateList;
            foreach (Educate educate1 in educateList)
            {
                prof_data.DataSource = educateList;
                prof_data.DataBind();
            }
        }
Beispiel #3
0
        public int RemoveSectionTeacher(Educate educate)
        {
            conn = DAO.getConnection();
            NpgsqlCommand     command     = new NpgsqlCommand(DAOEducateResource.DeleteEducateSP, conn);
            NpgsqlTransaction transaction = conn.BeginTransaction();

            NpgsqlParameter id = new NpgsqlParameter();

            id.ParameterName = DAOEducateResource.Id;

            id.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;

            id.Direction = ParameterDirection.Input;

            id.Value = educate.Id;

            command.Parameters.Add(id);

            command.CommandType = CommandType.StoredProcedure;

            int response = 500;

            NpgsqlDataReader dr = command.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    response = dr.GetInt32(0);
                }

                dr.Close();
                transaction.Commit();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(response);
        }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         try
         {
             if (Session["Username"] != null && Session["Token"] != null)
             {
                 Educate educate = new Educate();
                 Teacher teacher = new Teacher();
                 teacher.Email   = Session["Username"].ToString();
                 educate.Teacher = teacher;
                 GetSectionsByTeacherCommand cmd = new GetSectionsByTeacherCommand(educate);
                 cmd.Execute();
                 educateList = cmd.EducateList;
                 foreach (Educate educate1 in educateList)
                 {
                     ReadSectionCommand cmd_ = new ReadSectionCommand(educate1.Section);
                     cmd_.Execute();
                     section_aux = new Section();
                     section_aux = cmd_.Section;
                     sectionList.Add(section_aux);
                 }
                 foreach (Section section in sectionList)
                 {
                     list_section.DataTextField  = "Name";
                     list_section.DataValueField = "Id";
                     list_section.DataSource     = sectionList;
                     list_section.DataBind();
                 }
                 list_section.Items.Insert(0, new ListItem("Seleccione", ""));
                 list_section.Items[0].Selected = true;
                 list_section.Items[0].Attributes["disabled"] = "disabled";
             }
             else
             {
                 Response.Redirect("/site/professor/login.aspx");
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Beispiel #5
0
        protected void Reg_prof_mod(object sender, EventArgs e)
        {
            section         = new Section();
            section.Id      = Int32.Parse(list_section.SelectedValue);
            section.Name    = list_section.DataTextField;
            teacher         = new Teacher();
            teacher.Email   = list_prof.SelectedValue;
            educate         = new Educate();
            educate.Section = section;
            educate.Teacher = teacher;
            AssignSectionTeacherCommand cmd = new AssignSectionTeacherCommand(educate);

            cmd.Execute();
            if (this.educate.Code == 200)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme_succ()", true);
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme()", true);
            }
        }
Beispiel #6
0
        protected void prof_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            ImageButton action       = (ImageButton)e.CommandSource;
            string      actionString = action.ID;

            if (action.ID.Equals("delete"))
            {
                try
                {
                    string id = ((Label)prof_data.Items[e.Item.ItemIndex].FindControl("id")).Text;
                    educate    = new Educate();
                    section    = new Section();
                    teacher    = new Teacher();
                    educate.Id = Int32.Parse(id);
                    RemoveSectionTeacherCommand cmd = new RemoveSectionTeacherCommand(educate);
                    cmd.Execute();
                    if (educate.Code == 200)
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "random", "alertme()", true);
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                try
                {
                }
                catch (Exception ex)
                {
                }
            }
        }
Beispiel #7
0
        public List <Educate> GetSectionByTeacher(Educate educate)
        {
            conn = DAO.getConnection();
            Educate        readEducate = new Educate();
            List <Educate> sections    = new List <Educate>();
            int            id;
            String         teacherEmail;
            String         teacherName;
            String         teacherLastname;
            int            sectionId;
            String         sectionName;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand(DAOEducateResource.ReadEducateByTeacherEmailSp, conn);


                NpgsqlParameter fkteacher = new NpgsqlParameter();

                fkteacher.ParameterName = DAOEducateResource.EmailTeacher;

                fkteacher.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;

                fkteacher.Direction = ParameterDirection.Input;

                fkteacher.Value = educate.Teacher.Email;

                command.Parameters.Add(fkteacher);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        id              = dr.GetInt32(0);
                        teacherEmail    = dr.GetString(1);
                        teacherName     = dr.GetString(2);
                        teacherLastname = dr.GetString(3);
                        sectionId       = dr.GetInt32(4);
                        sectionName     = dr.GetString(5);
                        Section section = new Section();
                        section.Id   = sectionId;
                        section.Name = sectionName;
                        Teacher teacher = new Teacher(teacherEmail, teacherName);
                        readEducate = new Educate(id, section, teacher);
                        sections.Add(readEducate);
                    }
                    dr.Close();
                    tran.Commit();
                    return(sections);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
Beispiel #8
0
        public List <Educate> GetTeacherBySection(Educate educate)
        {
            conn = DAO.getConnection();
            Educate        readEducate = new Educate();
            List <Educate> teachers    = new List <Educate>();
            String         teacherEmail;
            String         teacherName;
            String         teacherLastname;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand(DAOEducateResource.ReadTeacherBySectionIdSP, conn);


                NpgsqlParameter fksection = new NpgsqlParameter();

                fksection.ParameterName = DAOEducateResource.SectionIDE;

                fksection.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;

                fksection.Direction = ParameterDirection.Input;

                fksection.Value = educate.Section.Id;

                command.Parameters.Add(fksection);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        teacherEmail    = dr.GetString(0);
                        teacherName     = dr.GetString(1);
                        teacherLastname = dr.GetString(2);
                        Teacher teacher = new Teacher();
                        teacher.Email       = teacherEmail;
                        teacher.Name        = teacherName;
                        teacher.LastName    = teacherLastname;
                        readEducate         = new Educate();
                        readEducate.Teacher = teacher;
                        teachers.Add(readEducate);
                    }
                    dr.Close();
                    tran.Commit();
                    return(teachers);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
 public AssignSectionTeacherCommand(Educate educate)
 {
     this.educate = educate;
 }
 public GetTeachersBySectionCommand(Educate educate)
 {
     this.educate = educate;
 }
Beispiel #11
0
 public RemoveSectionTeacherCommand(Educate educate)
 {
     this.educate = educate;
 }
Beispiel #12
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>();
                        teacher         = new Teacher();
                        student.Email   = Session["Username"].ToString();
                        educate         = new Educate();
                        teacher.Email   = student.Email;
                        educate.Teacher = teacher;
                        GetSectionsByTeacherCommand cmd_ = new GetSectionsByTeacherCommand(educate);
                        cmd_.Execute();
                        list_edu = cmd_.EducateList;
                        foreach (Educate educate in list_edu)
                        {
                            section    = new Section();
                            section.Id = educate.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 && classMeeting.Teacher.Email == "*****@*****.**")
                                {
                                    list_class_aux.Add(classMeeting);
                                }
                            }
                        }
                        class_data.DataSource = list_class_aux;
                        class_data.DataBind();
                        int i;
                        list_data = new List <object>();
                        for (i = 0; i < list_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)
                {
                }
            }
        }