示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
            DataView  dv     = location.GetUserLocations();
            DataTable result = dv.Table.Clone();

            result.Clear();

            if (dv != null)
            {
                string LocationName = string.Empty;
                foreach (DataRow dr in dv.Table.Rows)
                {
                    if (dr["LName"].ToString() != LocationName)
                    {
                        result.Rows.Add(dr.ItemArray);
                    }
                    else
                    {
                        result.Rows[result.Rows.Count - 1]["UName"] += "<br>" + dr["UName"].ToString();
                        result.Rows[result.Rows.Count - 1]["Email"] += "<br>" + dr["Email"].ToString();
                    }

                    LocationName = dr["LName"].ToString();
                }
            }
            LocationsList.DataSource = result.DefaultView;
            LocationsList.DataBind();
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
            DataView dv = location.GetUserLocations();
            DataTable result = dv.Table.Clone();
            result.Clear();

            if (dv != null)
            {
                string LocationName = string.Empty;
                foreach (DataRow dr in dv.Table.Rows)
                {
                    if (dr["LName"].ToString() != LocationName)
                    {
                        result.Rows.Add(dr.ItemArray);
                    }
                    else
                    {
                        result.Rows[result.Rows.Count - 1]["UName"] += "<br>" + dr["UName"].ToString();
                        result.Rows[result.Rows.Count - 1]["Email"] += "<br>" + dr["Email"].ToString();
                    }

                    LocationName = dr["LName"].ToString();
                }
            }
            LocationsList.DataSource = result.DefaultView;
            LocationsList.DataBind();
        }
        protected void btnSaveSelected_Click(object sender, EventArgs e)
        {
            string    value     = String.Empty;
            ArrayList regions   = new ArrayList();
            ArrayList locations = new ArrayList();

            foreach (GridDataItem gdi in ((Telerik.WebControls.RadGrid)(LocationGrid)).Items)
            {
                if (((Telerik.WebControls.GridItem)(gdi)).HasChildItems)
                {
                    foreach (GridDataItem gdiDetails in gdi.ChildItem.NestedTableViews[0].Items)
                    {
                        if (((System.Web.UI.WebControls.CheckBox)(gdiDetails.Cells[2].Controls[1])).Checked)
                        {
                            locations.Add(gdiDetails.Cells[4].Text);
                        }
                    }
                }
                if (((System.Web.UI.WebControls.CheckBox)(gdi.Cells[2].Controls[1])).Checked)
                {
                    regions.Add(gdi.Cells[4].Text);
                }
            }


            Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred();
            Miami.Substitute.Bll.Location  location  = new Miami.Substitute.Bll.Location();

            preferred.DeleteForSubstitute();

            for (int i = 0; i < locations.Count; i++)
            {
                int val = Convert.ToInt32(locations[i]);
                preferred.Insert(val);
            }

            for (int i = 0; i < regions.Count; i++)
            {
                int val = Convert.ToInt32(regions[i]);
                preferred.DeleteByRegion(val);
                DataView locs = location.LoadAllLocation(val);
                if (locs != null)
                {
                    foreach (DataRowView dr in locs)
                    {
                        preferred.Insert(Convert.ToInt32(dr["LocationId"]));
                    }
                }
            }

            Response.Redirect("Default.aspx");
        }
        protected void CheckChanged(Object sender, System.EventArgs e)
        {
            ((sender as CheckBox).Parent.Parent as GridItem).Selected = true;
            if (LocationGrid.SelectedValue != null)
            {
                Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred();
                if (((CheckBox)sender).Checked)
                {
                    if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId")
                    {
                        Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
                        DataView locs = location.LoadAllLocation(Convert.ToInt16(LocationGrid.SelectedValue));

                        preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue));

                        foreach (DataRowView dr in locs)
                        {
                            preferred.Insert(Convert.ToInt32(dr["LocationId"]));
                        }

                        LocationGrid.DataBind();
                    }
                    else
                    {
                        preferred.Insert(Convert.ToInt32(LocationGrid.SelectedValue));
                    }
                }
                else
                {
                    if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId")
                    {
                        Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
                        preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue));
                        LocationGrid.DataBind();
                    }
                    else
                    {
                        preferred.Delete(Convert.ToInt32(LocationGrid.SelectedValue));
                    }
                }
            }
        }
        protected void btnSaveSelected_Click(object sender, EventArgs e)
        {
            string value = String.Empty;
            ArrayList regions = new ArrayList();
            ArrayList locations = new ArrayList();

            foreach (GridDataItem gdi in ((Telerik.WebControls.RadGrid)(LocationGrid)).Items)
            {
                if (((Telerik.WebControls.GridItem)(gdi)).HasChildItems)
                    foreach (GridDataItem gdiDetails in gdi.ChildItem.NestedTableViews[0].Items)
                    {
                        if (((System.Web.UI.WebControls.CheckBox)(gdiDetails.Cells[2].Controls[1])).Checked)
                            locations.Add(gdiDetails.Cells[4].Text);
                    }
                if (((System.Web.UI.WebControls.CheckBox)(gdi.Cells[2].Controls[1])).Checked)
                    regions.Add(gdi.Cells[4].Text);
            }

            Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred();
            Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();

            preferred.DeleteForSubstitute();

            for (int i = 0; i < locations.Count; i++)
            {
                int val = Convert.ToInt32(locations[i]);
                preferred.Insert(val);
            }

            for (int i = 0; i < regions.Count; i++)
            {
                int val = Convert.ToInt32(regions[i]);
                preferred.DeleteByRegion(val);
                DataView locs = location.LoadAllLocation(val);
                if (locs != null)
                    foreach (DataRowView dr in locs)
                        preferred.Insert(Convert.ToInt32(dr["LocationId"]));
            }

            Response.Redirect("Default.aspx");
        }
        protected void CheckChanged(Object sender, System.EventArgs e)
        {
            ((sender as CheckBox).Parent.Parent as GridItem).Selected = true;
            if (LocationGrid.SelectedValue != null)
            {
                Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred();
                if (((CheckBox)sender).Checked)
                {
                    if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId")
                    {
                        Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
                        DataView locs = location.LoadAllLocation(Convert.ToInt16(LocationGrid.SelectedValue));

                        preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue));

                        foreach (DataRowView dr in locs)
                            preferred.Insert(Convert.ToInt32(dr["LocationId"]));

                        LocationGrid.DataBind();
                    }
                    else
                        preferred.Insert(Convert.ToInt32(LocationGrid.SelectedValue));
                }
                else
                {
                    if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId")
                    {
                        Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location();
                        preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue));
                        LocationGrid.DataBind();
                    }
                    else
                        preferred.Delete(Convert.ToInt32(LocationGrid.SelectedValue));
                }
            }
        }