Ejemplo n.º 1
0
    protected void rptAsignList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "save")
        {
            Guid qzTaId = Guid.Parse((e.Item.FindControl("hfTaId") as HiddenField).Value);
            QZTicketAsign qzTa = bllqz.GetOne(qzTaId);
            Repeater rptPartnerList = e.Item.FindControl("rptPartnerList") as Repeater;
            int Amount = 0;
            foreach (RepeaterItem item in rptPartnerList.Items)
            {
                TextBox tbxAsignAmount = item.FindControl("tbxAsignAmount") as TextBox;
                if (tbxAsignAmount.Text == "")
                    tbxAsignAmount.Text = "0";

                DateTime dateTime = DateTime.Parse(Request.QueryString["date"]);
                Guid partnerId = Guid.Parse((item.FindControl("hfPartnerId") as HiddenField).Value);
                int ticketId = qzTa.Ticket.Id;
                QZPartnerTicketAsign qzpartnerTa = bllqzPartnerTa.GetOneByDateAndPartnerIdAndTicketId(dateTime, partnerId, ticketId);
                if (qzpartnerTa == null)
                    qzpartnerTa = new QZPartnerTicketAsign();
                qzpartnerTa.Partner = bllqzPartner.GetOne(partnerId);
                qzpartnerTa.AsignedAmount = int.Parse(tbxAsignAmount.Text);
                qzpartnerTa.QZTicketAsign = qzTa;
                bllqzPartnerTa.SaveOrUpdate(qzpartnerTa);
                Amount += int.Parse(tbxAsignAmount.Text);
            }

            qzTa.Amount = Amount;
            bllqz.SaveOrUpdate(qzTa);
            //这里需要征询袁飞
            ScriptManager.RegisterStartupScript(this, this.GetType(), "s", "window.location=window.location", true);
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 该出票请求是否能够通过.
        /// </summary>
        /// <param name="clientFriendlyId"></param>
        /// <param name="amount"></param>
        /// <param name="idcardno"></param>
        /// <param name="ticketCode"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        private bool ValidateRequst(bool isMediaOrTaiZhou, QZPartnerTicketAsign partnerAsign, int amount, string idcardno, string ticketCode, out string errMsg)
        {
            TourLog.ErrorLog.Info("开始验证");

            errMsg = string.Empty;
            //验证这个分发商还有没有足够的门票

            CommonLibrary.ValidateHelper.verify_idcard(idcardno);

            bool hasEnough = true;
            //台州和媒体: 判断是否超出总量
            if (isMediaOrTaiZhou)
            {
                int[] totalAssignedAndSold = dalPTA.GetTotalAssignAndSold(partnerAsign.Partner.FriendlyId, ticketCode);
                int totalAssigned = totalAssignedAndSold[0];
                int totalSold = totalAssignedAndSold[1];
                if (totalAssigned == -1)
                {
                    errMsg = string.Format("没有分配门票信息.partner:{0},ticketcode:{1}", partnerAsign.Partner.Name, ticketCode);
                    return false;
                }
                else
                {
                    if (totalSold + amount > totalAssigned)
                    {
                        errMsg = string.Format("门票已经全部派送.partner:{0},ticketcode:{1}", partnerAsign.Partner.Name, ticketCode);
                        return false;
                    }
                }
            }
            else
            {
                hasEnough = partnerAsign.HasEnoughTickets(amount);
                if (!hasEnough) { errMsg = "当天门票已被抢完,请明天再来"; return false; }
            }

            //验证这个身份证号码是否已经抢到一定数量的某种类型的门票,无法继续抢订.

            //是否已经抢到了足够的票数
            //ticket的 productcode 不为空的门票总数-->
            //todo: 不太保险的判断

            //IList<TicketAssign> gotTotalTicketsOfThisType = listTa.Where(x => !string.IsNullOrEmpty(x.OrderDetail.TicketPrice.Ticket.ProductCode)).ToList();
            IList<TicketAssign> getAssignTicketForId = bllTicketAssign.GetTaByIdcardandTicketCode(idcardno, ticketCode);
            if (getAssignTicketForId.Count > 0)
            {

                errMsg = "该身份证号码已经抢到这个景区的门票,不能继续抢票";
                return false;
            }
            else
            {
                IList<object[]> gotTotalTicketsOfThisType = bllTicketAssign.GetTaByIdCardHasProductCodeBySql(idcardno);
                if (gotTotalTicketsOfThisType.Count >= 5)
                {
                    errMsg = "该身份证号码已经抢到足够票数,不能继续抢票";
                    return false;
                }
                int i = 0;
                foreach (var item in gotTotalTicketsOfThisType)
                {
                    if (item[0].ToString() == ticketCode)
                    {
                        i++;
                    }
                }
                if (i > 0)
                {
                    errMsg = "该身份证号码已经抢到足够票数,不能继续抢票";
                    return false;
                }
            }

            return true;
        }