/// <summary>
 /// <see cref="SelectAllButton"/>被点击,更新<see cref="PersonGridView"/>是否全选
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SelectAllButton_Click(object sender, RoutedEventArgs e)
 {
     if ((sender as ToggleButton).IsChecked == true)
     {
         PersonGridView.SelectAll();
     }
     else
     {
         PersonGridView.SelectedItems.Clear();
     }
 }
Exemple #2
0
        void UpdateDataGridView()
        {
            Guid          Id      = SearcId();
            List <Person> persons = workers.Get().ToList();

            teams = EFtems.GetSort(i => i.TeamName).ToList();
            PersonGridView.MultiSelect = true;
            PersonGridView.DataSource  = null;
            IndexNull = true;

            foreach (Person person in persons)
            {
                if (person.Team != null)
                {
                    teamsTwo.Add(person.Team.TeamName);
                }
                else
                {
                    IndexNull = true;
                }
            }
            if (IndexNull != true)
            {
                teams = EFtems.Get(i => teamsTwo.Contains(i.TeamName)).OrderBy(i => i.TeamName).ToList();

                PersonGridView.DataSource          = workers.GetSort(u => u.Team.TeamName);
                PersonGridView.CurrentRow.Selected = false;
                PersonGridView.ClearSelection();
                int IndexRow = 0;

                foreach (DataGridViewRow rows in PersonGridView.Rows)
                {
                    IndexRow++;
                    if ((Guid)rows.Cells[0].Value == Id)
                    {
                        PersonGridView.CurrentRow.Selected = false;

                        rows.Selected = true;
                        break;
                        //     PersonGridView.CurrentCell =rows.Cells[0];
                    }
                }
                PersonGridView.CurrentCell = PersonGridView.Rows[IndexRow - 1].Cells[4];
            }
            else
            {
                PersonGridView.DataSource = workers.Get();
            }

            /*  PersonGridView.FirstDisplayedScrollingRowIndex = Index;
             * PersonGridView.CurrentCell = PersonGridView.Rows[Index].Cells[3];*/
        }
        private void ChangeStatusRow(GridViewRow row, bool Blocked)
        {
            CheckBox checkBox = (CheckBox)row.FindControl("BlockedCheckbox");

            if (checkBox.Checked != Blocked)
            {
                int    id     = Convert.ToInt32(((Label)row.FindControl("PersonIDLabel")).Text);
                Person person = (from p in this.db.Persons where p.PersonID == id select p).FirstOrDefault();
                person.Blocked = Blocked;
                db.SaveChanges();
                PersonGridView.DataBind();
            }
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <person> myList = new List <person>();
            person        p1     = new person("Mark", 12, 6.2);
            person        p2     = new person("Jim", 3, 5.0);
            person        p3     = new person("Barry", 5, 4.2);
            person        p4     = new person("Jebney", 15, 6.3);
            person        p5     = new person("Eris", 22, 5.2);
            person        p6     = new person("Parker", 11, 6.2);
            person        p7     = new person("El", 10, 4.4);
            person        p8     = new person("Bill", 12, 4.2);
            person        p9     = new person("Bet", 12, 4.5);
            person        p10    = new person("Mak", 12, 4.7);

            myList.Add(p1);
            myList.Add(p2);
            myList.Add(p3);
            myList.Add(p4);
            myList.Add(p5);
            myList.Add(p6);
            myList.Add(p7);
            myList.Add(p8);
            myList.Add(p9);
            myList.Add(p10);

            // FIRST REQUIREMENT
            // PersonGridView.DataSource = from a in myList select a;
            // PersonGridView.DataSource = from a in myList where a.Age <= 12 select a;
            // PersonGridView.DataBind();

            // SECOND REQUIREMENT average height
            // count how many people
            int personCount = (from pa in myList
                               orderby pa.Name, pa.Height, pa.Age
                               select pa).Count();

            double average = 0;
            double sum     = 0;

            foreach (var pp in myList)
            {
                sum += pp.Height;
            }
            average = sum / personCount;

            PersonGridView.DataSource = from a in myList where a.Height >= average && a.Age <= 12 select a;
            PersonGridView.DataBind();
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <person> myList = new List <person>();
            person        p1     = new person("Mark", 12, 6.2);
            person        p2     = new person("John", 15, 5);
            person        p3     = new person("Rob", 10, 6.3);
            person        p4     = new person("Rick", 17, 5.0);
            person        p5     = new person("Evan", 10, 6.0);
            person        p6     = new person("James", 14, 5.5);
            person        p7     = new person("Jimmy", 11, 5.0);
            person        p8     = new person("Carl", 12, 5.4);
            person        p9     = new person("Jonathan", 9, 4.7);
            person        p10    = new person("Bob", 15, 5.7);

            myList.Add(p1);
            myList.Add(p2);
            myList.Add(p3);
            myList.Add(p4);
            myList.Add(p5);
            myList.Add(p6);
            myList.Add(p7);
            myList.Add(p8);
            myList.Add(p9);
            myList.Add(p10);

            //list requirement
            //PersonGridView.DataSource = from a in myList select a;
            //PersonGridView.DataSource = from pa in myList where pa.Age <= 12 select pa;
            //PersonGridView.DataBind();

            //average height
            //count people
            int personCount = (from pa in myList
                               orderby pa.Name, pa.Height, pa.Age
                               select pa).Count();

            double averageHeight = 0;
            double sum           = 0;

            foreach (var pp in myList)
            {
                sum += pp.Height;
            }
            averageHeight = sum / personCount;

            PersonGridView.DataSource = from pa in myList where pa.Height >= averageHeight && pa.Age <= 12 select pa;
            PersonGridView.DataBind();
        }
        private void LoadPersons()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadPersons():Start"
            });
            PersonProxyService.PersonServiceClient client   = new PersonProxyService.PersonServiceClient();
            IList <PersonProxyService.Person>      products = client.GetPersons();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadPersons():End"
            });
            PersonGridView.DataSource = products.Take(10);
            PersonGridView.DataBind();

            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <People> mylist = new List <People>();
            People        p1     = new People("Nate", 12, 6.4);
            People        p2     = new People("John", 10, 5.2);
            People        p3     = new People("Hank", 13, 5.0);
            People        p4     = new People("Jennie", 16, 6.0);
            People        p5     = new People("Frank", 10, 5.6);
            People        p6     = new People("Fran", 12, 5.9);
            People        p7     = new People("Jilly", 10, 6.2);
            People        p8     = new People("Taylor", 13, 5.4);
            People        p9     = new People("Cole", 16, 4.0);
            People        p10    = new People("Rob", 9, 5.7);

            mylist.Add(p1);
            mylist.Add(p2);
            mylist.Add(p3);
            mylist.Add(p4);
            mylist.Add(p5);
            mylist.Add(p6);
            mylist.Add(p7);
            mylist.Add(p8);
            mylist.Add(p9);
            mylist.Add(p10);

            //PersonGridView.DataSource = from a in mylist select a;
            //PersonGridView.DataSource = from a in mylist where a.Age <= 12 select a;
            //PersonGridView.DataBind();

            int personCount = (from a in mylist
                               orderby a.Name, a.Height, a.Age
                               select a).Count();
            double average = 0;
            double sum     = 0;

            foreach (var pp in mylist)
            {
                sum += pp.Height;
            }

            average = sum / personCount;

            PersonGridView.DataSource = from a in mylist where a.Height >= average && a.Age <= 12 select a;
            PersonGridView.DataBind();
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <person> mylist = new List <person>();
            person        p1     = new person("Mark", 12, 6.2);
            person        p2     = new person("John", 15, 5.0);
            person        p3     = new person("Rob", 10, 4.0);
            person        p4     = new person("Rick", 17, 5.0);
            person        p5     = new person("Morty", 23, 6.1);
            person        p6     = new person("Evan", 10, 4.2);
            person        p7     = new person("Grady", 12, 3.2);
            person        p8     = new person("Zach", 12, 7.2);
            person        p9     = new person("Martin", 12, 9.2);
            person        p10    = new person("Marcus", 12, 4.2);

            mylist.Add(p1);
            mylist.Add(p2);
            mylist.Add(p3);
            mylist.Add(p4);
            mylist.Add(p5);
            mylist.Add(p6);
            mylist.Add(p7);
            mylist.Add(p8);
            mylist.Add(p9);
            mylist.Add(p10);
            //1st requirement
            //PersonGridView.DataSource = from a in mylist select a;
            //PersonGridView.DataSource = from a in mylist where a.Age <= 12 select a;
            PersonGridView.DataBind();
            //2nd requirement = average height
            //count how many people
            int personCount = (from pa in mylist
                               orderby pa.Name, pa.Height, pa.Age
                               select pa).Count();

            double average = 0;
            double sum     = 0;

            foreach (var pp in mylist)
            {
                sum += pp.Height;
            }
            average = sum / personCount;
            PersonGridView.DataSource = from a in mylist where a.Height >= average && a.Age <= 12 select a;
            PersonGridView.DataBind();
        }
Exemple #9
0
        private void btnShowDate(object sender, EventArgs e)
        {
            Guid id = SearcId();

            if (id == IdError)
            {
                return;
            }
            date addHolForm = new date(id);

            addHolForm.onupdate += new ONupdate(evenstb);
            DialogResult result = addHolForm.ShowDialog(this);

            PersonGridView.Update();
            PersonGridView.Refresh();

            if (result == DialogResult.OK)
            {
                addHolForm.onupdate -= evenstb;
                addHolForm.Close();
                return;
            }
        }
 private void LoadPersons(IList <PersonProxyService.Person> persons)
 {
     //threadIds.Add(Thread.CurrentThread.ManagedThreadId);
     PersonGridView.DataSource = persons.Take(10);
     PersonGridView.DataBind();
 }
 private void DeleteUserRows()
 {
     ForEachSelectedRow(row => DeleteUserRow(row));
     db.SaveChanges();
     PersonGridView.DataBind();
 }
Exemple #12
0
    private void PopulatePersonGridView(List <People> tblPeople, int pageNo)
    {
        if (tblPeople == null)
        {
            tblPeople = Common.Person_GridViewData;
        }
        int           itemsperPage  = Int32.Parse(WebConfigurationManager.AppSettings["GridItemsPerPage"]);
        int           startRowIndex = (pageNo - 1) * itemsperPage;
        int           currentIndex  = 0;
        int           itemsRead     = 0;
        int           totalRecords  = tblPeople.Count;
        List <People> newPeople     = new List <People>();

        foreach (People row in tblPeople)
        {
            if (itemsRead < itemsperPage && currentIndex < totalRecords && currentIndex >= startRowIndex)
            {
                People newPerson = new People(_connString);
                newPerson.Person_ID          = row.Person_ID;
                newPerson.Person_Title       = row.Person_Title;
                newPerson.Person_Forename    = row.Person_Forename;
                newPerson.Person_Surname     = row.Person_Surname;
                newPerson.Address_ID         = row.Address_ID;
                newPerson.Person_Mobile      = row.Person_Mobile;
                newPerson.Person_Landline    = row.Person_Landline;
                newPerson.Person_Email       = row.Person_Email;
                newPerson.Person_OE_Owner_ID = row.Person_OE_Owner_ID;
                newPeople.Add(newPerson);
                itemsRead++;
            }
            currentIndex++;
        }
        lblTotalPages.Text = CalculateTotalPages(totalRecords).ToString();

        lblCurrentPage.Text = CurrentPage.ToString();

        if (CurrentPage == 1)
        {
            Btn_Previous.Enabled = false;

            if (Int32.Parse(lblTotalPages.Text) > 0)
            {
                Btn_Next.Enabled = true;
            }
            else
            {
                Btn_Next.Enabled = false;
            }
        }

        else
        {
            Btn_Previous.Enabled = true;

            if (CurrentPage == Int32.Parse(lblTotalPages.Text))
            {
                Btn_Next.Enabled = false;
            }
            else
            {
                Btn_Next.Enabled = true;
            }
        }
        PersonGridView.DataSource = newPeople;
        PersonGridView.DataBind();
    }