Exemplo n.º 1
0
        protected void butAdd_Click(object sender, EventArgs e)
        {
            try
            {
                var repo = new DataRepo();

                List <ChildGroupDTO> childgroups = new List <ChildGroupDTO>();

                for (int i = 0; i < this.gvMasterChildren.Rows.Count; i++)
                {
                    CheckBox chk = (CheckBox)this.gvMasterChildren.Rows[i].Cells[0].FindControl("chk");
                    if ((chk != null) && (chk.Checked))
                    {
                        string childId = this.gvMasterChildren.DataKeys[i].Values["Id"].ToString();

                        if (lstGroupChildren.Items.FindByValue(childId) == null)
                        {
                            var childGroup = new ChildGroupDTO()
                            {
                                GroupId = int.Parse(this.ddlGroup.SelectedValue),
                                ChildId = int.Parse(childId)
                            };

                            childgroups.Add(childGroup);
                        }
                    }
                }

                repo.postChildGroups(childgroups);

                this.populateGroupChildren();
            }
            catch (CBSException ex)
            {
                this.writeMessage(ex);
            }
            catch (Exception ex)
            {
                this.writeMessage(ex);
            }
        }
Exemplo n.º 2
0
        protected void butRemove_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lstGroupChildren.GetSelectedIndices().Length == 0)
                {
                    return;
                }

                var repo = new DataRepo();

                List <ChildGroupDTO> childgroups = new List <ChildGroupDTO>();

                foreach (int index in this.lstGroupChildren.GetSelectedIndices())
                {
                    var childGroup = new ChildGroupDTO()
                    {
                        GroupId = int.Parse(this.ddlGroup.SelectedValue),
                        ChildId = int.Parse(this.lstGroupChildren.Items[index].Value)
                    };

                    childgroups.Add(childGroup);
                }

                repo.deleteChildGroups(childgroups);

                this.populateGroupChildren();
            }
            catch (CBSException ex)
            {
                this.writeMessage(ex);
            }
            catch (Exception ex)
            {
                this.writeMessage(ex);
            }
        }