public static void PrintInvoices(string Ma_Px) { string strMa_Px = Ma_Px;// (string)drPhView["Ma_Px"]; bool bPreview = false; // bool bShowDialog; // bool bInVisibleNextPrint; // string strReport_File_First; bool bAcceptShowDialog = true; bool bInVisibleNextPrint = false; string strReport_File_First = string.Empty; DataTable dtHeader; DataTable dtDetail; Hashtable ht = new Hashtable(); ht.Add("MA_PX", strMa_Px); DataSet dsPrintVoucher = new DataSet(); dsPrintVoucher = SQLExec.ExecuteReturnDs("sp_PrintListOrder", ht, CommandType.StoredProcedure); //Upadte Gia = 0, Tien = 0, TTien = 0 khi in chung tu doi voi User cam ACCESS_PRICE DataTable dtPrinVoucherHeader = new DataTable(); DataTable dtPrinVoucherDetail = new DataTable(); dtPrinVoucherHeader = dsPrintVoucher.Tables[0]; dtPrinVoucherDetail = dsPrintVoucher.Tables[1]; dtHeader = dtPrinVoucherHeader; dtDetail = dtPrinVoucherDetail; if (dtDetail.Rows.Count > 0) { int i = 0; foreach (DataRow drCurrent in dtDetail.Rows) { if (drCurrent["Stt"].ToString() != string.Empty) { if (i == 0) { bAcceptShowDialog = PrintVoucher.Print(drCurrent, bPreview, true, ref bInVisibleNextPrint, ref strReport_File_First); } else { if (bAcceptShowDialog) { bAcceptShowDialog = PrintVoucher.Print(drCurrent, bPreview, false, ref bInVisibleNextPrint, ref strReport_File_First); } else { break; } } i++; } } } }
public static void PrintInvoices(string Ma_Px, bool IsRpt, bool IsPreview) { string strMa_Px = Ma_Px; bool bPreview = IsPreview; bool bAcceptShowDialog = true; bool bInVisibleNextPrint = false; string strReport_File_First = string.Empty; string rptFileName = Application.StartupPath + @"\Reports\CT_IN_Report.rpt"; if (IsPreview) { PrintVoucher.Print_Crytal(Ma_Px, rptFileName, bPreview, true, null); } else { DataTable dtHeader; DataTable dtDetail; Hashtable ht = new Hashtable(); ht.Add("MA_PX", strMa_Px); DataSet dsPrintVoucher = new DataSet(); dsPrintVoucher = SQLExec.ExecuteReturnDs("sp_PrintListOrder", ht, CommandType.StoredProcedure); DataTable dtPrinVoucherHeader = new DataTable(); DataTable dtPrinVoucherDetail = new DataTable(); dtPrinVoucherHeader = dsPrintVoucher.Tables[0]; dtPrinVoucherDetail = dsPrintVoucher.Tables[1]; dtHeader = dtPrinVoucherHeader; dtDetail = dtPrinVoucherDetail; PrintDialog dlgPrinter = new PrintDialog(); //Khởi tạo đối tượng PrintDialog dlgPrinter.ShowDialog(); //Hiển thị hộp thoại PrintDialog string PrinterName = dlgPrinter.PrinterSettings.PrinterName; if (dtDetail.Rows.Count > 0) { foreach (DataRow drCurrent in dtDetail.Rows) { string stt = drCurrent["Stt"].ToString(); bAcceptShowDialog = PrintVoucher.Print_Crytal(stt, rptFileName, bPreview, true, dlgPrinter); } } } }