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; } } }
public frmVoucher(float ticketprice, Flamingo.BLL.Type.PayType.Paytype vouchertype) { InitializeComponent(); _TicketPrice = ticketprice; _voucherType = vouchertype; }
private void OutTicket(bool isOnlyOutSelected) { if (dgvTicketList.Rows.Count > 0) { StringBuilder sb_rids = new StringBuilder(); StringBuilder sb_ticketid = new StringBuilder(); StringBuilder sb_seatids = new StringBuilder(); int paymentmethoedid = 1; float totalprice = 0; StringBuilder sb_tickettype = new StringBuilder(); StringBuilder sb_ticketprice = new StringBuilder(); StringBuilder sb_barcode = new StringBuilder(); string userid = FrmMain.curUser.UserId.ToString(); int templateid = FrmMain.template == null ? 1 : FrmMain.template.TemplateId; StringBuilder sb_showplanids = new StringBuilder(); StringBuilder sb_filmids = new StringBuilder(); StringBuilder sb_seatstatusids = new StringBuilder(); int count = 0; //获得选中支付方式 string ptStr; if (dgvTicketList.SelectedRows.Count == 0) { ptStr = dgvTicketList.Rows[0].Cells["支付方式"].Value.ToString(); } else { ptStr = dgvTicketList.SelectedRows[0].Cells["支付方式"].Value.ToString(); } Flamingo.BLL.Type.PayType.Paytype paytype = Flamingo.BLL.Type.PayType.ToPayType(ptStr); paymentmethoedid = Flamingo.BLL.Type.PayType.ToPayType(paytype); StringBuilder sb_paytypes = new StringBuilder(); //打印信息Flamingo.TemplateCore.TemplatePrintModel List <Flamingo.TemplateCore.TemplatePrintModel> PrintModels = new List <Flamingo.TemplateCore.TemplatePrintModel>(); Flamingo.TemplateCore.TemplatePrintModel PrintModel; #region 连场 if (_isShowGroup == true) { Hashtable ht; string[] spids = ShowGroupShowPlanIds.Split(','); string[] fids = ShowGroupFilmIds.Split(','); foreach (DataGridViewRow row in dgvTicketList.Rows) { if (isOnlyOutSelected == true) { if (row.Selected == false && row.Cells["支付方式"].Value.ToString() != "支票") { continue; } } if (float.Parse(row.Cells["价格"].Value.ToString()) <= 0) { continue; } #region 打印信息 PrintModel = new Flamingo.TemplateCore.TemplatePrintModel(); //影票ID PrintModel.TicketId = Guid.NewGuid().ToString(); //售票类型 PrintModel.TicketType = row.Cells["票种"].Value.ToString(); //票价 PrintModel.TicketPrice = float.Parse(row.Cells["价格"].Value.ToString()).ToString("0.00"); //条形码 PrintModel.BarCodeStr = row.Cells["SeatStatusId"].Value.ToString(); PrintModel.SeatNumberStr = row.Cells["座位"].Value.ToString(); string rc = PrintModel.SeatNumberStr.Replace("行", ",").Replace("排", ",").Replace("座", ",").Replace("号", ",").Replace("列", ","); PrintModel.RowNumber = rc.Split(',')[0]; PrintModel.SeatNumber = rc.Split(',')[1]; PrintModel.PayType = row.Cells["支付方式"].Value.ToString(); //票版其他信息 if (IsShowGroup == true) { PrintModel.FilmName = ShowGroupShowPlanNames.Replace(',', '+'); } else { PrintModel.FilmName = ShowPlanName; } PrintModel.CheckingType = _CheckingType; PrintModel.HallFieldCode = _HallId; PrintModel.HallName = ShowPlanHall; PrintModel.SellTime = DateTime.Now.ToString("yyyyMMddHHmm");; PrintModel.StaffNumber = FrmMain.curUser.EmployeeId; PrintModel.TheaterName = _TheaterName; PrintModel.TicketDate = ShowPlanDate; PrintModel.TicketTime = ShowPlanStartTime; PrintModel.Position = ShowPlanPosition; PrintModels.Add(PrintModel); #endregion #region 票信息 sb_rids.Append(row.Cells["ReservationId"].Value.ToString()); sb_rids.Append("|"); for (int i = 0; i < spids.Length; i++) { sb_showplanids.Append(spids[i]); sb_showplanids.Append("|"); sb_filmids.Append(fids[i]); sb_filmids.Append("|"); sb_seatstatusids.Append(row.Cells["SeatStatusId"].Value.ToString()); sb_seatstatusids.Append("|"); sb_ticketid.Append(Guid.NewGuid().ToString()); sb_ticketid.Append("|"); sb_seatids.Append(row.Cells["SeatStatusId"].Value.ToString().Substring(12)); sb_seatids.Append("|"); float tp = Flamingo.BLL.Ticket.GetPriceTotal(spids[i], row.Cells["SeatStatusId"].Value.ToString().Substring(12), row.Cells["票种"].Value.ToString(), out ht, true, ShowGroupShowPlanIds); if (float.Parse(row.Cells["价格"].Value.ToString()) == tp) { sb_ticketprice.Append(ht[spids[i] + row.Cells["SeatStatusId"].Value.ToString().Substring(12)].ToString()); } else { sb_ticketprice.Append(float.Parse(row.Cells["价格"].Value.ToString()) / spids.Length); } sb_ticketprice.Append("|"); sb_tickettype.Append(row.Cells["TicketType"].Value.ToString()); sb_tickettype.Append("|"); sb_paytypes.Append(Flamingo.BLL.Type.PayType.ToPayType(Flamingo.BLL.Type.PayType.ToPayType(row.Cells["支付方式"].Value.ToString()))); sb_paytypes.Append("|"); count++; } #endregion } if (sb_seatids.Length > 0) { sb_rids.Remove(sb_rids.Length - 1, 1); sb_seatstatusids.Remove(sb_seatstatusids.Length - 1, 1); sb_showplanids.Remove(sb_showplanids.Length - 1, 1); sb_filmids.Remove(sb_filmids.Length - 1, 1); sb_ticketid.Remove(sb_ticketid.Length - 1, 1); sb_seatids.Remove(sb_seatids.Length - 1, 1); sb_tickettype.Remove(sb_tickettype.Length - 1, 1); sb_ticketprice.Remove(sb_ticketprice.Length - 1, 1); sb_paytypes.Remove(sb_paytypes.Length - 1, 1); } } #endregion 连场 #region 非连场 else { foreach (DataGridViewRow row in dgvTicketList.Rows) { if (isOnlyOutSelected == true) { if (row.Selected == false && row.Cells["支付方式"].Value.ToString() != "支票") { continue; } } #region 打印信息 PrintModel = new Flamingo.TemplateCore.TemplatePrintModel(); //影票ID PrintModel.TicketId = Guid.NewGuid().ToString(); //售票类型 PrintModel.TicketType = row.Cells["票种"].Value.ToString(); //票价 PrintModel.TicketPrice = float.Parse(row.Cells["价格"].Value.ToString()).ToString("0.00"); //条形码 PrintModel.BarCodeStr = row.Cells["SeatStatusId"].Value.ToString(); PrintModel.SeatNumberStr = row.Cells["座位"].Value.ToString(); string rc = PrintModel.SeatNumberStr.Replace("行", ",").Replace("排", ",").Replace("座", ",").Replace("号", ",").Replace("列", ","); PrintModel.RowNumber = rc.Split(',')[0]; PrintModel.SeatNumber = rc.Split(',')[1]; //票版其他信息 PrintModel.FilmName = ShowPlanName; PrintModel.CheckingType = _CheckingType; PrintModel.HallFieldCode = _HallId; PrintModel.HallName = ShowPlanHall; PrintModel.SellTime = DateTime.Now.ToString("yyyyMMddHHmm");; PrintModel.StaffNumber = FrmMain.curUser.EmployeeId; PrintModel.TheaterName = _TheaterName; PrintModel.TicketDate = ShowPlanDate; PrintModel.TicketTime = ShowPlanStartTime; PrintModel.Position = ShowPlanPosition; PrintModels.Add(PrintModel); #endregion #region 票信息 sb_rids.Append(row.Cells["ReservationId"].Value.ToString()); sb_rids.Append("|"); sb_ticketid.Append(PrintModel.TicketId); sb_ticketid.Append("|"); sb_seatids.Append(row.Cells["SeatStatusId"].Value.ToString().Substring(12)); sb_seatids.Append("|"); totalprice += float.Parse(row.Cells["价格"].Value.ToString()); sb_tickettype.Append(row.Cells["TicketType"].Value.ToString()); sb_tickettype.Append("|"); sb_ticketprice.Append(row.Cells["价格"].Value.ToString()); sb_ticketprice.Append("|"); sb_barcode.Append(row.Cells["SeatStatusId"].Value.ToString()); sb_barcode.Append("|"); PrintModel.PayType = row.Cells["支付方式"].Value.ToString(); sb_paytypes.Append(row.Cells["支付方式"].Value.ToString()); #endregion } sb_rids.Remove(sb_rids.Length - 1, 1); sb_ticketid.Remove(sb_ticketid.Length - 1, 1); sb_seatids.Remove(sb_seatids.Length - 1, 1); sb_tickettype.Remove(sb_tickettype.Length - 1, 1); sb_ticketprice.Remove(sb_ticketprice.Length - 1, 1); sb_barcode.Remove(sb_barcode.Length - 1, 1); } #endregion if (sb_paytypes.ToString().IndexOf("支票") >= 0 && chkZP.Checked == false) { MessageBox.Show("预定出票包含支票支付\r\n请先填写支票信息"); return; } bool tf = false; if (_isShowGroup == true) { tf = Flamingo.BLL.Ticket.ReservationOutTicketGroup(sb_ticketid.ToString(), sb_ticketprice.ToString(), FrmMain.curUser.UserId, sb_seatstatusids.ToString(), sb_tickettype.ToString(), sb_paytypes.ToString(), templateid, sb_showplanids.ToString(), sb_filmids.ToString(), count, sb_rids.ToString()); } else { tf = Flamingo.BLL.Ticket.ReservationOutTicket(sb_rids.ToString(), sb_ticketid.ToString(), _model.ShowPlanId, sb_seatids.ToString(), paymentmethoedid, totalprice, sb_tickettype.ToString(), sb_ticketprice.ToString(), sb_barcode.ToString(), userid, templateid, _FilmId); } if (tf == true) { if (paytype == Flamingo.BLL.Type.PayType.Paytype.支票) { _DebtId = "-1"; } if (isOnlyOutSelected == true) { SeatMaDll.SeatStatusSim sss; List <DataGridViewRow> removerowslist = new List <DataGridViewRow>(); foreach (DataGridViewRow row in dgvTicketList.Rows) { if (isOnlyOutSelected == true) { if (row.Selected == false && row.Cells["支付方式"].Value.ToString() != "支票") { continue; } } sss = new SeatMaDll.SeatStatusSim(); sss._seatId = row.Cells["SeatStatusId"].Value.ToString().Substring(12); sss._seatStatusFlag = "4"; _SeatStatusSimList_Sold.Add(sss); removerowslist.Add(row); } int i = 0; StringBuilder sb_failedticketids = new StringBuilder(); foreach (DataGridViewRow row in removerowslist) { try { WinFormUI.SaleTicket.Print.PrintTicket(PrintModels[i]); } catch { sb_failedticketids.Append(PrintModels[i].TicketId); sb_failedticketids.Append(","); } finally { this.Activate(); } i++; dgvTicketList.Rows.Remove(row); } if (sb_failedticketids.Length > 0) { sb_failedticketids.Remove(sb_failedticketids.Length - 1, 1); Flamingo.BLL.Ticket.SetPrintStatus(sb_failedticketids, 0); } lblCount.Text = dgvTicketList.Rows.Count.ToString(); } else { int i = 0; SeatMaDll.SeatStatusSim sss; StringBuilder sb_failedticketids = new StringBuilder(); foreach (DataGridViewRow row in dgvTicketList.Rows) { sss = new SeatMaDll.SeatStatusSim(); sss._seatId = row.Cells["SeatStatusId"].Value.ToString().Substring(12); sss._seatStatusFlag = "4"; _SeatStatusSimList_Sold.Add(sss); try { WinFormUI.SaleTicket.Print.PrintTicket(PrintModels[i]); } catch { sb_failedticketids.Append(PrintModels[i].TicketId); sb_failedticketids.Append(","); } finally { this.Activate(); } } if (sb_failedticketids.Length > 0) { sb_failedticketids.Remove(sb_failedticketids.Length - 1, 1); Flamingo.BLL.Ticket.SetPrintStatus(sb_failedticketids, 0); } dgvTicketList.DataSource = null; lblCount.Text = "0"; } } else { _SeatStatusSimList_Cancel = null; MessageBox.Show("预定出票失败"); } } }