Example #1
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;
            }
        }
Example #2
0
        private void OrderDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if(OrderDataGridView.Columns[e.ColumnIndex].Name.Equals("Reorder") && e.RowIndex>=0 && OrderDataGridView[0,e.RowIndex].Value!=null)
            {
                Int64 oldOrderID = 0;
                Int64.TryParse(OrderDataGridView["OrderID", e.RowIndex].Value.ToString(), out oldOrderID);
                COrderManager tempOrderManager = new COrderManager();
                COrderInfoArchive tempOrderInfo = new COrderInfoArchive();
                List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
                m_htPreviousOrders = new Hashtable();
                CResult oResult = tempOrderManager.OrderInfoArchiveByOrderID(oldOrderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderInfo = (COrderInfoArchive)oResult.Data;
                }

                oResult = tempOrderManager.OrderDetailsArchiveByOrderID(oldOrderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDetailsList = (List<COrderDetails>)oResult.Data;
                }
                m_htPreviousOrders.Add("orderinfo", tempOrderInfo);
                m_htPreviousOrders.Add("orderdetail", tempOrderDetailsList);
                this.DialogResult = DialogResult.OK;
            }
        }