Ejemplo n.º 1
0
        protected void grvGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            SaveCheckedValues();
            int rowId   = grvGroup.SelectedIndex;
            int groupId = Convert.ToInt32(grvGroup.Rows[rowId].Cells[2].Text.ToString());

            XmlDocument doc    = new XmlDocument();
            ArrayList   arrIDs = ConvertToArrayList(txtListId.Text);

            List <int> list = new List <int>();

            list.Add(groupId);

            doc.LoadXml(MoodleGroup.GetGroupMembers(list, (string)Session["token"]));
            doc.Save("D:\\Grouping_Get_Members_" + cboGrouping.Text + ".xml");

            XmlNode xmlnode = doc.ChildNodes[1];

            treeDetail.Nodes.Clear();
            treeDetail.Nodes.Add(new TreeNode(doc.DocumentElement.Name));
            TreeNode tNode;

            tNode = treeDetail.Nodes[0];
            MoodleUtilites.AddNode(xmlnode, tNode);
            treeDetail.ExpandAll();
            treeDetail.Focus();
        }
Ejemplo n.º 2
0
        protected void btnDeleteGrouping_Click(object sender, EventArgs e)
        {
            if (cboGrouping.Items.Count == 0)
            {
                return;
            }

            DCVimaruDataContext dc = new DCVimaruDataContext();

            XmlDocument doc  = new XmlDocument();
            List <int>  list = new List <int>();

            int id = Convert.ToInt32(cboGrouping.SelectedValue);

            list.Add(id);

            doc.LoadXml(MoodleGroup.DeleteGroupings(list, (string)Session["token"]));
            doc.Save("D:\\Grouping_Delete_" + cboGrouping.SelectedItem.Text + ".xml");

            if (doc.DocumentElement.Name == "RESPONSE")
            {
                To to = dc.Tos.Single(t => t.ID_To == id);
                dc.Tos.DeleteOnSubmit(to);

                dc.ExecuteCommand("UPDATE Nhom SET ID_To = null WHERE ID_To = {0}", id);

                dc.SubmitChanges();

                cboGrouping.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected void btnCreateGroup_Click(object sender, EventArgs e)
        {
            if (cboFilterCourse.Items.Count == 0)
            {
                return;
            }

            DCVimaruDataContext dc = new DCVimaruDataContext();
            //get courseId
            ThoiKhoaBieu tkb      = dc.ThoiKhoaBieus.Single(t => t.STT == Convert.ToInt32(cboFilterCourse.SelectedValue));
            int          courseId = Convert.ToInt32(tkb.Id);

            XmlDocument        doc  = new XmlDocument();
            List <MoodleGroup> list = new List <MoodleGroup>();

            MoodleGroup group = new MoodleGroup
            {
                CourseId          = courseId,
                Name              = txtGroupName.Text,
                Description       = txtDescription.Text,
                DescriptionFormat = 1,
                EnrolmentKey      = null
            };

            list.Add(group);

            doc.LoadXml(MoodleGroup.CreateGroups(list, (string)Session["token"]));
            doc.Save("D:\\Group_Create_" + txtGroupName.Text + ".xml");

            if (doc.DocumentElement.Name == "RESPONSE")
            {
                long idnhom = (long)Convert.ToUInt64(doc.DocumentElement.ChildNodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[0].InnerText);

                Nhom nhom = new Nhom();
                nhom.ID_Nhom = idnhom;
                nhom.TenNhom = txtGroupName.Text;
                nhom.MoTa    = txtDescription.Text;
                nhom.MaTKB   = (long)Convert.ToUInt64(cboFilterCourse.SelectedValue);

                dc.Nhoms.InsertOnSubmit(nhom);
                dc.SubmitChanges();

                cboGroup.DataBind();
            }
        }
Ejemplo n.º 4
0
        protected void btnAddGroupMember_Click(object sender, EventArgs e)
        {
            SaveCheckedValues();
            grvUser.AllowPaging = false;
            grvUser.DataBind();

            DCVimaruDataContext dc = new DCVimaruDataContext();
            //get group Id
            int groupId = Convert.ToInt32(cboGroup.SelectedValue);
            //get user list

            XmlDocument doc    = new XmlDocument();
            ArrayList   arrIDs = ConvertToArrayList(txtMaSV.Text);
            string      MaSV   = "0";

            foreach (GridViewRow row in grvUser.Rows)
            {
                MaSV = grvUser.DataKeys[row.RowIndex]["MaSV"].ToString();
                if (arrIDs.Contains(MaSV))
                {
                    CheckBox chk = row.Cells[4].Controls[0] as CheckBox;

                    if (row.Cells[3].Text == "0" || !chk.Checked || row.Cells[10].Text != "&nbsp;")
                    {
                        continue;
                    }

                    List <KeyValuePair <int, int> > list = new List <KeyValuePair <int, int> >();
                    list.Add(new KeyValuePair <int, int>(groupId, Convert.ToInt32(row.Cells[3].Text)));

                    doc.LoadXml(MoodleGroup.AddGroupMembers(list, (string)Session["token"]));
                    doc.Save("D:\\Group_Add_Member_" + cboGroup.Text + ".xml");

                    if (doc.DocumentElement.Name == "RESPONSE")
                    {
                        DangKy dk = dc.DangKies.Single(t => t.STT == Convert.ToInt64(row.Cells[2].Text));
                        dk.ID_Nhom = (long?)groupId;
                        dc.SubmitChanges();
                    }
                }
            }

            grvUser.AllowPaging = true;
        }
Ejemplo n.º 5
0
        protected void btnUnsignGrouping_Click(object sender, EventArgs e)
        {
            SaveCheckedValues();
            grvGroup.AllowPaging = false;
            grvGroup.DataBind();

            DCVimaruDataContext dc = new DCVimaruDataContext();
            //get grouping Id
            int groupingId = Convert.ToInt32(cboGrouping.SelectedValue);
            //get group list

            XmlDocument doc    = new XmlDocument();
            ArrayList   arrIDs = ConvertToArrayList(txtListId.Text);
            string      idnhom = "0";

            foreach (GridViewRow row in grvGroup.Rows)
            {
                idnhom = grvGroup.DataKeys[row.RowIndex]["ID_Nhom"].ToString();
                if (arrIDs.Contains(idnhom))
                {
                    if (HttpUtility.HtmlDecode(row.Cells[5].Text) != cboGrouping.SelectedItem.Text)
                    {
                        continue;
                    }

                    List <KeyValuePair <int, int> > list = new List <KeyValuePair <int, int> >();
                    list.Add(new KeyValuePair <int, int>(groupingId, Convert.ToInt32(row.Cells[2].Text)));

                    doc.LoadXml(MoodleGroup.UnassignGrouping(list, (string)Session["token"]));
                    doc.Save("D:\\Grouping_Unassign_Group_" + cboGrouping.Text + ".xml");

                    if (doc.DocumentElement.Name == "RESPONSE")
                    {
                        Nhom nhom = dc.Nhoms.Single(t => t.ID_Nhom == Convert.ToInt64(row.Cells[2].Text));
                        nhom.ID_To = null;
                        dc.SubmitChanges();
                    }
                }
            }

            grvGroup.AllowPaging = true;
        }
Ejemplo n.º 6
0
        protected void btnUpdateGrouping_Click(object sender, EventArgs e)
        {
            if (cboFilterCourse.Items.Count == 0)
            {
                return;
            }

            DCVimaruDataContext dc = new DCVimaruDataContext();
            //get courseId
            ThoiKhoaBieu tkb      = dc.ThoiKhoaBieus.Single(t => t.STT == Convert.ToInt32(cboFilterCourse.SelectedValue));
            int          courseId = Convert.ToInt32(tkb.Id);

            XmlDocument        doc  = new XmlDocument();
            List <MoodleGroup> list = new List <MoodleGroup>();

            int         id       = Convert.ToInt32(cboGrouping.SelectedValue);
            MoodleGroup grouping = new MoodleGroup
            {
                Id                = id,
                Name              = txtGroupingName.Text,
                Description       = txtDescription.Text,
                DescriptionFormat = 1,
            };

            list.Add(grouping);

            doc.LoadXml(MoodleGroup.UpdateGroupings(list, (string)Session["token"]));
            doc.Save("D:\\Grouping_Update_" + txtGroupingName.Text + ".xml");

            if (doc.DocumentElement.Name == "RESPONSE")
            {
                To t = dc.Tos.Single(i => i.ID_To == id);
                t.TenTo = txtGroupingName.Text;
                t.MoTa  = txtDescription.Text;

                dc.SubmitChanges();

                cboGrouping.DataBind();
            }
        }