Esempio n. 1
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,检查用户卡片是否有效
        /// </summary>
        /// <param name="callIndex">卡片类别调用名称</param>
        /// <param name="username">用户名</param>
        /// <returns></returns>
        public bool CheckUserCard(string callIndex, string username)
        {
            bool check = false;

            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user                  = usersBll.GetModel(username);
            var cardCategory          = cardCategoryBll.GetModel(callIndex);
            var uclist                = ucBLL.GetModelList("UserId=" + user.id);
            var cardList              = cardBll.GetModelList("CardCategoryId=" + cardCategory.CardCategoryId);
            List <Model.UserCard> ucl = (from uc in uclist
                                         join c in cardList on uc.CardId equals c.CardId
                                         select new Model.UserCard()
            {
                UserId = uc.UserId,
                CardId = uc.CardId,
                UserCardId = uc.UserCardId,
                CardCategoryId = cardCategory.CardCategoryId
            }).ToList();

            foreach (var uc in ucl)
            {
                var card = cardBll.GetModel(uc.CardId);
                if (card.StartDate <= DateTime.Now && card.EndDate >= DateTime.Now)
                {
                    check = true;
                }
            }
            return(check);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,为用户创建卡片
        /// </summary>
        /// <param name="callindex">卡片类别调用名称</param>
        /// <param name="username">用户名</param>
        /// <param name="token">token</param>
        /// <returns></returns>
        public int CreateUserCard(string callindex, string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user         = usersBll.GetModel(username);
            var cardCategory = cardCategoryBll.GetModel(callindex);
            var card         = new Model.Card();

            card.CardCategoryId = cardCategory.CardCategoryId;
            card.Code           = Common.Utils.GetCheckCode(7);
            card.CreateDate     = DateTime.Now;
            card.StartDate      = DateTime.Now;
            card.EndDate        = card.StartDate.AddDays(double.Parse(cardCategory.Duration.ToString()));

            int cardId = cardBll.Add(card);
            var uc     = new Model.UserCard();

            uc.CardId         = cardId;
            uc.UserId         = user.id;
            uc.CardCategoryId = cardCategory.CardCategoryId;
            return(ucBLL.Add(uc));
        }
Esempio n. 3
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("manager_list", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.CardCategory bll = new BLL.CardCategory();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除卡片类别"
                        + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("CardCategory_list.aspx", "keywords={0}", this.keywords));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取用户的有效期内的卡片
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public List <Model.Card> GetCards(string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user           = usersBll.GetModel(username);
            var uclist         = ucBLL.GetModelList("UserId=" + user.id);
            var categoryIdlist = from uc in uclist
                                 group uc by uc.CardCategoryId into g
                                 select new { id = g.Key };
            List <Model.Card> cardList = new List <Model.Card>();

            foreach (var i in categoryIdlist)
            {
                var cc   = cardCategoryBll.GetModel(i.id);
                var card = GetUsersCard(cc.CallIndex, user.user_name);
                if (card != null)
                {
                    cardList.Add(card);
                }
            }
            return(cardList);
        }
Esempio n. 5
0
        private void ParentBind()
        {
            BLL.CardCategory bll = new BLL.CardCategory();
            DataTable        dt  = bll.GetList(0);

            this.ddlParentId.Items.Clear();
            this.ddlParentId.Items.Add(new ListItem("请选择类别...", ""));
            this.ddlParentId.Items.Add(new ListItem("顶级类别", "0"));
            foreach (DataRow dr in dt.Rows)
            {
                string Id    = dr["CardCategoryId"].ToString();
                int    layer = int.Parse(dr["Layer"].ToString());
                string name  = dr["FullName"].ToString().Trim();

                if (layer == 1)
                {
                    this.ddlParentId.Items.Add(new ListItem(name, Id));
                }
                else
                {
                    name = "├ " + name;
                    name = Utils.StringOfChar(layer - 1, " ") + Title;
                    this.ddlParentId.Items.Add(new ListItem(name, Id));
                }
            }
        }
Esempio n. 6
0
        private void RptBind(string _strWhere, string _orderby)
        {
            this.page        = DTRequest.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.CardCategory bll = new BLL.CardCategory();
            this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("CardCategory_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Esempio n. 7
0
 private void ShowInfo(int _id)
 {
     BLL.CardCategory   bll   = new BLL.CardCategory();
     Model.CardCategory model = bll.GetModel(_id);
     //编写赋值操作Begin
     ddlParentId.SelectedValue  = model.ParentId.ToString();
     txtFullName.Text           = model.FullName;
     txtBackImgUrl.Text         = model.BackImageUrl;
     txtImgUrl.Text             = model.ImagUrl;
     txtDescribe.Text           = model.Describe;
     txtDuration.Text           = model.Duration.ToString();
     txtCallIndex.Text          = model.CallIndex;
     txtUserGroupCallIndex.Text = model.UserGroupCallIndex;
     //编写赋值操作End
 }
Esempio n. 8
0
        /// <summary>
        /// 获取用户的所有的卡片
        /// </summary>
        /// <param name="username"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public List <Model.Card> GetAllCards(string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user   = usersBll.GetModel(username);
            var uclist = ucBLL.GetModelList("UserId=" + user.id);
            List <Model.Card> cardList = new List <Model.Card>();

            foreach (var uc in uclist)
            {
                cardList.Add(cardBll.GetModel(uc.CardId));
            }
            return(cardList);
        }
Esempio n. 9
0
        /// <summary>
        /// 根据卡片类别调用名称和用户名,获取卡片信息
        /// </summary>
        /// <param name="callIndex"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public Model.Card GetUsersCard(string callIndex, string username)
        {
            BLL.Card         cardBll         = new BLL.Card();
            BLL.CardCategory cardCategoryBll = new BLL.CardCategory();
            BLL.UserCard     ucBLL           = new BLL.UserCard();
            BLL.users        usersBll        = new BLL.users();

            var user                  = usersBll.GetModel(username);
            var cardCategory          = cardCategoryBll.GetModel(callIndex);
            var uclist                = ucBLL.GetModelList("UserId=" + user.id);
            var cardList              = cardBll.GetModelList("CardCategoryId=" + cardCategory.CardCategoryId);
            List <Model.UserCard> ucl = (from uc in uclist
                                         join c in cardList on uc.CardId equals c.CardId
                                         select new Model.UserCard()
            {
                UserId = uc.UserId,
                CardId = uc.CardId,
                UserCardId = uc.UserCardId,
                CardCategoryId = cardCategory.CardCategoryId
            }).ToList();

            Model.Card tcard = null;
            foreach (var uc in ucl)
            {
                Model.Card card = cardBll.GetModel(uc.CardId);
                if (card.StartDate <= DateTime.Now && card.EndDate >= DateTime.Now)
                {
                    if (tcard != null)
                    {
                        if (tcard.EndDate < card.EndDate)
                        {
                            tcard = card;
                        }
                    }
                    else
                    {
                        tcard = card;
                    }
                }
            }
            return(tcard);
        }
Esempio n. 10
0
        private bool DoAdd()
        {
            Model.CardCategory model = new Model.CardCategory();
            BLL.CardCategory   bll   = new BLL.CardCategory();
            //编写添加操作Begin
            model.FullName = txtFullName.Text;
            model.Describe = txtDescribe.Text;
            model.ImagUrl  = txtImgUrl.Text;
            if (!string.IsNullOrEmpty(ddlParentId.SelectedValue))
            {
                model.ParentId = Convert.ToInt32(ddlParentId.SelectedValue);
            }
            else
            {
                model.ParentId = 0;
            }
            var parent = bll.GetModel(model.ParentId);

            model.Layer              = parent.Layer + 1;
            model.BackImageUrl       = txtBackImgUrl.Text;
            model.CallIndex          = txtCallIndex.Text;
            model.Duration           = decimal.Parse(txtDuration.Text);
            model.CreateDate         = DateTime.Now;
            model.CreateUserName     = GetAdminInfo().user_name;
            model.ModifyDate         = DateTime.Now;
            model.UserGroupCallIndex = txtUserGroupCallIndex.Text;
            //编写添加操作End

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加卡片类别:"
                            + model.FullName); //记录日志
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.CardCategory   bll   = new BLL.CardCategory();
            Model.CardCategory model = bll.GetModel(_id);

            //编写编辑操作Begin
            model.FullName     = txtFullName.Text;
            model.Describe     = txtDescribe.Text;
            model.ImagUrl      = txtImgUrl.Text;
            model.BackImageUrl = txtBackImgUrl.Text;
            model.CallIndex    = txtCallIndex.Text;
            model.Duration     = decimal.Parse(txtDuration.Text);
            if (!string.IsNullOrEmpty(ddlParentId.SelectedValue))
            {
                model.ParentId = Convert.ToInt32(ddlParentId.SelectedValue);
            }
            else
            {
                model.ParentId = 0;
            }
            model.Layer              = model.ParentId + 1;
            model.ModifyDate         = DateTime.Now;
            model.ModifyUserName     = GetAdminInfo().user_name;
            model.UserGroupCallIndex = txtUserGroupCallIndex.Text;
            //编写编辑操作End

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改卡片类型:" + model.FullName); //记录日志
                result = true;
            }

            return(result);
        }
Esempio n. 12
0
        public IHttpActionResult PaySuccess(string ordernum, string tradeno)
        {
            var result = new PayResult();

            if (ordernum.StartsWith("R")) //充值订单
            {
                BLL.user_recharge   bll   = new BLL.user_recharge();
                Model.user_recharge model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                }
                else
                {
                    if (model.status == 1)
                    {
                        result.msg     = "该订单已经支付,请不要重复支付";
                        result.success = false;
                        result.status  = 202;
                    }
                    //订单编号验证通过后执行
                    bool r = bll.Confirm(ordernum);
                    if (r)
                    {
                        result.msg     = "充值成功";
                        result.status  = 200;
                        result.success = true;
                    }
                    else
                    {
                        result.msg     = "充值订单信息更新失败";
                        result.status  = 204;
                        result.success = false;
                    }
                }
            }
            else if (ordernum.StartsWith("B"))
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                }
                else
                {
                    if (model.payment_status == 2) //已付款
                    {
                        result.msg     = "该订单已经支付,请不要重复支付";
                        result.success = false;
                        result.status  = 202;
                    }
                    //订单编号验证通过后执行
                    bool r = bll.UpdateField(ordernum, "trade_no='" + tradeno + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                    if (r)
                    {
                        var articlebll = new BLL.article();
                        foreach (var g in model.order_goods)
                        {
                            //判断是否有卡片商品,如果有卡片商品,添加卡片和用户卡片
                            //todo:此处需要增加事务性操作
                            if (articlebll.IsCard(g.article_id))
                            {
                                var    article      = articlebll.GetModel(g.article_id);
                                string callindex    = article.fields["cardcategorycallindex"];
                                var    user         = new BLL.users().GetModel(model.user_name);
                                var    cardcategory = new BLL.CardCategory().GetModel(callindex);
                                var    card         = new Model.Card();
                                card.CardCategoryId = cardcategory.CardCategoryId;
                                card.Code           = Utils.GetCheckCode(7);
                                card.CreateDate     = DateTime.Now;
                                card.StartDate      = DateTime.Now;
                                card.EndDate        = DateTime.Now.AddDays((double)cardcategory.Duration);
                                var cardBll     = new BLL.Card();
                                int cardId      = cardBll.Add(card);
                                var usercardBll = new BLL.UserCard();
                                var usercard    = new Model.UserCard();
                                usercard.CardId         = cardId;
                                usercard.CardCategoryId = cardcategory.CardCategoryId;
                                usercard.UserId         = user.id;
                                usercardBll.Add(usercard);
                            }
                        }
                        result.msg     = "支付成功";
                        result.status  = 200;
                        result.success = true;
                    }
                    else
                    {
                        result.msg     = "商品订单信息更新失败";
                        result.status  = 204;
                        result.success = false;
                    }
                }
            }
            else
            {
                result.msg     = "订单号不正确";
                result.success = false;
                result.status  = 203;
            }
            return(Ok(result));
        }
Esempio n. 13
0
        public bool UpdatePaied(string order_no, string strValue)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql1 = new StringBuilder();
                        strSql1.Append("update " + siteConfig.sysdatabaseprefix + "orders set " + strValue);
                        strSql1.Append(" where order_no='@orderno';");
                        SqlParameter[] parameters1 =
                        {
                            new SqlParameter("@orderno", SqlDbType.NVarChar, 50)
                        };
                        parameters1[0].Value = order_no;
                        DbHelperSQL.GetSingle(conn, trans, strSql1.ToString(), parameters1); //带事务

                        var model = GetModel(order_no);
                        var user  = new users().GetModel(model.user_name);
                        foreach (var g in model.order_goods)
                        {
                            var abll = new article();
                            if (abll.IsCard(g.article_id))
                            {
                                StringBuilder strSql       = new StringBuilder();
                                var           article      = abll.GetModel(g.article_id);
                                string        callindex    = article.fields["cardcategorycallindex"];
                                var           cardcategory = new BLL.CardCategory().GetModel(callindex);
                                var           ug           = new BLL.user_groups().GetModel(cardcategory.UserGroupCallIndex);
                                strSql.Append("insert into " + siteConfig.edudatabaseprefix + "Card(");
                                strSql.Append("CardCategoryId,Code,CreateDate,StartDate,EndDate");
                                strSql.Append(") values (");
                                strSql.Append("@CardCategoryId,@Code,@CreateDate,@StartDate,@EndDate");
                                strSql.Append(") ");
                                strSql.Append(";select @@IDENTITY");
                                SqlParameter[] parameters =
                                {
                                    new SqlParameter("@CardCategoryId", SqlDbType.Int,        4),
                                    new SqlParameter("@Code",           SqlDbType.VarChar,   50),
                                    new SqlParameter("@CreateDate",     SqlDbType.DateTime),
                                    new SqlParameter("@StartDate",      SqlDbType.DateTime),
                                    new SqlParameter("@EndDate",        SqlDbType.DateTime)
                                };
                                var startTime = DateTime.Now;
                                var endTime   = DateTime.Now.AddDays((double)cardcategory.Duration);
                                parameters[0].Value = cardcategory.CardCategoryId;
                                parameters[1].Value = Utils.GetCheckCode(7);;
                                parameters[2].Value = startTime;
                                parameters[3].Value = startTime;
                                parameters[4].Value = endTime;
                                object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务

                                int           id       = Convert.ToInt32(obj);
                                StringBuilder strSqlUC = new StringBuilder();
                                strSqlUC.Append("insert into " + siteConfig.edudatabaseprefix + "UserCard(");
                                strSqlUC.Append("CardId,UserId,CardCategoryId");
                                strSqlUC.Append(") values (");
                                strSqlUC.Append("@CardId,@UserId,@CardCategoryId");
                                strSqlUC.Append(") ");
                                strSqlUC.Append(";select @@IDENTITY");
                                SqlParameter[] parametersUC =
                                {
                                    new SqlParameter("@CardId",         SqlDbType.Int, 4),
                                    new SqlParameter("@UserId",         SqlDbType.Int, 4),
                                    new SqlParameter("@CardCategoryId", SqlDbType.Int, 4)
                                };

                                parametersUC[0].Value = id;
                                parametersUC[1].Value = model.user_id;
                                parametersUC[2].Value = cardcategory.CardCategoryId;

                                DbHelperSQL.GetSingle(conn, trans, strSqlUC.ToString(), parametersUC);

                                StringBuilder strSqlUU = new StringBuilder();
                                strSqlUU.Append("update " + siteConfig.sysdatabaseprefix + "users set ");
                                strSqlUU.Append(" group_id=@group_id,");
                                strSqlUU.Append(" group_start_time=@group_start_time,");
                                strSqlUU.Append(" group_end_time=@group_end_time ");
                                strSqlUU.Append(" where id=@id");
                                SqlParameter[] parametersUU =
                                {
                                    new SqlParameter("@group_id",         SqlDbType.Int,       4),
                                    new SqlParameter("@group_start_time", SqlDbType.DateTime),
                                    new SqlParameter("@group_end_time",   SqlDbType.DateTime),
                                    new SqlParameter("@id",               SqlDbType.Int, 4)
                                };
                                parametersUU[0].Value = ug.id;
                                parametersUU[1].Value = startTime;
                                parametersUU[2].Value = endTime;
                                parametersUU[3].Value = user.id;
                                DbHelperSQL.GetSingle(conn, trans, strSqlUU.ToString(), parametersUU);
                            }
                        }
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }