public void LocalInstalledPrint(CPrintingFormat inPrintRequest) { KitchenPrintForm tempForm = new KitchenPrintForm(); //LocalReport tempReport = new LocalReport(); //tempForm.reportViewer1.LocalReport.ReportEmbeddedResource = "RMS.TableOrder.KitchenReport.rdlc"; //LocalReport tempReport = tempForm.reportViewer1.LocalReport; // tempReport.ReportPath = @"..\..\TableOrder\KitchenReport.rdlc"; KitchenPrintDataSet tempDataSet = new KitchenPrintDataSet(); tempDataSet.Items.Merge(inPrintRequest.KDataTable); //tempDataSet.Items.Merge(DataGridViewToDataTable(g_FoodDataGridView)); //tempDataSet.Items.Merge(DataGridViewToDataTable(g_BeverageDataGridView)); //tempForm.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Items", tempDataSet.Items)); tempForm.ItemsBindingSource.DataSource = tempDataSet; ReportParameter[] paramList = new ReportParameter[3]; COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = new COrderInfo(); CResult oResult = tempOrderManager.OrderInfoByOrderID(inPrintRequest.OrderID); if (oResult.IsSuccess && oResult.Data != null) { tempOrderInfo = (COrderInfo)oResult.Data; } paramList[0] = new ReportParameter("TableNumber", tempOrderInfo.TableNumber.ToString()); paramList[1] = new ReportParameter("Header", "IBACS RMS"); paramList[2] = new ReportParameter("Footer", "Please Come Again."); //tempReport.SetParameters(paramList); tempForm.reportViewer1.LocalReport.SetParameters(paramList); CCommonConstants oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CPrintMethods oPrintMethod = new CPrintMethods(); oPrintMethod.NetworkPrint(tempForm.reportViewer1.LocalReport, oCommonConstants.LocalPrinterName); tempForm.reportViewer1.RefreshReport(); tempForm.Show(); }
private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvLogRecords.RowCount > 0) { String logBody = String.Empty; string serialFooter = ""; string serialHeader = ""; CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>(); logBody += "\r\n\r\n\t\tLog Register"; logBody += "\r\n-----------------------------------"; logBody += "\r\nTID OID UID Date & Time Activity"; logBody += "\r\n-----------------------------------"; for (int rowIndex = 0; rowIndex < dgvLogRecords.Rows.Count; rowIndex++) { logBody += "\r\n\r " + dgvLogRecords[0, rowIndex].Value.ToString(); logBody += " " + dgvLogRecords[1, rowIndex].Value.ToString(); logBody += " " + dgvLogRecords[2, rowIndex].Value.ToString(); logBody += " " +Convert.ToDateTime(dgvLogRecords[3, rowIndex].Value).ToString("dd/MM/yy hh:mmtt"); logBody += " " +Convert.ToDouble("0"+ dgvLogRecords[4, rowIndex].Value).ToString("F02"); } CPrintingFormat tempPrintingFormat = new CPrintingFormat(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = logBody.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); oLogin.PostPrintingRequest(tempPrintingFormat); } } catch (Exception exp) { } }
public void PostPrintingRequest(CPrintingFormat inPrintRequest) { try { CPrintQueue.Init(); CCommonConstants oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); m_oPrintRequest = inPrintRequest; m_mPrintMutex = oCommonConstants.PrintMutex; try { m_mPrintMutex.WaitOne(oCommonConstants.ThreadWaitTime, false); } catch (Exception ex) { } try { if (m_oPrintRequest != null && CPrintQueue.PrintQueue != null) { CPrintQueue.PrintQueue.Enqueue(m_oPrintRequest); } } catch (Exception ex) { } try { m_mPrintMutex.ReleaseMutex(); } catch (Exception ex1) { } } catch (Exception ex2) { } }
private void KitchenPrintVoidCopy() { Hashtable htOrderedItems = new Hashtable(); bool itemAvailable = false; try { CPrintMethodsEXT tempPrintMethods = new CPrintMethodsEXT(); CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>(); COrderManager tempOrderManager = new COrderManager(); CResult oResult = tempOrderManager.OrderInfoByOrderID(m_orderID); COrderInfo tempOrderInfo = new COrderInfo(); StringPrintFormater strPrintFormatter = new StringPrintFormater(29); int papersize = 29; if (oResult.IsSuccess && oResult.Data != null) { tempOrderInfo = (COrderInfo)oResult.Data; } string serialHeader = ""; string serialFooter = ""; string serialBody = ""; if ("Table" == tempOrderInfo.OrderType) { serialBody += "\r\n\r\nTable NO:" + tempOrderInfo.TableNumber.ToString(); serialBody += "\r\nCovers:" + tempOrderInfo.GuestCount.ToString(); } serialBody += "\r\n Kitchen Copy"; if (!tempOrderInfo.Status.Equals("Seated") && "Table"== tempOrderInfo.OrderType) { serialBody += "\r\nReprint"; } serialBody += "\r\n\r\nOrdered Date:" + tempOrderInfo.OrderTime.ToString("dd/MM/yy hh:mm tt"); serialBody += "\r\nPrint Date: " + DateTime.Now.ToString("dd/MM/yy hh:mm tt"); if ("Table" == tempOrderInfo.OrderType) { //serialBody += "\r\n\r\nTable NO:" + tempOrderInfo.TableNumber.ToString(); //serialBody += "\r\nCovers:" + tempOrderInfo.GuestCount.ToString(); } else if ("TakeAway" == tempOrderInfo.OrderType) { serialBody += "\r\n\r\n Take Away"; serialBody += "\r\n Type: " + tempOrderInfo.Status; CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data; serialBody += "\r\n Customer Name: " + tempCustomerInfo.CustomerName; serialBody += "\r\nPhone:" + tempCustomerInfo.CustomerPhone; if (tempOrderInfo.Status.Equals("Delivery")) { serialBody += "\r\nAddress:"; if (tempCustomerInfo.FloorAptNumber.Length > 0) { serialBody += "\r\nFloor or Apartment:" + tempCustomerInfo.FloorAptNumber; } if (tempCustomerInfo.BuildingName.Length > 0) { serialBody += "\r\nBuilding Name:" + tempCustomerInfo.BuildingName; } if (tempCustomerInfo.HouseNumber.Length > 0) { serialBody += "\r\nHouse Number:" + tempCustomerInfo.HouseNumber; } string[] street = new string[0]; street = tempCustomerInfo.StreetName.Split('-'); if (street.Length > 1) { if (street[0].ToString().Length > 0) { serialBody += "\r\nStreet:" + street[0].ToString(); } if (street[1].ToString().Length > 0) { serialBody += "\r\n" + street[1].ToString(); } } else if (street.Length > 0 && street.Length < 2) { if (street[0].ToString().Length > 0) { serialBody += "\r\nStreet:" + street[0].ToString(); } } if (tempCustomerInfo.CustomerPostalCode.Length > 0) { serialBody += "\r\nPostal Code:" + tempCustomerInfo.CustomerPostalCode; } if (tempCustomerInfo.CustomerTown.Length > 0) { serialBody += "\r\nTown:" + tempCustomerInfo.CustomerTown; } serialBody += "\r\n----------------------------------------"; CDelivery objDelivery = new CDelivery(); objDelivery.DeliveryOrderID = m_orderID; CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery); objDelivery = (CDelivery)objDeliveryInfo.Data; serialBody += "\r\nDelivery Time:" + objDelivery.DeliveryTime; } } serialBody += "\r\n\r\nOrder Information"; serialBody += "\r\n---------------------------------"; serialBody += "\r\n Item Qty"; serialBody += "\r\n---------------------------------"; PrintUtility printUtility = new PrintUtility(); foreach (ListViewItem lsvItem in lsvRemovable.Items) { if (lsvItem.SubItems[5].Text.Replace(" ", "").ToUpper() == "Food".Replace(" ", "").ToUpper()) { // serialBody += "\r\n(Void)" + CPrintMethods.GetFixedString(lsvItem.Text, 20) + " "; // serialBody += lsvItem.SubItems[0].Text; itemAvailable = true; serialBody += "\r\n" + strPrintFormatter.ItemLabeledText( printUtility.MultipleLine("(Void)" + lsvItem.Text + " ", papersize - 5, lsvItem.SubItems[1].Text.ToString(), papersize), ""); } } serialBody += "\r\n---------------------------------"; serialBody += "\r\nOrder Prepared By:" + RMSGlobal.LoginUserName; CPcInfoManager tempPcInfoManager = new CPcInfoManager(); IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName()); CResult objResult = tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString()); CPcInfo tempPcInfo = new CPcInfo(); if (objResult.IsSuccess && objResult.Data != null) { tempPcInfo = (CPcInfo)objResult.Data; } serialBody += "\r\nTerminal Name:" + tempPcInfo.Name; serialBody += "\r\n\r\n [ E N D ]\r\n\r\n"; CPrintingFormat tempPrintingFormat = new CPrintingFormat(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.OrderID = m_orderID; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; if (itemAvailable == true) { CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); for (int printCopy = 0; printCopy < m_printedCopy; printCopy++) { // oLogin.PostPrintingRequest(tempPrintingFormat); tempPrintMethods.USBPrint(serialBody, PrintDestiNation.KITCHEN, false); } this.WriteString(serialBody);//Writing to the specified file } } catch (Exception exp) { throw exp; } }
public void PostPrintingRequest(CPrintingFormat inPrintRequest) { try { bool bTempFlag = false; Debug.WriteLine("in PostPrintingRequest 1"); CPrintQueue.Init(); CCommonConstants oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); #region "New at 15.06.2009" //CPrinterConstants objPrinterConstants = new CPrinterConstants(); //if (RMSServiceGlobal.m_printer_kitchen_cut_command.Equals("TMU220")) //{ // oCommonConstants.CutPaperCode = objPrinterConstants.Tmu220;// objPrinterConstants.Tmu220; //} oCommonConstants.CutPaperCode = this.ToByteArray(RMSServiceGlobal.m_printer_kitchen_cut_command); oCommonConstants.BeepCode = this.ToByteArray(RMSServiceGlobal.m_printer_beep_command); #endregion m_oPrintRequest = inPrintRequest; Debug.WriteLine("in PostPrintingRequest 2"); m_mPrintMutex = oCommonConstants.PrintMutex; Debug.WriteLine("in PostPrintingRequest 3"); try { Debug.WriteLine("in PostPrintingRequest 4"); bTempFlag = m_mPrintMutex.WaitOne(oCommonConstants.ThreadWaitTime, false); Debug.WriteLine("in PostPrintingRequest 5"); if (bTempFlag) { try { Debug.WriteLine("in PostPrintingRequest 6"); if (m_oPrintRequest != null && CPrintQueue.PrintQueue != null) { Debug.WriteLine("in PostPrintingRequest 7"); CPrintQueue.PrintQueue.Enqueue(m_oPrintRequest); Debug.WriteLine("in PostPrintingRequest 8"); } } catch (Exception exp) { } try { Debug.WriteLine("in PostPrintingRequest 9"); m_mPrintMutex.ReleaseMutex(); Debug.WriteLine("in PostPrintingRequest 10"); } catch (Exception exp) { } } } catch (Exception exp) { } } catch (Exception exp) { } }
/// <summary> /// Printing at the kitchen /// </summary> private void KitchenPrint() { int papersize = 29; StringPrintFormater strPrintFormatter = new StringPrintFormater(29); Hashtable htOrderedItems = new Hashtable(); SortedList slOrderedItems = null; try { bool itemAvailable = false; CPrintMethodsEXT tempPrintMethods = new CPrintMethodsEXT(); CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>(); COrderManager tempOrderManager = new COrderManager(); CResult oResult = tempOrderManager.OrderInfoByOrderID(orderID); COrderInfo tempOrderInfo = new COrderInfo(); if (oResult.IsSuccess && oResult.Data != null) { tempOrderInfo = (COrderInfo)oResult.Data; } if (oConstant.KitchenPrintFlag == 1) { bool otherfoodprint = false; bool foodprint = false; string serialHeader = ""; string serialFooter = ""; string serialBody = ""; string serialBody2 = ""; if (m_iType == m_cCommonConstants.TableType) { //serialBody += "\r\n\r\n Table Number:" + m_iTableNumber.ToString(); serialBody += "Table Number:\r\n" + m_iTableNumber.ToString(); serialBody += "\r\nCovers:" + tempOrderInfo.GuestCount.ToString(); } serialBody += "\n\r\n"; serialBody += strPrintFormatter.CenterTextWithWhiteSpace("Kitchen Copy"); if (!tempOrderInfo.Status.Equals("Seated") && m_iType == m_cCommonConstants.TableType) { //serialBody += "\r\nReprint"; serialBody += "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Reprint"); } serialBody += "\r\n\r\nOrder ID:" + orderID.ToString(); serialBody += "\r\n\r\nOrder Date:" + tempOrderInfo.OrderTime.ToString("dd/MM/yy hh:mm tt"); serialBody += "\r\nPrint Date:" + DateTime.Now.ToString("dd/MM/yy hh:mm tt"); if (m_iType == m_cCommonConstants.TableType) { //serialBody += "\r\n\r\n Table Number:" + m_iTableNumber.ToString(); //serialBody += "\r\n\n\r\nTable Number:" + m_iTableNumber.ToString(); //serialBody += "\r\nCovers:" + tempOrderInfo.GuestCount.ToString(); COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(orderID); if (orderWaiter != null && orderWaiter.WaiterID > 0) { serialBody += "\r\nWaiter Name: " + orderWaiter.WaiterName +"\r\n"; } } else if (m_iType == m_cCommonConstants.TakeAwayType) { //Waiter for Takeway COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(orderID); if (orderWaiter != null && orderWaiter.WaiterID > 0) { serialBody += "\r\nWaiter Name: " + orderWaiter.WaiterName + "\r\n"; } //serialBody += "\r\n\r\n Take Away"; serialBody += "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Take Away"); serialBody += "\r\nType: " + tempOrderInfo.Status; CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data; if (tempCustomerInfo.CustomerName.Length > 0) //If customer name is present { serialBody += "\r\nCustomer Name: " + tempCustomerInfo.CustomerName; } if (tempCustomerInfo.CustomerPhone.Length > 0) //If customer phone number is available { serialBody += "\r\nPhone:" + tempCustomerInfo.CustomerPhone; } if (tempOrderInfo.Status.Equals("Delivery")) { serialBody += "\r\nAddress:"; if (tempCustomerInfo.FloorAptNumber.Length > 0) { serialBody += "\r\nFloor or Apartment:" + tempCustomerInfo.FloorAptNumber; } if (tempCustomerInfo.BuildingName.Length > 0) { serialBody += "\r\nBuilding Name:" + tempCustomerInfo.BuildingName; } if (tempCustomerInfo.HouseNumber.Length > 0) { serialBody += "\r\nHouse Number:" + tempCustomerInfo.HouseNumber; } string[] street = new string[0]; street = tempCustomerInfo.StreetName.Split('-'); if (street.Length > 1) { if (street[0].ToString().Length > 0) { serialBody += "\r\nStreet:" + street[0].ToString(); } if (street[1].ToString().Length > 0) { serialBody += "\r\n" + street[1].ToString(); } } else if (street.Length > 0 && street.Length < 2) { if (street[0].ToString().Length > 0) { serialBody += "\r\nStreet:" + street[0].ToString(); } } if (tempCustomerInfo.CustomerPostalCode.Length > 0) { serialBody += "\r\nPostal Code:" + tempCustomerInfo.CustomerPostalCode; } if (tempCustomerInfo.CustomerTown.Length > 0) { serialBody += "\r\nTown:" + tempCustomerInfo.CustomerTown; } //serialBody += "\r\n----------------------------------------"; serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); CDelivery objDelivery = new CDelivery(); objDelivery.DeliveryOrderID = orderID; CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery); objDelivery = (CDelivery)objDeliveryInfo.Data; serialBody += "\r\nDelivery Time:" + objDelivery.DeliveryTime; } } //serialBody += "\r\n\r\nOrder Information"; serialBody += "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Order Information"); //serialBody += "\r\n---------------------------------"; serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); if (m_isKitchenPriceAvailable == true) { //serialBody += "\r\nQty Item Price(" + Program.currency.ToString() + ")"; serialBody += "\r\n" + strPrintFormatter.ItemLabeledText("Qty Item", "Price(" + Program.currency + ")"); } else { serialBody += "\r\nQty Item"; } serialBody2 = serialBody; // serialBody += "\r\n---------------------------------"; if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { string cat1ID = String.Empty; string cat2ID = String.Empty; string cat3ID = String.Empty; string separatorCatID = String.Empty; string category2Order = String.Empty; //Printing order will be according to category2 order for (int rowIndex = 0; rowIndex < g_FoodDataGridView.Rows.Count; rowIndex++) { DataGridViewRow tempRow = g_FoodDataGridView.Rows[rowIndex]; category2Order = String.Empty; if (!tempRow.Cells[0].Value.ToString().Equals("")) { // Int64 productID = Int64.Parse(tempRow.Cells[3].Value.ToString()); // Int32 productLevel = Int32.Parse(tempRow.Cells[4].Value.ToString()); Int64 productID = Int64.Parse(tempRow.Cells[4].Value.ToString()); Int32 productLevel = Int32.Parse(tempRow.Cells[5].Value.ToString()); if (productLevel == 3) { DataRow[] dtRow = dsCategory3.Tables[0].Select("cat3_id = " + productID); if (dtRow.Length > 0) { cat2ID = dtRow[0]["cat2_id"].ToString(); } cat1ID = Program.initDataSet.Tables["Category2"].Select("cat2_id = " + cat2ID)[0].GetParentRow(Program.initDataSet.Relations["category1_to_category2"])["cat1_id"].ToString(); } else if (productLevel == 4) { DataRow[] dtRow = dsCategory4.Tables[0].Select("cat4_id = " + productID); if (dtRow.Length > 0) { cat3ID = dtRow[0]["cat3_id"].ToString(); if (cat3ID != "" || cat3ID != null) { dtRow = dsCategory3.Tables[0].Select("cat3_id = " + cat3ID); } else { dtRow = null; } } if (dtRow.Length > 0) { cat2ID = dtRow[0]["cat2_id"].ToString(); } cat1ID = Program.initDataSet.Tables["Category2"].Select("cat2_id = " + cat2ID)[0].GetParentRow(Program.initDataSet.Relations["category1_to_category2"])["cat1_id"].ToString();//Not necessary } else if (productLevel == 0)// && inFoodType.Equals("Indian")) //If miscellenious foods. { cat1ID = "0"; cat2ID = "0"; } #region "New " CCategory3DAO aDao = new CCategory3DAO(); string printstatus = aDao.GetAllCategory3printareaByCategory3ID((int)productID); clsOrderReport objOrderedItems = new clsOrderReport(); // objOrderedItems.Quantity = Convert.ToInt32("0" + tempRow.Cells[1].Value.ToString()); // objOrderedItems.ItemName = tempRow.Cells[0].Value.ToString(); // objOrderedItems.Price = Convert.ToDouble("0" + tempRow.Cells[2].Value.ToString()); //For vat grid index objOrderedItems.Quantity = Convert.ToInt32("0" + tempRow.Cells[1].Value.ToString()); objOrderedItems.ItemName = tempRow.Cells[0].Value.ToString(); objOrderedItems.Price = Convert.ToDouble("0" + tempRow.Cells[3].Value.ToString()); objOrderedItems.PrintArea = printstatus; //htOrderedItems.Add(cat2ID + "-" + objOrderedItems.ItemName, objOrderedItems); //Int64 rankNumber = Int64.Parse(tempRow.Cells[5].Value.ToString()); //For Vat Int64 rankNumber = Int64.Parse(tempRow.Cells[6].Value.ToString()); Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID)); htOrderedItems.Add(category1OrderNumber + "-" + rankNumber.ToString() + "-" + objOrderedItems.ItemName, objOrderedItems);// Category 1 wise #endregion itemAvailable = true;//For drinks.When drinks is avalable then no separator is used. } } NumericComparer ncomp = new NumericComparer(); slOrderedItems = new SortedList(htOrderedItems, ncomp); int keyIndex = 0; SortedList slMiscellaneousItems = new SortedList(); PrintUtility printUtility = new PrintUtility(); string[] valueSplitter = new string[0]; foreach (clsOrderReport objReport in slOrderedItems.Values) { string keyValue = slOrderedItems.GetKey(keyIndex).ToString(); valueSplitter = keyValue.Split('-'); if ((separatorCatID.Trim() != valueSplitter[0].ToString().Trim()) && (valueSplitter[0].ToString().Trim() != "0"))//Insert separator { ////serialBody += "\r\n---------------------------------"; //serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); //separatorCatID = valueSplitter[0].ToString().Trim(); ///*serialBody += "\r\n" + objReport.Quantity.ToString() + " "; //serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20);*/ ////serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim(), objReport.ItemName.ToString()); //if (m_isKitchenPriceAvailable == true) //{ // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + // printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize-3), ""); //} //else //{ // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + // printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 5, "", papersize), ""); //} if (objReport.PrintArea == "Otherfood") { otherfoodprint = true; serialBody2 += "\r\n" + strPrintFormatter.CreateDashedLine(); separatorCatID = valueSplitter[0].ToString().Trim(); //serialBody += "\r\n" + objReport.Quantity.ToString() + " "; // serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20); if (m_isKitchenPriceAvailable == true) { //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName, objReport.Price.ToString("F02")); serialBody2 += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 10, objReport.Price.ToString("F02"), papersize - 3), ""); } else { // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName, ""); serialBody2 += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 5, "", papersize), ""); } } else { foodprint = true; serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); separatorCatID = valueSplitter[0].ToString().Trim(); //serialBody += "\r\n" + objReport.Quantity.ToString() + " "; // serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20); if (m_isKitchenPriceAvailable == true) { //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName, objReport.Price.ToString("F02")); serialBody += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 10, objReport.Price.ToString("F02"), papersize - 3), ""); } else { // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName, ""); serialBody += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 5, "", papersize), ""); } } } else if (valueSplitter[0].ToString() == "0") { slMiscellaneousItems.Add(slMiscellaneousItems.Count, objReport); } else { ///*serialBody += "\r\n" + objReport.Quantity.ToString() + " "; //serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20);*/ //// serialBody += "\r\n" + strPrintFormatter.SumupLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString()," "); //if (m_isKitchenPriceAvailable == true) //{ // //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), objReport.Price.ToString("F02")); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + // printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize-3), ""); //} //else //{ // //serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), ""); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + // printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 5, "", papersize), ""); //} if (objReport.PrintArea == "Otherfood") { otherfoodprint = true; //serialBody2 += "\r\n" + objReport.Quantity.ToString() + " "; //serialBody2 += CPrintMethods.GetFixedString(objReport.ItemName, 20); if (m_isKitchenPriceAvailable == true) { //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText("\r\n" + objReport.Quantity.ToString() + " " + objReport.ItemName, objReport.Price.ToString("F02")); serialBody2 += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 10, objReport.Price.ToString("F02"), papersize - 3), ""); } else { serialBody2 += "\r\n" + objReport.Quantity.ToString() + " "; serialBody2 += CPrintMethods.GetFixedString(objReport.ItemName, 20); } } else { foodprint = true; //serialBody += "\r\n" + objReport.Quantity.ToString() + " "; //serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20); if (m_isKitchenPriceAvailable == true) { //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText("\r\n" + objReport.Quantity.ToString() + " " + objReport.ItemName, objReport.Price.ToString("F02")); serialBody += "\r\n" + strPrintFormatter.ItemLabeledText( objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName, papersize - 10, objReport.Price.ToString("F02"), papersize - 3), ""); } else { serialBody += "\r\n" + objReport.Quantity.ToString() + " "; serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20); } } } keyIndex++; } if (slMiscellaneousItems.Count > 0) { foodprint = true; //serialBody += "\r\n----------Miscellaneous----------"; //separator for miscellaneous serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Miscelaneous"); foreach (clsOrderReport objReport in slMiscellaneousItems.Values) { /*serialBody += "\r\n" + objReport.Quantity.ToString() + " "; serialBody += CPrintMethods.GetFixedString(objReport.ItemName, 20);*/ // serialBody += "\r\n" + strPrintFormatter.SumupLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), ""); if (m_isKitchenPriceAvailable == true) { //serialBody += " " + CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6); // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), objReport.Price.ToString("F02")); serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize-3), ""); } else { // serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), ""); serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString().Trim() + " " + printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 5, "", papersize), ""); } } } //string[] kitchenCommand = new string[0]; //kitchenCommand = tempOrderInfo.InitialKitchenText.Split(','); //serialBody += "\r\n---------------------------------"; serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody2 += "\r\n" + strPrintFormatter.CreateDashedLine(); CResult objKitchenText = tempOrderManager.GetKitchenTextByOrderID(orderID); List<OrderLogInformation> tempOrderLogInfoList = new List<OrderLogInformation>(); tempOrderLogInfoList = (List<OrderLogInformation>)objKitchenText.Data; if (tempOrderLogInfoList.Count > 0) { serialBody += "\r\nKT Txt:"; serialBody2 += "\r\nKT Txt:"; } for (int recordCounter = 0; recordCounter < tempOrderLogInfoList.Count; recordCounter++) { if (tempOrderLogInfoList[recordCounter].KitchenTextPrintStatus < 1) { serialBody += "\r\n- " + tempOrderLogInfoList[recordCounter].KitchenText; serialBody += "\r\n- " + tempOrderLogInfoList[recordCounter].KitchenText; } } serialBody += "\r\nOrder Prepared By:" + m_OperatorName; serialBody += "\r\n" + m_TerminalName; serialBody += "\r\n\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("[ E N D ]") + "\r\n\r\n"; serialBody2 += "\r\nOrder Prepared By:" + m_OperatorName; serialBody2 += "\r\n" + m_TerminalName; serialBody2 += "\r\n\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("[ E N D ]") + "\r\n\r\n"; //tempPrintMethods.SerialPrint(PRINTER_TYPES.KITCHEN_PRINTER, serialHeader, serialBody, serialFooter); // string fullKitchenPrinttext=serialHeader+"\r\n"+serialBody+"\r\n"+serialFooter; // tempPrintMethods.USBPrint(fullKitchenPrinttext, PrintDestiNation.KITCHEN, false); if (itemAvailable == true) //If there is available items { ///Kitchen Print call /// CPrintingFormat tempPrintingFormat = new CPrintingFormat(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.OrderID = orderID; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; CPrintingFormat tempPrintingFormat1 = new CPrintingFormat(); tempPrintingFormat1.Header = serialHeader; tempPrintingFormat1.Body = serialBody2.ToUpper(); tempPrintingFormat1.Footer = serialFooter; tempPrintingFormat1.OrderID = orderID; tempPrintingFormat1.PrintType = (int)PRINTER_TYPES.Serial; CPrintMethodsEXT cPrintMethods = new CPrintMethodsEXT(); CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); for (int printCopy = 0; printCopy < m_printedCopy; printCopy++) { if (foodprint) { string fulltext = tempPrintingFormat.Header + "\r\n" + tempPrintingFormat.Body + "\r\n" + tempPrintingFormat.Footer; cPrintMethods.USBPrint(fulltext, PrintDestiNation.KITCHEN, false); } if (otherfoodprint) { string fulltext = tempPrintingFormat1.Header + "\r\n" + tempPrintingFormat1.Body + "\r\n" + tempPrintingFormat1.Footer; cPrintMethods.USBPrint(fulltext, PrintDestiNation.Other, false); } } if (tempOrderLogInfoList.Count > 0) //If kitchen command is available. { this.UpdateKitchenTextPrintStatus(); } this.WriteString(serialBody);//Writing to the specified file } } else //For online orders all items { bool isItemsAvailable = false; foodprint = false; otherfoodprint = false; serialBody += "\r\n---------------------------------"; for (int rowIndex = 0; rowIndex < g_FoodDataGridView.RowCount; rowIndex++) { // Int64 productID = Int64.Parse(tempRow.Cells[4].Value.ToString()); if (g_FoodDataGridView.Rows[rowIndex].Cells[1].Value.ToString() != String.Empty) { Int64 productID = Int64.Parse(g_FoodDataGridView.Rows[rowIndex].Cells[1].Value.ToString()); CCategory3DAO aDao = new CCategory3DAO(); string printstatus = aDao.GetAllCategory3printareaByCategory3ID((int)productID); if (printstatus == "Otherfood") { otherfoodprint = true; serialBody2 += "\r\n" + g_FoodDataGridView.Rows[rowIndex].Cells[1].Value.ToString() + " "; serialBody2 += CPrintMethods.GetFixedString( g_FoodDataGridView.Rows[rowIndex].Cells[0].Value.ToString(), 20); if (m_isKitchenPriceAvailable == true) { serialBody2 += " " + CPrintMethods.RightAlign( Convert.ToDouble("0" + g_FoodDataGridView.Rows[rowIndex].Cells[2]. Value).ToString("F02"), 6); } } else { foodprint = true; serialBody += "\r\n" + g_FoodDataGridView.Rows[rowIndex].Cells[1].Value.ToString() + " "; serialBody += CPrintMethods.GetFixedString( g_FoodDataGridView.Rows[rowIndex].Cells[0].Value.ToString(), 20); if (m_isKitchenPriceAvailable == true) { serialBody += " " + CPrintMethods.RightAlign( Convert.ToDouble("0" + g_FoodDataGridView.Rows[rowIndex].Cells[2]. Value).ToString("F02"), 6); } } isItemsAvailable = true; } } serialBody += "\r\n---------------------------------"; serialBody += "\r\nKT Txt:" + tempOrderInfo.InitialKitchenText; serialBody += "\r\n---------------------------------"; serialBody += "\r\nOrder Prepared By:" + m_OperatorName; serialBody += "\r\n\r\n [ E N D ]\r\n\r\n"; serialBody2 += "\r\n---------------------------------"; serialBody2 += "\r\nKT Txt:" + tempOrderInfo.InitialKitchenText; serialBody2 += "\r\n---------------------------------"; serialBody2 += "\r\nOrder Prepared By:" + m_OperatorName; serialBody2 += "\r\n\r\n [ E N D ]\r\n\r\n"; if (isItemsAvailable == false)//If there is no items in the datagrid view { return; } else { if (foodprint) { CPrintingFormat tempPrintingFormat = new CPrintingFormat(); CPrintMethodsEXT cPrintMethods = new CPrintMethodsEXT(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.OrderID = orderID; tempPrintingFormat.PrintType = (int) PRINTER_TYPES.Serial; CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin) Activator.GetObject(typeof (RmsRemote.CLogin), oConstant.RemoteURL); // oLogin.PostPrintingRequest(tempPrintingFormat); string fulltext = tempPrintingFormat.Header + "\r\n" + tempPrintingFormat.Body + "\r\n" + tempPrintingFormat.Footer; cPrintMethods.USBPrint(fulltext, PrintDestiNation.KITCHEN, false); this.WriteString(serialBody); //Writing to the specified file } if (otherfoodprint) { CPrintingFormat tempPrintingFormat = new CPrintingFormat(); CPrintMethodsEXT cPrintMethods = new CPrintMethodsEXT(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody2.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.OrderID = orderID; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin) Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); // oLogin.PostPrintingRequest(tempPrintingFormat); string fulltext = tempPrintingFormat.Header + "\r\n" + tempPrintingFormat.Body + "\r\n" + tempPrintingFormat.Footer; cPrintMethods.USBPrint(fulltext, PrintDestiNation.Other, false); this.WriteString(serialBody); //Writing to the specified file } } } if (tempOrderInfo.Status.Equals("Seated") && tempOrderInfo.OrderType.Equals("Table")) { tempOrderInfo.Status = "Ordered"; tempOrderManager.UpdateOrderInfo(tempOrderInfo); } } } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PostPrintingRequest(CPrintingFormat inPrintRequest) { try { bool bTempFlag = false; Debug.WriteLine("in PostPrintingRequest 1"); CPrintQueue.Init(); CCommonConstants oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); m_oPrintRequest = inPrintRequest; Debug.WriteLine("in PostPrintingRequest 2"); m_mPrintMutex = oCommonConstants.PrintMutex; Debug.WriteLine("in PostPrintingRequest 3"); try { Debug.WriteLine("in PostPrintingRequest 4"); bTempFlag = m_mPrintMutex.WaitOne(oCommonConstants.ThreadWaitTime, false); Debug.WriteLine("in PostPrintingRequest 5"); if (bTempFlag) { try { Debug.WriteLine("in PostPrintingRequest 6"); if (m_oPrintRequest != null && CPrintQueue.PrintQueue != null) { Debug.WriteLine("in PostPrintingRequest 7"); CPrintQueue.PrintQueue.Enqueue(m_oPrintRequest); Debug.WriteLine("in PostPrintingRequest 8"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } try { Debug.WriteLine("in PostPrintingRequest 9"); m_mPrintMutex.ReleaseMutex(); Debug.WriteLine("in PostPrintingRequest 10"); } catch (Exception ex1) { Console.WriteLine(ex1.Message); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } catch (Exception ex2) { Console.WriteLine(ex2.Message); } }
public void SerialPrint(CPrintingFormat[] inPrintRequest) { try { Debug.WriteLine("in serial print 1"); InitSerialPort(); Debug.WriteLine("in serial print 2"); CCommonConstants oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); for (int i = 0; i < inPrintRequest.Length; i++) { try { Debug.WriteLine("in serial print 3"); CPrintingFormat oTempPrint = inPrintRequest[i]; if (oTempPrint.PrintType == (int)PRINTER_TYPES.Normal) { Debug.WriteLine("in serial print 4"); CPrintMethods oPrintMethod = new CPrintMethods(); // LocalReport oTempLocalReport = oTempPrint.KitchenReport; //if (oTempLocalReport != null) //{ Debug.WriteLine("in serial print 5"); //oPrintMethod.NetworkPrint(oTempLocalReport, oCommonConstants.LocalPrinterName); LocalInstalledPrint(oTempPrint); Debug.WriteLine("in serial print 6"); //InitSerialPort(); m_pSerialPort.Open(); Debug.WriteLine("in serial print 7"); m_pSerialPort.Write("\r\n\r\n\r\n"); //m_pSerialPort.Write("\x1bd1"); //m_pSerialPort.Write("\r\n\r\n\r\n"); m_pSerialPort.Write(oCommonConstants.BeepCode, 0, oCommonConstants.BeepCode.Length); m_pSerialPort.Write(oCommonConstants.CutPaperCode, 0, oCommonConstants.CutPaperCode.Length); m_pSerialPort.Write("\n"); Debug.WriteLine("in serial print 8"); DisposeSerialPort(); Debug.WriteLine("in serial print 9"); ///update status COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(oTempPrint.OrderID).Data; Debug.WriteLine("in serial print 10"); if (tempOrderInfo.OrderType.Equals("Table")) { Debug.WriteLine("in serial print 11"); tempOrderInfo.Status = "Ordered"; tempOrderInfo.OrderTime = System.DateTime.Now; tempOrderManager.UpdateOrderInfo(tempOrderInfo); Debug.WriteLine("in serial print 12"); } //} else { Debug.WriteLine("in serial print 4a"); } } else if (oTempPrint.PrintType == (int)PRINTER_TYPES.Serial) { // Debug.WriteLine("in serial print 13"); m_pSerialPort.Open(); //Debug.WriteLine("in serial print 14"); //m_pSerialPort.Write(oCommonConstants.BoldOnCode, 0, oCommonConstants.BoldOnCode.Length); //m_pSerialPort.Write(inPrintRequest[i].Header); // Debug.WriteLine("in serial print 15"); //m_pSerialPort.Write(oCommonConstants.BoldOffCode, 0, oCommonConstants.BoldOffCode.Length); //m_pSerialPort.Write(inPrintRequest[i].Body); // SerialPrintHeader(); // Debug.WriteLine("in serial print 15a"); m_pSerialPort.Write(oCommonConstants.SelectFontSize, 0, oCommonConstants.SelectFontSize.Length); m_pSerialPort.Write(inPrintRequest[i].Body); // Debug.WriteLine("in serial print 15b"); //SerialPrintFooter(); // Debug.WriteLine("in serial print 16"); //m_pSerialPort.Write(inPrintRequest[i].Footer); // Debug.WriteLine("in serial print 17"); //m_pSerialPort.Write(m_oCommonConstants.CutPaperCode, 0, oCommonConstants.CutPaperCode.Length); m_pSerialPort.Write("\r\n\r\n\r\n\r\n\r\n\r\n"); // m_pSerialPort.Write("\x1bd1"); //m_pSerialPort.Write("\r\n\r\n\r\n\r\n\r\n\r\n"); m_pSerialPort.Write(oCommonConstants.BeepCode, 0, oCommonConstants.BeepCode.Length); m_pSerialPort.Write(oCommonConstants.CutPaperCode, 0, oCommonConstants.CutPaperCode.Length); m_pSerialPort.Write("\n"); // Debug.WriteLine("in serial print 18"); DisposeSerialPort(); // Debug.WriteLine("in serial print 19"); ///update status COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(oTempPrint.OrderID).Data; // Debug.WriteLine("in serial print 20"); if (tempOrderInfo.OrderType.Equals("Table")) { Debug.WriteLine("in serial print 21"); tempOrderInfo.Status = "Ordered"; tempOrderInfo.OrderTime = System.DateTime.Now; tempOrderManager.UpdateOrderInfo(tempOrderInfo); Debug.WriteLine("in serial print 22"); } } else { } } catch (Exception ex) { } } } catch (Exception ex) { } }
private void btnSend_Click(object sender, EventArgs e) { string serialHeader = ""; string serialFooter = ""; string serialBody = ""; if (txtKitchenText.Text == null || txtKitchenText.Text.Length < 1) { MessageBox.Show("Please enter kitchen text.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { if (MessageBox.Show("Do you confirm to send: '" + txtKitchenText.Text + "' at kitchen", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>(); COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(m_orderID).Data; CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data; string printedText = txtKitchenText.Text; serialBody += "\r\n----------------------------------------"; if (tempOrderInfo.OrderType == "Table") { serialBody += "\r\n TABLE NO: " + tempOrderInfo.TableNumber; serialBody += "\r\n COVERS: " + tempOrderInfo.GuestCount.ToString(); } else { serialBody += "\r\nCUSTOMER NAME: " + tempCustomerInfo.CustomerName; serialBody += "\r\nPHONE: " + tempCustomerInfo.CustomerPhone; if (tempOrderInfo.Status.Equals("Delivery")) { CDelivery objDelivery = new CDelivery(); objDelivery.DeliveryOrderID = m_orderID; CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery); objDelivery = (CDelivery)objDeliveryInfo.Data; serialBody += "\r\nDELIVERY TIME:" + objDelivery.DeliveryTime; } } serialBody += "\r\n----------------------------------------"; serialBody += "\r\n TIME:" + DateTime.Now.ToString("hh:m tt"); serialBody += "\r\n----------------------------------------"; serialBody += "\r\n" + printedText.ToUpper(); serialBody += "\r\n----------------------------------------"; serialBody += "\r\nWaiter:" + RMSGlobal.LoginUserName; serialBody += "\r\n" + m_terminalName; CPrintingFormat tempPrintingFormat = new CPrintingFormat(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody; tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); oLogin.PostPrintingRequest(tempPrintingFormat); tempOrderManager.SaveOrderKitchenText(m_orderID, txtKitchenText.Text,1); this.DialogResult = DialogResult.OK; } } catch (Exception exp) { throw exp; } }
/// <summary> /// Collecting the printed copy of the respective order .added by Baruri at 13.12.2008 /// </summary> private void GetPrintedCopy(Int64 orderID, List<COrderDetails> tempOrderDetailsList) { string Cat1ID = String.Empty; try { CPrintMethods tempPrintMethods = new CPrintMethods(); int categoryID = 0; string serialHeader = "IBACS RMS"; string serialFooter = "Please Come Again"; string serialBody = ""; CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); serialBody = " KITCHEN COPY\r\n"; COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(orderID).Data;//order information for online orders serialBody += "\r\nOrder Date: " + tempOrderInfo.OrderTime.ToString("dd/MM/yy hh:mm tt"); serialBody += "\r\nPrint Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt"); serialBody += "\r\nType: " + tempOrderInfo.Status; CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data; serialBody += "\r\nCustomer Name: " + tempCustomerInfo.CustomerName; serialBody += "\r\nPhone: " + tempCustomerInfo.CustomerPhone; if (tempOrderInfo.Status.Equals("Delivery")) { serialBody += "\r\nAddress:"; serialBody += "\r\n----------------------------------------"; serialBody += "\r\nFloor or Apartment:" + tempCustomerInfo.FloorAptNumber; serialBody += "\r\nBuilding Name:" + tempCustomerInfo.BuildingName; serialBody += "\r\nHouse Number:" + tempCustomerInfo.HouseNumber; serialBody += "\r\nPhone:" + tempCustomerInfo.CustomerPhone; serialBody += "\r\nPostal Code:" + tempCustomerInfo.CustomerPostalCode; serialBody += "\r\nTown:" + tempCustomerInfo.CustomerTown; serialBody += "\r\nCountry:" + tempCustomerInfo.CustomerCountry; serialBody += "\r\n----------------------------------------"; } serialBody += "\r\nOrder Information"; serialBody += "\r\n----------------------------------------"; serialBody += "\r\nQty Item Price "; serialBody += "\r\n----------------------------------------"; if (tempOrderDetailsList.Count > 0) { for (int counter = 0; counter < tempOrderDetailsList.Count; counter++) { serialBody += "\r\n" + tempOrderDetailsList[counter].OrderQuantity.ToString() + " "; serialBody += CPrintMethods.GetFixedString(tempOrderDetailsList[counter].ItemName.ToString(), 30)+" "; serialBody += CPrintMethods.RightAlign(tempOrderDetailsList[counter].OrderAmount.ToString(), 6); // billTotal += Convert.ToDouble("0" + tempOrderDetailsList[j].OrderAmount); } } serialBody += "\r\n----------------------------------------"; //serialBody += "\r\n Order Total: " + billTotal.ToString("F02"); //serialBody += "\r\n Total Payable: " + billTotal.ToString("F02"); //serialBody += "\r\n----------------------------------------"; //serialBody += "\r\n S/N: " + tempOrderInfo.SerialNo.ToString(); //serialBody += "\r\nDeveloped by:ibacs limited."; serialBody += "\r\nThis is an online order."; serialBody += "\r\n [END] "; CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>(); CPrintingFormat tempPrintingFormat = new CPrintingFormat(); tempPrintingFormat.Header = serialHeader; tempPrintingFormat.Body = serialBody.ToUpper(); tempPrintingFormat.Footer = serialFooter; tempPrintingFormat.OrderID = orderID; tempPrintingFormat.PrintType = (int)PRINTER_TYPES.Serial; CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), oConstant.RemoteURL); oLogin.PostPrintingRequest(tempPrintingFormat); ///Update status /// if (tempOrderInfo.OrderType.Equals("Table")) { tempOrderInfo.Status = "Billed"; tempOrderInfo.OrderTime = System.DateTime.Now; tempOrderManager.UpdateOrderInfo(tempOrderInfo); CPaymentManager tempPaymentManager = new CPaymentManager(); CPayment tempPayment = new CPayment(); tempPayment.OrderID = tempOrderInfo.OrderID; tempPayment.BillPrintTime = DateTime.Now; tempPaymentManager.InsertBillPrintTime(tempPayment); } } catch (Exception exp) { } }
private void btnPrintSummary_Click(object sender, EventArgs e) { m_htFoods = new Hashtable(); m_htNonFoods = new Hashtable(); // FormatDataTime(); DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); DateTime dtNow = DateTime.Now; DateTime dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0); DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 23, 59, 59); //if (chkFromTime.Checked) //{ dtStart = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, 7, 0, 0); dtEnd = new DateTime(dtEnd.Year, dtEnd.Month, dtEnd.Day, 6, 59, 59); // } dtEnd = dtEnd.AddDays(1); objResult = objSystemMgnr.GetSalesRecordsForINV(dtStart.Ticks, dtEnd.Ticks); StringPrintFormater strPrintFormatter = new StringPrintFormater(40); DataTable dt = (DataTable)objResult.Data; tableReport = new DataTable(); tableReport.Columns.Add("product_id", typeof(int)); tableReport.Columns.Add("product_Name", typeof(string)); tableReport.Columns.Add("amount", typeof(string)); tableReport.Columns.Add("quantity", typeof(string)); tableReport.Columns.Add("TotalAmount", typeof(string)); tableReport.Columns.Add("guest_count", typeof(int)); tableReport.Columns.Add("cat_level", typeof(int)); tableReport.Columns.Add("food_type", typeof(string)); if (dt != null || dt.Rows.Count > 0) for (int i = 0; i < dt.Rows.Count; i++) { tableReport.Rows.Add(Convert.ToInt16(dt.Rows[i]["product_id"]), Convert.ToString(dt.Rows[i]["product_Name"]), dt.Rows[i]["amount"].ToString(), dt.Rows[i]["quantity"].ToString(), dt.Rows[i]["TotalAmount"].ToString(), Convert.ToInt16(dt.Rows[i]["guest_count"]), Convert.ToInt16(dt.Rows[i]["cat_level"]), dt.Rows[i]["food_type"].ToString()); } if (dataGridView1.Rows.Count > 0) if (tableReport.Rows.Count > 0) { // Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].Rows[0]["guest_count"]); Int32 guestCounter = Convert.ToInt32(tableReport.Rows[0]["guest_count"]); CPrintMethods tempPrintMethods = new CPrintMethods(); string serialHeader = RMSClientController.CollectHeader(); string serialFooter = RMSClientController.CollectFooter(); List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>(); CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Inventory Sales Report") + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Date of Consumption of Items:" + DateTime.Now.ToString("dd/MM/yyyy")) + "\r\n"; serialBody.Add(tempSerialPrintContent); //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n"; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() +"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Qty Item Price(£)"+"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() + "\r\n"; serialBody.Add(tempSerialPrintContent); CCategory3DAO category3DAO = new CCategory3DAO(); SortedList slorderedFoodItems = new SortedList(); SortedList slorderedNonFoodItems = new SortedList(); //if (dsSalesRecords.Tables[0].Rows.Count > 0) if (tableReport.Rows.Count > 0) { // foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows) foreach (DataRow dtRrow in tableReport.Rows) { clsOrderReport objOrderedItems = new clsOrderReport(); string[] returnedValue = GetProductName(dtRrow).Split(':'); // string productName = Convert.ToString(returnedValue[0]); string productName = ""; CCategory3 cat3 = category3DAO.GetAllCategory3ByCategory3ID(Convert.ToInt32(dtRrow["product_id"].ToString())); if (cat3 != null && cat3.Category3Name.Length>0) { productName = cat3.Category3Name; } else { productName = Convert.ToString(dtRrow["product_Name"].ToString()); // @hafiz } string cat1ID = Convert.ToString(returnedValue[1]); objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString()); objOrderedItems.ItemName = productName; objOrderedItems.Price = Convert.ToDouble(dtRrow["TotalAmount"]); objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]); Int32 category1OrderNumber = 0; if (cat1ID != "") { category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID)); objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; if (Convert.ToString(dtRrow["food_type"]).Equals("Food")) //Separate food/nonfoods { m_htFoods.Add(keyCode, objOrderedItems); } else { m_htNonFoods.Add(keyCode, objOrderedItems); } } else { category1OrderNumber = maxOrder + 1; objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; if (Convert.ToString(dtRrow["food_type"]).Equals("Food")) //Separate food/nonfoods { m_htFoods.Add(keyCode, objOrderedItems); } else { m_htNonFoods.Add(keyCode, objOrderedItems); } } } int separatorNumber = -1; NumericComparer nc = new NumericComparer(); slorderedFoodItems = new SortedList(m_htFoods, nc); //Creating the sorted list from the hash table. slorderedNonFoodItems = new SortedList(m_htNonFoods, nc); SortedList slMaster1 = new SortedList(); ArrayList arrListItems = null; foreach (DictionaryEntry objOrderedItems in slorderedFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedItems.Value; string keyValue = objOrderedItems.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItems = new ArrayList(); arrListItems.Add(objItem); slMaster1.Add(separatorNumber, arrListItems); } else { arrListItems.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } PrintUtility printUtility = new PrintUtility(); ArrayList alReverseOrderedItem; foreach (DictionaryEntry deReverseOrderedItem in slMaster1) { alReverseOrderedItem = (ArrayList)deReverseOrderedItem.Value; alReverseOrderedItem.Reverse();//Reversing the current item order. foreach (clsOrderReport objOrderedItems in alReverseOrderedItem) { if (separatorNumber != objOrderedItems.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":" +"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + " " + printUtility.MultipleLine(objOrderedItems.ItemName, 32, objOrderedItems.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); separatorNumber = objOrderedItems.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + " " + printUtility.MultipleLine(objOrderedItems.ItemName, 32, objOrderedItems.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); } } } #region "Non food items" tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithDashed("Drinks") + "\r\n"; // tempSerialPrintContent.StringLine = "-----------------Drinks-----------------" + "\r\n"; serialBody.Add(tempSerialPrintContent); SortedList slMaster2 = new SortedList(); ArrayList arrListItemsNonFood = new ArrayList(); separatorNumber = -1; foreach (DictionaryEntry objOrderedNonFood in slorderedNonFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedNonFood.Value; string keyValue = objOrderedNonFood.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItemsNonFood = new ArrayList(); arrListItemsNonFood.Add(objItem); slMaster2.Add(separatorNumber, arrListItemsNonFood); } else { arrListItemsNonFood.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } separatorNumber = -1; bool istrue = false; foreach (DictionaryEntry objNonFood in slMaster2) { ArrayList alNonFoods = (ArrayList)objNonFood.Value; alNonFoods.Reverse(); foreach (clsOrderReport objNonFoodItem in alNonFoods) { if (separatorNumber != objNonFoodItem.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "----------------------------------------"; serialBody.Add(tempSerialPrintContent); if (tempSerialPrintContent != null && tempSerialPrintContent.StringLine.Equals("") && !istrue) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objNonFoodItem.FoodTypeName + ":" +"\r\n"; serialBody.Add(tempSerialPrintContent); } tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objNonFoodItem.Quantity.ToString() + " " + printUtility.MultipleLine(objNonFoodItem.ItemName, 32, objNonFoodItem.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); separatorNumber = objNonFoodItem.OrderNumber; istrue = true; } else { tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objNonFoodItem.Quantity.ToString() + " " + printUtility.MultipleLine(objNonFoodItem.ItemName, 32, objNonFoodItem.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); } } } #endregion tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "----------------------------------------\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total No Of Item: " + lblNoOfItemsSold.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Qty: " + lblTotalQty.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Item Amount: " + lblTotalAmount.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Developed By: www.ibacs.co.uk") + "\r\n\n"; serialBody.Add(tempSerialPrintContent); #region "Testing printing area" string printingObject = ""; for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++) { printingObject += serialBody[arrayIndex].StringLine.ToString(); } this.WriteString(printingObject);///Write to a file when print command is executed #endregion //@aamr Remote Print CCommonConstants m_oCommonConstants; m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), m_oCommonConstants.RemoteURL); CResult oResult = oLogin.GetInitialDBStr(); Object o = oLogin.GetType(); CPrintingFormat inPrintRequest = new CPrintingFormat(); inPrintRequest.Header = "Header"; inPrintRequest.Footer = "Footer"; inPrintRequest.Body = "Hello Remote Printing..."; try { oLogin.PostPrintingRequest(inPrintRequest); PostPrintingRequest1(inPrintRequest); } catch (Exception ex) { } CPrintMethodsEXT tempPrintMethods1 = new CPrintMethodsEXT(); DataSet tempDataSet = new DataSet(); tempDataSet.ReadXml("Config/Print_Config.xml"); if (Convert.ToBoolean(tempDataSet.Tables[0].Rows[0]["IsGuestBillPrinterSerial"]) == true) { // tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "SN".ToString()); tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, printingObject, serialFooter, "SN".ToString()); } else { tempPrintMethods1.USBPrint(printingObject, PrintDestiNation.CLIENT, true); } } } else { MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }