コード例 #1
0
        void LoadDataToGrid(string message = null)
        {
            //TODO: check filters
            int    projectID             = Convert.ToInt32(numericUpDownId.Value);
            bool   includeHiddenProjects = checkBoxIncludeHidden.Checked;
            string keyword = textBoxFilterName.Text;


            var rawDataList = db.ExpenseController.Get().ToList();

            if (projectID > 0)
            {
                rawDataList = rawDataList.Where(x => x.Id == projectID).ToList();
            }

            if (String.IsNullOrEmpty(keyword) == false)
            {
                keyword     = keyword.ToLower();
                rawDataList = rawDataList.Where(x =>
                                                x.ORNUmber.ToLower().Contains(keyword) ||
                                                x.CompanyName.ToLower().Contains(keyword) ||
                                                x.Date.ToShortDateString().ToLower().Contains(keyword) ||
                                                x.Description.ToLower().Contains(keyword) ||
                                                x.ExpenseCategory.ToString().ToLower().Contains(keyword) ||
                                                x.Amount.ToString().ToLower().Contains(keyword) ||
                                                x.Project.Name.ToString().ToLower().Contains(keyword) ||
                                                x.Check.VoucherNumber.ToString().ToLower().Contains(keyword)
                                                ).ToList();
            }

            if (includeHiddenProjects == false)
            {
                rawDataList = rawDataList.Where(x => x.IsHidden == false).ToList();
            }

            List <ExpenseViewModel> result = new List <ExpenseViewModel>();

            foreach (var item in rawDataList)
            {
                result.Add(new ExpenseViewModel(item));
            }

            dataGridView1.DataSource = result;

            if (message != null)
            {
                mainform.WriteStatusBar(message);
                return;
            }
            mainform.WriteStatusBar(String.Format("Total Rows : {0}", result.Count));
        }
コード例 #2
0
        void LoadDataToGrid(string message = null)
        {
            //TODO: check filters
            int    checkID             = Convert.ToInt32(numericUpDownId.Value);
            bool   includeHiddenChecks = checkBoxIncludeHidden.Checked;
            string filter = textBoxFilterName.Text;


            var rawDataList = db.CheckController.Get().ToList();

            if (checkID > 0)
            {
                rawDataList = rawDataList.Where(x => x.Id == checkID).ToList();
            }

            if (String.IsNullOrEmpty(filter) == false)
            {
                filter      = filter.ToLower();
                rawDataList = rawDataList.Where(x =>
                                                x.VoucherNumber.ToLower().Contains(filter) ||
                                                x.Amount.ToString().ToLower().Contains(filter) ||
                                                x.IssueDate.ToShortDateString().ToLower().Contains(filter)
                                                ).ToList();
            }

            if (includeHiddenChecks == false)
            {
                rawDataList = rawDataList.Where(x => x.IsHidden == false).ToList();
            }

            List <CheckViewModel> result = new List <CheckViewModel>();

            foreach (var item in rawDataList)
            {
                result.Add(new CheckViewModel(item));
            }

            dataGridView1.DataSource = result;
            if (message != null)
            {
                mainform.WriteStatusBar(message);
                return;
            }
            mainform.WriteStatusBar(String.Format("Total Rows : {0}", result.Count));
        }