Пример #1
0
        private void PassData2dgvDeail()
        {
            var cons    = consumptionService.GetConsumptions().ToList();
            var getById = from cus in cons where cus.MeterID == id select cus;

            dgvDetail.AutoGenerateColumns = false;
            dgvDetail.DataSource          = getById.ToList();
        }
Пример #2
0
        public ActionResult <List <Consumption> > Get(string category)
        {
            string loggedUser = User.FindFirstValue("userId");

            if (loggedUser == null)
            {
                return(Unauthorized());
            }

            List <Consumption> consumptions = consumptionService.GetConsumptions(category);

            return(consumptions);
        }
Пример #3
0
        public void LoadData()
        {
            IEnumerable <ConsumptionModel> Consumptions = consumptionService.GetConsumptions().Select(c => new ConsumptionModel
            {
                ID                = c.ID,
                Month             = c.Month,
                Year              = c.Year,
                CurrentReading    = c.CurrentReading,
                PreviousReading   = c.PreviousReading,
                MeterKey          = c.Meter.MeterKey,
                MeterID           = c.Meter.ID,
                CustomerName      = c.Meter.Customer.CustomerName,
                ConsumptionEnergy = c.ConsumptionEnergy,
                UnitPrice         = c.UnitPrice
            });

            dgvConsumption.AutoGenerateColumns = false;
            dgvConsumption.DataSource          = Consumptions.ToList();

            month = dtp.Value.Month;
            year  = dtp.Value.Year;
            //txtUnitPrice.Text = (1000).ToString();
            txtUnitPrice.Text = string.Format("{0:0,0}", 1000);
        }
        private void btnLoad_Click(object sender, EventArgs e)
        {
            IEnumerable <ConsumptionModel> Consumptions = consumptionService.GetConsumptions().Select(c => new ConsumptionModel
            {
                ID                = c.ID,
                Month             = c.Month,
                Year              = c.Year,
                CurrentReading    = c.CurrentReading,
                PreviousReading   = c.PreviousReading,
                MeterKey          = c.Meter.MeterKey,
                MeterID           = c.Meter.ID,
                CustomerName      = c.Meter.Customer.CustomerName,
                ConsumptionEnergy = c.ConsumptionEnergy,
                UnitPrice         = c.UnitPrice,
                Date              = c.Date
            });

            /*
             * var result = from con in Consumptions
             *           where con.Month >= Convert.ToInt16(dtpFromDate.Value.Month)
             *           && con.Month <= Convert.ToInt16(dtpToDate.Value.Month)
             *           && con.Year >= Convert.ToInt16(dtpFromDate.Value.Year)
             *           && con.Year <= Convert.ToInt16(dtpToDate.Value.Year)
             *           select con;
             */
            //string fromDate = dtpFromDate.Value.Year.ToString() + "-" + dtpFromDate.Value.Month.ToString() + "-" + dtpFromDate.Value.Day.ToString();
            var fromDate = new DateTime(dtpFromDate.Value.Year, dtpFromDate.Value.Month, dtpFromDate.Value.Day);
            //string toDate = dtpToDate.Value.Year.ToString() + "-" + dtpToDate.Value.Month.ToString() + "-" + dtpToDate.Value.Day.ToString();
            var toDate = new DateTime(dtpToDate.Value.Year, dtpToDate.Value.Month, dtpToDate.Value.Day);
            var result = from con in Consumptions
                         where con.Date >= fromDate && con.Date <= toDate
                         select con;

            ConsumptionModelBindingSource.DataSource = result.ToList();
            //ConsumptionModelBindingSource.DataSource = Consumptions.ToList();
            //Convert.ToDateTime(fromDate) && con.Date <= Convert.ToDateTime(toDate)

            this.rpReceipt.RefreshReport();
        }
Пример #5
0
        public ActionResult GetConsumptions(DateTime?startDate = null, DateTime?endDate = null, Int32 typeId = 0)
        {
            List <ConsumptionDto> consumptions = _consumptionService.GetConsumptions(UserId, startDate, endDate, typeId);

            return(Ok(consumptions));
        }