private void ExportBillForm_Load(object sender, EventArgs e) { BillDetailsCrystalReport billDetailsCrystalReport = new BillDetailsCrystalReport(); DataTable dataTable1 = BillDAO.SelectBillDetails1ByBillID(billID); billDetailsCrystalReport.Database.Tables["Bill_Details_1"].SetDataSource(dataTable1); DataTable dataTable2 = BillDAO.SelectBillDetails2ByBillID(billID); billDetailsCrystalReport.Database.Tables["Bill_Details_2"].SetDataSource(dataTable2); crystalReportViewer.ReportSource = billDetailsCrystalReport; }
public static List <Bill> getBillByEmployeeNameAndDate(string employeeName, string dateFrom, string dateTo) { List <Bill> l = new List <Bill>(); DataTable dt = BillDAO.getBillByEmployeeNameAndDate(employeeName, dateFrom, dateTo); if (dt.Rows.Count == 0) { return(null); } foreach (DataRow dr in dt.Rows) { Bill a = new Bill(); a.billID = dr["BillID"].ToString(); a.dateOfBill = dr["BillDate"].ToString(); a.employeeID = int.Parse(dr["EmployeeID"].ToString()); a.firstName = dr["FirstName"].ToString(); l.Add(a); } return(l); }
private void DrawSaleChart() { string[] monthsName = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; lstTotalByDate.Clear(); string month = (cbxMonthsSale.SelectedIndex + 1).ToString(); dgvTopBook.DataSource = BookDAO.GetTopBookByMonth(month); dgvTopEmployee.DataSource = AccountDAO.GetTopEmployeeByMonth(month); for (int i = 0; i < DateTime.DaysInMonth(DateTime.Now.Year, Convert.ToInt32(month)); i++) { string year = "2020"; string date = (i + 1).ToString(); string conDate = year + "-" + month + "-" + date; try { DateTime dt = Convert.ToDateTime(conDate); double value = BillDAO.getTotalByDate(conDate); lstTotalByDate.Add(value); } catch (FormatException) { lstTotalByDate.Add(0); } } int basehei = 200; double maxVal = 0; double minVal = 0; foreach (double d in lstTotalByDate) { if (d > maxVal) { maxVal = d; } } minVal = maxVal; foreach (double d in lstTotalByDate) { if (d < minVal) { minVal = d; } } flpDisplaySale.Controls.Clear(); for (int i = 0; i < lstTotalByDate.Count; i++) { int height = CalToCol(basehei, maxVal, lstTotalByDate[i]); MyLabel l = new MyLabel(); l.Height = height; l.BackColor = Color.Gray; l.Months = i; l.MouseHover += L_MouseHover; l.MouseLeave += L_MouseLeave; MyLabel l2 = new MyLabel(); l2.Text = (i + 1).ToString(); l2.Height = 25; FlowLayoutPanel fl1 = new FlowLayoutPanel(); fl1.Width = 30; fl1.Height = 300; fl1.FlowDirection = FlowDirection.BottomUp; fl1.Controls.Add(l2); fl1.Controls.Add(l); flpDisplaySale.Controls.Add(fl1); } lblSaleHighest.Text = String.Format("Heightest Of" + monthsName[Convert.ToInt32(month) - 1] + ": {0:n0} VND ", maxVal); lblLowest.Text = String.Format("Lowest Of" + monthsName[Convert.ToInt32(month) - 1] + ": {0:n0} VND ", minVal); double aver = 0; foreach (double d in lstTotalByDate) { aver += d; } lblSaleAver.Text = String.Format("Average : {0:n0} VND / Day", (aver / lstTotalByDate.Count)); }