Example #1
0
        private void ShowItemsButton_Click(object sender, EventArgs e)
        {
            try
            {
                ItemDataGridView.Rows.Clear();
                Int64 tempOrderID = Int64.Parse(OrderDataGridView.CurrentRow.Cells[4].Value.ToString());

                COrderManager tempOrderManager = new COrderManager();
                List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
                CResult oResult = tempOrderManager.OrderDetailsArchiveByOrderID(tempOrderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDetailsList = (List<COrderDetails>)oResult.Data;
                }

                for (int itemIndex = 0; itemIndex < tempOrderDetailsList.Count; itemIndex++)
                {
                    Int64 tempProductID = tempOrderDetailsList[itemIndex].ProductID;
                    int tempCategoryLevel = tempOrderDetailsList[itemIndex].CategoryLevel;

                    string tempProductName = "";
                    if (tempCategoryLevel == 3)
                    {
                        DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempProductID);
                        tempProductName = tempDataRowArr[0]["cat3_name"].ToString();
                    }
                    else if (tempCategoryLevel == 4)
                    {
                        int tempCat3_id = int.Parse(Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID)[0].GetParentRow(Program.initDataSet.Relations["category3_to_category4"])["cat3_id"].ToString());
                        tempProductName = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCat3_id)[0]["cat3_name"].ToString();
                        tempProductName += " " + Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID)[0]["cat4_name"].ToString();
                    }
                    else if (tempCategoryLevel == 0)
                        tempProductName = tempOrderDetailsList[itemIndex].OrderRemarks;

                    //if remarks exists append it... otherwise append nothing...
                    string appendString = "";
                    if (tempCategoryLevel != 0)
                        appendString = (tempOrderDetailsList[itemIndex].OrderRemarks.Equals("")) ? ("") : (" (" + tempOrderDetailsList[itemIndex].OrderRemarks + ")");

                    string[] tempDataGridViewRow = {
                    tempProductName+appendString,
                    tempOrderDetailsList[itemIndex].OrderQuantity.ToString(),
                    ((double)tempOrderDetailsList[itemIndex].OrderAmount).ToString("F02"),
                    tempOrderDetailsList[itemIndex].ProductID.ToString(),
                    tempOrderDetailsList[itemIndex].CategoryLevel.ToString(),
                    Int64.MaxValue.ToString(),//max rank
                    tempOrderDetailsList[itemIndex].OrderDetailsID.ToString()
                    };

                    //not misc item... rank is specified
                    if (tempCategoryLevel != 0)
                        tempDataGridViewRow[5] = Program.initDataSet.Tables["Category" + tempCategoryLevel].Select("cat" + tempCategoryLevel + "_id = " + tempProductID)[0]["cat" + tempCategoryLevel + "_rank"].ToString();

                    ItemDataGridView.Rows.Add(tempDataGridViewRow);
                    ItemDataGridView.Sort(ItemDataGridView.Columns[5], ListSortDirection.Ascending);
                    ItemDataGridView.Update();
                }

                //get discount
                g_DiscountLabel.Text = "0.000";
                COrderDiscount tempOrderDiscount = new COrderDiscount();
                oResult = tempOrderManager.OrderDiscountGetByOrderID(tempOrderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDiscount = (COrderDiscount)oResult.Data;
                    g_DiscountLabel.Text = tempOrderDiscount.Discount.ToString("F02");
                }

                Double tempTotal = 0.0;
                for (int rowIndex = 0; rowIndex < ItemDataGridView.Rows.Count; rowIndex++)
                {
                    if (ItemDataGridView[2, rowIndex].Value != null && !ItemDataGridView[2, rowIndex].Value.ToString().Equals(""))
                    {
                        tempTotal += Double.Parse(ItemDataGridView[2, rowIndex].Value.ToString());
                    }
                }

                tempTotal = tempTotal - tempOrderDiscount.Discount;

                g_AmountLabel.Text = tempTotal.ToString("F02");
                FillRMSDataGridView();
            }
            catch (FormatException exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OverflowException exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidOperationException exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ArgumentNullException exp)
            {
                MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message,RMSGlobal.MessageBoxTitle,MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
Example #2
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 #3
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;
            }
        }