Esempio n. 1
0
        private COrderDiscount ReaderToOrderDiscount(IDataReader inReader)
        {
            COrderDiscount tempOrderDiscount = new COrderDiscount();

            if (inReader["order_id"] != null)
                tempOrderDiscount.OrderID = Int64.Parse(inReader["order_id"].ToString());
            if (inReader["discount"] != null)
                tempOrderDiscount.Discount = Double.Parse(inReader["discount"].ToString());

            return tempOrderDiscount;
        }
Esempio n. 2
0
        public CResult UpdateOrderDiscount(COrderDiscount inOrderDiscount)
        {
            try
            {

                m_oResult = Database.Instance.OrderInfo.UpdateOrderDiscount(inOrderDiscount);
                m_oResult.Message = "Data Updated Successfully";

            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception occuer at UpdateOrderDiscount() : " + ex.Message);
                m_oResult.IsException = true;
                m_oResult.Action = EERRORNAME.EXCEPTION_OCCURE;
                //m_oResult.SetParams(ex.Message);

                m_oResult.Message = ex.Message;
                Logger.Write("Exception : " + ex + " in UpdateOrderDiscount()", LogLevel.Error, "COrderManager");
            }
            return m_oResult;
        }
Esempio n. 3
0
        /// <summary>
        /// Total amount in the gridview of the selected order
        /// </summary>
        private void TotalAmountCalculation()
        {
            try
            {
                Decimal MainFoodTotal = 0;//@Salim Only for Main Item with out additional service charge or discount
                Decimal vatTotal = 0;
                Decimal tempTotal = 0;
                for (int foodCounter = 0; foodCounter < g_FoodDataGridView.Rows.Count; foodCounter++)
                {
                    if (g_FoodDataGridView[3, foodCounter].Value != null && !g_FoodDataGridView[2, foodCounter].Value.ToString().Equals(""))
                    {
                        tempTotal += Decimal.Parse(g_FoodDataGridView[3, foodCounter].Value.ToString());
                        vatTotal += Decimal.Parse(g_FoodDataGridView[2, foodCounter].Value.ToString());
                    }
                }
                for (int beverageCounter = 0; beverageCounter < g_BeverageDataGridView.Rows.Count; beverageCounter++)
                {
                    if (g_BeverageDataGridView[3, beverageCounter].Value != null && !g_BeverageDataGridView[2, beverageCounter].Value.ToString().Equals(""))
                    {
                        tempTotal += Decimal.Parse(g_BeverageDataGridView[3, beverageCounter].Value.ToString());
                        try
                        {
                            vatTotal += Decimal.Parse(g_BeverageDataGridView[2, beverageCounter].Value.ToString());
                        }
                        catch { }
                    }
                }
                MainFoodTotal = tempTotal;
                Decimal discountAmount = 0;
                decimal membershipDiscountAmount = 0;
                if (m_sDiscountType.Equals("Fixed"))
                {
                    discountAmount = m_dDiscountAmount;
                }
                else if (m_sDiscountType.Equals("Percent"))
                {
                    discountAmount = MainFoodTotal * m_dDiscountAmount / 100;    // HOW CAN THIS BE CALCULATED IN SUCH WAY

                }

                COrderManager tempOrderManager = new COrderManager();
                COrderDiscount tempOrderDiscount = new COrderDiscount();
                CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
                double itemDiscount = 0;
                if (oResult.IsSuccess && oResult.Data != null)
                {

                    tempOrderDiscount = (COrderDiscount)oResult.Data;
                    itemDiscount = tempOrderDiscount.TotalItemDiscount;

                    if (membership != null && membership.id > 0)
                    {
                        tempOrderDiscount.clientID = membership.customerID;
                        tempOrderDiscount.membershipCardID = membership.mebershipCardID;
                        tempOrderDiscount.membershipID = membership.id;
                        tempOrderDiscount.membershipPoint = membership.point;
                        tempOrderDiscount.membershipDiscountRate = membership.discountPercentRate;
                        if (tempOrderDiscount.membershipDiscountRate > 0)
                        {
                            tempOrderDiscount.membershipTotalPoint = 0;
                            tempOrderDiscount.membershipDiscountAmount = float.Parse(tempTotal.ToString()) * tempOrderDiscount.membershipDiscountRate / 100;

                        }
                        else
                        {
                            tempOrderDiscount.membershipTotalPoint = float.Parse(tempTotal.ToString()) * tempOrderDiscount.membershipTotalPoint / 100;
                            tempOrderDiscount.membershipDiscountAmount = 0;
                        }
                    }
                    else if (tempOrderDiscount.membershipID > 0 && tempOrderDiscount.membershipDiscountRate > 0)
                    {
                        tempOrderDiscount.membershipTotalPoint = 0;
                        tempOrderDiscount.membershipDiscountAmount = float.Parse(tempTotal.ToString()) * tempOrderDiscount.membershipDiscountRate / 100;

                    }

                    //update
                    tempOrderDiscount.Discount = Convert.ToDouble(discountAmount);
                    discountAmount = (decimal)tempOrderDiscount.Discount;
                    tempOrderManager.UpdateOrderDiscount(tempOrderDiscount);

                    lblMembershipDiscountValue.Text = tempOrderDiscount.membershipDiscountAmount.ToString("F2");
                    membershipDiscountAmount = decimal.Parse(tempOrderDiscount.membershipDiscountAmount.ToString());
                }
                else
                {
                    //insert
                    tempOrderDiscount.OrderID = orderID;
                    tempOrderDiscount.Discount = Convert.ToDouble(discountAmount);
                    discountAmount = (decimal)tempOrderDiscount.Discount;

                    if (membership != null && membership.id > 0)
                    {
                        tempOrderDiscount.clientID = membership.customerID;
                        tempOrderDiscount.membershipCardID = membership.mebershipCardID;
                        tempOrderDiscount.membershipID = membership.id;
                        tempOrderDiscount.membershipPoint = membership.point;
                        tempOrderDiscount.membershipDiscountRate = membership.discountPercentRate;

                        if (tempOrderDiscount.membershipDiscountRate > 0)
                        {
                            tempOrderDiscount.membershipTotalPoint = 0;
                            tempOrderDiscount.membershipDiscountAmount = float.Parse(tempTotal.ToString()) * tempOrderDiscount.membershipDiscountRate / 100;

                            lblMembershipDiscountValue.Text = tempOrderDiscount.membershipDiscountAmount.ToString("F2");
                        }
                        else
                        {
                            tempOrderDiscount.membershipTotalPoint = float.Parse(tempTotal.ToString()) * tempOrderDiscount.membershipTotalPoint / 100;
                            tempOrderDiscount.membershipDiscountAmount = 0;
                        }
                    }

                    tempOrderManager.InsertOrderDiscount(tempOrderDiscount);

                    lblMembershipDiscountValue.Text = tempOrderDiscount.membershipDiscountAmount.ToString("F2");
                    membershipDiscountAmount = decimal.Parse(tempOrderDiscount.membershipDiscountAmount.ToString());
                }

                #region "Service Charge"
                ServiceCharge tempOrderCharge = new ServiceCharge();
                CResult cResult = tempOrderManager.OrderServiceChargeGetByOrderID(orderID);
                double chargeAmount = 0.000;
                if (m_chargeType.Equals("Fixed"))
                {
                    if (cResult.IsSuccess && cResult.Data != null)
                    {
                        tempOrderCharge = (ServiceCharge) cResult.Data;
                        chargeAmount = tempOrderCharge.ServiceChargeAmount;
                    }
                }
                else if (m_chargeType.Equals("Percent"))
                {
                    //  chargeAmount = tempTotal * m_chargeAmount / 100;

                    chargeAmount = Convert.ToDouble(MainFoodTotal) * m_chargeAmount / 100;
                }

                if (cResult.IsSuccess && cResult.Data != null)
                {
                    tempOrderCharge = (ServiceCharge)cResult.Data;

                    //update
                    tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount);
                    tempOrderManager.UpdateOrderServiceCharge(tempOrderCharge);
                }

                else
                {
                   // UpdateServiceCharge();
                    //insert
                  //  tempOrderCharge.OrderID = orderID;
                   // tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount);
                   // tempOrderManager.InsertOrderServiceCharge(tempOrderCharge);
                }
                g_serviceCharge.Text = chargeAmount.ToString("F02");

                #endregion

                g_SubtotalLabel.Text = MainFoodTotal.ToString("F02");

                tempTotal = MainFoodTotal - discountAmount;

                decimal d = decimal.Round(decimal.Parse(discountAmount.ToString()), 2);
                g_DiscountLabel.Text = discountAmount.ToString("F02");
                tempTotal = tempTotal + decimal.Parse(g_serviceCharge.Text);

                //   lblVat.Text = (tempTotal * Convert.ToDecimal(vat / 100)).ToString("F02");

                // lblVat.Text = (MainFoodTotal * Convert.ToDecimal(vat / 100)).ToString("F02");

                lblVat.Text=vatTotal.ToString();
                tempTotal = MainFoodTotal + decimal.Parse(g_serviceCharge.Text) + decimal.Parse(lblVat.Text) - decimal.Parse(g_DiscountLabel.Text)-membershipDiscountAmount-(decimal) itemDiscount;
                g_AmountLabel.Text = tempTotal.ToString("F02");

                TableValueStatusLabel.Text = " Total Value £" + tempTotal.ToString("F02");

                totalItemWiseDiscountlabel.Text = itemDiscount.ToString("F02");

                try
                {
                  //  UpdateServiceCharge();
                }
                catch (Exception)
                {

                    throw;
                }

            }
            catch (Exception exp)
            {
                Console.Write(exp.Message);
            }
        }
Esempio n. 4
0
        public CResult UpdateOrderDiscount(COrderDiscount inOrderDiscount)
        {
            CResult oResult = new CResult();
            try
            {
                this.OpenConnection();

                string sSql = string.Format(SqlQueries.GetQuery(Query.OrderDiscountUpdate),
                     inOrderDiscount.Discount, inOrderDiscount.OrderID);

                this.ExecuteNonQuery(sSql);
                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in UpdateOrderDiscount()", LogLevel.Error, "Database");

                // throw new Exception("Exception occure at InsertOrderSeatTime()", ex);
                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
Esempio n. 5
0
        private void functionalButton1_Click_2(object sender, EventArgs e)
        {
            CResult aCResult = new CResult();
              CUserInfoDAO aUserInfoDao = new CUserInfoDAO();
              CUserInfo aUserInfo = new CUserInfo();
              aUserInfo.UserID = RMSGlobal.m_iLoginUserID;
              aCResult = aUserInfoDao.GetUser(aUserInfo);
              aUserInfo = (CUserInfo)aCResult.Data;

              if (aUserInfo.Type != 0)
              {
              MessageBox.Show("You are not correct person to give Item Complementory Opportunity");
              return;
              }

              CDiscountForm tempDiscountForm = new CDiscountForm();
              tempDiscountForm.ShowDialog();

              if (CDiscountForm.discountType.Equals("Cancel"))
              return;

            double   discountAmount = Convert.ToDouble(CDiscountForm.discountAmount);
            string   discountType = CDiscountForm.discountType;

              COrderDetailsDAO aOrderInfoDao = new COrderDetailsDAO();
              foreach (DataGridViewRow row in g_FoodDataGridView.Rows)
              {

              if (Convert.ToBoolean(row.Cells["complementoryfood"].Value) == true)
              {
                  COrderDetails aCOrderDetails = new COrderDetails();

                  aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value);

                  aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID);

                  double totalAmount = aCOrderDetails.UnitPrice*aCOrderDetails.OrderQuantity;
                  double discount=0;
                  if (discountType == "Fixed")
                  {
                      discount = discountAmount;
                  } else
                  {
                      discount = (totalAmount*discountAmount)/100.0;
                  }

                  aCOrderDetails.DiscountAmount = discount;

                  string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails);

              }

              }

              foreach (DataGridViewRow row in g_BeverageDataGridView.Rows)
              {

              if (Convert.ToBoolean(row.Cells["complementorynonfood"].Value) == true)
              {
                  COrderDetails aCOrderDetails = new COrderDetails();
                  aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value);
                  aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID);
                  double totalAmount = aCOrderDetails.UnitPrice * aCOrderDetails.OrderQuantity;
                  double discount = 0;
                  if (discountType == "Fixed")
                  {
                      discount = discountAmount;
                  }
                  else
                  {
                      discount = (totalAmount * discountAmount) / 100.0;
                  }

                  aCOrderDetails.DiscountAmount = discount;
                  string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails);

              }

              }

              CResult oResult1 = aOrderInfoDao.OrderDetailsGetByOrderID(orderID);
             List<COrderDetails> aOrderDetailses = oResult1.Data as List<COrderDetails>;
              double totalItemDiscount = 0;
              if (aOrderDetailses != null)
              {
               totalItemDiscount = aOrderDetailses.Sum(a => a.DiscountAmount);
              }

              COrderManager tempOrderManager = new COrderManager();
              COrderDiscount tempOrderDiscount = new COrderDiscount();
              CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
              if (oResult.IsSuccess && oResult.Data != null)
              {

              tempOrderDiscount = (COrderDiscount)oResult.Data;

              tempOrderDiscount.TotalItemDiscount = totalItemDiscount;
              tempOrderManager.UpdateOrderDiscount(tempOrderDiscount);

              }
              else
              {
              //insert
              tempOrderDiscount.OrderID = orderID;
              tempOrderDiscount.TotalItemDiscount = totalItemDiscount;
              tempOrderManager.InsertOrderDiscount(tempOrderDiscount);
              }

              LoadOrderDetails();
        }
Esempio n. 6
0
        /// <summary>
        /// This function loads the items details information.
        /// </summary>
        private void LoadOrderDetails()
        {
            g_FoodDataGridView.Rows.Clear();
               g_BeverageDataGridView.Rows.Clear();
            FillRMSDataGridView();
            g_FoodDataGridView.ClearSelection();
            g_BeverageDataGridView.ClearSelection();

            if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
            {
                COrderManager tempOrderManager = new COrderManager();
                List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
                CResult oResult = tempOrderManager.OrderDetailsByOrderID(orderID);
                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);

                        if (tempDataRowArr.Length > 0)  //Added by Baruri .This was a bug previously when no row found.
                        {
                            tempProductName = tempDataRowArr[0]["cat3_name"].ToString();
                        }
                    }
                    else if (tempCategoryLevel == 4)
                    {
                        DataRow[] tempDataRowArr = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID);
                        int tempCat3_id = 0;
                        if (tempDataRowArr.Length > 0)
                        {
                            tempCat3_id = Convert.ToInt32("0" + tempDataRowArr[0]["cat3_id"]);
                        }

                        tempProductName = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempProductID)[0]["cat4_name"].ToString();

                        tempDataRowArr = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCat3_id);

                        if (tempDataRowArr.Length > 0)//If rows found
                        {
                            tempProductName += " " + tempDataRowArr[0]["cat3_name"].ToString();
                        }
                    }
                    else if (tempCategoryLevel == 0)
                    {
                        tempProductName = tempOrderDetailsList[itemIndex].OrderRemarks;
                    }

                    int tempFoodType = 1;
                    if (tempCategoryLevel == 3)
                    {
                        tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempProductID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].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());
                        tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCat3_id)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString());
                    }
                    else
                    {
                        tempFoodType = -1;
                    }

                    DataGridView tempDataGridView = new DataGridView();
                    if (tempFoodType == 1)//Food Type
                    {
                        tempDataGridView = g_FoodDataGridView;
                    }
                    else if (tempFoodType == 0)//Nonfood Type
                    {
                        tempDataGridView = g_BeverageDataGridView;
                    }
                    else if (tempFoodType == -1)
                    {
                        if (tempOrderDetailsList[itemIndex].OrderFoodType == "Food")
                        {
                            tempDataGridView = g_FoodDataGridView;
                        }
                        else
                        {
                            tempDataGridView = g_BeverageDataGridView;
                        }
                    }

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

                    string[] tempDataGridViewRow = {
                    tempProductName+appendString,
                    tempOrderDetailsList[itemIndex].OrderQuantity.ToString(),
                     ((double)tempOrderDetailsList[itemIndex].VatTotal).ToString("F02"),
                    ((double)tempOrderDetailsList[itemIndex].OrderAmount).ToString("F02"),
                    tempOrderDetailsList[itemIndex].ProductID.ToString(),
                    tempOrderDetailsList[itemIndex].CategoryLevel.ToString(),
                    (Int64.MaxValue-1)+"",//max rank
                    tempOrderDetailsList[itemIndex].OrderDetailsID.ToString(),
                    tempOrderDetailsList[itemIndex].PrintedQuantity.ToString(),
                     tempOrderDetailsList[itemIndex].UnitPrice.ToString("F2"),

                    };

                    //not misc item... rank is specified
                    if (tempCategoryLevel != 0)
                    {
                        try
                        {
                            tempDataGridViewRow[6] = Program.initDataSet.Tables["Category" + tempCategoryLevel].Select("cat" + tempCategoryLevel + "_id = " + tempProductID)[0]["cat" + tempCategoryLevel + "_rank"].ToString();
                        }
                        catch { }
                    }
                    try
                    {
                        tempDataGridView.Rows.Add(tempDataGridViewRow);
                    }
                    catch (Exception ex)
                    {
                       // MessageBox.Show(ex.ToString());
                    }

                    ConvertRank();
                    if (tempDataGridView.Columns["Order_details_id"] !=null)
                    tempDataGridView.Sort(tempDataGridView.Columns["Order_details_id"], ListSortDirection.Descending);

                    if (tempDataGridView.Columns["dataGridViewTextBoxColumn5"] != null)
                        tempDataGridView.Sort(tempDataGridView.Columns["dataGridViewTextBoxColumn5"], ListSortDirection.Descending);

                    //this.FillCategory1OrderNumber();//New
                    //tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                    tempDataGridView.Update();
                }

                //get discount
                COrderDiscount tempOrderDiscount = new COrderDiscount();
                oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDiscount = (COrderDiscount)oResult.Data;
                    m_dDiscountAmount = Convert.ToDecimal(tempOrderDiscount.Discount.ToString("F02"));
                }
            }
            else
            {
                //Loading the online orders information
                //g_FoodDataGridView.RowCount = 0;
                COrderManager tempOrderManager = new COrderManager();
                string remarks = "";
                string itemName = "";
                List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
                CResult oResult = tempOrderManager.GetOnlineOrderDetailsByOrderID(orderID);
                if (oResult.IsSuccess && oResult.Data != null)
                    tempOrderDetailsList = (List<COrderDetails>)oResult.Data;
                for (int counter = 0; counter < tempOrderDetailsList.Count; counter++)
                {
                    remarks = tempOrderDetailsList[counter].OrderRemarks.ToString();
                    itemName = tempOrderDetailsList[counter].ItemName.ToString();

                    if (remarks.Length > 0)
                    {
                        itemName = itemName + "(" + remarks + ")";
                    }
                    string[] tempDataGridViewRow = {
                    itemName,
                    tempOrderDetailsList[counter].OrderQuantity.ToString(),
                    tempOrderDetailsList[counter].OrderAmount.ToString("F02"),
                    tempOrderDetailsList[counter].CategoryID.ToString(),
                    tempOrderDetailsList[counter].CategoryLevel.ToString(),
                    tempOrderDetailsList[counter].Rank.ToString(),
                    tempOrderDetailsList[counter].OrderDetailsID.ToString(),
                    tempOrderDetailsList[counter].PrintedQuantity.ToString(),
                    tempOrderDetailsList[counter].UnitPrice.ToString("F2"),
                    };

                    if (tempOrderDetailsList[counter].OrderFoodType.Replace(" ", "").ToUpper() == "Food".Replace(" ", "").ToUpper())
                    {
                        g_FoodDataGridView.Rows.Add(tempDataGridViewRow);
                        g_FoodDataGridView.Sort(g_FoodDataGridView.Columns[5], ListSortDirection.Ascending);
                    }
                    else
                    {
                        g_BeverageDataGridView.Rows.Add(tempDataGridViewRow); //If drinks
                        g_BeverageDataGridView.Sort(g_BeverageDataGridView.Columns[5], ListSortDirection.Ascending);
                    }
                }

                //get discount
                COrderDiscount tempOrderDiscount = new COrderDiscount();
                oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDiscount = (COrderDiscount)oResult.Data;
                    m_dDiscountAmount = Convert.ToDecimal(tempOrderDiscount.Discount.ToString("F02"));
                }
            }
            this.TotalAmountCalculation();

              g_FoodDataGridView.ClearSelection();
               g_BeverageDataGridView.ClearSelection();
            try
            {
                this.SetPrintedItemBackColor(); //set the back color
            }
            catch { }
        }
Esempio n. 7
0
        private void TotalAmountCalculation()
        {
            try
            {
                Double tempTotal = new Double();
                tempTotal = 0.0;

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

                Double discountAmount = 0.000;
                if (m_sDiscountType.Equals("Fixed"))
                {
                    discountAmount = m_dDiscountAmount;
                }
                else if (m_sDiscountType.Equals("Percent"))
                {
                    discountAmount = tempTotal * m_dDiscountAmount / 100;
                }

                COrderManager tempOrderManager = new COrderManager();
                COrderDiscount tempOrderDiscount = new COrderDiscount();
                CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
                if (oResult.IsSuccess && oResult.Data != null)
                {
                    tempOrderDiscount = (COrderDiscount)oResult.Data;

                    //update
                    tempOrderDiscount.Discount = discountAmount;
                    tempOrderManager.UpdateOrderDiscount(tempOrderDiscount);
                }
                else
                {
                    //insert
                    tempOrderDiscount.OrderID = orderID;
                    tempOrderDiscount.Discount = discountAmount;
                    tempOrderManager.InsertOrderDiscount(tempOrderDiscount);
                }
                tempTotal = tempTotal - discountAmount;
                g_DiscountLabel.Text = discountAmount.ToString("F02");

                g_BalanceLabel.Text = tempTotal.ToString("F02");
                numericInputButton13.Text = "�"+tempTotal.ToString("F02");
                TableValueStatusLabel.Text = " Total Value �" + tempTotal.ToString("F02")+" ";
                TableValueStatusLabel.Visible = true;
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Esempio n. 8
0
        private void FillNonFoods()
        {
            g_FoodDataGridView.RowCount = 0;
            COrderManager tempOrderManager = new COrderManager();
            List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>();
            CResult oResult = tempOrderManager.OrderDetailsByOrderID(orderID);

            if (oResult.IsSuccess && oResult.Data != null)
            {
                tempOrderDetailsList = (List<COrderDetails>)oResult.Data;
            }

            for (int detailsCounter = 0; detailsCounter < tempOrderDetailsList.Count; detailsCounter++)
            {
                Int64 tempProductID = tempOrderDetailsList[detailsCounter].ProductID;
                int tempCategoryLevel = tempOrderDetailsList[detailsCounter].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)
                {
                    //Latest name is at first
                    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["Category4"].Select("cat4_id = " + tempProductID)[0]["cat4_name"].ToString();
                    tempProductName += " " + Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCat3_id)[0]["cat3_name"].ToString();

                }
                else if (tempCategoryLevel == 0)
                    tempProductName = tempOrderDetailsList[detailsCounter].OrderRemarks;

                int tempFoodType = 0;

                DataGridView tempDataGridView = new DataGridView();
                tempDataGridView = g_FoodDataGridView;

                string[] tempDataGridViewRow = {
                    tempProductName,
                    tempOrderDetailsList[detailsCounter].OrderQuantity.ToString(),
                    ((double)tempOrderDetailsList[detailsCounter].OrderAmount).ToString("F02"),
                    tempOrderDetailsList[detailsCounter].ProductID.ToString(),
                    tempOrderDetailsList[detailsCounter].CategoryLevel.ToString(),
                    (Int64.MaxValue-1)+"",//max rank
                    tempOrderDetailsList[detailsCounter].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();

                tempDataGridView.Rows.Add(tempDataGridViewRow);
                ConvertRank();
                tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending);
                tempDataGridView.Update();
                g_FoodDataGridView.ClearSelection();
            }

            //get discount
            COrderDiscount tempOrderDiscount = new COrderDiscount();
            oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID);
            if (oResult.IsSuccess && oResult.Data != null)
            {
                tempOrderDiscount = (COrderDiscount)oResult.Data;
                m_dDiscountAmount = tempOrderDiscount.Discount;
            }

            if (category2ButtonList.Count > CATEGORY2PANEL_CAPACITY)
                g_NextButton.Enabled = true;
            else
                g_NextButton.Enabled = false;

            g_PreviousButton.Enabled = false;

            TotalAmountCalculation();
            LoadStatusBar();
        }
Esempio n. 9
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());
            }
        }
Esempio n. 10
0
        private void PrintPaymentBill(int paymentMethodIndex)
        {
            bool isPrintA5GuestBill = false;
            if (isPrintA5GuestBill)
            {
                PrintA5GuestBillReport(2);
            }
            else
            {

                int paperSize = 37;
                StringPrintFormater strPrintFormatter = new StringPrintFormater(37);

                COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); // Change by Mithu
                COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(m_iOrderID); // Change by Mithu

                m_itemCost = 0.0;
                CPrintMethodsEXT tempPrintMethods = new CPrintMethodsEXT();
                Hashtable htOrderedItems = new Hashtable();
                SortedList slOrderedItems = new SortedList();
                //string serialHeader = "IBACS RMS";
                string serialHeader = "";
                //string serialFooter = "Please Come Again";
                string serialFooter = "";

                string serialBody = "";

                serialBody += "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Bill  Payment"); // Change by Mithu
                COrderManager tempOrderManager = new COrderManager();
                COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(m_iOrderID).Data;
                serialBody += "\r\n\r\n       Vat Reg. No: " + Program.vatRegDes; // Change by Mithu
                serialBody = "\r\nWaiter Name: " + orderWaiter.WaiterName + "\r\n";
                serialBody += "\r\n\nOrder ID:" + m_iOrderID.ToString();
                //serialBody += "\r\n" + strPrintFormatter.CreateDashedLine(); // Change by Mithu
                if (m_sTableType.Equals("Table"))
                {

                    serialBody += "\r\n\nTable #" + tempOrderInfo.TableNumber.ToString(); // Change by Mithu
                    serialBody += "\r\n                    Served by:" + m_OperatorName; // Change by Mithu
                    serialBody += "\r\n\n                    Cust #" + tempOrderInfo.GuestCount.ToString();  // Change by Mithu
                    //serialBody += "\r\nDate: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt"); // Change by Mithu
                    serialBody += "\r\n" + System.DateTime.Now.ToString("\r\ndd/MM/yy hh:mm tt");  // Change by Mithu
                }

                else if (m_sTableType.Equals("TakeAway"))
                {
                    serialBody += "\r\n\nTake Away" + "Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt");
                    CCustomerManager tempCustomerManager = new CCustomerManager();
                    CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data;

                    if (tempCustomerInfo.CustomerName.Length > 0)
                    {
                        serialBody += "\r\nCustomer Name: " + tempCustomerInfo.CustomerName;
                    }
                    if (tempCustomerInfo.CustomerPhone.Length > 0)
                    {
                        serialBody += "\r\nPhone:" + tempCustomerInfo.CustomerPhone;
                    }

                    serialBody += "\r\nType: " + tempOrderInfo.Status;
                    if (tempOrderInfo.Status.Equals("Delivery"))
                    {
                        serialBody += "\r\nAddress:";
                        serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                        if (tempCustomerInfo.FloorAptNumber.Length > 0)
                        {
                            serialBody += "\r\nFloor or Apartment:" + tempCustomerInfo.FloorAptNumber;
                        }
                        if (tempCustomerInfo.BuildingName.Length > 0)
                        {
                            serialBody += "\r\nBuilding Name:" + tempCustomerInfo.BuildingName;
                        }
                        if (tempCustomerInfo.HouseNumber.Length > 0)
                        {
                            serialBody += "\r\nHouse Number:" + tempCustomerInfo.HouseNumber;
                        }
                        string[] street = new string[0];
                        street = tempCustomerInfo.StreetName.Split('-');

                        if (street.Length > 1)
                        {
                            if (street[0].ToString().Length > 0)
                            {
                                serialBody += "\r\nStreet:" + street[0].ToString();
                            }
                            if (street[1].ToString().Length > 0)
                            {
                                serialBody += "\r\n" + street[1].ToString();
                            }
                        }
                        else if (street.Length > 0 && street.Length < 2)
                        {
                            if (street[0].ToString().Length > 0)
                            {
                                serialBody += "\r\nStreet:" + street[0].ToString();
                            }
                        }
                        if (tempCustomerInfo.CustomerPostalCode.Length > 0)
                        {
                            serialBody += "\r\nPostal Code:" + tempCustomerInfo.CustomerPostalCode;
                        }
                        if (tempCustomerInfo.CustomerTown.Length > 0)
                        {
                            serialBody += "\r\nTown:" + tempCustomerInfo.CustomerTown;
                        }
                        serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                        CDelivery objDelivery = new CDelivery();
                        objDelivery.DeliveryOrderID = m_iOrderID;
                        CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery);
                        objDelivery = (CDelivery)objDeliveryInfo.Data;
                        serialBody += "\r\nDelivery Time:" + objDelivery.DeliveryTime;
                    }
                }
                else if (m_sTableType.Equals("Tabs"))
                {
                    serialBody += "\r\n\nBar Service" + " Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt");
                    if (tempOrderInfo.TableNumber != 0)
                        serialBody += "\r\nTab Number: " + tempOrderInfo.TableNumber.ToString();
                }

                serialBody += "\r\n\nOrder Information";
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                serialBody += "\r\n" + strPrintFormatter.ItemLabeledText("Qty Item", "Price(" + Program.currency + ")");
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                //serialBody += "\n----------------------------------------";

                #region "Local Orders"
                if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper())
                {
                    #region "For Bar service"

                    if (m_dtItemList.Columns.Count == 3) //For bar service
                    {
                        //serialBody += "\r\n----------------------------------------";
                        serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                        for (int rowIndex = 0; rowIndex < m_dtItemList.Rows.Count; rowIndex++)
                        {
                            if (rowIndex == m_iDrinksIndex)
                                // serialBody += "\r\n----------------------------------------";
                                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                            DataRow tempRow = m_dtItemList.Rows[rowIndex];
                            serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(tempRow["Qty"].ToString() + "  " +
                             tempRow["Item"].ToString(), tempRow["Price"].ToString());
                            m_itemCost += Convert.ToDouble("0" + tempRow["Price"].ToString()); //New for item cost of the bar service
                        }
                        serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();//Separator after the bar items.
                    }
                    #endregion

                    #region "For foods separator is used "

                    else
                    {
                        string cat2ID = "";
                        string cat3ID = "";
                        string cat1ID = "";
                        Int32 internalCategoryID = 0;
                        Int32 categoryID = 0;
                        string categoryOrder = String.Empty;

                        for (int rowIndex = 0; rowIndex < m_dtItemList.Rows.Count; rowIndex++)
                        {
                            #region "Parent Category"
                            DataRow tempRow = m_dtItemList.Rows[rowIndex];
                            categoryOrder = String.Empty;
                            if (Convert.ToInt32("0" + tempRow["Catlevel"].ToString()) == 3)//Item from Category 3
                            {
                                internalCategoryID = Convert.ToInt32("0" + tempRow["Catid"].ToString());
                                DataRow[] dtRow = dsCategory3.Tables[0].Select("cat3_id = " + internalCategoryID);
                                if (dtRow.Length > 0)
                                {
                                    cat2ID = dtRow[0]["cat2_id"].ToString();
                                    DataRow[] dtRowCat2 = dsCategory2.Tables[0].Select("cat2_id = " + cat2ID);//new
                                    cat1ID = dtRowCat2[0]["cat1_id"].ToString();
                                }
                            }

                            else if (Convert.ToInt32("0" + tempRow["Catlevel"].ToString()) == 0)//Item from Category 3
                            {
                                cat1ID = "0";
                                cat2ID = "0";
                            }
                            else
                            {
                                internalCategoryID = Convert.ToInt32("0" + tempRow["Catid"].ToString());
                                DataRow[] dtRow = dsCategory4.Tables[0].Select("cat4_id = " + internalCategoryID);
                                if (dtRow.Length > 0)
                                {
                                    cat3ID = dtRow[0]["cat3_id"].ToString();
                                }

                                dtRow = dsCategory3.Tables[0].Select("cat3_id = " + cat3ID);
                                if (dtRow.Length > 0)
                                {
                                    cat2ID = dtRow[0]["cat2_id"].ToString();
                                    DataRow[] dtRowCat2 = dsCategory2.Tables[0].Select("cat2_id = " + cat2ID);//new
                                    cat1ID = dtRowCat2[0]["cat1_id"].ToString();
                                }
                            }
                            #endregion

                            clsOrderReport objOrderedReport = new clsOrderReport();
                            objOrderedReport.Quantity = Convert.ToInt32("0" + tempRow["Qty"].ToString());
                            objOrderedReport.ItemName = tempRow["Item"].ToString();
                            objOrderedReport.Price = Convert.ToDouble("0" + tempRow["Price"].ToString());
                            int drinkValue = Convert.ToInt32("0" + tempRow["isdrink"].ToString());
                            if (drinkValue > 0)
                            {
                                objOrderedReport.DrinkStatus = true;
                            }
                            else
                            {
                                objOrderedReport.DrinkStatus = false;
                            }
                            Int64 rankNumber = Int64.Parse(tempRow["rank"].ToString());

                            Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID));
                            htOrderedItems.Add(category1OrderNumber + "-" + rankNumber + "-" + objOrderedReport.ItemName, objOrderedReport);

                            m_itemCost += Convert.ToDouble("0" + tempRow["Price"].ToString());
                        }

                        NumericComparer nc = new NumericComparer();
                        slOrderedItems = new SortedList(htOrderedItems, nc);
                        int keyIndex = 0;
                        string[] valueSplitter = new string[0];
                        SortedList slDrinkItems = new SortedList();
                        SortedList slMiscellaneousItems = new SortedList();

                        PrintUtility printUtility = new PrintUtility();

                        foreach (clsOrderReport objOrderedItems in slOrderedItems.Values)
                        {
                            objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("''", "'");
                            objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("'", "''");

                            string keyValue = slOrderedItems.GetKey(keyIndex).ToString();
                            valueSplitter = keyValue.Split('-');

                            if (objOrderedItems.DrinkStatus == true) //To make all drink items consecutively
                            {
                                slDrinkItems.Add(slDrinkItems.Count, objOrderedItems);
                            }

                            else if ((categoryID != Convert.ToInt32("0" + valueSplitter[0].ToString())) && (Convert.ToInt32("0" + valueSplitter[0].ToString()) != 0)) //All the items except drinks.
                            {
                                categoryID = Convert.ToInt32("0" + valueSplitter[0].ToString());
                                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine() + "\r\n"; //Add the separator.

                                /*serialBody += "\r\n" + objOrderedItems.Quantity.ToString() + "  ";
                                serialBody += CPrintMethods.GetFixedString(objOrderedItems.ItemName.ToString(), 29);
                                serialBody += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6);*/

                                //Blocked by Salim
                                //serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                //objOrderedItems.ItemName.ToString(), objOrderedItems.Price.ToString("F02"));

                                //if (qty_length_with_twospace + objOrderedItems.ItemName.Length + objOrderedItems.Price.ToString().Length <= printlinelength)
                                //{
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + objOrderedItems.ItemName.ToString(),
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //}
                                //else
                                //{
                                //    // line 1
                                //    int itemname_firstline_length = printlinelength - 4 - 1 - objOrderedItems.Price.ToString().Length;
                                //    string itemname_first_part = objOrderedItems.ItemName.Substring(0, itemname_firstline_length);
                                //    string itemname_second_part = objOrderedItems.ItemName.Substring(itemname_firstline_length);
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + itemname_first_part,
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //    // line 2
                                //    serialBody += "\r\n   "
                                //                                    + strPrintFormatter.ItemLabeledText(itemname_second_part,
                                //                                    " ");
                                //}

                                serialBody += strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                                                printUtility.MultipleLine(objOrderedItems.ItemName.ToString(), paperSize - 10, objOrderedItems.Price.ToString("F02"), paperSize - 5), "");

                            }
                            else if (valueSplitter[0].ToString() == "0")
                            {
                                slMiscellaneousItems.Add(slMiscellaneousItems.Count, objOrderedItems);
                            }
                            else
                            {
                                /* serialBody += "\r\n" + objOrderedItems.Quantity.ToString() + "  ";
                                 serialBody += CPrintMethods.GetFixedString(objOrderedItems.ItemName.ToString(), 29);
                                 serialBody += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6);*/
                                //Blocked by Salim
                                //serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                //objOrderedItems.ItemName.ToString(), objOrderedItems.Price.ToString("F02"));

                                //if (qty_length_with_twospace + objOrderedItems.ItemName.Length + objOrderedItems.Price.ToString().Length <= printlinelength)
                                //{
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + objOrderedItems.ItemName.ToString(),
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //}
                                //else
                                //{
                                //    // line 1
                                //    int itemname_firstline_length = printlinelength - 4 - 1 - objOrderedItems.Price.ToString().Length;
                                //    string itemname_first_part = objOrderedItems.ItemName.Substring(0, itemname_firstline_length);
                                //    string itemname_second_part = objOrderedItems.ItemName.Substring(itemname_firstline_length);
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + itemname_first_part,
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //    // line 2
                                //    serialBody += "\r\n   "
                                //                                    + strPrintFormatter.ItemLabeledText(itemname_second_part,
                                //                                    " ");
                                //}

                                serialBody += strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                                               printUtility.MultipleLine(objOrderedItems.ItemName.ToString(), paperSize - 10, objOrderedItems.Price.ToString("F02"), paperSize - 5), "");

                            }
                            keyIndex++;
                        }

                        //Add drinks only
                        if (slMiscellaneousItems.Count > 0)
                        {
                            serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Miscellaneous") + "\r\n";
                            foreach (clsOrderReport objOrderedItems in slMiscellaneousItems.Values)
                            {
                                objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("''", "'");
                                objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("'", "''");

                                /*  serialBody += "\r\n" + objOrderedItems.Quantity.ToString() + "  ";
                                  serialBody += CPrintMethods.GetFixedString(objOrderedItems.ItemName.ToString(), 29);
                                  serialBody += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6);*/

                                //serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                //objOrderedItems.ItemName.ToString(), objOrderedItems.Price.ToString("F02"));

                                //if (qty_length_with_twospace + objOrderedItems.ItemName.Length + objOrderedItems.Price.ToString().Length <= printlinelength)
                                //{
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + objOrderedItems.ItemName.ToString(),
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //}
                                //else
                                //{
                                //    // line 1
                                //    int itemname_firstline_length = printlinelength - 4 - 1 - objOrderedItems.Price.ToString().Length;
                                //    string itemname_first_part = objOrderedItems.ItemName.Substring(0, itemname_firstline_length);
                                //    string itemname_second_part = objOrderedItems.ItemName.Substring(itemname_firstline_length);
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + itemname_first_part,
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //    // line 2
                                //    serialBody += "\r\n   "
                                //                                    + strPrintFormatter.ItemLabeledText(itemname_second_part,
                                //                                    " ");
                                //}

                                serialBody += strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                                               printUtility.MultipleLine(objOrderedItems.ItemName.ToString(), paperSize - 10, objOrderedItems.Price.ToString("F02"), paperSize - 5), "");

                            }
                        }

                        //Add drinks only
                        if (slDrinkItems.Count > 0)
                        {
                            serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Drinks") + "\r\n"; //Add the separator.
                            foreach (clsOrderReport objOrderedItems in slDrinkItems.Values)
                            {
                                objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("''", "'");
                                objOrderedItems.ItemName = objOrderedItems.ItemName.Replace("'", "''");

                                //serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  "+
                                //objOrderedItems.ItemName.ToString(),objOrderedItems.Price.ToString("F02"));

                                //if (qty_length_with_twospace + objOrderedItems.ItemName.Length + objOrderedItems.Price.ToString().Length <= printlinelength)
                                //{
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + objOrderedItems.ItemName.ToString(),
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //}
                                //else
                                //{
                                //    // line 1
                                //    int itemname_firstline_length = printlinelength - 4 - 1 - objOrderedItems.Price.ToString().Length;
                                //    string itemname_first_part = objOrderedItems.ItemName.Substring(0, itemname_firstline_length);
                                //    string itemname_second_part = objOrderedItems.ItemName.Substring(itemname_firstline_length);
                                //    serialBody += "\r\n"
                                //                                    + strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " + itemname_first_part,
                                //                                    " " + objOrderedItems.Price.ToString("F02"));
                                //    // line 2
                                //    serialBody += "\r\n   "
                                //                                    + strPrintFormatter.ItemLabeledText(itemname_second_part,
                                //                                    " ");
                                //}

                                serialBody += strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + "  " +
                                                            printUtility.MultipleLine(objOrderedItems.ItemName.ToString(), paperSize - 10, objOrderedItems.Price.ToString("F02"), paperSize - 5), "");

                            }
                        }
                        serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                    #endregion
                    }
                }
                #endregion

                #region "Online orders"
                else
                {
                    m_itemCost = 0.0;
                    serialBody += "\r\n-----------------------------";
                    for (int rowIndex = 0; rowIndex < m_dtItemList.Rows.Count; rowIndex++)
                    {
                        DataRow tempRow = m_dtItemList.Rows[rowIndex];
                        serialBody += "\r\n" + strPrintFormatter.ItemLabeledText(Convert.ToInt32("0" + tempRow["Qty"]).ToString() + "  " +
                        tempRow["Item"].ToString(), Convert.ToDouble("0" + tempRow["Price"]).ToString("F02"));
                        m_itemCost += Convert.ToDouble("0" + tempRow["Price"].ToString()); //New for item cost of the bar service
                    }
                    serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                }
                #endregion

                Double discountAmount = Double.Parse(g_DiscountLabel.Text.Substring(Program.currency.Length));
                Double searviceChargeAmount = Double.Parse(g_ServiceChargeLabel.Text.Substring(Program.currency.Length));
                Double billTotal = ((searviceChargeAmount) + m_dTotalAmount);

                //serialBody += "\r\n                     Order Total: " + CPrintMethods.RightAlign(billTotal.ToString("F02"), 6);
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Order Amount: ", m_itemCost.ToString("F02")); //New at 03.03.2009
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                if (discountAmount > 0)
                {
                    Double totalAmount = m_dTotalAmount;
                    Double discountPercent = 100 * discountAmount / (m_itemCost);
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Discount(" + discountPercent.ToString("F02") + "%): ", Convert.ToDouble(g_DiscountLabel.Text.Substring(Program.currency.Length)).ToString("F02"));
                }

                double itemiscount = 0;

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

              tempOrderDiscount = (COrderDiscount) oResult.Data;
              itemiscount = tempOrderDiscount.TotalItemDiscount;
              }

                if (itemiscount > 0)
                {

                    //Discount is based on the total item cost
                    //tempSerialPrintContent.StringLine = "                  Discount:(" + discountPercent.ToString("F02") + "%) " +Convert.ToDecimal(g_DiscountLabel.Text).ToString("F02");
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText(" Item Discount: ", itemiscount.ToString("F02"));

                }

                serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Membership Discount: ", membershipdiscount.ToString("F02"));

                #region "Voucher"
                if (!g_VoucherLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Voucher Discount:", g_VoucherLabel.Text.Substring(Program.currency.Length));
                }
                #endregion

                if ((m_serviceCharge_accounts + m_serviceCharge_cash + m_serviceCharge_cheque + m_serviceCharge_eft + m_serviceCharge_voucher) > 0) //If service charge is assigned
                {
                    CResult cResult = tempOrderManager.OrderServiceChargeGetByOrderID(m_iOrderID);
                    ServiceCharge serviceCharge = cResult.Data as ServiceCharge;

                    double subtotalserviceCharg = m_serviceCharge_accounts + m_serviceCharge_cash + m_serviceCharge_cheque + m_serviceCharge_eft + m_serviceCharge_voucher-tipsamount;
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Service Charge(" + serviceCharge.ServicechargeRate.ToString("F02") + "%): ", (subtotalserviceCharg).ToString("F02"));// + CPrintMethods.RightAlign(Convert.ToDouble("0" + g_ServiceChargeLabel.Text.Substring(Program.currency.Length)).ToString("F02"), 6); // Change by Mithu
                }
                serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Tips Amount: ", tipsamount.ToString("F02"));
                double pvat = (billTotal * (vat / 100)) / (1 + (vat / 100));

                if (isVatEnabled) //If service charge is assigned
                {
                    // serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Vat(" + vat + "%): ", pvat.ToString("F02"));
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Vat Total(15%): ", Convert.ToDouble("0" + lblVat.Text.Substring(Program.currency.Length)).ToString("F02")); // Change by Mithu
                }

                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                double totalAmountForAddvance = 0;

                if ((m_serviceCharge_accounts + m_serviceCharge_cash + m_serviceCharge_cheque + m_serviceCharge_eft + m_serviceCharge_voucher) > 0)
                {
                    totalAmountForAddvance = (m_dTotalAmount +
                                              (m_serviceCharge_accounts + m_serviceCharge_cash + m_serviceCharge_cheque +
                                               m_serviceCharge_eft + m_serviceCharge_voucher));
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Total: ", (m_dTotalAmount + (m_serviceCharge_accounts + m_serviceCharge_cash + m_serviceCharge_cheque + m_serviceCharge_eft + m_serviceCharge_voucher)).ToString("F02"));
                }
                else
                {
                    totalAmountForAddvance = m_dTotalAmount;
                    serialBody += "\r\n" + strPrintFormatter.SumupLabeledText("Total:", m_dTotalAmount.ToString("F02"));
                }
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
                serialBody += "\r\nPayment:";

                if (!g_InputTextBox.Text.Substring(Program.currency.Length).Equals("0.00"))
                {

                    if (complementorylabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                    {
                        serialBody += "\r\nReceived :" + "0.00";
                    }

                    else   serialBody += "\r\nReceived :" + g_InputTextBox.Text.Substring(Program.currency.Length);
                }
                if (!g_CashLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nCash:" + g_CashLabel.Text.Substring(Program.currency.Length);
                }
                if (!g_EFTLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nCard - " + EFTOptionForm.seletedEFTCard.CardName + " :" + g_EFTLabel.Text.Substring(Program.currency.Length);
                }
                if (!g_ChequeLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nDue:" + g_ChequeLabel.Text.Substring(Program.currency.Length);
                }

                if (!g_VoucherLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nVoucher:" + g_VoucherLabel.Text.Substring(Program.currency.Length);
                }

                if (!g_AccountLabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nAccounts:" + g_AccountLabel.Text.Substring(Program.currency.Length);
                }

                if (!complementorylabel.Text.Substring(Program.currency.Length).Equals("0.00"))
                {
                    serialBody += "\r\nComplementory:" + complementorylabel.Text.Substring(Program.currency.Length);
                }

                if (m_isAddServiceCharge == false)
                {
                    if (Convert.ToDouble("0" + g_BalaceLabel.Text.Substring(9 + Program.currency.Length)) > 0)
                    {
                        serialBody += "\r\nPay Back: " + g_BalaceLabel.Text.Substring(9 + Program.currency.Length) + "\n";
                    }
                }

                if(addvancecAmountCheckBox.Checked)
                {
                    serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Addvance Payment Information");
                    serialBody += "\r\nAddvance Amount:" +(Convert.ToDouble("0"+advanceAmountTextBox.Text.Trim()));
                    serialBody += "\r\nPaid Amount:" + (totalAmountForAddvance-(Convert.ToDouble("0" + advanceAmountTextBox.Text.Trim())));

                }

                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();
            //    serialBody += "\r\nS/N: " + tempOrderInfo.SerialNo.ToString();
                if (Program.vatRegDes != "")
                {
                  serialBody += "\r\nVat Reg. No: " + Program.vatRegDes; // Change by Mithu
                }
                // serialBody += "\r\n\r\nDeveloped By: www.ibacs.co.uk";
                serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                if(complementoryMessage!=null && complementoryMessage.Length!=0)
                {
                    serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Complementory Message");
                    serialBody += "\r\n" + GetMessageFitOnPaper(complementoryMessage);
                    serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                }

                if (dueMessage!=null && dueMessage.Length != 0)
                {
                    serialBody += "\r\n" + strPrintFormatter.CenterTextWithDashed("Due Message");
                    serialBody += "\r\n" + GetMessageFitOnPaper(dueMessage);
                    serialBody += "\r\n" + strPrintFormatter.CreateDashedLine();

                }

                this.WriteString(serialBody);
                gusetBillStr = serialBody;
                //tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, tempOrderInfo.SerialNo.ToString());
                tempPrintMethods.USBPrint(serialBody, PrintDestiNation.CLIENT, true);
            }
        }
Esempio n. 11
0
        public CResult InsertOrderDiscount(COrderDiscount inOrderDiscount)
        {
            CResult oResult = new CResult();
            try
            {
                this.OpenConnection();

                string sSql = string.Format(SqlQueries.GetQuery(Query.OrderDiscountInsert),
                      inOrderDiscount.OrderID, inOrderDiscount.Discount, inOrderDiscount.discountPercentRate, inOrderDiscount.membershipID, inOrderDiscount.membershipCardID, inOrderDiscount.clientID, inOrderDiscount.membershipPoint, inOrderDiscount.membershipTotalPoint, inOrderDiscount.membershipDiscountRate, inOrderDiscount.membershipDiscountAmount,inOrderDiscount.TotalItemDiscount);

                this.ExecuteNonQuery(sSql);
                oResult.IsSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.Write("Exception : " + ex + " in InsertOrderDiscount()", LogLevel.Error, "Database");

                // throw new Exception("Exception occure at InsertOrderSeatTime()", ex);
                oResult.IsException = true;
            }
            finally
            {
                this.CloseConnection();
            }
            return oResult;
        }
Esempio n. 12
0
        private COrderDiscount ReaderToOrderDiscount(IDataReader inReader)
        {
            COrderDiscount tempOrderDiscount = new COrderDiscount();

            if (inReader["order_id"] != null)
                tempOrderDiscount.OrderID = Int64.Parse(inReader["order_id"].ToString());
            if (inReader["discount"] != null)
                tempOrderDiscount.Discount = Double.Parse(inReader["discount"].ToString());

            if (inReader["discountPercentRate"] != null)
                tempOrderDiscount.discountPercentRate = float.Parse(inReader["discountPercentRate"].ToString());

            if (inReader["membershipID"] != null)
                tempOrderDiscount.membershipID = long.Parse(inReader["membershipID"].ToString());

            if (inReader["membershipCardID"] != null)
                tempOrderDiscount.membershipCardID = long.Parse(inReader["membershipCardID"].ToString());

            if (inReader["clientID"] != null)
                tempOrderDiscount.clientID = long.Parse(inReader["clientID"].ToString());

            if (inReader["membershipPoint"] != null)
                tempOrderDiscount.membershipPoint = float.Parse(inReader["membershipPoint"].ToString());

            if (inReader["membershipTotalPoint"] != null)
                tempOrderDiscount.membershipTotalPoint = float.Parse(inReader["membershipTotalPoint"].ToString());

            if (inReader["membershipDiscountRate"] != null)
                tempOrderDiscount.membershipDiscountRate = float.Parse(inReader["membershipDiscountRate"].ToString());

            if (inReader["membershipDiscountAmount"] != null)
                tempOrderDiscount.membershipDiscountAmount = float.Parse(inReader["membershipDiscountAmount"].ToString());
            if (inReader["TotalItemDiscount"] != null)
                tempOrderDiscount.TotalItemDiscount = float.Parse(inReader["TotalItemDiscount"].ToString());

            return tempOrderDiscount;
        }
Esempio n. 13
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);
            }
        }