Exemple #1
0
        protected void lnkBtnSearch_Click(object sender, EventArgs e)
        {
            Model.Pay.PO_MainTicket mainTicket = new Model.Pay.PO_MainTicket();
            mainTicket.ActiveCode  = hf_ActiveCode.Value;
            mainTicket.ActiveMoney = decimal.Parse(txtMoney.Text);
            mainTicket.StartTime   = System.DateTime.Now.ToString();
            mainTicket.EndTime     = txtEndTime.Text.ToString();
            mainTicket.MainID      = 0;
            mainTicket.IsActive    = false;
            mainTicket.Valid       = true;
            long add_result = mainTicket.ExecNonQuery(1);//添加兑换券

            if (add_result > 0)
            {
                Response.Redirect("TicketList.aspx");
            }
        }
Exemple #2
0
        /// <summary>
        /// 递归 验证数据库中是否有此随机数,有的话重新获取
        /// </summary>
        /// <param name="length">随机数长度</param>
        /// <param name="randomStr">当前要验证的随机数</param>
        /// <returns></returns>
        public string ReGetRandomNumber(int length, string randomStr)
        {
            string newRandomStr = randomStr;

            Model.Pay.PO_MainTicket mainTicket = new Model.Pay.PO_MainTicket();
            mainTicket.ActiveCode = randomStr;
            DataTable ticket_data = mainTicket.ExecDT(4);

            if (ticket_data.Rows.Count > 0)//如果存在重复的,则再次获取激活码
            {
                newRandomStr          = GenerateRandomNumber(12);
                mainTicket.ActiveCode = newRandomStr;
                DataTable newticket_data = mainTicket.ExecDT(4);
                if (newticket_data.Rows.Count > 0)//如果存在重复的,则再次获取激活码
                {
                    ReGetRandomNumber(length, newRandomStr);
                }
            }
            return(newRandomStr);
        }