private void btn_create_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=DESKTOP-GAF2823;Initial Catalog=DB_SOF_01;Integrated Security=True"; conn.Open(); DateTime dateInput = dtp_bill.Value; String query = "SELECT [BILL].[ID_BIL], [BILL].[DATETIME], [TABLE].[ID_TAB], [BILL].[SUMPRICE], [BILL].[SUBPRICE], [USER].[NAME] "; query += "FROM [BILL] INNER JOIN [TABLE] ON [BILL].[ID_TAB] = [TABLE].[ID_TAB] "; query += "INNER JOIN [USER] ON [BILL].[ID_EMP] = [USER].[ID_EMP] "; query += "GROUP BY [BILL].[ID_BIL], [BILL].[DATETIME], [TABLE].[ID_TAB], [BILL].[SUMPRICE], [BILL].[SUBPRICE], [USER].[NAME] "; query += "HAVING DAY([BILL].[DATETIME]) = '" + dateInput.Day + "'"; query += "AND MONTH([BILL].[DATETIME]) = '" + dateInput.Month + "'"; query += "AND YEAR([BILL].[DATETIME]) = '" + dateInput.Year + "'"; SqlCommand cmmd = new SqlCommand(query, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmmd); DataSet_Price dataSet1 = new DataSet_Price(); adapter.Fill(dataSet1.DataTable2); ReportDocument report = new ReportDocument(); report.Load("C:\\Users\\Ho Thai Ngoc\\Desktop\\SOF_01_public\\SOF_01\\MCoffee_GUI\\RP_price.rpt"); report.SetDataSource(dataSet1.Tables["DataTable2"]); crystalReportViewer1.ReportSource = report; crystalReportViewer1.Refresh(); }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=DESKTOP-GAF2823;Initial Catalog=DB_SOF_01;Integrated Security=True"; conn.Open(); String obs = textBox1.Text; String query = "SELECT OBJECT.DISPLAYNAME, SUPLIER.DISPLAYNAME AS Expr1, OBJECT.NUM_REPO, OBJECT.ID_OBJ, UNIT.DISPLAYNAME AS Expr2 "; query += "FROM OBJECT INNER JOIN SUPLIER ON OBJECT.ID_SUP = SUPLIER.ID_SUP "; query += "INNER JOIN UNIT ON OBJECT.ID_UNI = UNIT.ID_UNI "; SqlCommand cmmd = new SqlCommand(query, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmmd); DataSet_Price dataSet1 = new DataSet_Price(); adapter.Fill(dataSet1.DataTable4); ReportDocument report = new ReportDocument(); //report.Load("D:\\HK6\\SOF_01_public-master\\SOF_01_public-master\\SOF_01\\MCoffee_GUI\\RP_object.rpt"); report.Load("C:\\Users\\Ho Thai Ngoc\\Desktop\\SOF_01_public\\SOF_01\\MCoffee_GUI\\RP_object.rpt"); report.SetDataSource(dataSet1.Tables["DataTable4"]); crystalReportViewer1.ReportSource = report; crystalReportViewer1.Refresh(); }
private void btn_create_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=DESKTOP-GAF2823;Initial Catalog=DB_SOF_01;Integrated Security=True"; conn.Open(); DateTime dateInput = dtp_bill.Value; //String query = "SELECT [BILL_INFO].[ID_BILF], [BILL_INFO].[ID_BIL], [DATETIME] "; //query += "FROM [BILL_INFO] "; //query += "INNER JOIN [BILL] ON [BILL].[ID_BIL] = [BILL_INFO].[ID_BIL] "; //query += "ORDER BY [BILL_INFO].[ID_BILF] "; //query += "HAVING [BILL].[DATETIME] = '" + dateInput.ToShortDateString() + "'"; String query = "SELECT FOOD_CATEGORY.DISPLAYNAME, FOOD.DISPLAYNAME AS Expr1, BILL.DATETIME, BILL.ID_TAB, BILL_INFO.ID_BILF, BILL_INFO.COUNT "; query += "FROM BILL INNER JOIN BILL_INFO ON BILL.ID_BIL = BILL_INFO.ID_BIL "; query += "INNER JOIN FOOD ON BILL_INFO.ID_FOD = FOOD.ID_FOD "; query += "INNER JOIN FOOD_CATEGORY ON FOOD.ID_CAT = FOOD_CATEGORY.ID_CAT "; query += "INNER JOIN [USER] ON BILL.ID_EMP = [USER].ID_EMP "; query += "GROUP BY FOOD_CATEGORY.DISPLAYNAME, FOOD.DISPLAYNAME, BILL.DATETIME, BILL.ID_TAB, BILL_INFO.ID_BILF, BILL_INFO.COUNT "; query += "HAVING DAY([BILL].[DATETIME]) = '" + dateInput.Day + "'"; query += "AND MONTH([BILL].[DATETIME]) = '" + dateInput.Month + "'"; query += "AND YEAR([BILL].[DATETIME]) = '" + dateInput.Year + "'"; SqlCommand cmmd = new SqlCommand(query, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmmd); DataSet_Price dataSet1 = new DataSet_Price(); adapter.Fill(dataSet1.DataTable3); ReportDocument report = new ReportDocument(); report.Load("C:\\Users\\Ho Thai Ngoc\\Desktop\\SOF_01_public\\SOF_01\\MCoffee_GUI\\RP_Food.rpt"); report.SetDataSource(dataSet1.Tables["DataTable3"]); crystalReportViewer1.ReportSource = report; crystalReportViewer1.Refresh(); }