public decimal GetDiscount(decimal SubTotal) { BPVolumeDiscounts bp = new BPVolumeDiscounts(); DSVolumeDiscounts = bp.SelectBySubTotal(SubTotal); if (DSVolumeDiscounts.tbl_VolumeDiscounts.Count > 0) { return (SubTotal * DSVolumeDiscounts.tbl_VolumeDiscounts[0].VolumeDiscountPercentage / 100); }else { return 0; } }
private void btnSubmitDiscount_ServerClick(object sender, System.EventArgs e) { BEVolumeDiscounts discounts = new BEVolumeDiscounts(); BPVolumeDiscounts bp = new BPVolumeDiscounts(); discounts = bp.SelectAll(); FillDataRowFromTextBoxes(1,txtDiscount1MinimumPrice,txtDiscount1Percentage,discounts); FillDataRowFromTextBoxes(2,txtDiscount2MinimumPrice,txtDiscount2Percentage,discounts); FillDataRowFromTextBoxes(3,txtDiscount3MinimumPrice,txtDiscount3Percentage,discounts); FillDataRowFromTextBoxes(4,txtDiscount4MinimumPrice,txtDiscount4Percentage,discounts); FillDataRowFromTextBoxes(5,txtDiscount5MinimumPrice,txtDiscount5Percentage,discounts); bp.Update(discounts); Response.Redirect("index.aspx"); }
private void FillTextBoxesFromDataRow(int whichDiscount, TextBox minimum, TextBox percentage, BEVolumeDiscounts ds) { BEVolumeDiscounts.tbl_VolumeDiscountsRow dr; if (ds.tbl_VolumeDiscounts.Rows.Count > whichDiscount - 1) { dr = ds.tbl_VolumeDiscounts[whichDiscount - 1]; minimum.Text = dr.VolumeDiscountMinimumPrice.ToString("#,##0.00"); percentage.Text = dr.VolumeDiscountPercentage.ToString("##0.00"); } }
private void FillDataRowFromTextBoxes(int whichDiscount, TextBox minimum, TextBox percentage, BEVolumeDiscounts ds) { bool isNew = false; BEVolumeDiscounts.tbl_VolumeDiscountsRow dr; if (ds.tbl_VolumeDiscounts.Rows.Count > whichDiscount - 1) { dr = ds.tbl_VolumeDiscounts[whichDiscount -1]; isNew = false; } else { dr = ds.tbl_VolumeDiscounts.Newtbl_VolumeDiscountsRow(); dr.DateCreated = DateTime.Now; isNew = true; } if (minimum.Text == "") { dr.VolumeDiscountMinimumPrice = 0; } else { dr.VolumeDiscountMinimumPrice = Convert.ToDecimal(minimum.Text); } if (percentage.Text == "") { dr.VolumeDiscountPercentage = 0; } else { dr.VolumeDiscountPercentage = Convert.ToDecimal(percentage.Text); } dr.DateModified = DateTime.Now; dr.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID); if (isNew == true) { ds.tbl_VolumeDiscounts.Addtbl_VolumeDiscountsRow(dr); } }
private void FillVolumeDiscounts() { BEVolumeDiscounts discounts = new BEVolumeDiscounts(); BPVolumeDiscounts bp = new BPVolumeDiscounts(); discounts = bp.SelectAll(); FillTextBoxesFromDataRow(1,txtDiscount1MinimumPrice,txtDiscount1Percentage,discounts); FillTextBoxesFromDataRow(2,txtDiscount2MinimumPrice,txtDiscount2Percentage,discounts); FillTextBoxesFromDataRow(3,txtDiscount3MinimumPrice,txtDiscount3Percentage,discounts); FillTextBoxesFromDataRow(4,txtDiscount4MinimumPrice,txtDiscount4Percentage,discounts); FillTextBoxesFromDataRow(5,txtDiscount5MinimumPrice,txtDiscount5Percentage,discounts); }