private void servicechargebutton_Click(object sender, EventArgs e) { Double MainFoodTotal = PartyReservation.MainGuestAmount+PartyReservation.OtherGuestAmount+PartyReservation.UtilityCostAmount; ChargeAmountForm tempChargeForm = new ChargeAmountForm(); tempChargeForm.ShowDialog(); if (ChargeAmountForm.m_serviceChargeType.Equals("Cancel")) return; m_chargeAmount = ChargeAmountForm.m_serviceChargeAmount; m_chargeType = ChargeAmountForm.m_serviceChargeType; Double chargeAmount = 0.000; Double servicechargeRate = 0.000; if (m_chargeType.Equals("Fixed")) { chargeAmount = m_chargeAmount; if (MainFoodTotal != 0) { servicechargeRate = m_chargeAmount * 100 / MainFoodTotal; } } else if (m_chargeType.Equals("Percent")) { chargeAmount = MainFoodTotal * m_chargeAmount / 100; servicechargeRate = m_chargeAmount; } ServiceCharge tempOrderCharge = new ServiceCharge(); tempOrderCharge= aPartyReservationDao.OrderServiceChargeGetByOrderID(reservationId); if (tempOrderCharge.OrderID==reservationId) { //update tempOrderCharge.OrderID = reservationId; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount); tempOrderCharge.ServicechargeRate = servicechargeRate; aPartyReservationDao.UpdateOrderServiceCharge(tempOrderCharge); } else { //insert tempOrderCharge.OrderID = reservationId; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount); tempOrderCharge.ServicechargeRate = servicechargeRate; aPartyReservationDao.InsertOrderServiceCharge(tempOrderCharge); } PartyReservation.ServiceCharge = chargeAmount; servicechargelabel.Text = chargeAmount.ToString("F02"); LoadTotalPayable(); }
/// <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); } }
private void discountbutton_Click(object sender, EventArgs e) { double discountRate = 0.0; Double MainFoodTotal = PartyReservation.MainGuestAmount + PartyReservation.OtherGuestAmount + PartyReservation.UtilityCostAmount; CDiscountForm tempDiscountForm = new CDiscountForm(); tempDiscountForm.ShowDialog(); if (CDiscountForm.discountType.Equals("Cancel")) return; m_dDiscountAmount = Convert.ToDecimal(CDiscountForm.discountAmount); m_sDiscountType = CDiscountForm.discountType; double discountAmount = 0; if (m_sDiscountType.Equals("Fixed")) { discountAmount = (double)m_dDiscountAmount; if (MainFoodTotal != 0) { discountRate = m_chargeAmount*100/MainFoodTotal; } } else if (m_sDiscountType.Equals("Percent")) { discountAmount =MainFoodTotal*(double) m_dDiscountAmount / 100; discountRate =(double)m_dDiscountAmount; } ServiceCharge tempOrderCharge = new ServiceCharge(); tempOrderCharge = aPartyReservationDao.OrderDiscountGetByOrderID(reservationId); if (tempOrderCharge.OrderID == reservationId) { //update tempOrderCharge.OrderID = reservationId; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(discountAmount); tempOrderCharge.ServicechargeRate = discountRate; aPartyReservationDao.UpdateOrderDiscount(tempOrderCharge); } else { //insert tempOrderCharge.OrderID = reservationId; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(discountAmount); tempOrderCharge.ServicechargeRate = discountRate; aPartyReservationDao.InsertOrderDiscount(tempOrderCharge); } PartyReservation.Discount = discountAmount; discountlabel.Text = discountAmount.ToString("F02"); LoadTotalPayable(); }
private void g_ServiceChargeButton_Click(object sender, EventArgs e) { Double MainFoodTotal = 0;//@Salim Only for Main Item with out additional service charge or discount Double tempTotal = 0.0; for (int rowIndex = 0; rowIndex < g_FoodDataGridView.Rows.Count; rowIndex++) { if (g_FoodDataGridView[3, rowIndex].Value != null && !g_FoodDataGridView[3, rowIndex].Value.ToString().Equals("")) { tempTotal += Double.Parse(g_FoodDataGridView[3, rowIndex].Value.ToString()); } } for (int rowIndex = 0; rowIndex < g_BeverageDataGridView.Rows.Count; rowIndex++) { if (g_BeverageDataGridView[3, rowIndex].Value != null && !g_BeverageDataGridView[3, rowIndex].Value.ToString().Equals("")) { tempTotal += Double.Parse(g_BeverageDataGridView[3, rowIndex].Value.ToString()); } } MainFoodTotal = tempTotal; ChargeAmountForm tempChargeForm = new ChargeAmountForm();//Change by Mithu tempChargeForm.ShowDialog(); //Change by Mithu //ServiceChargeControl objSvcCtl = new ServiceChargeControl(this);//Change by Mithu //g_ItemSelectionFlowLayoutPanel.Controls.Clear();//Change by Mithu //g_ItemSelectionFlowLayoutPanel.Controls.Add(objSvcCtl);//Change by Mithu if (ChargeAmountForm.m_serviceChargeType.Equals("Cancel"))//Change by Mithu return; m_chargeAmount = ChargeAmountForm.m_serviceChargeAmount;//Change by Mithu m_chargeType = ChargeAmountForm.m_serviceChargeType;//Change by Mithu Double chargeAmount = 0.000; Double servicechargeRate = 0.000; if (m_chargeType.Equals("Fixed"))//Change by Mithu { chargeAmount = m_chargeAmount;//Change by Mithu servicechargeRate = m_chargeAmount * 100 / MainFoodTotal;//Change by Mithu } else if (m_chargeType.Equals("Percent"))//Change by Mithu { chargeAmount = tempTotal * m_chargeAmount / 100;//Change by Mithu //chargeAmount = MainFoodTotal * 10 / 100; // Change by Mithu chargeAmount = MainFoodTotal * m_chargeAmount / 100; servicechargeRate = m_chargeAmount; }//Change by Mithu COrderManager tempOrderManager = new COrderManager(); ServiceCharge tempOrderCharge = new ServiceCharge(); CResult cResult = tempOrderManager.OrderServiceChargeGetByOrderID(orderID); if (cResult.IsSuccess && cResult.Data != null) { tempOrderCharge = (ServiceCharge)cResult.Data; //update tempOrderCharge.OrderID = orderID; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount); tempOrderCharge.ServicechargeRate = servicechargeRate; tempOrderManager.UpdateOrderServiceCharge(tempOrderCharge); } else { //insert tempOrderCharge.OrderID = orderID; tempOrderCharge.ServiceChargeAmount = Convert.ToDouble(chargeAmount); tempOrderCharge.ServicechargeRate = servicechargeRate; tempOrderManager.InsertOrderServiceCharge(tempOrderCharge); } serviceCharge = chargeAmount.ToString("F02"); //Service charge amount g_serviceCharge.Text = chargeAmount.ToString("F02"); tempTotal = (tempTotal + double.Parse(g_serviceCharge.Text) - double.Parse(g_DiscountLabel.Text)); //Field for vat // lblVat.Text = (MainFoodTotal * (vat / 100)).ToString("F02"); // g_AmountLabel.Text = (tempTotal + double.Parse(g_serviceCharge.Text) - double.Parse(g_DiscountLabel.Text)).ToString(); //Deduct the discount amount // g_AmountLabel.Text = (tempTotal * (1 + (vat / 100))).ToString("F02"); g_AmountLabel.Text = (MainFoodTotal + double.Parse(lblVat.Text) + double.Parse(g_serviceCharge.Text) - double.Parse(g_DiscountLabel.Text)).ToString("F02"); // this.ServiceChargeModification(); }
private void ServiceChargeModification() { double chargeAmount = double.Parse(g_serviceCharge.Text);//Charge amount from the label COrderManager tempOrderManager = new COrderManager(); ServiceCharge tempOrderCharge = new ServiceCharge(); CResult oResult = tempOrderManager.OrderServiceChargeGetByOrderID(orderID); if (oResult.IsSuccess && oResult.Data != null) { tempOrderCharge = (ServiceCharge)oResult.Data; //update service charge tempOrderCharge.ServiceChargeAmount = chargeAmount; tempOrderCharge.OrderID = orderID; tempOrderManager.UpdateOrderServiceCharge(tempOrderCharge); } else { //insert service charge tempOrderCharge.OrderID = orderID; tempOrderCharge.ServiceChargeAmount = chargeAmount; tempOrderManager.InsertOrderServiceCharge(tempOrderCharge); } }
/// <summary> /// Order service charge insertion developed by Baruri /// </summary> /// <param name="inOrderServiceCharge"></param> /// <returns></returns> public CResult InsertOrderServiceCharge(ServiceCharge inOrderServiceCharge) { try { m_oResult = Database.Instance.OrderInfo.InsertOrderServiceCharge(inOrderServiceCharge); m_oResult.Message = "Data Inserted Successfully"; } catch (Exception ex) { System.Console.WriteLine("Exception occuer at InsertOrderServiceCharge() : " + 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 InsertOrderServiceCharge()", LogLevel.Error, "COrderManager"); } return m_oResult; }
public CResult InsertOrderServiceCharge(ServiceCharge inOrderServiceCharge) { CResult oResult = new CResult(); try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.InsertServiceCharge), inOrderServiceCharge.OrderID, inOrderServiceCharge.ServiceChargeAmount, inOrderServiceCharge.ServicechargeRate); this.ExecuteNonQuery(sqlCommand); oResult.IsSuccess = true; } catch (Exception ex) { Logger.Write("Exception : " + ex + " in InsertOrderServiceCharge()", LogLevel.Error, "Database"); oResult.IsException = true; } finally { this.CloseConnection(); } return oResult; }
public CResult GetOrderServiceChargeByOrderID(long inOrderID) { CResult oResult = new CResult(); ServiceCharge tempServiceCharge = new ServiceCharge(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.GetServiceCharge), inOrderID); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { tempServiceCharge.ServiceChargeAmount = Convert.ToDouble("" + oReader["svc_charge"]); tempServiceCharge.ServicechargeRate = Convert.ToDouble("" + oReader["svc_chargeRate"]); oResult.IsSuccess = true; } } oResult.Data = tempServiceCharge; } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in GetOrderServiceChargeByOrderID()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at GetOrderServiceChargeByOrderID()", ex); } else { throw new Exception("Exception occure at GetOrderServiceChargeByOrderID()", ex); } } finally { this.CloseConnection(); } return oResult; }
public void UpdateOrderServiceCharge(ServiceCharge tempOrderCharge) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.UpdateReservationServiceCharge), tempOrderCharge.ServiceChargeAmount, tempOrderCharge.ServicechargeRate, tempOrderCharge.OrderID); this.ExecuteNonQuery(sqlCommand); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in UpdateOrderServiceCharge()", LogLevel.Error, "Database"); } finally { this.CloseConnection(); } }
public ServiceCharge OrderServiceChargeGetByOrderID(int reservationId) { ServiceCharge tempServiceCharge = new ServiceCharge(); try { this.OpenConnection(); string sqlCommand = String.Format(SqlQueries.GetQuery(Query.GetReservationServiceCharge), reservationId); IDataReader oReader = this.ExecuteReader(sqlCommand); if (oReader != null) { while (oReader.Read()) { try { tempServiceCharge.ServiceChargeAmount = Convert.ToDouble("" + oReader["svc_charge"]); tempServiceCharge.ServicechargeRate = Convert.ToDouble("" + oReader["svc_chargeRate"]); tempServiceCharge.OrderID = reservationId; } catch (Exception) { } } } } catch (Exception ex) { Console.Write("###" + ex.ToString() + "###"); Logger.Write("Exception : " + ex + " in GetOrderServiceChargeByOrderID()", LogLevel.Error, "Database"); if (ex.GetType().Equals(typeof(SqlException))) { SqlException oSQLEx = ex as SqlException; if (oSQLEx.Number != 7619) throw new Exception("Exception occured at GetOrderServiceChargeByreservationId()", ex); } else { throw new Exception("Exception occure at GetOrderServiceChargeByreservationId)", ex); } } finally { this.CloseConnection(); } return tempServiceCharge; }