Ejemplo n.º 1
0
        /// <summary>
        /// 将学习卡暂存名下
        /// </summary>
        /// <param name="context"></param>
        private void getCode(HttpContext context)
        {
            //学习卡的编码与密钥
            string code  = WeiSha.Common.Request.Form["card"].String;
            string state = "\"state\":{0},\"info\":\"{1}\",";
            string json  = "\"items\":[";

            //没有传入充值码
            if (!string.IsNullOrWhiteSpace(code))
            {
                //开始验证
                try
                {
                    Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardCheck(code);
                    if (card != null)
                    {
                        Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser;
                        if (st != null)
                        {
                            Business.Do <ILearningCard>().CardGet(card, st);
                            Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                            state = string.Format(state, 1, "成功");
                        }
                    }
                }
                catch (Exception ex)
                {
                    state = string.Format(state, 0, ex.Message);
                }
            }
            json += "]";
            Response.Write("({" + state + json + "})");
            this.Response.End();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 使用学习卡
        /// </summary>
        /// <param name="context"></param>
        private void useCode(HttpContext context)
        {
            //学习卡的编码与密钥
            string code  = WeiSha.Common.Request.Form["card"].String;
            string state = "\"state\":{0},\"info\":\"{1}\",";
            string json  = "\"items\":[";

            //没有传入充值码
            if (!string.IsNullOrWhiteSpace(code))
            {
                try
                {
                    //开始验证
                    Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardCheck(code);
                    if (card != null)
                    {
                        Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser;
                        if (st != null)
                        {
                            Business.Do <ILearningCard>().CardUse(card, st);
                            Extend.LoginState.Accounts.Refresh(st.Ac_ID);
                            //输出关联的课程
                            Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesForCard(card.Lc_Code, card.Lc_Pw);
                            for (int i = 0; i < courses.Length; i++)
                            {
                                Song.Entities.Course c = courses[i];
                                json += c.ToJson("Cou_ID,Cou_Name", null, null) + ",";
                            }
                            if (json.EndsWith(","))
                            {
                                json = json.Substring(0, json.Length - 1);
                            }
                        }
                    }
                    state = string.Format(state, 1, "成功");
                }
                catch (Exception ex)
                {
                    state = string.Format(state, 0, ex.Message);
                }
            }
            json += "]";
            Response.Write("({" + state + json + "})");
            this.Response.End();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 回滚按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)sender;
            int        id  = Convert.ToInt32(btn.CommandArgument);

            Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardSingle(id);
            if (card == null)
            {
                return;
            }
            try
            {
                Business.Do <ILearningCard>().CardRollback(card);
                this.Alert("回滚成功!");
                BindData(null, null);
            }
            catch (Exception ex)
            {
                this.Alert("错误:" + ex.Message);
            }
        }