Exemplo n.º 1
0
        private void SearchStudent( )
        {
            if(readAll != null)
            {
                var query = from item in readAll
                            where item.name == SearchBox.Text
                            select item;

                if (query.Any())
                {
                    writeOne.Clear();
                    oneGridModel.Clear();
                    foreach (var item in query)
                    {
                        GridModel gm = new GridModel() { name = item.name
                        ,hms = item.hms
                        ,termId = item.termId
                        ,roomNum = item.roomNum
                        ,ymd = item.ymd};
                        //item.ymd.ToShortDateString()
                        WriteItem wi = new WriteItem() { ymd = item.ymd, hms = item.hms
                        , name = item.name, roomNum = item.roomNum, termId = item.termId };
                        writeOne.Add(wi);
                        oneGridModel.Add(gm);
                    }
                    IsSearch = true;
                    DG1.Items.SortDescriptions.Clear();
                    DG1.Items.SortDescriptions.Add(new SortDescription("roomNum", ListSortDirection.Ascending));
                }
            }
        }
Exemplo n.º 2
0
 private void SaveOutButton_Click(object sender, RoutedEventArgs e)
 {
     if (readAll != null)
     {
         if(!writeOut.Any())
         {
             var query = readAll.OrderBy(i => i.time).GroupBy(i => new { i.name, i.roomNum });
             foreach (var item in query)
             {
                 var lastItem = item.Last();
                 if (lastItem.termId == 2)
                 {
                     WriteItem wi = new WriteItem()
                     {
                         ymd = lastItem.ymd,
                         hms = lastItem.hms,
                         name = lastItem.name,
                         roomNum = lastItem.roomNum,
                         termId = lastItem.termId
                     };
                     writeOut.Add(wi);
                 }
             }
         }
         saveFile(writeOut);
     }
 }