/// <summary> /// /// </summary> /// <param name="displayModel">显示模式 1:单品折扣, 2:整单折扣</param> /// <param name="expenditure">未打折的消费金额</param> /// <param name="actualSellPrice">整单实际金额</param> public FormDiscount(DiscountDisplayModel displayModel, decimal expenditure, decimal actualSellPrice) { m_ActualSellPrice = actualSellPrice; InitializeComponent(); //显示折扣方式 //1:折扣率 2:固定折扣 IList <Discount> discountRateList = new List <Discount>(); IList <Discount> discountOffPayList = new List <Discount>(); foreach (Discount item in ConstantValuePool.DiscountList) { if (item.DisplayModel == (int)DiscountDisplayModel.ALL || item.DisplayModel == (int)displayModel) { if (expenditure == -1 || expenditure > item.MinQuotas) { if (item.DiscountType == (int)DiscountItemType.DiscountRate) { if (item.DiscountRate <= ConstantValuePool.CurrentEmployee.MinDiscount) { discountRateList.Add(item); } } if (item.DiscountType == (int)DiscountItemType.OffFixPay) { if (item.OffFixPay / item.MinQuotas <= ConstantValuePool.CurrentEmployee.MinDiscount) { discountOffPayList.Add(item); } } } } } //显示折扣率 int count = discountRateList.Count; int maxColumn = (int)Math.Ceiling(Convert.ToDecimal(count) / 5); int maxRow = (int)Math.Ceiling(Convert.ToDecimal(count) / maxColumn); int space = 8; int width = (this.tabPage1.Width - (maxColumn - 1) * space) / maxColumn; int height = (this.tabPage1.Height - (maxRow - 1) * space) / maxRow; int px = 0, py = 0, index = 1; foreach (Discount item in discountRateList) { CrystalButton btn = new CrystalButton(); btn.Name = item.DiscountID.ToString(); btn.Text = item.DiscountName; btn.BackColor = Color.Teal; btn.Font = new Font("微软雅黑", 12F, FontStyle.Regular); btn.ForeColor = Color.White; btn.Width = width; btn.Height = height; btn.Location = new Point(px, py); btn.Tag = item; btn.Click += new System.EventHandler(this.btnDiscount_Click); this.tabPage1.Controls.Add(btn); index++; if (index > maxColumn) { px = 0; py += height + space; index = 1; } else { px += width + space; } } //显示固定折扣 if (discountOffPayList.Count > 0) { count = discountOffPayList.Count; maxColumn = (int)Math.Ceiling(Convert.ToDecimal(count) / 5); maxRow = (int)Math.Ceiling(Convert.ToDecimal(count) / maxColumn); width = (this.tabPage2.Width - (maxColumn - 1) * space) / maxColumn; height = (this.tabPage2.Height - (maxRow - 1) * space) / maxRow; px = 0; py = 0; index = 1; foreach (Discount item in discountOffPayList) { CrystalButton btn = new CrystalButton(); btn.Name = item.DiscountID.ToString(); btn.Text = item.DiscountName; btn.BackColor = Color.Teal; btn.Font = new Font("Microsoft YaHei", 12F, FontStyle.Regular); btn.ForeColor = Color.White; btn.Width = width; btn.Height = height; btn.Location = new Point(px, py); btn.Tag = item; btn.Click += new System.EventHandler(this.btnDiscount_Click); this.tabPage2.Controls.Add(btn); index++; if (index > maxColumn) { px = 0; py += height + space; index = 1; } else { px += width + space; } } } }
/// <summary> /// /// </summary> /// <param name="displayModel">显示模式 1:单品折扣, 2:整单折扣</param> /// <param name="expenditure">未打折的消费金额</param> /// <param name="actualSellPrice">整单实际金额</param> public FormDiscount(DiscountDisplayModel displayModel, decimal expenditure, decimal actualSellPrice) { m_ActualSellPrice = actualSellPrice; InitializeComponent(); //显示折扣方式 //1:折扣率 2:固定折扣 IList<Discount> discountRateList = new List<Discount>(); IList<Discount> discountOffPayList = new List<Discount>(); foreach (Discount item in ConstantValuePool.DiscountList) { if (item.DisplayModel == (int)DiscountDisplayModel.ALL || item.DisplayModel == (int)displayModel) { if (expenditure == -1 || expenditure > item.MinQuotas) { if (item.DiscountType == (int)DiscountItemType.DiscountRate) { if (item.DiscountRate <= ConstantValuePool.CurrentEmployee.MinDiscount) { discountRateList.Add(item); } } if (item.DiscountType == (int)DiscountItemType.OffFixPay) { if (item.OffFixPay / item.MinQuotas <= ConstantValuePool.CurrentEmployee.MinDiscount) { discountOffPayList.Add(item); } } } } } //显示折扣率 int count = discountRateList.Count; int maxColumn = (int)Math.Ceiling(Convert.ToDecimal(count) / 5); int maxRow = (int)Math.Ceiling(Convert.ToDecimal(count) / maxColumn); int space = 8; int width = (this.tabPage1.Width - (maxColumn - 1) * space) / maxColumn; int height = (this.tabPage1.Height - (maxRow - 1) * space) / maxRow; int px = 0, py = 0, index = 1; foreach (Discount item in discountRateList) { CrystalButton btn = new CrystalButton(); btn.Name = item.DiscountID.ToString(); btn.Text = item.DiscountName; btn.BackColor = Color.Teal; btn.Font = new Font("微软雅黑", 12F, FontStyle.Regular); btn.ForeColor = Color.White; btn.Width = width; btn.Height = height; btn.Location = new Point(px, py); btn.Tag = item; btn.Click += new System.EventHandler(this.btnDiscount_Click); this.tabPage1.Controls.Add(btn); index++; if (index > maxColumn) { px = 0; py += height + space; index = 1; } else { px += width + space; } } //显示固定折扣 if (discountOffPayList.Count > 0) { count = discountOffPayList.Count; maxColumn = (int)Math.Ceiling(Convert.ToDecimal(count) / 5); maxRow = (int)Math.Ceiling(Convert.ToDecimal(count) / maxColumn); width = (this.tabPage2.Width - (maxColumn - 1) * space) / maxColumn; height = (this.tabPage2.Height - (maxRow - 1) * space) / maxRow; px = 0; py = 0; index = 1; foreach (Discount item in discountOffPayList) { CrystalButton btn = new CrystalButton(); btn.Name = item.DiscountID.ToString(); btn.Text = item.DiscountName; btn.BackColor = Color.Teal; btn.Font = new Font("Microsoft YaHei", 12F, FontStyle.Regular); btn.ForeColor = Color.White; btn.Width = width; btn.Height = height; btn.Location = new Point(px, py); btn.Tag = item; btn.Click += new System.EventHandler(this.btnDiscount_Click); this.tabPage2.Controls.Add(btn); index++; if (index > maxColumn) { px = 0; py += height + space; index = 1; } else { px += width + space; } } } }