Пример #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            AuthUserOperationPermission(Permission.Edit);
            //更新充值卡表
            string date     = CtrlHelper.GetText(txtEnjoinOverDate);
            string password = CtrlHelper.GetText(txtPassword);
            int    buildId  = Convert.ToInt32(GameRequest.GetString("buildId").Trim( ));

            if (date == "" && password == "")
            {
                MessageBox("请输入密码或者有效期");
                return;
            }
            StringBuilder sqlQuery = new StringBuilder();

            if (date != "" && password != "")
            {
                sqlQuery.AppendFormat("update {0} set ValidDate='{1}',PassWord='******' where CardID in ({3})", LivcardAssociator.Tablename, date, Utility.MD5(password), StrParamsList);
            }
            else
            {
                if (date != "")
                {
                    sqlQuery.AppendFormat("update {0} set ValidDate='{1}' where CardID in ({2})", LivcardAssociator.Tablename, date, StrParamsList);
                }
                else
                {
                    sqlQuery.AppendFormat("update {0} set PassWord='******' where CardID in ({2})", LivcardAssociator.Tablename, Utility.MD5(password), StrParamsList);
                }
            }
            int results = FacadeManage.aideTreasureFacade.ExecuteSql(sqlQuery.ToString());
            LivcardBuildStream LivcardBuild = FacadeManage.aideTreasureFacade.GetLivcardBuildStreamInfo(buildId);

            //更新批次表
            string        byteList     = UnicodeEncoding.Default.GetString(LivcardBuild.BuildCardPacket);
            StringBuilder sqlQueryCard = new StringBuilder( );

            sqlQueryCard.AppendFormat("SELECT SerialID FROM {0} WHERE CardID in ({1})", LivcardAssociator.Tablename, StrParamsList);
            DataSet ds = FacadeManage.aideTreasureFacade.GetDataSetBySql(sqlQueryCard.ToString());

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string serialID = row["SerialID"].ToString( );
                int    number1  = byteList.IndexOf(serialID);
                string prefix   = byteList.Substring(0, number1 + serialID.Length + 1);
                int    number2  = byteList.IndexOf("/", number1 + serialID.Length + 1);
                string profix   = byteList.Substring(number2);
                byteList = prefix + password + profix;
            }
            LivcardBuild.BuildCardPacket = UnicodeEncoding.Default.GetBytes(byteList);
            FacadeManage.aideTreasureFacade.UpdateLivcardBuildStream(LivcardBuild);
            if (results > 0)
            {
                MessageBoxClose("成功更新" + results + "条记录");
            }
            else
            {
                MessageBoxClose("没有符合的数据更新");
            }
        }
        //导出
        protected void Export()
        {
            LivcardBuildStream cardBuild = FacadeManage.aideTreasureFacade.GetLivcardBuildStreamInfo(IntParam);

            if (cardBuild == null)
            {
                ShowError("实卡类型不存在");
                return;
            }
            if (cardBuild.BuildCardPacket.Length > 0)
            {
                //string style = @"<style>.text { mso-number-format:\@; }</style> "; //设置格式
                byte[] bytes = cardBuild.BuildCardPacket;
                //兼容asp网站生成的点卡
                string str = Encoding.Default.GetString(bytes);
                if (str.IndexOf("/") != -1)
                {
                    str   = str.Replace("/", "\r\n");
                    str   = str.Replace(",", ",\t");
                    str   = "第" + cardBuild.BuildID + "批次 (" + GetCardTypeName(cardBuild.CardTypeID) + ") " + cardBuild.BuildCount + " 张\r\n卡号,\t卡密\r\n" + str;
                    bytes = Encoding.Default.GetBytes(str);
                }
                Response.Clear();
                Response.ContentType = "application/ms-excel";
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("实卡信息" + DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss") + ".csv"));
                int length = bytes.Length;
                Response.AddHeader("Content-Length", length.ToString());
                Response.BinaryWrite(bytes);
                Response.End();
            }
        }
        /// <summary>
        /// 获取实卡批次实体
        /// </summary>
        /// <param name="buildID"></param>
        /// <returns></returns>
        public LivcardBuildStream GetLivcardBuildStreamInfo(int buildID)
        {
            string             sqlQuery           = string.Format("(NOLOCK) WHERE BuildID= '{0}'", buildID);
            LivcardBuildStream livcardBuildStream = aideLivcardBuildStreamProvider.GetObject <LivcardBuildStream>(sqlQuery);

            return(livcardBuildStream);
        }
        /// <summary>
        /// 更新实卡批次记录
        /// </summary>
        /// <param name="livcardBuildStream"></param>
        public void UpdateLivcardBuildStream(LivcardBuildStream livcardBuildStream)
        {
            StringBuilder sqlQuery = new StringBuilder( );

            sqlQuery.Append("UPDATE LivcardBuildStream SET ")
            .Append("BuildCardPacket=@BuildCardPacket ")
            .Append("WHERE BuildID=@BuildID");

            var prams = new List <DbParameter>( );

            prams.Add(Database.MakeInParam("BuildCardPacket", livcardBuildStream.BuildCardPacket));
            prams.Add(Database.MakeInParam("BuildID", livcardBuildStream.BuildID));

            Database.ExecuteNonQuery(CommandType.Text, sqlQuery.ToString( ), prams.ToArray( ));
        }
        /// <summary>
        /// 插入实卡批次记录
        /// </summary>
        /// <param name="livcardBuildStream"></param>
        /// <returns></returns>
        public int InsertLivcardBuildStream(LivcardBuildStream livcardBuildStream)
        {
            var prams = new List <DbParameter>( );

            prams.Add(Database.MakeInParam("AdminName", livcardBuildStream.AdminName));
            prams.Add(Database.MakeInParam("CardTypeID", livcardBuildStream.CardTypeID));
            prams.Add(Database.MakeInParam("CardPrice", livcardBuildStream.CardPrice));
            prams.Add(Database.MakeInParam("CardGold", livcardBuildStream.CardGold));
            prams.Add(Database.MakeInParam("BuildCount", livcardBuildStream.BuildCount));
            prams.Add(Database.MakeInParam("BuildAddr", livcardBuildStream.BuildAddr));
            prams.Add(Database.MakeInParam("NoteInfo", livcardBuildStream.NoteInfo));
            prams.Add(Database.MakeInParam("BuildCardPacket", livcardBuildStream.BuildCardPacket));

            object obj;

            Database.RunProc("WSP_PM_BuildStreamAdd", prams, out obj);
            if (obj == null || obj.ToString( ).Length <= 0)
            {
                return(0);
            }
            return(int.Parse(obj.ToString( )));
        }
Пример #6
0
        //生成实卡
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            #region 验证
            //判断权限
            AuthUserOperationPermission(Permission.CreateCard);
            int cardCount  = CtrlHelper.GetInt(txtCount, 0);
            int cardTypeID = string.IsNullOrEmpty(ddlCardType.SelectedValue) ? 0 : int.Parse(ddlCardType.SelectedValue);
            if (cardTypeID <= 0)
            {
                ShowError("请先添加实卡类型");
                return;
            }
            if (cardCount <= 0)
            {
                ShowError("生成实卡的数量必须大于零的整数");
                return;
            }
            if (cardCount > 10000)
            {
                ShowError("生成实卡的数量一次最多10000张");
                return;
            }
            // 卡号规则
            int cardLen = CtrlHelper.GetInt(txtCardNumLen, 0);
            if (cardLen < 15 || cardLen > 32)
            {
                ShowError("卡号长度必须大于等于15小于32 ");
                return;
            }
            //卡密规则
            int passwordLen = CtrlHelper.GetInt(txtPassLen, 0);
            if (passwordLen < 8 || passwordLen > 32)
            {
                ShowError("密码长度必须大于等于8小于33 ");
                return;
            }
            #endregion

            GlobalLivcard cardType = aideTreasureFacade.GetGlobalLivcardInfo(cardTypeID);
            if (cardType == null)
            {
                ShowError("实卡类型不存在");
                return;
            }
            byte[]             bytes     = Encoding.Default.GetBytes("");
            LivcardBuildStream cardBuild = new LivcardBuildStream( );
            cardBuild.AdminName       = userExt.Username;
            cardBuild.BuildAddr       = GameRequest.GetUserIP( );
            cardBuild.BuildCardPacket = bytes;
            cardBuild.BuildCount      = cardCount;
            cardBuild.BuildDate       = DateTime.Now;
            cardBuild.CardGold        = cardType.CardGold;
            cardBuild.CardPrice       = cardType.CardPrice;
            cardBuild.CardTypeID      = cardTypeID;
            cardBuild.DownLoadCount   = 0;
            cardBuild.NoteInfo        = CtrlHelper.GetText(txtRemark);
            int buildID = aideTreasureFacade.InsertLivcardBuildStream(cardBuild);
            if (buildID <= 0)
            {
                ShowError("添加实卡批次失败");
                return;
            }
            //实卡信息
            LivcardAssociator card = new LivcardAssociator( );
            card.BuildID      = buildID;
            card.CardTypeID   = cardType.CardTypeID;
            card.CardPrice    = cardType.CardPrice;
            card.CardGold     = CtrlHelper.GetInt(txtCardGold, 0);
            card.MemberOrder  = cardType.MemberOrder;
            card.MemberDays   = CtrlHelper.GetInt(txtMemberDays, 0);
            card.UserRight    = cardType.UserRight;
            card.ServiceRight = cardType.ServiceRight;
            card.UseRange     = int.Parse(ddlUseRange.SelectedValue);
            card.SalesPerson  = CtrlHelper.GetText(txtSalesPerson);
            card.ValidDate    = Convert.ToDateTime(txtValidDate.Text.Trim( ));

            StringBuilder sb = new StringBuilder( );
            string[,] list = new string[cardCount, 2];
            int    i    = 0;
            Random rand = new Random( );
            while (cardCount > 0)
            {
                string serialID = GetSerialID(cardLen, cardType.CardTypeID, rand);    //卡号
                bool   isRepeat = false;
                for (int j = i; j > 0; j--)
                {
                    if (list[j, 0] == serialID)
                    {
                        isRepeat = true;
                        break;
                    }
                }
                if (isRepeat)
                {
                    isRepeat = false;
                    continue;
                }
                string password = GetPassword(passwordLen, rand); //卡密
                sb.AppendFormat("{0},{1}/", serialID, password);
                list[i, 0] = serialID;
                list[i, 1] = Utility.MD5(password);
                cardCount--;
                i++;
            }
            aideTreasureFacade.InsertLivcardAssociator(card, list);
            bytes                     = Encoding.Default.GetBytes(sb.ToString( ));
            cardBuild.BuildID         = buildID;
            cardBuild.BuildCardPacket = bytes;
            try
            {
                aideTreasureFacade.UpdateLivcardBuildStream(cardBuild);
                txtCount.Text = "0";
                ShowInfo("生成会员卡成功");
            }
            catch
            {
                ShowError("生成会员卡失败");
            }
        }
Пример #7
0
 public void UpdateLivcardBuildStream(LivcardBuildStream livcardBuildStream)
 {
     this.aideTreasureData.UpdateLivcardBuildStream(livcardBuildStream);
 }
Пример #8
0
 public int InsertLivcardBuildStream(LivcardBuildStream livcardBuildStream)
 {
     return(this.aideTreasureData.InsertLivcardBuildStream(livcardBuildStream));
 }