private void PrintOrderForKitchens(string order_id, string job_id, string title = "New Order") { NewOrderReport report = new NewOrderReport(); try { report.DataDefinition.FormulaFields["ReportTitle"].Text = "'" + title + "'"; foreach (DataRow r in kitchen_printers_dt.Rows) { NewOrderDataSet ds = generateNewOrderDataSet(order_id, r["Category"].ToString()); if (ds.OrderDetail.Rows.Count > 0) { report.SetDataSource(ds); report.PrintOptions.PrinterName = r["Printer"].ToString(); report.PrintToPrinter(1, false, 0, 0); } } MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } catch (Exception ex) { MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "', " + " error = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(ex.Message) + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } finally { report.Dispose(); } }
private void PrintOrderEdit(string edit_id, string job_id) { OrderEditReport report = new OrderEditReport(); try { foreach (DataRow r in kitchen_printers_dt.Rows) { OrderEditDataSet ds = generateOrderEditDataSet(edit_id, r["Category"].ToString()); if (ds.OrderEditDetails.Rows.Count > 0) { report.SetDataSource(ds); report.PrintOptions.PrinterName = r["Printer"].ToString(); report.PrintToPrinter(1, false, 0, 0); } } MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } catch (Exception ex) { MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "', " + " error = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(ex.Message) + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } finally { report.Dispose(); } }
private void PrintOrderCancellation(string order_id, string job_id) { OrderCancellation report = new OrderCancellation(); try { report.DataDefinition.FormulaFields["order_id"].Text = "'" + order_id + "'"; foreach (DataRow r in kitchen_printers_dt.Rows) { report.PrintOptions.PrinterName = r["Printer"].ToString(); report.PrintToPrinter(1, false, 0, 0); } MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } catch (Exception ex) { MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "', " + " error = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(ex.Message) + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } finally { report.Dispose(); } }
private void PrintOrder(string order_id, string job_id, bool printInvoice) { PrintForCustomer report = new PrintForCustomer(); try { NewOrderDataSet ds = generateNewOrderDataSet(order_id); if (printInvoice) { string invoice_id = ""; DataTable inv_dt = null; inv_dt = MySqlFunctions.GetTable("select id from invoices where order_id = '" + ds.Order.Rows[0]["id"].ToString() + "' limit 1", Program.GlobalConn); if (inv_dt != null && inv_dt.Rows.Count > 0) { invoice_id = "Invoice:" + inv_dt.Rows[0]["id"].ToString(); } inv_dt = MySqlFunctions.GetTable("select id from ent_bills where order_id = '" + ds.Order.Rows[0]["id"].ToString() + "' limit 1", Program.GlobalConn); if (inv_dt != null && inv_dt.Rows.Count > 0) { invoice_id = "Ent Bill:" + inv_dt.Rows[0]["id"].ToString(); } if (invoice_id != "") { //report.DataDefinition.FormulaFields["invoice_id"].Text = "'" + invoice_id + "'"; } } report.SetDataSource(ds); DataTable restaurant_infoDT = MySqlFunctions.GetTable("select " + "(select `value` from settings where slug = 'restaurant_name') as 'name', " + "(select `value` from settings where slug = 'restaurant_address') as 'address', " + "(select `value` from settings where slug = 'restaurant_ntn') as 'ntn', " + "(select `value` from settings where slug = 'restaurant_stn') as 'stn'; ", Program.GlobalConn); if (restaurant_infoDT != null && restaurant_infoDT.Rows.Count > 0) { DataRow r = restaurant_infoDT.Rows[0]; //report.DataDefinition.FormulaFields["restaurant_name"].Text = "'" + r["name"].ToString() + "'"; //report.DataDefinition.FormulaFields["restaurant_address"].Text = "'" + r["address"].ToString() + "'"; //report.DataDefinition.FormulaFields["ntn"].Text = "'" + r["ntn"].ToString() + "'"; //report.DataDefinition.FormulaFields["stn"].Text = "'" + r["stn"].ToString() + "'"; } var path = System.IO.Path.GetDirectoryName(Application.ExecutablePath); var rtb = new RichTextBox(); rtb.LoadFile(path + "/header.txt"); var headerLines = rtb.Text.Split('\n'); for (int i = 0; i < headerLines.Length && i < 5; i++) { report.DataDefinition.FormulaFields["header_line" + i.ToString()].Text = "'" + headerLines[i] + "'"; } rtb.LoadFile(path + "/footer.txt"); var footerLines = rtb.Text.Split('\n'); for (int i = 0; i < footerLines.Length && i < 5; i++) { report.DataDefinition.FormulaFields["footer_line" + i.ToString()].Text = "'" + footerLines[i] + "'"; } foreach (DataRow r in pos_printers_dt.Rows) { report.PrintOptions.PrinterName = r["Printer"].ToString(); report.PrintToPrinter(1, false, 0, 0); } MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } catch (Exception ex) { MySqlFunctions.SqlNonQuery("update print_jobs set executed_at = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "', " + " error = '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(ex.Message) + "' " + "where id = '" + job_id + "'", Program.GlobalConn); } finally { report.Dispose(); } }