/// <summary> /// 获得代用券信息 /// </summary> /// <param name="voucherbatchid"></param> /// <returns></returns> public static Flamingo.Entity.Para_Voucher ValidateVoucherSubstitute(string voucherbatchid) { Flamingo.Entity.Para_Voucher model = DAL.Voucher.GetVoucherSubstitute(voucherbatchid); if (model.AllowUse != false) { if (model.BeginDate > DateTime.Now) { model.AllowUse = false; model.ErrorMsg = "代用券未到启用时间"; } else if (model.EndDate < DateTime.Now) { model.AllowUse = false; model.ErrorMsg = "代用券已过期"; } else { //Int64 count = model.SerialScopeEnd - model.SerialScopeBegin; //model.Count = (Int32)count; //if (count > 0) //{ model.AllowUse = true; model.ErrorMsg = "有效"; //} //else //{ // model.AllowUse = false; // model.ErrorMsg = "兑换券已用完"; //} } } return(model); }
/// <summary> /// 获得票券信息(优惠券/兑换券) /// </summary> /// <param name="voucherid"></param> /// <returns></returns> public static Flamingo.Entity.Para_Voucher Validate(string voucherid) { Flamingo.Entity.Para_Voucher model = DAL.Voucher.GetVoucher(voucherid); if (model.AllowUse != false) { Int64 voucherid_int = Int64.Parse(voucherid); if (voucherid_int < model.SerialScopeBegin || voucherid_int > model.SerialScopeEnd) { model.AllowUse = false; model.ErrorMsg = "无效票券"; } else if (model.BeginDate > DateTime.Now) { model.AllowUse = false; model.ErrorMsg = "票券未到启用时间"; } else if (model.EndDate < DateTime.Now) { model.AllowUse = false; model.ErrorMsg = "票券已过期"; } else { model.AllowUse = true; model.ErrorMsg = "有效"; } } return(model); }
private void btnDYQuery_Click(object sender, EventArgs e) { if (combVoucherName.SelectedIndex > -1) { Flamingo.Entity.Para_Voucher model = Flamingo.BLL.Voucher.ValidateVoucherSubstitute(combVoucherName.SelectedValue.ToString()); string msg = string.Format("票券批号:{0}\r\n有效期:{1}\r\n券类:{2} {3}\r\n购券单位:{4}\r\n状态:{5}\r\n", model.VoucherBatchId, model.BeginDate.ToString("yyyy.MM.dd") + "-" + model.EndDate.ToString("yyyy.MM.dd"), model.VoucherType , model.VoucherSubType, model.VoucherName, model.ErrorMsg); MessageBox.Show(msg, "票券查询", MessageBoxButtons.OK); } }
private void btnQuery_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVoucherId.Text.Trim())) { MessageBox.Show("请输入票券编号"); } else if (txtVoucherId.Text.Trim().Length < 16) { MessageBox.Show("票券应该是16位编码"); } else if (!Flamingo.Common.StringHelper.IsInt64(txtVoucherId.Text.Trim())) { MessageBox.Show("请输入有效票券编号"); } else { bool hasTheVoucher = false; foreach (Flamingo.Entity.Para_Voucher m in list) { if (m.VoucherId == txtVoucherId.Text.Trim()) { hasTheVoucher = true; break; } } Flamingo.Entity.Para_Voucher model = Flamingo.BLL.Voucher.Validate(txtVoucherId.Text.Trim()); if (hasTheVoucher == true) { model.ErrorMsg = "正在使用"; } string msg = string.Format("票券批号:{0}\r\n票券号码:{1}\r\n有效期:{2}\r\n券类:{3} {7}\r\n票面价值:{4}元\r\n购券单位:{5}\r\n状态:{6}\r\n", model.VoucherBatchId, model.VoucherId, model.BeginDate.ToString("yyyy.MM.dd") + "-" + model.EndDate.ToString("yyyy.MM.dd"), model.VoucherType , model.VoucherPrice.ToString(), model.VoucherName, model.ErrorMsg, model.VoucherSubType); MessageBox.Show(msg, "票券查询", MessageBoxButtons.OK); } }
private void btnDYAdd_Click(object sender, EventArgs e) { if (combVoucherName.Items.Count == 0) { return; } string key = combVoucherName.Text; Flamingo.Entity.Para_Voucher model = Flamingo.BLL.Voucher.ValidateVoucherSubstitute(combVoucherName.SelectedValue.ToString()); if (model.AllowUse == true) { if (htVoucherModels.Count == 3) { MessageBox.Show("最多只能添加3张代用券"); return; } if (htVoucherModels[key] == null) { List <Flamingo.Entity.Para_Voucher> listDY = new List <Flamingo.Entity.Para_Voucher>(); list.Add(model); listDY.Add(model); htVoucherModels.Add(key, listDY); if (htVoucherModels.Count == 1) { lblDY1.Text = model.VoucherName + " 1 张"; htLables.Add(key, lblDY1); } else if (htVoucherModels.Count == 2) { lblDY2.Text = model.VoucherName + " 1 张"; htLables.Add(key, lblDY2); } else if (htVoucherModels.Count == 3) { lblDY3.Text = model.VoucherName + " 1 张"; htLables.Add(key, lblDY3); } } else { List <Flamingo.Entity.Para_Voucher> listDY = ((List <Flamingo.Entity.Para_Voucher>)htVoucherModels[key]); list.Add(model); listDY.Add(model); } //显示数量 int count = 0; int total = 0; Label l; foreach (object k in htVoucherModels.Keys) { count = ((List <Flamingo.Entity.Para_Voucher>)htVoucherModels[k]).Count; total += count; l = ((Label)htLables[k]); if (l == null) { break; } l.Text = k.ToString() + " " + count.ToString() + "张"; } lblDYTotal.Text = total.ToString(); } lblDYStatus.Text = model.ErrorMsg; }
private void btnValidate_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtVoucherId.Text.Trim())) { MessageBox.Show("请输入票券编号"); } else if (txtVoucherId.Text.Trim().Length < 16) { MessageBox.Show("票券应该是16位编码"); } else if (!Flamingo.Common.StringHelper.IsInt64(txtVoucherId.Text.Trim())) { MessageBox.Show("请输入有效票券编号"); } else { bool hasTheVoucher = false; foreach (Flamingo.Entity.Para_Voucher m in list) { if (m.VoucherId == txtVoucherId.Text.Trim()) { hasTheVoucher = true; break; } } foreach (Flamingo.Entity.Para_Voucher m in allVoucher) { if (m.VoucherId == txtVoucherId.Text.Trim()) { hasTheVoucher = true; break; } } if (hasTheVoucher == true) { MessageBox.Show("该票券正在使用"); } else if (panelMore.Visible == false && list.Count > 0) { MessageBox.Show("您使用的是单换模式"); } else if (list.Count == 3) { MessageBox.Show("多换模式最多使用三张票券"); } else { Flamingo.Entity.Para_Voucher model = Flamingo.BLL.Voucher.Validate(txtVoucherId.Text.Trim()); if (model.AllowUse == true) { list.Add(model); allVoucher.Add(model); if (list.Count == 1) { lblVoucher1.Text = model.VoucherPrice.ToString(); float total1 = model.VoucherPrice + float.Parse(txtCash1.Text.Trim()); txtResult1.Text = total1.ToString(); } else if (list.Count == 2) { lblVoucher2.Text = model.VoucherPrice.ToString(); float total2 = model.VoucherPrice + float.Parse(txtCash2.Text.Trim()); txtResult2.Text = total2.ToString(); txtCash2.Text = txtCash1.Text; txtCash2.Enabled = true; txtCash1.Text = "0"; txtCash1.Enabled = false; } else if (list.Count == 3) { lblVoucher3.Text = model.VoucherPrice.ToString(); float total3 = model.VoucherPrice + float.Parse(txtCash3.Text.Trim()); txtResult3.Text = total3.ToString(); txtCash3.Text = txtCash1.Text; txtCash3.Enabled = true; txtCash2.Text = "0"; txtCash2.Enabled = false; } lblTotal.Text = (float.Parse(txtResult1.Text) + float.Parse(txtResult2.Text.Trim()) + float.Parse(txtResult3.Text.Trim())).ToString(); if (model.VoucherTypeId == 1) { _voucherType = Flamingo.BLL.Type.PayType.Paytype.兑换券; } if (model.VoucherTypeId == 2) { _voucherType = Flamingo.BLL.Type.PayType.Paytype.代用券; } if (model.VoucherTypeId == 3) { _voucherType = Flamingo.BLL.Type.PayType.Paytype.优惠券; } lblVoucherType.Text = model.VoucherType + " " + model.VoucherSubType; } else { MessageBox.Show(model.ErrorMsg); } lblValidate.Text = model.ErrorMsg; } } }