コード例 #1
0
 private void LoadRevenuePerDay(int month, int year)
 {
     chartControl.Series.Clear();
     try
     {
         Series series = new Series("VND/Ngày", ViewType.Bar);
         SE_08  db     = new SE_08();
         //  DateTime today = DateTime.Now;
         DateTime dBegin = new DateTime(year, month, 1);
         DateTime dEnd   = dBegin.AddMonths(1).AddDays(-1);
         long[]   total  = new long[dEnd.Day];
         for (int i = 0; i < total.Length; ++i)
         {
             total[i] = 0;
         }
         var           q    = db.BillInfos.Where(p => p.Bill.Date_Pay.Day >= 1 && p.Bill.Date_Pay.Day <= dEnd.Day && p.Bill.Date_Pay.Month == dBegin.Month && p.Bill.Date_Pay.Year == dBegin.Year && p.Bill.Status == true && p.Bill.Is_Deleted == false).GroupBy(x => x.Bill.Date_Pay.Day).Select(p => new { DatePay = p.Key, Total = p.Sum(x => x.Amount * x.Item.Price) }).ToList();
         List <Object> list = new List <object>();
         int           cnt  = 0;
         foreach (var item in q)
         {
             var amonyousType = new { STT = ++cnt, DatePay = item.DatePay + "/" + dBegin.Month + "/" + dBegin.Year, Total = item.Total };
             list.Add(amonyousType);
             total[item.DatePay - 1] = Convert.ToInt32(item.Total);
         }
         for (int i = 0; i < dEnd.Day; ++i)
         {
             series.Points.Add(new SeriesPoint((i + 1).ToString(), total[i]));
         }
         chartControl.Series.Add(series);
         dtgvRevenue.DataSource = list;
     }
     catch { }
 }
コード例 #2
0
 private void LoadInfo(int month, int year)
 {
     try
     {
         SE_08 db = new SE_08();
         btnTotal.Text = "Doanh thu\n" + BUS_Bill.Instance.GetTotal(month, year).ToString();
         btnBill.Text  = "Hoá đơn\n" + BUS_Bill.Instance.GetCntBill(month, year).ToString();
         btnDrink.Text = "Thức uống\n" + BUS_Bill.Instance.GetCntDrink(month, year).ToString();
         btnFood.Text  = "Món ăn\n" + BUS_Bill.Instance.GetCntFood(month, year).ToString();
     }
     catch { }
 }
コード例 #3
0
 private bool RemoveFood(int[] selectedRowHandles)
 {
     try
     {
         using (SE_08 db = new SE_08())
         {
             int IDTable = (int)(dtgvBill.Tag);
             int IDBill  = BUS_Bill.Instance.GetIDBillByIDTable(IDTable);
             foreach (int row in selectedRowHandles)
             {
                 String foodName = (String)gridView1.GetRowCellValue(row, "Name");
                 var    x        = db.BillInfos.Where(p => p.Id_Bill == IDBill && p.Item.Name == foodName).Select(p => p).FirstOrDefault();
                 db.BillInfos.Remove(x);
             }
             return(db.SaveChanges() > 0);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         MessageBox.Show("Có lỗi xảy ra khi xoá món từ hoá đơn");
         return(false);
     }
 }