コード例 #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Button oBtn = sender as Button;

            if (oBtn != null && FormLoaded)
            {
                dataGridView1.Rows.Clear();

                DyeParameters.FromDate = Convert.ToDateTime(dtpFromDate.Value.ToShortDateString());
                DyeParameters.ToDate   = Convert.ToDateTime(dtpToDate.Value.ToShortDateString());
                DyeParameters.ToDate   = DyeParameters.ToDate.AddHours(23);

                var CommTransGrps = repo.CommissionTransactions(DyeParameters).GroupBy(x => x.GreigeCom_GrnNo);
                using (var context = new TTI2Entities())
                {
                    foreach (var Grp in CommTransGrps)
                    {
                        var index = dataGridView1.Rows.Add();
                        dataGridView1.Rows[index].Cells[0].Value = Grp.FirstOrDefault().GreigeCom_GrnNo.ToString();
                        dataGridView1.Rows[index].Cells[1].Value = Grp.FirstOrDefault().GreigeCom_Transdate;
                        dataGridView1.Rows[index].Cells[2].Value = Grp.FirstOrDefault().GreigeCom_Custdoc;
                        var Pk = Grp.FirstOrDefault().GreigeCom_ProductType_FK;
                        dataGridView1.Rows[index].Cells[3].Value = context.TLADM_Griege.Find(Pk).TLGreige_Description;
                        dataGridView1.Rows[index].Cells[4].Value = Grp.FirstOrDefault().GreigeCom_Custdoc;
                        dataGridView1.Rows[index].Cells[5].Value = Grp.Count();
                        dataGridView1.Rows[index].Cells[6].Value = Grp.Sum(x => x.GreigeCom_NettWeight);
                    }
                }

                comboCustomers.Items.Clear();
                comboQuality.Items.Clear();

                frmViewCommissionReceipts_Load(this, null);
            }
        }
コード例 #2
0
        public IActionResult ByState( )
        {
            // Get every orders with customers
            var orders = _ctx.Orders.Include(o => o.Customer).ToList();

            // Get every orders grouped by state
            var groupedResult = orders.GroupBy(o => o.Customer.State).ToList()
                                //Create a new object from the grouping with the state and the number of total states
                                .Select(Grp => new
            {
                State = Grp.Key,
                Total = Grp.Sum(x => x.OrderTotal)
            })
                                .OrderByDescending(res => res.Total).ToList();

            return(new ObjectResult(groupedResult));
        }
コード例 #3
0
        public IActionResult ByCustomer(int n)
        {
            // Get every orders with customers
            var orders = _ctx.Orders.Include(o => o.Customer).ToList();

            // Get every orders grouped by customer id
            var groupedResult = orders.GroupBy(o => o.Customer.Id).ToList()
                                //Create a new object from the grouping with the customername and total orders
                                .Select(Grp => new
            {
                Name  = _ctx.Customers.Find(Grp.Key).Name,
                Total = Grp.Sum(x => x.OrderTotal)
            })
                                .OrderByDescending(res => res.Total)
                                .Take(n)
                                .ToList();

            return(new ObjectResult(groupedResult));
        }