//private void btnPLU_Click(object sender, EventArgs e) //{ // int priceTakeType; // Int32 productPLU = 0; // int returnVal = 0; // Int32 productQuantity = 0; // COrderManager objOrderManager = new COrderManager(); // if (m_iType == m_cCommonConstants.TableType) // { // priceTakeType = 1; // } // else if (m_iType == m_cCommonConstants.TakeAwayType) // { // priceTakeType = 2; // } // else // { // priceTakeType = 3; // } // CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product"); // tableNumberForm.ShowDialog(); // if (CCalculatorForm.inputResult.Equals("Cancel")) // return; // if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0) // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); // tempMessageBox.ShowDialog(); // return; // } // productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult); // CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU); // if (Convert.ToString(objProductName.Data) == "NO") // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU"); // tempMessageBox.ShowDialog(); // return; // } // ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data)); // quantityForm.ShowDialog(); // if (ProductQuantityForm.m_productQuantity.Equals("Cancel")) // { // return; // } // if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0) // { // CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); // tempMessageBox.ShowDialog(); // return; // } // productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity); // CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity); // if (oResult.IsSuccess && oResult.Data != null) // { // returnVal = int.Parse(oResult.Data.ToString()); // //for vat includr option // String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails); // CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>(); // String tempConnStr = oTempDal.ConnectionString; // // Create a new data adapter based on the specified query. // SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr); // // Populate a new data table and bind it to the BindingSource. // DataTable table = new DataTable(); // //table.Locale = System.Globalization.CultureInfo.InvariantCulture; // dataAdapter.Fill(table); // int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); // Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); // int catLavel=Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); // //vat in cat Three // double vatRate = 0; // bool vat_included = false; // double vatAmountRate = 0; // if(catLavel==3) // { // DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString()); // vatRate = 0; // vat_included = false; // vatAmountRate = 0; // try // { // vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); // vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); // if (vat_included) // { // vatAmountRate = (amount * vatRate) / 100; // // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); // } // else // { // vatAmountRate = 0.00; // } // } // catch (Exception ex) { } // } // if(catLavel==4) // { // DataRow[] temp3DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID); // vatRate = 0; // vat_included = false; // vatAmountRate = 0; // try // { // vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString()); // vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString()); // if (vat_included) // { // vatAmountRate = (amount * vatRate) / 100; // // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); // } // else // { // vatAmountRate = 0.00; // } // } // catch (Exception ex) { } // } // //string tableTypePrice = string.Empty; // //if (m_iType == m_cCommonConstants.TableType) // //{ // // tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); // //} // //else if (m_iType == m_cCommonConstants.TakeAwayType) // //{ // // tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); // //} // COrderManager tempOrderManager = new COrderManager(); // COrderDetails tempOrderDetails = new COrderDetails(); // if (returnVal == 1) // { // //update Order_details table // //int tempRowIndex = tempResult; // //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; // //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; // //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); // tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); // tempOrderDetails.OrderID =Convert.ToInt32(table.Rows[0]["order_id"].ToString()); // tempOrderDetails.ProductID =Convert.ToInt32( table.Rows[0]["product_id"].ToString()); // tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); // tempOrderDetails.UnitPrice = 0.00; // tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString()); // tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); // tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString(); // // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString()); // // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); // if (vat_included) // { // tempOrderDetails.VatTotal = vatAmountRate; // } // else // { // tempOrderDetails.VatTotal = 0.00; // } // //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) // //{ // // tempOrderManager.UpdateOrderDetails(tempOrderDetails); // //} // //else // //{ // // tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); // //} // try // { // tempOrderManager.UpdateOrderDetails(tempOrderDetails); // } // catch { } // } // //tempOrderDetails.VatTotal = vatAmountRate; // //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); // //try // //{ // //tempOrderManager.UpdateOrderDetails(tempOrderDetails); // //} // //catch { } // } // if (returnVal == 0) // { // MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle, // MessageBoxButtons.OK, MessageBoxIcon.Information); // } // else // { // COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); // orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); // } // this.LoadOrderDetails(); // btnPLU_Click(sender, e); //} private void btnPLU_Click(object sender, EventArgs e) { int priceTakeType; Int32 productPLU = 0; int returnVal = 0; Int32 productQuantity = 0; COrderManager objOrderManager = new COrderManager(); if (m_iType == m_cCommonConstants.TableType) { priceTakeType = 1; } else if (m_iType == m_cCommonConstants.TakeAwayType) { priceTakeType = 2; } else { priceTakeType = 3; } CCalculatorForm tableNumberForm = new CCalculatorForm("Product PLU Information", "PLU of the Product"); tableNumberForm.ShowDialog(); if (CCalculatorForm.inputResult.Equals("Cancel")) return; if (CCalculatorForm.inputResult.Equals("") || Int32.Parse(CCalculatorForm.inputResult) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } productPLU = Convert.ToInt32("0" + CCalculatorForm.inputResult); // Add for find updating order_detail int id = productPLU; long order = orderID; COrderDetailsDAO aDao = new COrderDetailsDAO(); List<COrderDetails> aList = aDao.OrderDetailsGetAll(); // CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU, priceTakeType); CResult objProductName = objOrderManager.GetProductByProductPLU(productPLU); var check = (from orderdetail in aList where (orderdetail.OrderID == orderID && orderdetail.ProductID == objProductName.Productid) select orderdetail); if (Convert.ToString(objProductName.Data) == "NO") { CMessageBox tempMessageBox = new CMessageBox("Error", "Invalid PLU.Please enter valid PLU"); tempMessageBox.ShowDialog(); return; } ProductQuantityForm quantityForm = new ProductQuantityForm(Convert.ToString(objProductName.Data)); quantityForm.ShowDialog(); if (ProductQuantityForm.m_productQuantity.Equals("Cancel")) { return; } if (ProductQuantityForm.m_productQuantity.Equals("") || Int32.Parse(ProductQuantityForm.m_productQuantity) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } productQuantity = Convert.ToInt32("0" + ProductQuantityForm.m_productQuantity); // Add for updating order_detail when orderwith same product if (check.Count() == 1) { COrderDetails aOrderDetails = new COrderDetails(); aOrderDetails = check.Single(); //double vat = aOrderDetails.Amount_with_vat - aOrderDetails.OrderAmount; //vat = (vat * 100) / aOrderDetails.OrderAmount; productQuantity += aOrderDetails.OrderQuantity; aOrderDetails.OrderQuantity = productQuantity; aOrderDetails.OrderAmount = aOrderDetails.UnitPrice * productQuantity; aOrderDetails.PrintedQuantity = aOrderDetails.PrintedQuantity; aOrderDetails.VatTotal = (objProductName.VateRate * aOrderDetails.OrderAmount) / 100.0; aOrderDetails.Amount_with_vat = aOrderDetails.OrderAmount + aOrderDetails.VatTotal; COrderDetailsDAO aCOrderDetailsDao = new COrderDetailsDAO(); aCOrderDetailsDao.OrderDetailsUpdate(aOrderDetails); //COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); //orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); } if (check.Count() == 0) { CResult oResult = objOrderManager.GetPluDataByProductPLU(productPLU, priceTakeType, orderID, productQuantity); if (oResult.IsSuccess && oResult.Data != null) { returnVal = int.Parse(oResult.Data.ToString()); //for vat includr option String queryStr = SqlQueries.GetQuery(Query.LastPLUOrderDetails); CDalConfig oTempDal = ConfigManager.GetConfig<CDalConfig>(); String tempConnStr = oTempDal.ConnectionString; // Create a new data adapter based on the specified query. SqlDataAdapter dataAdapter = new SqlDataAdapter(queryStr, tempConnStr); // Populate a new data table and bind it to the BindingSource. DataTable table = new DataTable(); //table.Locale = System.Globalization.CultureInfo.InvariantCulture; dataAdapter.Fill(table); int CategoryID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); Double amount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); int catLavel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); //vat in cat Three double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; if (catLavel == 3) { DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + CategoryID.ToString()); vatRate = 0; vat_included = false; vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (amount * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } } if (catLavel == 4) { DataRow[] temp3DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + CategoryID); vatRate = 0; vat_included = false; vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp3DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp3DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (amount * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); // tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } } //string tableTypePrice = string.Empty; //if (m_iType == m_cCommonConstants.TableType) //{ // tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); //} //else if (m_iType == m_cCommonConstants.TakeAwayType) //{ // tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); //} COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (returnVal == 1) { //update Order_details table //int tempRowIndex = tempResult; //int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; //tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; //tempDataGridView.Rows[tempRowIndex].Cells[2].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); tempOrderDetails.OrderDetailsID = Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); tempOrderDetails.OrderID = Convert.ToInt32(table.Rows[0]["order_id"].ToString()); tempOrderDetails.ProductID = Convert.ToInt32(table.Rows[0]["product_id"].ToString()); tempOrderDetails.CategoryLevel = Convert.ToInt32(table.Rows[0]["cat_level"].ToString()); tempOrderDetails.UnitPrice = 0.00; tempOrderDetails.OrderQuantity = Convert.ToInt32(table.Rows[0]["quantity"].ToString()); tempOrderDetails.OrderAmount = Convert.ToDouble(table.Rows[0]["amount"].ToString()); tempOrderDetails.OrderFoodType = table.Rows[0]["food_type"].ToString(); // tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[5].Value.ToString()); // tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); if (vat_included) { tempOrderDetails.VatTotal = vatAmountRate; } else { tempOrderDetails.VatTotal = 0.00; } //if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //{ // tempOrderManager.UpdateOrderDetails(tempOrderDetails); //} //else //{ // tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); //} try { tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; tempOrderManager.UpdateOrderDetails(tempOrderDetails); } catch { } } //tempOrderDetails.VatTotal = vatAmountRate; //tempOrderDetails.OrderDetailsID =Convert.ToInt32(table.Rows[0]["order_detail_id"].ToString()); //try //{ //tempOrderManager.UpdateOrderDetails(tempOrderDetails); //} //catch { } } if (returnVal == 0) { MessageBox.Show("Please enter valid plu product", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { COrderDetailsDAO orderDetailsDao = new COrderDetailsDAO(); orderDetailsDao.UpdateOrderDetailsPricebyPLUProductTablePrice(productPLU, orderID, priceTakeType); } } this.LoadOrderDetails(); btnPLU_Click(sender, e); }
public void UpdateGuestQuantity(Int64 orderId) { List<COrderDetails> aList = new List<COrderDetails>(); COrderDetailsDAO aDao = new COrderDetailsDAO(); aList = aDao.OrderDetailsGetByOrderIDForUpdateGuestQuantity(orderId); try { this.OpenConnection(); foreach (COrderDetails details in aList) { string sqlCommand = String.Format(SqlQueries.GetQuery(Query.UpdateGuestQuantity), details.OrderID, details.ProductID, details.OrderQuantity); this.ExecuteNonQuery(sqlCommand); } } catch (Exception ex) { throw new Exception("Database error for UpdateGuestQuantity()", ex); } finally { this.CloseConnection(); } }
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(); }
private void g_PrintGuestBillButton_Click(object sender, EventArgs e) { COrderDetailsDAO aDao = new COrderDetailsDAO(); aDao.UpdateGuestQuantity(orderID); bool isPrintA5SizeReport = false; if (isPrintA5SizeReport) { PrintA5GuestBillReport(); } else { int papersize = 37; StringPrintFormater strPrintFormatter = new StringPrintFormater(37); string Cat1ID = String.Empty; try { CPrintMethodsEXT tempPrintMethods = new CPrintMethodsEXT(); //CPrintMethods tempPrintMethods = new CPrintMethods(); int categoryID = 0; //serial print //string serialHeader = "IBACS RMS"; string serialHeader = ""; //string serialFooter = "Please Come Again"; string serialFooter = ""; List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>(); CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Guest Bill"); tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); COrderManager tempOrderManager = new COrderManager(); COrderInfo tempOrderInfo = (COrderInfo)tempOrderManager.OrderInfoByOrderID(orderID).Data; //string s=tempOrderInfo. if (m_iType == m_cCommonConstants.TableType) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n\r\n" + strPrintFormatter.CenterTextWithWhiteSpace(" MUSAK-11"); // Change by Mithu //tempSerialPrintContent.StringLine = "\r\n\nOrder ID:" + orderID.ToString(); serialBody.Add(tempSerialPrintContent); //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "\r\n\nTable Number:" + tempOrderInfo.TableNumber.ToString(); //serialBody.Add(tempSerialPrintContent); COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); // Change by Mithu COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(orderID); // Change by Mithu tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n\r\nVat Registration No: " + Program.vatRegDes.ToString(); //tempSerialPrintContent.StringLine = "\r\nPrint Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt"); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent.StringLine = "\r\nWaiter Name: " + orderWaiter.WaiterName + "\r\n"; // Change by Mithu tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n\nOrder ID:" + orderID.ToString(); //tempSerialPrintContent.StringLine = "\r\nTable No: " + m_iTableNumber.ToString() + "\r\n"; tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nPrint Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt"); //tempSerialPrintContent.StringLine = "Covers: " + tempOrderInfo.GuestCount.ToString() + "\r\n"; tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nTable No: " + m_iTableNumber.ToString() + "\r\n"; // tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); //try //{ // tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "Vat Registration : " + Program.vatRegDes + "\r\n"; // serialBody.Add(tempSerialPrintContent); //} //catch { } tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Covers: " + tempOrderInfo.GuestCount.ToString() + "\r\n"; //tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithDashed("Order Information"); serialBody.Add(tempSerialPrintContent); } else if (m_iType == m_cCommonConstants.TakeAwayType) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n\nOrder ID:" + orderID.ToString(); //tempSerialPrintContent.StringLine = "\r\nTable No: " + m_iTableNumber.ToString() + "\r\n"; tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nOrder Date: " + tempOrderInfo.OrderTime.ToString("dd/MM/yy hh:mm tt"); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nPrint Date: " + System.DateTime.Now.ToString("dd/MM/yy hh:mm tt"); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nType: " + tempOrderInfo.Status; serialBody.Add(tempSerialPrintContent); COrderWaiterDao orderWaiterDao = new COrderWaiterDao(); COrderwaiter orderWaiter = orderWaiterDao.GetOrderwaiterByOrderID(orderID); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + "Waiter Name: " + orderWaiter.WaiterName + "\r\n"; // tempSerialPrintContent.Bold = true; serialBody.Add(tempSerialPrintContent); CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = (CCustomerInfo)tempCustomerManager.CustomerInfoGetByCustomerID(tempOrderInfo.CustomerID).Data; if (tempCustomerInfo.CustomerName.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nCustomer Name: " + tempCustomerInfo.CustomerName; serialBody.Add(tempSerialPrintContent); } if (tempCustomerInfo.CustomerPhone.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nPhone:" + tempCustomerInfo.CustomerPhone; serialBody.Add(tempSerialPrintContent); } if (tempOrderInfo.Status.Equals("Delivery")) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nAddress:"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); if (tempCustomerInfo.FloorAptNumber.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Floor or Apartment:" + tempCustomerInfo.FloorAptNumber; serialBody.Add(tempSerialPrintContent); } if (tempCustomerInfo.BuildingName.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Building Name:" + tempCustomerInfo.BuildingName; serialBody.Add(tempSerialPrintContent); } if (tempCustomerInfo.HouseNumber.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "House Number:" + tempCustomerInfo.HouseNumber; serialBody.Add(tempSerialPrintContent); } string[] street = new string[0]; street = tempCustomerInfo.StreetName.Split('-'); if (street.Length > 1) { if (street[0].ToString().Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Street:" + street[0].ToString(); serialBody.Add(tempSerialPrintContent); } if (street[1].ToString().Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = street[1].ToString(); serialBody.Add(tempSerialPrintContent); } } else if (street.Length > 0 && street.Length < 2) { if (street[0].ToString().Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Street:" + street[0].ToString(); serialBody.Add(tempSerialPrintContent); } } if (tempCustomerInfo.CustomerPostalCode.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Postal Code:" + tempCustomerInfo.CustomerPostalCode; serialBody.Add(tempSerialPrintContent); } if (tempCustomerInfo.CustomerTown.Length > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Town:" + tempCustomerInfo.CustomerTown; serialBody.Add(tempSerialPrintContent); } //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "Country:" + tempCustomerInfo.CustomerCountry; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); CDelivery objDelivery = new CDelivery(); objDelivery.DeliveryOrderID = orderID; CResult objDeliveryInfo = tempOrderManager.GetDeliveryInfo(objDelivery); objDelivery = (CDelivery)objDeliveryInfo.Data; if (objDelivery != null) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nDelivery Time:" + objDelivery.DeliveryTime; serialBody.Add(tempSerialPrintContent); } } } tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n\nOrder Information"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.ItemLabeledText("Qty Item", "Price(" + Program.currency + ")"); serialBody.Add(tempSerialPrintContent); //Line after above line //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "----------------------------------------"; //serialBody.Add(tempSerialPrintContent); if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { Hashtable htOrderedItems = new Hashtable(); SortedList slorderedItems = null; string categoryOrder = String.Empty; int internalCategoryID = 0; //Modification By Baruri at 04/08/2008 for (int rowIndex = 0; rowIndex < g_FoodDataGridView.Rows.Count; rowIndex++) { internalCategoryID = 0; string cat3ID = String.Empty; string cat2ID = String.Empty; string cat1ID = String.Empty; DataGridViewRow tempRow = g_FoodDataGridView.Rows[rowIndex]; categoryOrder = String.Empty; if (!tempRow.Cells[0].Value.ToString().Equals("")) { #region "Parent Category" if (Convert.ToInt32("0" + tempRow.Cells[5].Value.ToString()) == 3)//Item from Category 3 { internalCategoryID = Convert.ToInt32("0" + tempRow.Cells[4].Value.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.Cells[5].Value.ToString()) == 0) { cat1ID = "0"; cat2ID = "0"; } else { internalCategoryID = Convert.ToInt32("0" + tempRow.Cells[4].Value.ToString()); DataRow[] dtRow = dsCategory4.Tables[0].Select("cat4_id = " + internalCategoryID); if (dtRow.Length > 0) { cat3ID = dtRow[0]["cat3_id"].ToString(); if (cat3ID != "" || cat3ID != null) { dtRow = dsCategory3.Tables[0].Select("cat3_id = " + cat3ID); } else { dtRow = null; } } if (dtRow.Length > 0) { cat2ID = dtRow[0]["cat2_id"].ToString(); DataRow[] dtRowCat2 = dsCategory2.Tables[0].Select("cat2_id = " + cat2ID);//new cat1ID = dtRowCat2[0]["cat1_id"].ToString(); } } #endregion clsOrderReport objOrderedItems = new clsOrderReport(); objOrderedItems.Quantity = Convert.ToInt32("0" + tempRow.Cells[1].Value.ToString()); objOrderedItems.ItemName = tempRow.Cells[0].Value.ToString(); //objOrderedItems.Price = Convert.ToDouble("0" + tempRow.Cells[2].Value.ToString()); //ater adding vat col in grid index is changed objOrderedItems.Price = Convert.ToDouble("0" + tempRow.Cells[3].Value.ToString()); //htOrderedItems.Add(cat2ID + "-" + objOrderedItems.ItemName, objOrderedItems);//Showing the products according to categpry 2 Int64 rankNumber = Int64.Parse(tempRow.Cells[5].Value.ToString()); Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID)); htOrderedItems.Add(category1OrderNumber + "-" + rankNumber + "-" + objOrderedItems.ItemName, objOrderedItems);//Category 1 wise separator } } NumericComparer nc = new NumericComparer(); slorderedItems = new SortedList(htOrderedItems, nc); int keyIndex = 0; string[] valueSplitter = new string[0]; SortedList slMiscellaneousItems = new SortedList(); //Only for miscellenious category PrintUtility printUtility = new PrintUtility(); foreach (clsOrderReport objReport in slorderedItems.Values) { string keyValue = slorderedItems.GetKey(keyIndex).ToString(); valueSplitter = keyValue.Split('-'); if ((categoryID != Convert.ToInt32("0" + valueSplitter[0].ToString())) && Convert.ToInt32("0" + valueSplitter[0].ToString()) != 0)//Insert separator { categoryID = Convert.ToInt32("0" + valueSplitter[0].ToString()); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine() + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); /*tempSerialPrintContent.StringLine += objReport.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objReport.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6);*/ //tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + //objReport.ItemName.ToString(), objReport.Price.ToString("F02")); //if (qty_length_with_twospace + objReport.ItemName.Length + objReport.Price.ToString().Length <= printlinelength) //{ // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), // " " + objReport.Price.ToString("F02")); //} //else //{ // // line 1 // int itemname_firstline_length = printlinelength - 4 - 1 - objReport.Price.ToString().Length; // string itemname_first_part = objReport.ItemName.Substring(0, itemname_firstline_length); // string itemname_second_part = objReport.ItemName.Substring(itemname_firstline_length); // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + itemname_first_part, // " " + objReport.Price.ToString("F02")); // // line 2 // tempSerialPrintContent.StringLine += "\r\n " // + strPrintFormatter.ItemLabeledText(itemname_second_part, // " "); //} tempSerialPrintContent.StringLine += strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize - 5), ""); serialBody.Add(tempSerialPrintContent); } else if (valueSplitter[0].ToString() == "0") //Used for miscellenious items. i.e these items have no parent category. { tempSerialPrintContent = new CSerialPrintContent(); /*tempSerialPrintContent.StringLine += objReport.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objReport.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6);*/ //tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + //objReport.ItemName.ToString(), objReport.Price.ToString("F02")); //if (qty_length_with_twospace + objReport.ItemName.Length + objReport.Price.ToString().Length <= printlinelength) //{ // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), // " " + objReport.Price.ToString("F02")); //} //else //{ // // line 1 // int itemname_firstline_length = printlinelength - 4 - 1 - objReport.Price.ToString().Length; // string itemname_first_part = objReport.ItemName.Substring(0, itemname_firstline_length); // string itemname_second_part = objReport.ItemName.Substring(itemname_firstline_length); // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + itemname_first_part, // " " + objReport.Price.ToString("F02")); // // line 2 // tempSerialPrintContent.StringLine += "\r\n " // + strPrintFormatter.ItemLabeledText(itemname_second_part, // " "); //} tempSerialPrintContent.StringLine += strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize - 5), ""); slMiscellaneousItems.Add(slMiscellaneousItems.Count, tempSerialPrintContent); } else { tempSerialPrintContent = new CSerialPrintContent(); /*tempSerialPrintContent.StringLine += objReport.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objReport.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objReport.Price.ToString("F02"), 6);*/ //tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + //objReport.ItemName.ToString(), objReport.Price.ToString("F02")); //if (qty_length_with_twospace + objReport.ItemName.Length + objReport.Price.ToString().Length <= printlinelength) //{ // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + objReport.ItemName.ToString(), // " " + objReport.Price.ToString("F02")); //} //else //{ // // line 1 // int itemname_firstline_length = printlinelength - 4 - 1 - objReport.Price.ToString().Length; // string itemname_first_part = objReport.ItemName.Substring(0, itemname_firstline_length); // string itemname_second_part = objReport.ItemName.Substring(itemname_firstline_length); // tempSerialPrintContent.StringLine += "\r\n" // + strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + itemname_first_part, // " " + objReport.Price.ToString("F02")); // // line 2 // tempSerialPrintContent.StringLine += "\r\n " // + strPrintFormatter.ItemLabeledText(itemname_second_part, // " "); //} tempSerialPrintContent.StringLine += strPrintFormatter.ItemLabeledText(objReport.Quantity.ToString() + " " + printUtility.MultipleLine(objReport.ItemName.ToString(), papersize - 10, objReport.Price.ToString("F02"), papersize - 5), ""); serialBody.Add(tempSerialPrintContent); } keyIndex++; } //Add the miscellaneous items with the separator if (slMiscellaneousItems.Count > 0) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithDashed("Miscellaneous") + "\r\n"; serialBody.Add(tempSerialPrintContent); foreach (CSerialPrintContent tempSerialContent in slMiscellaneousItems.Values) { serialBody.Add(tempSerialContent); } } for (int rowIndex = 0; rowIndex < g_BeverageDataGridView.Rows.Count; rowIndex++) { DataGridViewRow tempRow = g_BeverageDataGridView.Rows[rowIndex]; if (rowIndex == 0 && (!tempRow.Cells[0].Value.ToString().Equals(""))) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithDashed("Drinks") + "\r\n"; serialBody.Add(tempSerialPrintContent); } if (!tempRow.Cells[0].Value.ToString().Equals("")) { tempSerialPrintContent = new CSerialPrintContent(); /*tempSerialPrintContent.StringLine = tempRow.Cells[1].Value.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(tempRow.Cells[0].Value.ToString(), 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(tempRow.Cells[2].Value.ToString(), 6);*/ tempSerialPrintContent.StringLine += strPrintFormatter.ItemLabeledText(tempRow.Cells[1].Value.ToString() + " " + printUtility.MultipleLine(tempRow.Cells[0].Value.ToString(), papersize - 10, tempRow.Cells[3].Value.ToString(), papersize - 5), ""); //tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.ItemLabeledText(tempRow.Cells[1].Value.ToString() + " " + //tempRow.Cells[0].Value.ToString(), tempRow.Cells[2].Value.ToString()); serialBody.Add(tempSerialPrintContent); } } } else { //For online orders tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); for (int rowIndex = 0; rowIndex < g_FoodDataGridView.RowCount; rowIndex++) { if (Convert.ToInt32("0" + g_FoodDataGridView.Rows[rowIndex].Cells[1].Value) > 0) { tempSerialPrintContent = new CSerialPrintContent(); /* tempSerialPrintContent.StringLine += Convert.ToString(g_FoodDataGridView.Rows[rowIndex].Cells[1].Value) + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(Convert.ToString(g_FoodDataGridView.Rows[rowIndex].Cells[0].Value), 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(Convert.ToDouble("0" + g_FoodDataGridView.Rows[rowIndex].Cells[2].Value).ToString("F02"), 6);*/ //**************// tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.ItemLabeledText(g_FoodDataGridView.Rows[rowIndex].Cells[1].Value.ToString() + " " + (g_FoodDataGridView.Rows[rowIndex].Cells[0].Value.ToString()), (Convert.ToDouble("0" + g_FoodDataGridView.Rows[rowIndex].Cells[2].Value).ToString("F02"))); serialBody.Add(tempSerialPrintContent); } } for (int rowIndex = 0; rowIndex < g_BeverageDataGridView.RowCount; rowIndex++) { if (Convert.ToInt32("0" + g_BeverageDataGridView.Rows[rowIndex].Cells[1].Value) > 0) { tempSerialPrintContent = new CSerialPrintContent(); /*tempSerialPrintContent.StringLine += Convert.ToString(g_BeverageDataGridView.Rows[rowIndex].Cells[1].Value) + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(Convert.ToString(g_BeverageDataGridView.Rows[rowIndex].Cells[0].Value), 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(Convert.ToDouble("0" + g_BeverageDataGridView.Rows[rowIndex].Cells[2].Value).ToString("F02"), 6);*/ tempSerialPrintContent.StringLine += strPrintFormatter.ItemLabeledText(g_BeverageDataGridView.Rows[rowIndex].Cells[1].Value.ToString() + " " + (g_BeverageDataGridView.Rows[rowIndex].Cells[0].Value.ToString()), (Convert.ToDouble("0" + g_BeverageDataGridView.Rows[rowIndex].Cells[2].Value).ToString("F02"))); serialBody.Add(tempSerialPrintContent); } } } tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); decimal discountAmount = decimal.Parse(g_DiscountLabel.Text); Decimal totalAmount = Decimal.Parse(g_AmountLabel.Text); Decimal billTotal = discountAmount + totalAmount; //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = " Order Total: " + billTotal.ToString("F02"); //serialBody.Add(tempSerialPrintContent); //New at 02.03.2009 tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = " Order Total: " + this.GetOrderTotal().ToString("F02"); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Order Amount: ", GetOrderTotal().ToString("F02")); serialBody.Add(tempSerialPrintContent); if (discountAmount > 0) { decimal itemCost = this.GetOrderTotal(); tempSerialPrintContent = new CSerialPrintContent(); decimal discountPercent = 100 * discountAmount / (itemCost); //Discount is based on the total item cost //tempSerialPrintContent.StringLine = " Discount:(" + discountPercent.ToString("F02") + "%) " +Convert.ToDecimal(g_DiscountLabel.Text).ToString("F02"); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Discount(" + discountPercent.ToString("F02") + "%): ", Convert.ToDecimal(g_DiscountLabel.Text).ToString("F02")); serialBody.Add(tempSerialPrintContent); } double itemiscount = Convert.ToDouble(totalItemWiseDiscountlabel.Text); if (itemiscount > 0) { tempSerialPrintContent = new CSerialPrintContent(); //Discount is based on the total item cost //tempSerialPrintContent.StringLine = " Discount:(" + discountPercent.ToString("F02") + "%) " +Convert.ToDecimal(g_DiscountLabel.Text).ToString("F02"); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText(" Item Discount: ", itemiscount.ToString("F02")); serialBody.Add(tempSerialPrintContent); } if (Convert.ToDouble("0" + g_serviceCharge.Text) > 0) //If service charge is assigned { CResult cResult = tempOrderManager.OrderServiceChargeGetByOrderID(orderID); ServiceCharge serviceCharge = cResult.Data as ServiceCharge; tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = " Service Charge: " + Convert.ToDecimal("0" + g_serviceCharge.Text).ToString("F02"); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Service Charge(" + serviceCharge.ServicechargeRate.ToString("F02") + "%): ", Convert.ToDecimal("0" + g_serviceCharge.Text).ToString("F02")); serialBody.Add(tempSerialPrintContent); } if (isVatEnabled) //If vat is assigned { tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = " Vat("+vat.ToString()+"%): " + Convert.ToDecimal("0" + lblVat.Text).ToString("F02"); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Vat Total(15%) : ", Convert.ToDecimal("0" + lblVat.Text).ToString("F02")); serialBody.Add(tempSerialPrintContent); } //tempSerialPrintContent = new CSerialPrintContent(); //double payableAmount = Convert.ToDouble("0" + g_serviceCharge.Text) + Convert.ToDouble("0" + g_AmountLabel.Text); //tempSerialPrintContent.StringLine = " Total Payable: " + payableAmount.ToString("F02"); //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "----------------------------------------"; tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); decimal payableAmount = Convert.ToDecimal(Convert.ToDecimal("0" + g_serviceCharge.Text).ToString("F02")) + Convert.ToDecimal(this.GetOrderTotal()) - Convert.ToDecimal(Convert.ToDecimal("0" + g_DiscountLabel.Text).ToString("F02")); payableAmount = Convert.ToDecimal(Convert.ToDouble(payableAmount) * (1 + vat / 100)); //tempSerialPrintContent.StringLine = " Total Payable: " + payableAmount.ToString("F02"); //tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Total Payable: ", payableAmount.ToString("F02")); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Total: ", Convert.ToDecimal("0" + g_AmountLabel.Text).ToString("F02")); serialBody.Add(tempSerialPrintContent); //if (Convert.ToDouble("0" + g_serviceCharge.Text) == 0)//If service charge is not assigned then blank for assigining. //{ // tempSerialPrintContent = new CSerialPrintContent(); // //tempSerialPrintContent.StringLine = " Service Charge:______"; // tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.SumupLabeledText("Service Charge:", " ______"); // serialBody.Add(tempSerialPrintContent); //} tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "----------------------------------------"; tempSerialPrintContent.StringLine += "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); //New at 22.08.2008 tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "You've Served by :" + m_OperatorName; tempSerialPrintContent.StringLine = "\r\nYou've Served by:" + m_OperatorName; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + m_TerminalName.Trim(); serialBody.Add(tempSerialPrintContent); //------------------------ tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nS/N: " + tempOrderInfo.SerialNo.ToString() + "\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "----------------------------------------"; tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); //For Vat Registration Number tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\nVat Registration No : " + Program.vatRegDes.ToString(); // Change by Mithu serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "----------------------------------------"; tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "\r\nDeveloped By: www.ibacs.co.uk"; //serialBody.Add(tempSerialPrintContent); #region "Testing printing area" string printingObject = ""; for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++) { printingObject += serialBody[arrayIndex].StringLine.ToString(); } this.WriteString(printingObject);///Write to a file when print command is executed #endregion // tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, tempOrderInfo.SerialNo.ToString()); tempPrintMethods.USBPrint(printingObject, PrintDestiNation.CLIENT, true); ///Update status /// if (tempOrderInfo.OrderType.Equals("Table")) { tempOrderInfo.Status = "Billed"; tempOrderInfo.OrderTime = System.DateTime.Now; tempOrderManager.UpdateOrderInfo(tempOrderInfo); CPaymentManager tempPaymentManager = new CPaymentManager(); CPayment tempPayment = new CPayment(); tempPayment.OrderID = tempOrderInfo.OrderID; tempPayment.BillPrintTime = DateTime.Now; tempPaymentManager.InsertBillPrintTime(tempPayment); } this.ChangeGuestBillPrintStatus(); } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private bool CheckRawProduct(List<COrderDetails> tempOrderDetailsList) { CCategory3DAO cCategory3Dao = new CCategory3DAO(); FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO(); string stockMessage = "Stock is unavailable "; bool isStockAvailable = true; KitchenStockDAO aKitchenStockDao = new KitchenStockDAO(); foreach (COrderDetails orderDetail in tempOrderDetailsList) { List<CFinishedRawProductList> finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID(Convert.ToInt32(orderDetail.ProductID)); foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList) { // CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(finishedRawProduct.RawProductID)); KitchenStock aKitchenStock = new KitchenStock(); // KitchenStockDAO aKitchenStockDao=new KitchenStockDAO(); aKitchenStock = aKitchenStockDao.GetStockByItemidFrominventory_kitchen_stock((int)finishedRawProduct.RawProductID); //List<CCategory3> aList = cCategory3Dao.GetAllCategory3(); //var temp = from acategory in aList where acategory.Category2ID == cCategory3.Category2ID select acategory; if (finishedRawProduct.Qnty * (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > aKitchenStock.Stocks) { stockMessage += "\n " + finishedRawProduct.RawProductName + ": Needed: " + finishedRawProduct.Qnty * (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + "\n " + " But Have: " + (aKitchenStock.Stocks); isStockAvailable = false; } } } if(!isStockAvailable) { CUserInfoDAO aUserInfoDao=new CUserInfoDAO(); CUserInfo aUserInfo=new CUserInfo(); aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName); if (aUserInfo.Type == 0) { DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { isStockAvailable = true; } else if (dialogResult == DialogResult.No) { } } } if (!isStockAvailable) { CMessageBox cMessageBox = new CMessageBox("Raw Product", stockMessage); cMessageBox.ShowDialog(); return false; } else { foreach (COrderDetails orderDetails in tempOrderDetailsList) { List<CFinishedRawProductList> finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID( Convert.ToInt32(orderDetails.ProductID)); foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList) { aKitchenStockDao.UpdateStock(Convert.ToInt32(finishedRawProduct.RawProductID), finishedRawProduct.Qnty * (orderDetails.OrderQuantity - orderDetails.KitchenQuantity)); } COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO(); cOrderDetailsDao.UpdateKitchenQuantity(orderDetails); } } return true; }
private bool CheckStockControl() { CCategory3DAO cCategory3Dao = new CCategory3DAO(); 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; string stockMessage = "Stock is unavailable "; bool isStockAvailable = true; foreach (COrderDetails orderDetail in tempOrderDetailsList) { CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetail.ProductID)); if ((orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > cCategory3.MUnitsInStock && cCategory3.MNonStockable) { //stockMessage += "\n " + orderDetail.Product_Name + " " + (orderDetail.OrderQuantity - cCategory3.MUnitsInStock); stockMessage += "\n " + cCategory3.Category3Name + ": Needed: " + (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + " But Have " + (cCategory3.MUnitsInStock); isStockAvailable = false; } } if (!isStockAvailable) { CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName); if (aUserInfo.Type == 0) { DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { isStockAvailable = true; } else if (dialogResult == DialogResult.No) { } } } if (!isStockAvailable || !CheckRawProduct(tempOrderDetailsList)) { CMessageBox cMessageBox = new CMessageBox("Finished Product", stockMessage); cMessageBox.ShowDialog(); //MessageBox.Show(stockMessage); return false; } else { foreach (COrderDetails orderDetails in tempOrderDetailsList) { CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetails.ProductID)); if (!cCategory3.MNonStockable) { cCategory3Dao.UpdateStock(Convert.ToInt32(orderDetails.ProductID), orderDetails.OrderQuantity - orderDetails.KitchenQuantity); COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO(); cOrderDetailsDao.UpdateKitchenQuantity(orderDetails); } } } // parrentForm.scre return true; }
public void VoidTableDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (VoidTableDataGridView.Columns[e.ColumnIndex].Name == "ActionButtonColumn" && e.RowIndex >= 0 && VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value != null) { DialogResult tempDialogResult = MessageBox.Show("Are you sure you want to void this order?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (tempDialogResult.Equals(DialogResult.No)) return; //ItemInfo c = new ItemInfo(); //c.ShowDialog(); //c.Close(); //DialogResult tempDialogResult1 = MessageBox.Show("Ok Done", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Question); //if (tempDialogResult1.Equals(DialogResult.No)) return; else { String tempOldOrderID = VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value.ToString(); int tempOldTableNumber = int.Parse(VoidTableDataGridView.Rows[e.RowIndex].Cells["TableNumberColumn"].Value.ToString()); String tempOldTableType = VoidTableDataGridView.Rows[e.RowIndex].Cells["TableTypeColumn"].Value.ToString(); // add by mithu OrderVoid aOrderVoid=new OrderVoid(); aOrderVoid.OrderId = Convert.ToInt32(VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value); COrderDetailsDAO aDao = new COrderDetailsDAO(); List<COrderDetails> aList = new List<COrderDetails>(); CResult aResult = new CResult(); aResult = aDao.OrderDetailsGetByOrderID(aOrderVoid.OrderId); aList = (List<COrderDetails>)aResult.Data; aOrderVoid.TableNumber = tempOldTableNumber; aOrderVoid.RemoverId = RMS.RMSGlobal.m_iLoginUserID; aOrderVoid.VoidDate = DateTime.Now; COrderDetailsDAO aCOrderDetailsDAO=new COrderDetailsDAO(); aOrderVoid.OrderAmount = aCOrderDetailsDAO.GetOrderAmount(aOrderVoid.OrderId); COrderInfo aInfo=new COrderInfo(); COrderInfoDAO aCOrderInfoDao=new COrderInfoDAO(); aInfo = aCOrderInfoDao.GetOrderInfoByOrderID(aOrderVoid.OrderId); aOrderVoid.OrderDate = aInfo.OrderTime; aOrderVoid.Creator_Id = aInfo.UserID; ReasonForm aReasonForm=new ReasonForm(); aReasonForm.ShowDialog(); aOrderVoid.Reason = aReasonForm.reason; OrderVoidDAO aOrderVoidDao=new OrderVoidDAO(); aOrderVoidDao.InsertOrderForVoid(aOrderVoid); DataSet tempStockDataSet = new DataSet(); tempStockDataSet.ReadXml("Config/StockSetting.xml"); bool isAllowedToOrder = Convert.ToBoolean(tempStockDataSet.Tables[0].Rows[0]["AllowedtoOrder"].ToString()); if (!isAllowedToOrder) { UpdateRawMaterial(aList); } COrderManager tempVoidTableManager = new COrderManager(); CResult tempResult = tempVoidTableManager.UpdateForVoidTable(tempOldOrderID, tempOldTableNumber, tempOldTableType, false); if (tempResult.IsSuccess) { this.PopulateVoidTableDataGridView(); } } } } catch (Exception ex) { } }
private double GetTotalCost(long mIOrderId) { COrderDetailsDAO aDetailsDao=new COrderDetailsDAO(); List<COrderDetails> aDetailses=new List<COrderDetails>(); aDetailses = (List<COrderDetails>)aDetailsDao.OrderDetailsGetByOrderID(mIOrderId).Data; CCategory3DAO aCCategory3Dao=new CCategory3DAO(); List<CCategory3> aCCategory3s=new List<CCategory3>(); aCCategory3s = aCCategory3Dao.GetAllCategory3(); double totalcost = 0; foreach (COrderDetails order in aDetailses) { foreach (CCategory3 category3 in aCCategory3s) { if(category3.Category3ID==order.ProductID) { totalcost += (category3.TableCost*order.OrderQuantity); } } } return totalcost; }
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()); } }
//Add for vat and cost find out private COrderDetails GetAll(COrderDetails objDetails) { try { COrderDetailsDAO aDao = new COrderDetailsDAO(); List<COrderDetails> aCOrderDetailses = aDao.OrderDetailsGetAll(); COrderDetails orderDetails = new COrderDetails(); foreach (COrderDetails details in aCOrderDetailses) { if (details.OrderID == objDetails.OrderID && details.ProductID == objDetails.ProductID) { orderDetails = details; } } int quantity = objDetails.OrderQuantity; double unit_amount = (orderDetails.OrderAmount / orderDetails.OrderQuantity); double unit_vat = ((orderDetails.Amount_with_vat - orderDetails.OrderAmount) * 100) / orderDetails.OrderAmount; unit_vat = (unit_amount * unit_vat) / 100.0; objDetails.OrderAmount = (unit_amount * quantity); objDetails.VatTotal = unit_vat * quantity; objDetails.Amount_with_vat = objDetails.OrderAmount + objDetails.VatTotal; objDetails.KitchenQuantity = orderDetails.KitchenQuantity; } catch { } return objDetails; }
public CResult VoidPrintedItems(System.Collections.SortedList slPrintedList, long orderID) { DataSet tempStockDataSet = new DataSet(); tempStockDataSet.ReadXml("Config/StockSetting.xml"); bool isAllowedToOrder = Convert.ToBoolean(tempStockDataSet.Tables[0].Rows[0]["AllowedtoOrder"].ToString()); CResult oResult = new CResult(); string sqlCommand = ""; try { this.OpenConnection(); foreach (COrderDetails objDetails in slPrintedList.Values) { COrderDetails aDetails = new COrderDetails(); aDetails = GetAll(objDetails); // Add for Vat and Cost find out if (objDetails.OrderQuantity > 0) //If item is rest. { sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateLocalVoidItems), aDetails.OrderQuantity, aDetails.PrintedQuantity, aDetails.OrderDetailsID, aDetails.OrderAmount, aDetails.Amount_with_vat, aDetails.VatTotal); } else { sqlCommand = string.Format(SqlQueries.GetQuery(Query.OrderDetailsDelete), objDetails.OrderDetailsID); } this.ExecuteNonQuery(sqlCommand); //Add for raw materials update if (!isAllowedToOrder) { if (objDetails.KitchenQuantity - objDetails.OrderQuantity >= 0) { double quantity = objDetails.KitchenQuantity - objDetails.OrderQuantity; //if (objDetails.OrderQuantity == 0) //{ // quantity = 1; //} COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO(); cOrderDetailsDao.UpdateKitchenQuantity(aDetails); FinishedRawProductListDAO aDao = new FinishedRawProductListDAO(); List<CFinishedRawProductList> aList = aDao.GetFinishedRawProductListByProductID(objDetails.ProductID); foreach (CFinishedRawProductList list in aList) { string command = string.Format(SqlQueries.GetQuery(Query.UpdateRawMaterialsByRawProductID), list.RawProductID, (list.Qnty * quantity)); this.ExecuteNonQuery(command); } } } } oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in VoidPrintedItems()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return oResult; }