예제 #1
0
        private void btnDrawerOpen_Click(object sender, EventArgs e)
        {
            Int64 startTime = 0;
            Int64 endTime = 0;

            CPrintMethods tempPrintMethods = new CPrintMethods();
            CCommonConstants oConstant = ConfigManager.GetConfig<CCommonConstants>();

            //Set Start of the day
            DateTime dtStart = new DateTime(dtpOrders.Value.Year, dtpOrders.Value.Month, dtpOrders.Value.Day, 0, 0, 0);

            //Set End of the day
            DateTime dtEnd = new DateTime(dtpOrders.Value.Year, dtpOrders.Value.Month, dtpOrders.Value.Day, 23, 59, 59);
            startTime = dtStart.Ticks;
            endTime = dtEnd.Ticks;

            CPaymentManager objPaymentManager = new CPaymentManager();
            CResult objResult = null;
            objResult = objPaymentManager.GetPaymentLogDetails(startTime, endTime);
            ViewDrawerLogForm objViewLog = ViewDrawerLogForm.CreateInstance();
            objViewLog.objResult = objResult;
            objViewLog.Show();
            CFormManager.Forms.Push(this);
            this.Hide();
        }
예제 #2
0
        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();
        }
예제 #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                CDepositManager tempDepositManager = new CDepositManager();
                CDeposit tempDeposit = new CDeposit();

                Double tempCash = 0.000;
                Double tempEFT = 0.000;
                Double tempCheque = 0.000;
                Double tempAccount = 0.000;
                Double tempTotal = 0.000;

                Double.TryParse(g_CashLabel.Text.Substring(1), out tempCash);
                Double.TryParse(g_EFTLabel.Text.Substring(1), out tempEFT);
                Double.TryParse(g_ChequeLabel.Text.Substring(1), out tempCheque);
                Double.TryParse(g_AccountLabel.Text.Substring(1), out tempAccount);
                Double.TryParse(g_DepositTotalLabel.Text.Substring(1), out tempTotal);

                if (tempTotal == 0)
                {
                    MessageBox.Show("Zero amount given for deposit. Please recheck", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                tempDeposit.DepositBalance = tempTotal;
                tempDeposit.DepositTime = DateTime.Now.Ticks;
                tempDeposit.CustomerID=m_iCustomerID;
                tempDeposit.DepositTotalAmount = tempTotal;
                tempDeposit.DepositType = m_sDepositType;
                tempDeposit.Status = 1;

                CPcInfoManager tempPcInfoManager = new CPcInfoManager();
                IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName());
                CPcInfo tempPcInfo=new CPcInfo();
                CResult oResult= tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString());
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempPcInfo = (CPcInfo)oResult.Data;
                }
                tempDeposit.PcID = tempPcInfo.PcID;

                oResult = tempDepositManager.InsertDeposit(tempDeposit);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempDeposit = (CDeposit)oResult.Data;
                }

                //get customer name & phone
                CCustomerManager tempCustomerManager= new CCustomerManager();
                CCustomerInfo tempCustomerInfo= new CCustomerInfo();
                oResult = tempCustomerManager.CustomerInfoGetByCustomerID(m_iCustomerID);
                if(oResult.IsSuccess && oResult.Data!=null)
                {
                    tempCustomerInfo = (CCustomerInfo)oResult.Data;
                }

                //string serialBody = "\r\n         Deposit Token\r\n";
                //serialBody += "\r\n         Customer Name: "+tempCustomerInfo.CustomerName;
                //serialBody += "\r\n         Phone: " + tempCustomerInfo.CustomerPhone+"\r\n";

                //serialBody += "\r\n         By " + tempDeposit.DepositType;
                //serialBody += "\r\n---------------------------------";
                //serialBody += "\r\n         Total: " + tempDeposit.DepositBalance.ToString("F02");
                //serialBody += "\r\n";
                //serialBody += "\r\nS/N: " + tempDeposit.DepositID.ToString();

                string serialBody = "\r\n                Deposit Token\r\n";
                DateTime tempODate = new DateTime(tempDeposit.DepositTime);
                string tempODateString = "Deposit Date: " + tempODate.ToLongDateString();
                serialBody += "".PadRight((int)((45 - tempODateString.Length) / 2), ' ') + tempODateString.Trim() + "\r\n";
                string tempDateString = "Reprint Date: " + DateTime.Now.ToLongDateString();
                serialBody += "".PadRight((int)((45 - tempDateString.Length) / 2), ' ') + tempDateString.Trim() + "\r\n\r\n";
                serialBody += "Customer Name: " + tempCustomerInfo.CustomerName + "\r\n";
                string tempAddressString = "Customer Address: " + tempCustomerInfo.CustomerAddress.Trim();
                if (tempAddressString.Length > 40)
                {
                    tempAddressString = tempAddressString.Substring(0, 40) + "\r\n".PadRight(19, ' ') + tempAddressString.Substring(40);
                }
                serialBody += tempAddressString + "\r\n";
                serialBody += "Phone: " + tempCustomerInfo.CustomerPhone + "\r\n\r\n";
                serialBody += "Deposit Type:     " + tempDeposit.DepositType + "\r\n";
                serialBody += "Deposited Amount: " + tempDeposit.DepositTotalAmount.ToString("F02") + "\r\n";
                double tempDepositUsed = (tempDeposit.DepositTotalAmount - tempDeposit.DepositBalance);
                serialBody += "Deposit Used:     " + tempDepositUsed.ToString("F02") + "\r\n";
                serialBody += "---------------------------------\r\n";
                serialBody += "Total Balance:    " + tempDeposit.DepositBalance.ToString("F02") + "\r\n\r\n";
                serialBody += "S/N: " + tempDeposit.DepositID.ToString() + "\r\n";

                CPrintMethods tempPrintMethods = new CPrintMethods();
                tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER,"",serialBody,"",tempDeposit.DepositID.ToString());
                this.Close();

            }
            catch (Exception eee)
            {
            }
        }
예제 #4
0
        private void ReprintButton_Click(object sender, EventArgs e)
        {
            try
            {
                int tempRowIndex = 0;
                bool tempFlag = false;
                for (int rowCounter = 0; rowCounter < ViewReportDataGridView.RowCount; rowCounter++)
                {
                    if (ViewReportDataGridView.Rows[rowCounter].Selected == true && ViewReportDataGridView.Rows[rowCounter].Cells["OrderIDColumn"].Value != null)
                    {
                        tempRowIndex = rowCounter;
                        tempFlag = true;
                        break;
                    }
                }

                if (tempFlag)
                {
                    CPrintMethods tempPrintMethods = new CPrintMethods();

                    Int64 orderID = 0;
                    Int64.TryParse(ViewReportDataGridView.Rows[tempRowIndex].Cells["OrderIDColumn"].Value.ToString(), out orderID);
                    COrderManager tempOrderManager = new COrderManager();
                    COrderInfoArchive tempOrderInfo = (COrderInfoArchive)tempOrderManager.OrderInfoArchiveByOrderID(orderID).Data;

                    //serial print
                    //string serialHeader = "IBACS RMS";
                    string serialHeader = "";
                    string serialFooter = "";
                    List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>();
                    CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "               Guest Bill\n";
                    serialBody.Add(tempSerialPrintContent);

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "Reprint Date: " + System.DateTime.Now.ToLongDateString() + "\n";
                    serialBody.Add(tempSerialPrintContent);

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "Billing Date: " +  tempCurrentDate.ToLongDateString() + "\n";
                    serialBody.Add(tempSerialPrintContent);

                    if (tempOrderInfo.OrderType.Equals("Table"))
                    {
                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "            Table Number: " + tempOrderInfo.TableNumber + "\n";
                        tempSerialPrintContent.Bold = true;
                        serialBody.Add(tempSerialPrintContent);

                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "                  Covers: " + tempOrderInfo.GuestCount + "\n";
                        tempSerialPrintContent.Bold = true;
                        serialBody.Add(tempSerialPrintContent);
                    }
                    else if (tempOrderInfo.OrderType.Equals("TakeAway"))
                    {

                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "Take Away ";
                        serialBody.Add(tempSerialPrintContent);
                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "Type: " + tempOrderInfo.Status;
                        serialBody.Add(tempSerialPrintContent);

                        CCustomerManager tempCustomerManager = new CCustomerManager();
                        CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data;

                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "Customer Name: " + tempCustomerInfo.CustomerName;
                        serialBody.Add(tempSerialPrintContent);
                        if (tempOrderInfo.Status.Equals("Delivery"))
                        {
                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine = "Address:";
                            serialBody.Add(tempSerialPrintContent);

                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine = "----------------------------------------";
                            serialBody.Add(tempSerialPrintContent);

                            if (tempCustomerInfo.FloorAptNumber.Length > 0)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "Floor or Apartment:" + tempCustomerInfo.FloorAptNumber;
                                serialBody.Add(tempSerialPrintContent);
                            }

                            if (tempCustomerInfo.BuildingName.Length > 0)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "Building Name:" + tempCustomerInfo.BuildingName;
                                serialBody.Add(tempSerialPrintContent);
                            }

                            if (tempCustomerInfo.HouseNumber.Length > 0)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "House Number:" + tempCustomerInfo.HouseNumber;
                                serialBody.Add(tempSerialPrintContent);
                            }

                            string[] street = new string[0];
                            street = tempCustomerInfo.StreetName.Split('-');

                            if (street.Length > 1)
                            {
                                if (street[0].ToString().Length > 0)
                                {
                                    tempSerialPrintContent = new CSerialPrintContent();
                                    tempSerialPrintContent.StringLine = "Street:" + street[0].ToString();
                                    serialBody.Add(tempSerialPrintContent);
                                }

                                if (street[1].ToString().Length > 0)
                                {
                                    tempSerialPrintContent = new CSerialPrintContent();
                                    tempSerialPrintContent.StringLine = street[1].ToString();
                                    serialBody.Add(tempSerialPrintContent);
                                }
                            }
                            else if (street.Length > 0 && street.Length < 2)
                            {
                                if (street[0].ToString().Length > 0)
                                {
                                    tempSerialPrintContent = new CSerialPrintContent();
                                    tempSerialPrintContent.StringLine = "Street:" + street[0].ToString();
                                    serialBody.Add(tempSerialPrintContent);
                                }
                            }

                            if (tempCustomerInfo.CustomerPostalCode.Length > 0)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "Postal Code:" + tempCustomerInfo.CustomerPostalCode;
                                serialBody.Add(tempSerialPrintContent);
                            }
                            if (tempCustomerInfo.CustomerTown.Length > 0)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "Town:" + tempCustomerInfo.CustomerTown;
                                serialBody.Add(tempSerialPrintContent);
                            }

                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine = "----------------------------------------";
                            serialBody.Add(tempSerialPrintContent);

                            CDelivery objDelivery = new CDelivery();
                            objDelivery.DeliveryOrderID = orderID;
                            CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery);
                            objDelivery = (CDelivery)objDeliveryInfo.Data;
                            if (objDelivery != null)
                            {
                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = "\r\nDelivery Time:" + objDelivery.DeliveryTime;
                                serialBody.Add(tempSerialPrintContent);
                            }
                        }
                    }
                    else if (tempOrderInfo.OrderType.Equals("Tabs"))
                    {
                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "            Tabs Number: " + tempOrderInfo.TableNumber + "\n";
                        tempSerialPrintContent.Bold = true;
                        serialBody.Add(tempSerialPrintContent);

                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = "            Guest Number: " + tempOrderInfo.GuestCount + "\n";
                        tempSerialPrintContent.Bold = true;
                        serialBody.Add(tempSerialPrintContent);
                    }

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "Order Information";
                    serialBody.Add(tempSerialPrintContent);
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "----------------------------------------";
                    serialBody.Add(tempSerialPrintContent);
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "Qty Item                         Price  ";
                    serialBody.Add(tempSerialPrintContent);
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "----------------------------------------";
                    serialBody.Add(tempSerialPrintContent);

                    CResult tempResult = new CResult();
                    tempResult = tempOrderManager.OrderDetailsArchiveByOrderID(orderID);

                    if (tempResult.IsSuccess)
                    {
                        List<COrderDetails> tempList = new List<COrderDetails>();
                        tempList = (List<COrderDetails>)tempResult.Data;
                        COrderDetails[] tempOrderDetails = tempList.ToArray();

                        for (int recordIndex = 0; recordIndex < tempOrderDetails.Length; recordIndex++)
                        {
                            String tempItemName = String.Empty;
                            if (tempOrderDetails[recordIndex].CategoryLevel == 3)
                            {
                                DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempOrderDetails[recordIndex].ProductID);
                                tempItemName = tempDataRowArr[0]["cat3_name"].ToString();
                            }
                            else if (tempOrderDetails[recordIndex].CategoryLevel == 4)
                            {
                                DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempOrderDetails[recordIndex].ProductID);
                                tempItemName = tempDataRowArr[0]["cat4_name"].ToString();
                            }

                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine = tempOrderDetails[recordIndex].OrderQuantity.ToString()+" ";
                            tempSerialPrintContent.StringLine += ProcessItemNameFormat(tempItemName, 38);
                            tempSerialPrintContent.StringLine += "\r\n---------------------------------- " + tempOrderDetails[recordIndex].OrderAmount.ToString("F02");
                            serialBody.Add(tempSerialPrintContent);
                        }
                    }

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "----------------------------------------";
                    serialBody.Add(tempSerialPrintContent);
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "                      Order Total: " + ViewReportDataGridView.Rows[tempRowIndex].Cells["TotalPaymentColumn"].Value.ToString();
                    serialBody.Add(tempSerialPrintContent);

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "----------------------------------------";
                    serialBody.Add(tempSerialPrintContent);
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "\nS/N: " + tempOrderInfo.SerialNo.ToString();
                    serialBody.Add(tempSerialPrintContent);
                    tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, tempOrderInfo.SerialNo.ToString());

                    string printingObject = "";
                    for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++)
                    {
                        printingObject += serialBody[arrayIndex].StringLine.ToString() + "\r\n";
                    }

                    this.WriteString(printingObject);///Write to a file when print command is executed

                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #5
0
        private void PrintSummaryButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (tempCurrentDate.Date.CompareTo(DateTime.Today.Date) != 0) tempCurrentDate = new DateTime(tempCurrentDate.Year, tempCurrentDate.Month, tempCurrentDate.Day, 8, 0, 0);
                else if (tempCurrentDate.Date.CompareTo(DateTime.Today.Date) == 0) tempCurrentDate = DateTime.Now;

                CPaymentSummaryManager tempPaymentSummaryManager = new CPaymentSummaryManager();
                CPaymentSummary tempPayamentSummary = new CPaymentSummary();
                tempPayamentSummary = (CPaymentSummary)tempPaymentSummaryManager.GetTotalPaymentSummary(tempCurrentDate).Data;

                CPrintMethods tempPrintMethods = new CPrintMethods();

                string serialHeader = "";
                string serialFooter = "";

                string serialBody = "";
                serialBody += "            Payment Summary Report";
                String DateString = "Billing Date: " + tempCurrentDate.ToLongDateString();
                serialBody += "\r\n".PadRight((int)(45 - DateString.Length) / 2) + DateString + "\r\n\r\n";

                if (tempPayamentSummary != null)
                {
                    serialBody += "Payable Summary:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nGross Sale:" + (tempPayamentSummary.TotalPayment + tempPayamentSummary.TotalServicePayment + tempPayamentSummary.TotalDiscount + tempPayamentSummary.TotalVoucherPayment - tempPayamentSummary.ServiceChargeVoucher).ToString("F02");
                    serialBody += "\r\nNet Sale:" + (Convert.ToDouble(lblGrossValue.Text) - tempPayamentSummary.TotalDiscount - tempPayamentSummary.TotalVoucherPayment - tempPayamentSummary.TotalServicePayment + tempPayamentSummary.ServiceChargeVoucher).ToString("F02");

                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nNet Sales Breakdown:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nTotal Cash: " + (tempPayamentSummary.TotalCashPayment-tempPayamentSummary.ServiceChargeCash).ToString("F02");
                    serialBody += "\r\n EFT: " + (tempPayamentSummary.TotalEFTPayment-tempPayamentSummary.ServiceChargeEft).ToString("F02");
                    serialBody += "\r\n Cheque: " + (tempPayamentSummary.TotalChequePayment-tempPayamentSummary.ServiceChargeCheque).ToString("F02");
                    serialBody += "\r\n Account: " + (tempPayamentSummary.TotalAccPayment - tempPayamentSummary.ServiceChargeAcc).ToString("F02");

                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nPromotions and Discounts:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Voucher: " + tempPayamentSummary.TotalVoucherPayment.ToString("F02");
                    serialBody += "\r\n Discount: " + tempPayamentSummary.TotalDiscount.ToString("F02");
                    serialBody += "\r\n Service Ch: " + tempPayamentSummary.TotalServicePayment.ToString("F02");
                    serialBody += "\r\n----------------------------------------";

                    serialBody += "\r\nService Charge Breakdown:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Cash: " + tempPayamentSummary.ServiceChargeCash.ToString("F02");
                    serialBody += "\r\n Cheque: " + tempPayamentSummary.ServiceChargeCheque.ToString("F02");
                    serialBody += "\r\n Voucher: " + tempPayamentSummary.ServiceChargeVoucher.ToString("F02");
                    serialBody += "\r\n Eft: " + tempPayamentSummary.ServiceChargeEft.ToString("F02");
                    serialBody += "\r\n Accounts: " + tempPayamentSummary.ServiceChargeAcc.ToString("F02");
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Deposit Used: " + tempPayamentSummary.TotalDepositePayment.ToString("F02");
                }
                serialBody += "\r\n\r\n";
                tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "");

                this.WriteString(serialBody);///Write to a file when print command is executed
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #6
0
        private void PrintDetailButton_Click(object sender, EventArgs e)
        {
            try
            {
                CPrintMethods tempPrintMethods = new CPrintMethods();
                string serialHeader = "";
                string serialFooter = "";

                string serialBody = "";
                serialBody += "            Payment Detail Report";
                String DateString = "Billing Date: " + tempCurrentDate.ToLongDateString();
                serialBody += "\r\n".PadRight((int)(45 - DateString.Length) / 2) + DateString + "\r\n\r\n";

                if (tempCurrentDate.Date.CompareTo(DateTime.Today.Date) != 0) tempCurrentDate = new DateTime(tempCurrentDate.Year, tempCurrentDate.Month, tempCurrentDate.Day, 8, 0, 0);
                else if (tempCurrentDate.Date.CompareTo(DateTime.Today.Date) == 0) tempCurrentDate = DateTime.Now;

                CPaymentSummaryManager tempSummaryByOrderManager = new CPaymentSummaryManager();
                List<CPaymentSummaryByOrder> tempSummaryByOrder = (List<CPaymentSummaryByOrder>)tempSummaryByOrderManager.GetTotalPaymentSummaryForViewReport(tempCurrentDate).Data;

                CPaymentSummaryByOrder[] tempSummaryByOrderArray = tempSummaryByOrder.ToArray();

                serialBody += "SL  Order     Table   Payment     Total";
                serialBody += "\r\n    Type      Number   Type";
                serialBody += "\r\n--- -------- ---- --------------- ------";
                for (int counter = 0; counter < tempSummaryByOrderArray.Length; counter++)
                {
                    bool tempbool = false;
                    float tempCashPayment = 0;
                    float tempChequePayment = 0;
                    float tempVoucherPayment = 0;
                    float tempDiscount = 0;
                    float tempDepositePayment = 0;
                    float tempEFTPayment = 0;
                    float tempServicePayment = 0;

                    float.TryParse(tempSummaryByOrderArray[counter].TotalCashPayment.ToString(), out tempCashPayment);
                    float.TryParse(tempSummaryByOrderArray[counter].TotalChequePayment.ToString(), out tempChequePayment);
                    float.TryParse(tempSummaryByOrderArray[counter].TotalVoucherPayment.ToString(), out tempVoucherPayment);
                    float.TryParse(tempSummaryByOrderArray[counter].TotalDepositePayment.ToString(), out tempDepositePayment);
                    float.TryParse(tempSummaryByOrderArray[counter].TotalEFTPayment.ToString(), out tempEFTPayment);
                    float.TryParse(tempSummaryByOrderArray[counter].TotalServicePayment.ToString(), out tempServicePayment);
                    float.TryParse(tempSummaryByOrderArray[counter].Discount.ToString(), out tempDiscount);

                    serialBody += "\r\n" + ((int)(counter + 1)).ToString().PadRight(3) + " " + (tempSummaryByOrderArray[counter].OrderType.Trim()).PadRight(8, ' ') + " " + tempSummaryByOrderArray[counter].TableNumber.ToString().PadRight(4, ' ') + " ";// +tempPayString.Trim().PadRight(13, ' ') + "  " + tempSummaryByOrderArray[i].TotalPayment;
                    if (tempCashPayment > 0)
                    {
                        string temp = "Cash:(" + tempCashPayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment+tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempChequePayment > 0)
                    {
                        string temp = "Cheque(" + tempChequePayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment+tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempVoucherPayment > 0)
                    {
                        string temp = "Voucher(" + tempVoucherPayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment + tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempEFTPayment > 0)
                    {
                        string temp = "EFT(" + tempEFTPayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment + tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempServicePayment > 0)
                    {
                        string temp = "Sevice(" + tempServicePayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment + tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempDiscount > 0)
                    {
                        string temp = "Discount(" + tempDiscount.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment + tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                    if (tempDepositePayment > 0)
                    {
                        string temp = "Deposit(" + tempDepositePayment.ToString("F02") + ")";
                        if (!tempbool)
                        {
                            serialBody += temp.PadRight(15, ' ') + " " + (tempSummaryByOrderArray[counter].TotalPayment + tempSummaryByOrderArray[counter].TotalServicePayment).ToString("F02") + "\r\n";
                            tempbool = true;
                        }
                        else
                        {
                            serialBody += "                  " + temp.PadRight(15, ' ') + "\r\n";
                        }
                    }
                }

                CPaymentSummaryManager tempPaymentSummaryManager = new CPaymentSummaryManager();
                CPaymentSummary tempPayamentSummary = new CPaymentSummary();
                tempPayamentSummary = (CPaymentSummary)tempPaymentSummaryManager.GetTotalPaymentSummary(tempCurrentDate).Data;

                if (tempPayamentSummary != null)
                {
                    serialBody += "Payable Summary:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nGross Sale:" + (tempPayamentSummary.TotalPayment + tempPayamentSummary.TotalServicePayment + tempPayamentSummary.TotalDiscount + tempPayamentSummary.TotalVoucherPayment - tempPayamentSummary.ServiceChargeVoucher).ToString("F02");
                    serialBody += "\r\nNet Sale:" + (Convert.ToDouble(lblGrossValue.Text) - tempPayamentSummary.TotalDiscount - tempPayamentSummary.TotalVoucherPayment - tempPayamentSummary.TotalServicePayment + tempPayamentSummary.ServiceChargeVoucher).ToString("F02");

                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nNet Sales Breakdown:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nTotal Cash: " + (tempPayamentSummary.TotalCashPayment-tempPayamentSummary.ServiceChargeCash) .ToString("F02");
                    serialBody += "\r\n EFT: " + (tempPayamentSummary.TotalEFTPayment-tempPayamentSummary.ServiceChargeEft).ToString("F02");
                    serialBody += "\r\n Cheque: " + (tempPayamentSummary.TotalChequePayment-tempPayamentSummary.ServiceChargeCheque).ToString("F02");
                    serialBody += "\r\n Account: " + (tempPayamentSummary.TotalAccPayment - tempPayamentSummary.ServiceChargeAcc).ToString("F02");

                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\nPromotions and Discounts:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Voucher: " + tempPayamentSummary.TotalVoucherPayment.ToString("F02");
                    serialBody += "\r\n Discount: " + tempPayamentSummary.TotalDiscount.ToString("F02");
                    serialBody += "\r\n Service Ch: " + tempPayamentSummary.TotalServicePayment.ToString("F02");
                    serialBody += "\r\n----------------------------------------";

                    serialBody += "\r\nService Charge Breakdown:";
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Cash: " + tempPayamentSummary.ServiceChargeCash.ToString("F02");
                    serialBody += "\r\n Cheque: " + tempPayamentSummary.ServiceChargeCheque.ToString("F02");
                    serialBody += "\r\n Voucher: " + tempPayamentSummary.ServiceChargeVoucher.ToString("F02");
                    serialBody += "\r\n Eft: " + tempPayamentSummary.ServiceChargeEft.ToString("F02");
                    serialBody += "\r\n Accounts: " + tempPayamentSummary.ServiceChargeAcc.ToString("F02");
                    serialBody += "\r\n----------------------------------------";
                    serialBody += "\r\n Deposit Used: " + tempPayamentSummary.TotalDepositePayment.ToString("F02");
                    serialBody += "\r\n\r\n";
                }
                serialBody += "\r\n\r\n";

                tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "");

                this.WriteString(serialBody);///Write to a file when print command is executed
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #7
0
        private void btnCurrentDay_Click(object sender, EventArgs e)
        {
            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);

            objResult = objSystemMgnr.GetSalesRecords(dtStart.Ticks, dtEnd.Ticks);
            dsSalesRecords = (DataSet)objResult.Data;
            if (dsSalesRecords.Tables.Count > 0 && dsSalesRecords.Tables[0].Rows.Count > 0)
            {
                Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].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 = "         Inventory Sales Report\n";
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Date of Consumption of Items:" + DateTime.Now.ToString("dd/MM/yyyy"); ;
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n";
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Qty Item                           Price";
                serialBody.Add(tempSerialPrintContent);

                SortedList slorderedFoodItems = new SortedList();
                SortedList slorderedNonFoodItems = new SortedList();
                if (dsSalesRecords.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows)
                    {
                        clsOrderReport objOrderedItems = new clsOrderReport();
                        string[] returnedValue = GetProductName(dtRrow).Split(':');

                        string productName = Convert.ToString(returnedValue[0]);
                        string cat1ID = Convert.ToString(returnedValue[1]);

                        objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString());
                        objOrderedItems.ItemName = productName;
                        objOrderedItems.Price = Convert.ToDouble(dtRrow["amount"]);
                        objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]);

                        Int32 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);
                        }
                    }
                    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]);
                        }
                    }

                    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 = "----------------------------------------";
                                serialBody.Add(tempSerialPrintContent);

                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":";
                                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);
                                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);
                                serialBody.Add(tempSerialPrintContent);
                            }
                        }
                    }

                    #region "Non food items"
                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "-----------------Drinks-----------------";
                    serialBody.Add(tempSerialPrintContent);

                    SortedList slMaster2 = new SortedList();
                    ArrayList arrListItemsNonFood = null;

                    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;
                    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);

                                tempSerialPrintContent = new CSerialPrintContent();
                                tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + "  ";
                                tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30);
                                tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6);
                                serialBody.Add(tempSerialPrintContent);

                                separatorNumber = objNonFoodItem.OrderNumber;
                            }
                            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);
                                serialBody.Add(tempSerialPrintContent);
                            }
                        }
                    }

                    #endregion

                    tempSerialPrintContent = new CSerialPrintContent();
                    tempSerialPrintContent.StringLine = "----------------------------------------";
                    serialBody.Add(tempSerialPrintContent);

                    #region "Testing printing area"
                    string printingObject = "";
                    for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++)
                    {
                        printingObject += serialBody[arrayIndex].StringLine.ToString() + "\r\n";
                    }

                    this.WriteString(printingObject);///Write to a file when print command is executed

                    #endregion

                    tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "SN".ToString());
                }
            }
            else
            {
                MessageBox.Show("There is no record",RMSGlobal.MessageBoxTitle,MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
        }
예제 #8
0
        private void g_CashButton_Click(object sender, EventArgs e)
        {
            try
            {
                Double tempTotal = Double.Parse(g_BalanceLabel.Text);
                Double tempInput = Double.Parse(g_InputTextBox.Text.Substring(1));
                if (tempTotal > tempInput)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Paid Amount less than Balance Amount.");
                    tempMessageBox.ShowDialog();
                    return;
                }

                CPaymentManager tempPaymentManager = new CPaymentManager();

                ///insert into payment table
                CPayment tempPayment = new CPayment();
                tempPayment.OrderID = orderID;

                //get pc id from pc ip
                CPcInfoManager tempPcInfoManager = new CPcInfoManager();
                IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName());
                CResult oResult = tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString());
                CPcInfo tempPcInfo = new CPcInfo();
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempPcInfo = (CPcInfo)oResult.Data;
                }

                tempPayment.PcID = tempPcInfo.PcID;
                tempPayment.TotalAmount = Double.Parse(g_BalanceLabel.Text);
                tempPayment.CashAmount = tempPayment.TotalAmount;
                tempPayment.PaymentTime = System.DateTime.Now;

                oResult = tempPaymentManager.InsertPayment(tempPayment);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempPayment = (CPayment)oResult.Data;
                }

                ////update order info status
                COrderManager tempOrderManager = new COrderManager();
                COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(orderID).Data;
                //tempOrderInfo.Status = "Paid";
                //tempOrderManager.UpdateOrderInfo(tempOrderInfo);

                //opening cash drawer
                try
                {
                    CPrintMethods tempPrintMethods = new CPrintMethods();
                    tempPrintMethods.OpenDrawer();
                }
                catch (Exception eee)
                {
                }

                //archiving
                tempOrderManager.InsertOrderArchive(tempOrderInfo);
                tempOrderManager.InsertOrderDetailsArchive(tempOrderInfo);
                tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, "Tabs");
                Reload();
            }
            catch (Exception eee)
            {
            }
        }
예제 #9
0
        private void g_PrintTokenButton_Click(object sender, EventArgs e)
        {
            try
            {
                CPrintMethods tempPrintMethods = new CPrintMethods();

                CKeyBoardForm tempKeyboardForm = new CKeyBoardForm("Bar Token Information", "Enter Customer Name");
                tempKeyboardForm.ShowDialog();

                if (CKeyBoardForm.Content.Equals("Cancel"))
                    return;

                CCalculatorForm tempCalculatorForm = new CCalculatorForm("Bar Token Information", "Enter Number of Guest");
                tempCalculatorForm.ShowDialog();

                if (CCalculatorForm.inputResult.Equals("Cancel"))
                    return;

                if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0)
                {
                    CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!");
                    tempMessageBox.ShowDialog();
                    return;
                }
            }
            catch (Exception eee)
            {
            }
        }
예제 #10
0
        private void g_PrintGuestBillButton_Click(object sender, EventArgs e)
        {
            try
            {
                CPrintMethods tempPrintMethods = new CPrintMethods();
                COrderManager tempOrderManager = new COrderManager();
                COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(orderID).Data;

                //serial print
                string serialHeader = "IBACS RMS";
                string serialFooter = "Please Come Again";
                List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>();
                CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine="               Guest Bill";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Date: " + System.DateTime.Now.ToLongDateString()+"\n";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "               Bar Service\n";
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine="Order Information";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "----------------------------------------";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Qty Item                         Price  ";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "----------------------------------------";
                serialBody.Add(tempSerialPrintContent);

                for (int rowIndex = 0; rowIndex < g_FoodDataGridView.Rows.Count; rowIndex++)
                {
                    DataGridViewRow tempRow = g_FoodDataGridView.Rows[rowIndex];
                    if (!tempRow.Cells[0].Value.ToString().Equals(""))
                    {
                        tempSerialPrintContent = new CSerialPrintContent();
                        tempSerialPrintContent.StringLine = tempRow.Cells[1].Value.ToString() + "  ";
                        tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(tempRow.Cells[0].Value.ToString(), 30);
                        tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(tempRow.Cells[2].Value.ToString(), 6);
                        serialBody.Add(tempSerialPrintContent);
                    }
                }

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "----------------------------------------";
                serialBody.Add(tempSerialPrintContent);
                Double discountAmount = Double.Parse(g_DiscountLabel.Text);
                Double totalAmount = Double.Parse(g_BalanceLabel.Text);
                Double billTotal = discountAmount + totalAmount;
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "                     Order Total: " + billTotal.ToString("F02");
                serialBody.Add(tempSerialPrintContent);
                if (discountAmount > 0)
                {
                    tempSerialPrintContent = new CSerialPrintContent();
                    Double discountPercent = 100 * discountAmount / (discountAmount + totalAmount);
                    tempSerialPrintContent.StringLine = "                 Discount:(" + discountPercent.ToString("F02") + "%) " + g_DiscountLabel.Text;
                    serialBody.Add(tempSerialPrintContent);
                }
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "                   Total Payable: " + g_BalanceLabel.Text;
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "----------------------------------------";
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine="\nS/N: " + tempOrderInfo.SerialNo.ToString();
                serialBody.Add(tempSerialPrintContent);

                //tempSerialPrintContent = new CSerialPrintContent();
                //tempSerialPrintContent.StringLine = "Developed By:ibacs limited";
                //serialBody.Add(tempSerialPrintContent);

                //tempSerialPrintContent = new CSerialPrintContent();
                //tempSerialPrintContent.StringLine = "www.ibacs.co.uk";
                //serialBody.Add(tempSerialPrintContent);

                tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, tempOrderInfo.SerialNo.ToString());
            }
            catch (Exception eee)
            {
            }
        }
예제 #11
0
        private void UpdateCalculation(int paymentMethodIndex)
        {
            try
                {
                Double tempTotalPaid = 0.0;

                Debug.WriteLine("UpdateCalc 1");
                tempTotalPaid += Double.Parse(g_CashLabel.Text.Substring(Program.currency.Length)) + Double.Parse(g_EFTLabel.Text.Substring(Program.currency.Length)) + Double.Parse(g_ChequeLabel.Text.Substring(Program.currency.Length))
                     + Double.Parse(g_AccountLabel.Text.Substring(Program.currency.Length)) + Double.Parse(complementorylabel.Text.Substring(Program.currency.Length));

                Debug.WriteLine("UpdateCalc 2");
                Double tempBillTotal = m_dTotalAmount + Convert.ToDouble("0" + g_ServiceChargeLabel.Text.Substring(Program.currency.Length));
                Debug.WriteLine("UpdateCalc 3");
                Double tempDifference = tempBillTotal - tempTotalPaid;
                Debug.WriteLine("UpdateCalc 4");
                if (tempDifference > 0)
                {
                    m_dBalance = tempDifference;
                    g_BalaceLabel.Text = String.Format("Balance Due {0}" + m_dBalance.ToString("F02"), Program.currency);
                    Debug.WriteLine("UpdateCalc 5");
                }
                else
                {
                    if (CurrentPaymentMethod.Equals("Cash"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            g_CashLabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }
                    else if (CurrentPaymentMethod.Equals("EFT"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            g_EFTLabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }
                    else if (CurrentPaymentMethod.Equals("Due"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            g_ChequeLabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }
                    else if (CurrentPaymentMethod.Equals("Voucher"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            g_VoucherLabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }
                    else if (CurrentPaymentMethod.Equals("Account"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            g_AccountLabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }
                    else if (CurrentPaymentMethod.Equals("Discount"))
                    {
                        g_DiscountLabel.Text = Program.currency + m_dBalance.ToString("F02");
                    }
                    else if (CurrentPaymentMethod.Equals("Deposit"))
                    {
                        g_DepositUsedLabel.Text = Program.currency + m_dBalance.ToString("F02");
                    }

                    else if (CurrentPaymentMethod.Equals("Complementory"))
                    {
                        if (m_isAddServiceCharge == false)
                        {
                            complementorylabel.Text = Program.currency + m_dBalance.ToString("F02");
                        }
                    }

                    Debug.WriteLine("UpdateCalc 6");
                    m_dBalance = -tempDifference;

                    g_BalaceLabel.Text = "Pay Back " + Program.currency + (m_dBalance-tipsamount).ToString("F02");

                    Debug.WriteLine("UpdateCalc 7");
                    CPaymentManager tempPaymentManager = new CPaymentManager();

                    /***********************/
                    /********New Print******/
                    /***********************/

                    if (isCheatManuallyhandled())
                    {
                        DialogResult dresult = MessageBox.Show("Make It Open?", "Message", MessageBoxButtons.YesNo);

                        if (dresult == DialogResult.Yes)
                        {
                            makeOpen = true;
                        }
                        if (dresult == DialogResult.No)
                        {
                            makeOpen = false;
                        }
                    }

                    DataSet tempDataSet = new DataSet();
                    tempDataSet.ReadXml("Config/Print_Config.xml");
                    if (tempDataSet.Tables[0].Rows[0]["PrintPaymentBill"].ToString().ToLower().Equals("true"))
                    {
                        Debug.WriteLine("UpdateCalc 17");
                        PrintPaymentBill(paymentMethodIndex);//Payment method index .Cash=1,EFT=2,Cheque=3
                    }

                    COrderManager temmpOrderManager = new COrderManager();
              COrderDiscount tempOrderDiscount = new COrderDiscount();
              CResult ooResult = temmpOrderManager.OrderDiscountGetByOrderID(m_iOrderID);
                    double itemDiscount = 0;
              if (ooResult.IsSuccess && ooResult.Data != null)
              {

              tempOrderDiscount = (COrderDiscount) ooResult.Data;
              itemDiscount = tempOrderDiscount.TotalItemDiscount;
              }

                    //Check whether payment data exists
                    if (m_cPayment == null)
                    {
                        Debug.WriteLine("UpdateCalc 8");
                        ///insert into payment table
                        CPayment tempPayment = new CPayment();
                        tempPayment.OrderID = m_iOrderID;

                        //get pc id from pc ip
                        CPcInfoManager tempPcInfoManager = new CPcInfoManager();
                        IPHostEntry ipEntry = System.Net.Dns.GetHostByName(Dns.GetHostName());

                        CPcInfo tempPcInfo = (CPcInfo)tempPcInfoManager.PcInfoByPcIP(ipEntry.AddressList[0].ToString()).Data;

                        tempPayment.PcID = tempPcInfo.PcID;
                        Debug.WriteLine("UpdateCalc 9");
                        tempPayment.TotalAmount = m_dTotalAmount;
                        tempPayment.CashAmount = Double.Parse(g_CashLabel.Text.Substring(Program.currency.Length));
                        tempPayment.EFTAmount = Double.Parse(g_EFTLabel.Text.Substring(Program.currency.Length));
                        tempPayment.ChequeAmount = Double.Parse(g_ChequeLabel.Text.Substring(Program.currency.Length));
                        tempPayment.ServiceAmount = m_serviceCharge_cash + m_serviceCharge_voucher + m_serviceCharge_eft + m_serviceCharge_cheque + m_serviceCharge_accounts - tipsamount;  //Double.Parse(g_ServiceChargeLabel.Text.Substring(Program.currency.Length));
                        tempPayment.VoucherAmount = Double.Parse(complementorylabel.Text.Substring(Program.currency.Length));
                        tempPayment.Discount = Double.Parse(g_DiscountLabel.Text.Substring(Program.currency.Length));
                        tempPayment.AccountPay = Double.Parse(g_AccountLabel.Text.Substring(Program.currency.Length));
                        tempPayment.DepositID = m_oDeposit.DepositID;
                        tempPayment.DepositAmount = Double.Parse(g_DepositUsedLabel.Text.Substring(Program.currency.Length));
                        tempPayment.PaymentTime = System.DateTime.Now;

                        tempPayment.ServiceChargeCash = m_serviceCharge_cash;
                        tempPayment.ServiceChargeCheque = m_serviceCharge_cheque;
                        tempPayment.ServiceChargeEft = m_serviceCharge_eft;
                        tempPayment.ServiceChargeVoucher = m_serviceCharge_voucher;
                        tempPayment.ServiceChargeAcc = m_serviceCharge_accounts;

                        tempPayment.DueMessage = dueMessage;
                        tempPayment.ComplementoryMessage = complementoryMessage;

                        double totalCost = GetTotalCost(m_iOrderID);
                        tempPayment.TotalCost = totalCost;
                        tempPayment.TipsAmount = tipsamount;

                        tempPayment.VatImposed = Program.vat.ToString();

                        tempPayment.membershipDiscount = (double)membershipdiscount;
                        tempPayment.ItemDiscount = itemDiscount;

                        //tempPayment.VatImposed = Program.vat.ToString();
                        tempPayment.GuestBill = gusetBillStr;
                        COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); // Change by Mithu
                        COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(m_iOrderID); // Change by Mithu

                        try
                        {
                            tempPayment.Waiter = orderWaiter.WaiterName;
                        }
                        catch (Exception)
                        {

                        }

                        if (makeOpen)
                            tempPayment.Vat_stat = true;
                        else
                            tempPayment.Vat_stat = false;

                        tempPayment.PaymentPerson = RMSGlobal.LoginUserName;

                        DataSet tempStockDataSet = new DataSet();
                        tempStockDataSet.ReadXml("Config/StockSetting.xml");
                        bool isAllowedToOrder = Convert.ToBoolean(tempStockDataSet.Tables[0].Rows[0]["AllowedtoOrder"].ToString());
                        if (!isAllowedToOrder)
                        {
                            COrderDetailsDAO aDao = new COrderDetailsDAO();
                            List<COrderDetails> aList = new List<COrderDetails>();
                            double cost = 0.0;
                            try
                            {
                                aList = aDao.OrderDetailsGetAll();
                                var check = from list in aList where list.OrderID == tempPayment.OrderID select list;
                                SaleReportDAO aSaleReportDao = new SaleReportDAO();
                                aSaleReportDao.InsertOrUpdateSaleRawmaterialsReport(check);
                            }
                            catch
                            {
                            }

                        }

                        CResult oResult = tempPaymentManager.InsertPayment(tempPayment);
                        if (oResult.IsSuccess && oResult.Data != null)
                        {
                            tempPayment = (CPayment)oResult.Data;
                            m_cPayment = tempPayment;
                            Debug.WriteLine("UpdateCalc 10");
                        }
                    }
                    else
                    {
                        Debug.WriteLine("UpdateCalc 11");
                        //update payment table
                        CPayment tempPayment = new CPayment();
                        tempPayment.PaymentID = m_cPayment.PaymentID;
                        tempPayment.OrderID = m_iOrderID;

                        tempPayment.TotalAmount = m_dTotalAmount;
                        tempPayment.CashAmount = Double.Parse(g_CashLabel.Text.Substring(Program.currency.Length));
                        tempPayment.EFTAmount = Double.Parse(g_EFTLabel.Text.Substring(Program.currency.Length));
                        tempPayment.ChequeAmount = Double.Parse(g_ChequeLabel.Text.Substring(Program.currency.Length));
                        tempPayment.ServiceAmount = m_serviceCharge_cash + m_serviceCharge_voucher + m_serviceCharge_eft + m_serviceCharge_cheque + m_serviceCharge_accounts - tipsamount;  //Double.Parse(g_ServiceChargeLabel.Text.Substring(Program.currency.Length));
                        tempPayment.VoucherAmount = Double.Parse(complementorylabel.Text.Substring(Program.currency.Length));
                        tempPayment.Discount = Double.Parse(g_DiscountLabel.Text.Substring(Program.currency.Length));
                        tempPayment.AccountPay = Double.Parse(g_AccountLabel.Text.Substring(Program.currency.Length));
                        tempPayment.DepositID = m_oDeposit.DepositID;
                        tempPayment.DepositAmount = Double.Parse(g_DepositUsedLabel.Text.Substring(Program.currency.Length));
                        tempPayment.PaymentTime = System.DateTime.Now;

                        tempPayment.ServiceChargeCash = m_serviceCharge_cash;
                        tempPayment.ServiceChargeCheque = m_serviceCharge_cheque;
                        tempPayment.ServiceChargeEft = m_serviceCharge_eft;
                        tempPayment.ServiceChargeVoucher = m_serviceCharge_voucher;
                        tempPayment.ServiceChargeAcc = m_serviceCharge_accounts;
                        tempPayment.VatImposed = Program.vat.ToString();
                        tempPayment.TipsAmount = tipsamount;
                        tempPayment.GuestBill = gusetBillStr;
                        tempPayment.membershipDiscount = (double)membershipdiscount;
                        tempPayment.ItemDiscount = itemDiscount;
                        //tempPayment.DueMessage = dueMessage;
                        //tempPayment.ComplementoryMessage = complementoryMessage;

                        if (isCheatManuallyhandled())
                        {
                            DialogResult dresult = MessageBox.Show("Make It Open?", "Message", MessageBoxButtons.YesNo);

                            if (dresult == DialogResult.Yes)
                            {
                                makeOpen = true;
                            }
                            if (dresult == DialogResult.No)
                            {
                                makeOpen = false;
                            }
                        }

                        if (makeOpen)
                            tempPayment.Vat_stat = true;
                        else
                            tempPayment.Vat_stat = false;
                        tempPayment.PaymentPerson = RMSGlobal.LoginUserName;

                        tempPaymentManager.UpdatePayment(tempPayment);
                        m_cPayment = tempPayment;
                        Debug.WriteLine("UpdateCalc 12");
                    }

                    //Update Deposit
                    CDepositManager tempDepositManager = new CDepositManager();
                    tempDepositManager.UpdateDeposit(m_oDeposit);

                    //opening cash drawer
                    try
                    {
                        CPrintMethods tempPrintMethods = new CPrintMethods();
                        tempPrintMethods.OpenDrawer();

                        #region "Tracking Area"
                        CCommonConstants m_oCommonConstants;
                        //Drawer Opening log
                        DateTime dtPayment = DateTime.Now;
                        dtPayment = new DateTime(dtPayment.Year, dtPayment.Month, dtPayment.Day, dtPayment.Hour, dtPayment.Minute, dtPayment.Second);
                        Int64 dateTime = dtPayment.Ticks;
                        m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>();
                        CUserInfo objUserInfo = m_oCommonConstants.UserInfo;
                        tempPaymentManager.SaveDrawerLogs(RMSGlobal.Terminal_Id, objUserInfo.UserName, dateTime);
                        #endregion

                        Debug.WriteLine("UpdateCalc 18");
                    }
                    catch (Exception eee)
                    {
                        Debug.WriteLine("UpdateCalc 19");
                        Debug.WriteLine(eee.ToString());
                    }

                    ///Print Payment Bill
                    ///
                    /*  DataSet tempDataSet = new DataSet();
                      tempDataSet.ReadXml("Config/Print_Config.xml");
                      if (tempDataSet.Tables[0].Rows[0]["PrintPaymentBill"].ToString().ToLower().Equals("true"))
                      {
                          Debug.WriteLine("UpdateCalc 17");
                          PrintPaymentBill(paymentMethodIndex);//Payment method index .Cash=1,EFT=2,Cheque=3
                      }
              */

                    COrderManager tempOrderManager = new COrderManager();
                    COrderInfo tempOrderInfo = null;

                    if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local orders are processed
                    {
                        tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(m_iOrderID).Data;
                        tempOrderManager.UpdateOrderInfo(tempOrderInfo);
                        Debug.WriteLine("UpdateCalc 13");
                        tempOrderManager.InsertOrderArchive(tempOrderInfo);
                        Debug.WriteLine("UpdateCalc 14");
                        tempOrderManager.InsertOrderDetailsArchive(tempOrderInfo);
                        Debug.WriteLine("UpdateCalc 15");
                    }
                    else //If online orders are processed
                    {
                        tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(m_iOrderID).Data;
                        tempOrderManager.InsertOnlineOrderArchive(tempOrderInfo);
                        Debug.WriteLine("Online orders archiving");
                    }

                    tempOrderManager.DeleteTableInfo(tempOrderInfo.TableNumber, m_sTableType);
                    Debug.WriteLine("UpdateCalc 16");

                    //insert voucher
                    tempOrderManager.InsertOrderVoucher(m_oOrderVoucher);

                    ///back to main screen
                    ///

                    CFormManager.Forms.Pop();
                    Form tempForm = CFormManager.Forms.Pop();
                    tempForm.Show();
                    this.Close();
                }
                g_BalaceLabel.ForeColor = Color.Red;
            }
            catch (Exception eee)
            {
                //MessageBox.Show(eee.ToString());
                Debug.WriteLine("UpdateCalc catch");
                Debug.WriteLine(eee.ToString());
            }
        }
예제 #12
0
        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)
            {
            }
        }
예제 #13
0
파일: CMainForm.cs 프로젝트: Jusharra/RMS
        /// <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)
            {

            }
        }
예제 #14
0
        private void OpenDrawerButton_Click(object sender, EventArgs e)
        {
            try
            {
                CPrintMethods tempPrintMethods = new CPrintMethods();

                tempPrintMethods.OpenDrawer();

            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #15
0
파일: SalesReport.cs 프로젝트: Jusharra/RMS
        private void btnPrint_Click(object sender, EventArgs e)
        {
            StringPrintFormater strPrintFormatter = new StringPrintFormater(40);

            DataSet dsSalesRecords = new DataSet();
            CResult objResult = new CResult();
            SystemManager objSystemMgnr = new SystemManager();
            m_htFoods = new Hashtable();
            m_htNonFoods = new Hashtable();

            DateTime dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0);
            DateTime dtEnd = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59);

            //if (chkFromTime.Checked)
            //{
                dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 7, 0, 0);
                dtEnd = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 6, 59, 59);
               // }

            dtEnd = dtEnd.AddDays(1);

            objResult = objSystemMgnr.GetSalesRecords(dtStart.Ticks, dtEnd.Ticks);
            dsSalesRecords = (DataSet)objResult.Data;

            if (dsSalesRecords.Tables.Count > 0 && dsSalesRecords.Tables[0].Rows.Count > 0)
            {
                Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].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");
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Date of Consumption of Items");
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("From " + dtpStart.Value.Date.ToString("dd/MM/yyyy") + " To " + dtpEnd.Value.Date.ToString("dd/MM/yyyy"));
                serialBody.Add(tempSerialPrintContent);

                //tempSerialPrintContent = new CSerialPrintContent();
                //tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n";
                //serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine();
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Qty Item                         Price(£)";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine();
                serialBody.Add(tempSerialPrintContent);
                SortedList slorderedFoodItems = new SortedList();
                SortedList slorderedNonFoodItems = new SortedList();

                PrintUtility printUtility = new PrintUtility();
                CCategory3DAO category3DAO = new CCategory3DAO();

                foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows)
                {
                    clsOrderReport objOrderedItems = new clsOrderReport();
                    string[] returnedValue = GetProductName(dtRrow).Split(':');

                   // string productName = Convert.ToString(returnedValue[0]);
                    string cat1ID = Convert.ToString(returnedValue[1]);

                    objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString());
                    //  objOrderedItems.ItemName = productName;
                    string productName = "";
                    CCategory3 cat3 = category3DAO.GetAllCategory3ByCategory3ID(Convert.ToInt32(dtRrow["product_id"].ToString()));
                    if (cat3 != null && cat3.Category3Name.Length>0)
                    {
                        productName = cat3.Category3Name.Trim();
                    }
                    else
                    {
                        productName = Convert.ToString(dtRrow["product_Name"].ToString());  // @hafiz
                    }

                    objOrderedItems.ItemName = productName; //Convert.ToString(dtRrow["product_Name"].ToString());  //@Hafiz

                    objOrderedItems.Price = Convert.ToDouble(dtRrow["amount"]);
                    objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]);

                    Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32("0" + cat1ID));
                    objOrderedItems.OrderNumber = category1OrderNumber;
                    string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName;

                    string tempKey = 99999 + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; ;
                    if (Convert.ToString(dtRrow["food_type"]).Equals("Food") && Convert.ToInt16(dtRrow["product_id"]) != 0) //Separate food/nonfoods
                    {
                        if (!m_htFoods.ContainsKey(keyCode))
                        {
                            m_htFoods.Add(keyCode, objOrderedItems);
                        }
                        else
                        {
                            clsOrderReport orderReport = m_htFoods[keyCode] as clsOrderReport;
                            objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity;
                            m_htFoods[keyCode] = objOrderedItems;
                        }
                    }
                    else if (Convert.ToString(dtRrow["product_id"]).Equals("0")) //Separate food/nonfoods
                    {
                      //  m_htFoods.Add(tempKey, objOrderedItems);

                        if (!m_htFoods.ContainsKey(tempKey))
                        {
                            m_htFoods.Add(tempKey, objOrderedItems);
                        }
                        else
                        {
                            clsOrderReport orderReport = m_htFoods[tempKey] as clsOrderReport;
                            objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity;
                            m_htFoods[tempKey] = objOrderedItems;
                        }
                    }
                    else
                    {
                        //m_htNonFoods.Add(keyCode, objOrderedItems);

                        if (!m_htNonFoods.ContainsKey(keyCode))
                        {
                            m_htNonFoods.Add(keyCode, objOrderedItems);
                        }
                        else
                        {
                            clsOrderReport orderReport = m_htNonFoods[keyCode] as clsOrderReport;
                            objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity;
                            m_htNonFoods[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]);
                    }
                }

                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 = "----------------------------------------";
                            //serialBody.Add(tempSerialPrintContent);

                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":";
                            serialBody.Add(tempSerialPrintContent);

                            tempSerialPrintContent = new CSerialPrintContent();
                            tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + "  ";
                            tempSerialPrintContent.ISAlredyNewLine = true;
                          //  tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30);
                           // tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6);
                              tempSerialPrintContent.StringLine += printUtility.MultipleLine(objOrderedItems.ItemName, 30,
                                                                          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 += printUtility.MultipleLine(objOrderedItems.ItemName, 30,
                                                                          objOrderedItems.Price.ToString("F02"), 37);
                            tempSerialPrintContent.ISAlredyNewLine = true;
                            serialBody.Add(tempSerialPrintContent);
                        }
                    }
                }

                #region "Non food items"
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "-----------------Drinks-----------------";
                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;
                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);

                            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 += printUtility.MultipleLine(objNonFoodItem.ItemName, 30,
                                                                          objNonFoodItem.Price.ToString("F02"), 37);
                            serialBody.Add(tempSerialPrintContent);
                            tempSerialPrintContent.ISAlredyNewLine = true;
                            separatorNumber = objNonFoodItem.OrderNumber;
                        }
                        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 += printUtility.MultipleLine(objNonFoodItem.ItemName, 30,
                                                                        objNonFoodItem.Price.ToString("F02"), 37);
                            tempSerialPrintContent.ISAlredyNewLine = true;
                            serialBody.Add(tempSerialPrintContent);
                        }
                    }
                }

                #endregion

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine();// "----------------------------------------";
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Total No Of Item: " + lblNoOfItemsSold.Text;
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Total Qty: " + lblTotalQty.Text;
                serialBody.Add(tempSerialPrintContent);

                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = "Total Item Amount: " + lblTotalAmount.Text;
                serialBody.Add(tempSerialPrintContent);
                tempSerialPrintContent = new CSerialPrintContent();
                tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine();
                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++)
                {
                    if (serialBody[arrayIndex].ISAlredyNewLine)
                    {
                        printingObject += serialBody[arrayIndex].StringLine.ToString() ;
                    }
                    else
                    {
                        printingObject += serialBody[arrayIndex].StringLine.ToString() + "\r\n";
                    }
                }

                this.WriteString(printingObject);///Write to a file when print command is executed

                #endregion
                A4Text = printingObject;
                CPrintMethodsEXT tempPrintMethods1 = new CPrintMethodsEXT();
                DataSet tempDataSet = new DataSet();
                tempDataSet.ReadXml("Config/Print_Config.xml");
                if (dataGridView1.Rows.Count > 0)
                    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);
                }
            }
            else
            {
                MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #16
0
파일: SalesReport.cs 프로젝트: Jusharra/RMS
        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);
                }
        }