Ejemplo n.º 1
0
        private void frmReport_DT_Load(object sender, EventArgs e)
        {
            SqlConnection connect;

            connect = new SqlConnection(@"server=.\SQLEXPRESS; Database=QuanLiCaPhe;integrated security=true");
            connect.Open();
            SqlDataAdapter da    = new SqlDataAdapter();
            string         query = "SELECT * FROM tblDoanhThu";
            SqlDataAdapter dscm  = new SqlDataAdapter(query, connect);
            DSDoanhThu     ds    = new DSDoanhThu();

            dscm.Fill(ds, "tblDoanhThu");
            connect.Close();
            Report_DT objRpt = new Report_DT();

            objRpt.SetDataSource(ds.Tables[1]);
            crystalReportViewer_DT.ReportSource = objRpt;
            crystalReportViewer_DT.Refresh();
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtSoLuong.Text == "")
     {
         MessageBox.Show("Vui lòng nhập số lượng bàn bạn muốn xem");
     }
     else
     {
         int           i = int.Parse(txtSoLuong.Text);
         SqlConnection connect;
         connect = new SqlConnection(@"server=.\SQLEXPRESS; Database=QuanLiCaPhe;integrated security=true");
         connect.Open();
         SqlDataAdapter da    = new SqlDataAdapter();
         string         query = "SELECT top " + i + " * FROM tblBanSDNhieu ORDER BY LuotSD DESC";
         SqlDataAdapter dscm  = new SqlDataAdapter(query, connect);
         DSDoanhThu     ds    = new DSDoanhThu();
         dscm.Fill(ds, "tblBanSDNhieu");
         connect.Close();
         Report_BanSDNhieu objRpt = new Report_BanSDNhieu();
         objRpt.SetDataSource(ds.Tables[1]);
         crystalReportViewer_BanSDNhieu.ReportSource = objRpt;
         crystalReportViewer_BanSDNhieu.Refresh();
     }
 }