Пример #1
0
 public GrossProfitForm()
 {
     InitializeComponent();
     // This line of code is generated by Data Source Configuration Wizard
     // Instantiate a new DBContext
     MiniSteelworksMES.Data.MesEntities dbContext = new MiniSteelworksMES.Data.MesEntities();
     // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
     dbContext.GrossProfits.LoadAsync().ContinueWith(loadTask =>
     {
         // Bind data to control when loading complete
         pivotGridControl1.DataSource = dbContext.GrossProfits.Local.ToBindingList();
     }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
     // This line of code is generated by Data Source Configuration Wizard
     // Instantiate a new DBContext
     //MiniSteelworksMES.Data.MesEntities dbContext = new MiniSteelworksMES.Data.MesEntities();
     // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
     dbContext.GrossProfits.LoadAsync().ContinueWith(loadTask =>
     {
         // Bind data to control when loading complete
         pivotGridControl1.DataSource = dbContext.GrossProfits.Local.ToBindingList();
     }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
     // This line of code is generated by Data Source Configuration Wizard
     // Instantiate a new DBContext
     //MiniSteelworksMES.Data.MesEntities dbContext = new MiniSteelworksMES.Data.MesEntities();
     // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
     dbContext.GrossProfits.LoadAsync().ContinueWith(loadTask =>
     {
         // Bind data to control when loading complete
         pivotGridControl1.DataSource = dbContext.GrossProfits.Local.ToBindingList();
     }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
 }
Пример #2
0
        public List <Transaction> GetByDate(DateTime start, DateTime end)
        {
            using (var context = new MesEntities())
            {
                var query = from x in context.Transactions
                            where x.Date >= start && x.Date <= end
                            select x;

                return(query.ToList());
            }
        }
Пример #3
0
        public List <Transaction> GetByResourceIdAndDate(int rscId, DateTime start, DateTime end)
        {
            using (var context = new MesEntities())
            {
                var query = from x in context.Transactions
                            where x.Date >= start && x.Date <= end && x.ResourceId == rscId
                            select x;

                List <Transaction> list = query.ToList();

                return(query.ToList());
            }
        }
Пример #4
0
        public List <Transaction> GetByResourceId(int rscId)
        {
            using (var context = new MesEntities())
            {
                var query = from x in context.Transactions
                            where x.ResourceId == rscId
                            select x;

                List <Transaction> list = query.ToList();

                return(query.ToList());
            }
        }
Пример #5
0
        public int GetPageCount(int skipCount)
        {
            using (var context = new MesEntities())
            {
                int totalCount = (from x in context.Transactions
                                  select x).Count();

                int nPageCount = 0;
                nPageCount = totalCount / skipCount;
                if (totalCount % skipCount != 0)
                {
                    nPageCount += 1;
                }

                return(nPageCount);
            }
        }
Пример #6
0
        public List <Transaction> GetAllByPagingQuery(int showPage)
        {
            using (var context = new MesEntities())
            {
                int totalCount = (from x in context.Transactions
                                  select x).Count();

                int nPageCount = 0;
                nPageCount = totalCount / rowsCountPerPage;
                if (totalCount % rowsCountPerPage != 0)
                {
                    nPageCount += 1;
                }

                var query = (from x in context.Transactions
                             select x).OrderBy(x => x.Date).Skip((showPage - 1) * rowsCountPerPage).Take(rowsCountPerPage);

                return(query.ToList());
            }
        }
        public List <Transaction> Search()
        {
            using (MesEntities context = DbContextCreator.Create())
            {
                Dictionary <int, string> ResourCeategories = context.Resources.ToDictionary(
                    x => x.ResourceId,
                    x => x.Name);

                var query = from x in context.Transactions
                            select x;

                var list = query.ToList();
                foreach (var x in list)
                {
                    x.ResourceCategory = ResourCeategories[x.ResourceId];
                }

                return(list);
            }
        }
        //public List<TransactionModel> GetModels()
        //{
        //    using (MesEntities context = (MesEntities)DbContextCreator.Create())
        //    {
        //        var query = (from x in context.Transactions
        //                     select x).GroupBy(x => x.ResourceId).Select(
        //            group => new
        //            {
        //                group.FirstOrDefault().ResourceId,
        //                Quantity = group.Sum(
        //                x => x.Quantity)
        //            });

        //        List<TransactionModel> list = new List<TransactionModel>();

        //        foreach (var item in query)
        //        {
        //            if (item != null)
        //                list.Add(new TransactionModel(item.ResourceId, item.Quantity));
        //        }

        //        foreach (var item in list)
        //        {
        //            Debug.WriteLine(item.ResourceId + " " + item.Quantity);
        //        }

        //        return list;
        //    }
        //}

        //public List<TransactionModel> GetModels()
        //{
        //    using (MesEntities context = (MesEntities)DbContextCreator.Create())
        //    {
        //        Dictionary<int, string> resourceNames = context.Resources.ToDictionary(x => x.ResourceId, x => x.Name);

        //        var query = from x in context.Transactions
        //                    group x by x.ResourceId into g
        //                    select g;

        //        List<TransactionModel> models = new List<TransactionModel>();
        //        foreach (var @group in query)
        //        {
        //            TransactionModel model = new TransactionModel(group.Key, group.Sum(x => x.Quantity));//key는 위에서 만든 g의 ResourceId
        //            model.ResourceName = resourceNames[model.ResourceId];

        //            models.Add(model);
        //        }

        //        return models;
        //    }
        //}

        public List <TransactionModel> GetModels()
        {
            using (MesEntities context = (MesEntities)DbContextCreator.Create())
            {
                Dictionary <int, string> resourceNames = context.Resources.ToDictionary(x => x.ResourceId, x => x.Name);
                //Dictionary<int, DateTime> period = context.Transactions.ToDictionary(x => x.ResourceId, x => x.Date);

                var query = from x in context.Transactions //Transaction 요소를 모두 가져와
                            group x by x.ResourceId into g //ResourceId별로 정렬
                            select g;

                List <TransactionModel> models = new List <TransactionModel>();

                foreach (var @group in query)
                {
                    TransactionModel model = new TransactionModel(group.Key, group.Sum(x => x.Quantity));//key는 위에서 만든 g의 ResourceId
                    model.ResourceName = resourceNames[model.ResourceId];
                    models.Add(model);
                }

                return(models);
            }
        }