private void PrintOR(int queueID) { System.Threading.Thread.Sleep(2000); // Check if able to print Printer = tmpMaintenance.GetValue("PrinterReciept"); IsPrint = tmpMaintenance.GetValue("IsRecieptPrint"); if (!canPrint(Printer)) { return; } string mysql = "SELECT * FROM customer_order WHERE QUEUEID = " + queueID + " and QIStatus =1"; DataSet ds = null; string fillData = "TBLQUEUE"; ds = Database.LoadSQL(mysql, fillData); string OrderNum = String.Format("ORDER # 0000{0}", ds.Tables[0].Rows[0]["ORDERNUM"].ToString()); DateTime DocDate = Convert.ToDateTime(System.DateTime.Now); // Declare AutoPrint Reporting autoPrint = null; LocalReport report = new LocalReport(); autoPrint = new Reporting(); // Initialize Auto Print report.ReportPath = @"Report\rptReciept.rdlc"; report.DataSources.Add(new ReportDataSource(fillData, ds.Tables[fillData])); // Assign Parameters Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("txtUsername", mod_system.ORuser.Username); // Importer Parameters if ((dic != null)) { foreach (KeyValuePair <string, string> param in dic) { var nPara = param; ReportParameter tmpPara = new ReportParameter(); tmpPara.Name = nPara.Key; tmpPara.Values.Add(nPara.Value); report.SetParameters(new ReportParameter[] { tmpPara }); Console.WriteLine(string.Format("{0}: {1}", nPara.Key, nPara.Value)); } } if (IsPrint == "YES") { frmReport frm = new frmReport(); frm.ReportInit(mysql, "dsORPRINT", @"Report\rptReciept.rdlc", dic); frm.Show(); } else { // Executing Auto Print autoPrint.Export(report); autoPrint.m_currentPageIndex = 0; autoPrint.Print(Printer); } }
private void btnOrder_Click(object sender, EventArgs e) { QueOrder = new Queue(); Maintenance tmpMain = new Maintenance(); string tmpOrderNum = tmpMain.GetValue("ORDERNUM"); var with = QueOrder; with.OrderNum = tmpOrderNum; //Queue Number from table Maintenance with.OrderDate = DateTime.Now; //with.Status = true; with.SaveQueue(); foreach (ListViewItem lv in lvOrderList.Items) { QueueLines tmpLines = new QueueLines(); tmpLines.QueueID = QueOrder.GetLastID(); tmpLines.MenuID = Convert.ToInt32(lv.Tag); tmpLines.QTY = Convert.ToDouble(lv.SubItems[4].Text.ToString()); tmpLines.Price = Convert.ToDouble(lv.SubItems[3].Text.ToString()); tmpLines.Status = true; tmpLines.SaveInfo(); } MessageBox.Show("Order Post", "Information"); int tmpNum = Convert.ToInt32(tmpOrderNum) + 1; string finalNum = Convert.ToString(tmpNum); tmpMain.UpdateOption("ORDERNUM", finalNum); lvDisplay.Items.Clear(); lvOrderList.Items.Clear(); string optPrint = tmpMain.GetValue("ORDERPRINT"); if (optPrint == "YES") { Reporting AutoPrint = new Reporting(); string printerName = tmpMain.GetValue("PrinterOrder"); if (canPrint(printerName) == false) { return; } LocalReport report = new LocalReport(); String dsName = "dsOrderPrint"; string mysql = "Select OrderNum From tblQueue Where ID = '" + QueOrder.GetLastID() + "'"; DataSet ds = Database.LoadSQL(mysql, "tblQueue"); report.ReportPath = @"Report\rpt_OrderPrint.rdlc"; report.DataSources.Clear(); report.DataSources.Add(new ReportDataSource(dsName, ds.Tables[0])); Dictionary <string, string> addParameters = new Dictionary <string, string>(); if ((addParameters != null)) { foreach (KeyValuePair <string, string> nPara_loopVariable in addParameters) { var nPara = nPara_loopVariable; ReportParameter tmpPara = new ReportParameter(); tmpPara.Name = nPara.Key; tmpPara.Values.Add(nPara.Value); report.SetParameters(new ReportParameter[] { tmpPara }); } } Dictionary <string, double> paperSize = new Dictionary <string, double>(); paperSize.Add("width", 3.5); paperSize.Add("height", 2.5); try { AutoPrint.Export(report, paperSize); AutoPrint.m_currentPageIndex = 0; AutoPrint.Print(printerName); } catch (Exception ex) { MessageBox.Show(ex.Message, "PRINT FAILED"); } } }