private void dgvTicketList_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 6) { string paytype = dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); string tickettype = dgvTicketList.Rows[e.RowIndex].Cells[3].Value.ToString(); Permission p = (Permission)Flamingo.BLL.Type.PayType.ListPermissions[Flamingo.BLL.Type.PayType.ToPayType(paytype)]; if (!FrmMain.curUser.HavePermission(p)) { MessageBox.Show("您没有" + paytype + "权限", "提示"); return; } if (paytype == "会员卡" || paytype == "优惠券" || paytype == "兑换券" || paytype == "代用券" || paytype == "积分" || paytype == "赠票") { if (tickettype != "零售") { MessageBox.Show(string.Format("{0}票不能使用{1}支付", tickettype, paytype)); dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "现金"; } else { if (paytype == "优惠券" || paytype == "兑换券" || paytype == "代用券") { #region 优惠券 float price = float.Parse(dgvTicketList.Rows[e.RowIndex].Cells["价格"].Value.ToString()); frmVoucher frm = new frmVoucher(price, Flamingo.BLL.Type.PayType.ToPayType(paytype)); if (frm.ShowDialog() == DialogResult.Yes) { Flamingo.Entity.Para_VoucherAdd model = new Flamingo.Entity.Para_VoucherAdd(frm.Voucherlist); model.BarCode = dgvTicketList.Rows[e.RowIndex].Cells["SeatStatusId"].Value.ToString(); model.FilmId = _FilmId; model.PaymentMethodId = Flamingo.BLL.Type.PayType.ToPayType(frm.VoucherType); model.SeatId = dgvTicketList.Rows[e.RowIndex].Cells["SeatStatusId"].Value.ToString().Substring(12); model.ShowPlanId = _model.ShowPlanId; model.SoldBy = FrmMain.curUser.UserId; model.TemplateId = FrmMain.template == null ? 1 : FrmMain.template.TemplateId; model.TicketPrice = price;//frm.OutTicketPrice; model.TicketType = Flamingo.BLL.Ticket.ToTicketType(Flamingo.BLL.Ticket.TicketType.团体); model.TicketId = Guid.NewGuid().ToString(); model.VoucherTypeId = Flamingo.BLL.Type.PayType.ToPayType(frm.VoucherType); bool tf = false; if (_isShowGroup == true) { StringBuilder sb_showplanids = new StringBuilder(); StringBuilder sb_filmids = new StringBuilder(); StringBuilder sb_seatstatusids = new StringBuilder(); StringBuilder sb_ticketid = new StringBuilder(); StringBuilder sb_seatids = new StringBuilder(); StringBuilder sb_tickettype = new StringBuilder(); StringBuilder sb_ticketprice = new StringBuilder(); StringBuilder sb_barcode = new StringBuilder(); string[] spids = ShowGroupShowPlanIds.Split(','); string[] fids = ShowGroupFilmIds.Split(','); int count = spids.Length; Hashtable ht = null; int templateid = FrmMain.template == null ? 1 : FrmMain.template.TemplateId; 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(spids[i] + model.SeatId); sb_seatstatusids.Append("|"); //票ID sb_ticketid.Append(Guid.NewGuid().ToString()); sb_ticketid.Append("|"); //座位ID sb_seatids.Append(model.SeatId); sb_seatids.Append("|"); //售票类型 sb_tickettype.Append("6"); sb_tickettype.Append("|"); //票价 Flamingo.BLL.Ticket.GetPriceTotal(spids[i], dgvTicketList.Rows[e.RowIndex].Cells["SeatStatusId"].Value.ToString().Substring(12), dgvTicketList.Rows[e.RowIndex].Cells["票种"].Value.ToString(), out ht, true, ShowGroupShowPlanIds); sb_ticketprice.Append(ht[spids[i] + model.SeatId].ToString()); sb_ticketprice.Append("|"); } if (sb_seatids.Length > 0) { 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); } if (paytype == "代用券") { tf = Flamingo.BLL.Ticket.VoucherSubstituteSaleGroup(model.VoucherBatchIds, sb_ticketid.ToString(), sb_ticketprice.ToString(), FrmMain.curUser.UserId, sb_seatstatusids.ToString(), sb_tickettype.ToString(), 5, templateid, sb_showplanids.ToString(), sb_filmids.ToString(), count); } else { int pid = 4; if (paytype == "优惠券") { pid = 6; } tf = Flamingo.BLL.Ticket.VoucherSaleGroup(model.VoucherIds, model.Prices, model.BarCodes, model.VoucherTypeId, model.VoucherBatchIds, sb_ticketid.ToString(), sb_ticketprice.ToString(), FrmMain.curUser.UserId, sb_seatstatusids.ToString(), sb_tickettype.ToString(), pid, templateid, sb_showplanids.ToString(), sb_filmids.ToString(), count); } } else { if (paytype == "代用券") { tf = Flamingo.BLL.Ticket.VoucherSubstituteSale(model); } else { tf = Flamingo.BLL.Ticket.VoucherSale(model); } } if (tf == true) { Flamingo.BLL.Ticket.ReservationDel(dgvTicketList.Rows[e.RowIndex].Cells["ReservationId"].Value.ToString()); SeatMaDll.SeatStatusSim sss = new SeatMaDll.SeatStatusSim(); sss._seatId = model.SeatId; sss._seatStatusFlag = "4"; _SeatStatusSimList_SoldByVoucher.Add(sss); Flamingo.TemplateCore.TemplatePrintModel PrintModel = new Flamingo.TemplateCore.TemplatePrintModel(); PrintModel.BarCodeStr = model.BarCode; PrintModel.CheckingType = _CheckingType; PrintModel.FilmName = ShowPlanName; PrintModel.HallFieldCode = _HallId; PrintModel.HallName = ShowPlanHall; PrintModel.PayType = paytype; PrintModel.SeatNumberStr = dgvTicketList.Rows[e.RowIndex].Cells["座位"].Value.ToString(); string rc = PrintModel.SeatNumberStr.Replace("行", ",").Replace("排", ",").Replace("座", ",").Replace("号", ",").Replace("列", ","); PrintModel.RowNumber = rc.Split(',')[0]; PrintModel.SeatNumber = rc.Split(',')[1]; PrintModel.SellTime = DateTime.Now.ToString("yyyyMMddHHmm"); PrintModel.StaffNumber = FrmMain.curUser.EmployeeId; PrintModel.TheaterName = _TheaterName; PrintModel.TicketDate = ShowPlanDate; PrintModel.TicketId = model.TicketId; PrintModel.TicketPrice = model.TicketPrice.ToString("0.00"); PrintModel.TicketTime = ShowPlanStartTime; PrintModel.TicketType = dgvTicketList.Rows[e.RowIndex].Cells["票种"].Value.ToString(); PrintModel.Position = ShowPlanPosition; if (IsShowGroup == true) { PrintModel.FilmName = ShowGroupShowPlanNames.Replace(',', '+'); } else { PrintModel.FilmName = ShowPlanName; } dgvTicketList.Rows.RemoveAt(e.RowIndex); try { WinFormUI.SaleTicket.Print.PrintTicket(PrintModel); } catch { Flamingo.BLL.Ticket.SetPrintStatus(PrintModel.TicketId, 0); } } else { MessageBox.Show("票券出票失败"); } } #endregion } else { MessageBox.Show(string.Format("暂不支持会员功能")); dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "现金"; } } } else if (paytype == "支票") { if (tickettype != "团体") { MessageBox.Show(string.Format("{0}票不能使用{1}支付", tickettype, paytype)); dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "现金"; } else if (chkZP.Checked == true) { MessageBox.Show(string.Format("支票已填写完毕\r\n如需将该票添加到支票\r\n请重置支票并重新填写支票信息", tickettype, paytype)); dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "现金"; } } else if (paytype == "会员卡支付卡") { if (tickettype != "零售" || tickettype != "学生") { MessageBox.Show(string.Format("{0}票不能使用{1}支付", tickettype, paytype)); dgvTicketList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "现金"; } } _HasGroupDebt = SetHasGroupDept(); btnAddZP.Enabled = _HasGroupDebt; } }
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("预定出票失败"); } } }