167 lines
5.9 KiB
C#
167 lines
5.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Security;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
using System.Web.UI.WebControls.WebParts;
|
|||
|
|
using System.Web.UI.HtmlControls;
|
|||
|
|
|
|||
|
|
|
|||
|
|
using WeiSha.Common;
|
|||
|
|
|
|||
|
|
using Song.ServiceInterfaces;
|
|||
|
|
using Song.Entities;
|
|||
|
|
using WeiSha.WebControl;
|
|||
|
|
using System.IO;
|
|||
|
|
|
|||
|
|
namespace Song.Site.Manage.Student
|
|||
|
|
{
|
|||
|
|
public partial class Learningcard : Extend.CustomPage
|
|||
|
|
{
|
|||
|
|
Song.Entities.Organization org;
|
|||
|
|
//<2F><>ǰѧԱ<D1A7><D4B1>ѧϰ<D1A7><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>
|
|||
|
|
protected int cardcount, usecount;
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser;
|
|||
|
|
if (st == null) return;
|
|||
|
|
|
|||
|
|
if (Request.ServerVariables["REQUEST_METHOD"] == "GET")
|
|||
|
|
{
|
|||
|
|
org = Business.Do<IOrganization>().OrganCurrent();
|
|||
|
|
if (!this.IsPostBack)
|
|||
|
|
{
|
|||
|
|
//<2F><>ǰѧԱ<D1A7><D4B1>ѧϰ<D1A7><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int accid = Extend.LoginState.Accounts.UserID;
|
|||
|
|
if (accid > 0)
|
|||
|
|
{
|
|||
|
|
cardcount = Business.Do<ILearningCard>().AccountCardOfCount(accid);
|
|||
|
|
usecount = cardcount - Business.Do<ILearningCard>().AccountCardOfCount(accid, 0);
|
|||
|
|
//ѧԱ<D1A7><D4B1>ѧϰ<D1A7><CFB0>
|
|||
|
|
Song.Entities.LearningCard[] cards = Business.Do<ILearningCard>().AccountCards(accid);
|
|||
|
|
rptCards.DataSource = cards;
|
|||
|
|
rptCards.DataBind();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//
|
|||
|
|
//<2F><>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>ajax<61>ύ<EFBFBD><E1BDBB>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>POST<53><54>ʽ
|
|||
|
|
if (Request.ServerVariables["REQUEST_METHOD"] == "POST")
|
|||
|
|
{
|
|||
|
|
string action = WeiSha.Common.Request.Form["action"].String;
|
|||
|
|
switch (action)
|
|||
|
|
{
|
|||
|
|
//ʹ<><CAB9>ѧϰ<D1A7><CFB0>
|
|||
|
|
case "useCode":
|
|||
|
|
useCode(this.Context);
|
|||
|
|
break;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ѧϰ<D1A7><CFB0>
|
|||
|
|
case "getCode":
|
|||
|
|
getCode(this.Context);
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#region ѧϰ<EFBFBD><EFBFBD>
|
|||
|
|
/// <summary>
|
|||
|
|
/// ʹ<><CAB9>ѧϰ<D1A7><CFB0>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="context"></param>
|
|||
|
|
private void useCode(HttpContext context)
|
|||
|
|
{
|
|||
|
|
//ѧϰ<D1A7><CFB0><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ
|
|||
|
|
string code = WeiSha.Common.Request.Form["card"].String;
|
|||
|
|
string state = "\"state\":{0},\"info\":\"{1}\",";
|
|||
|
|
string json = "\"items\":[";
|
|||
|
|
//û<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
|
if (!string.IsNullOrWhiteSpace(code))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC>֤
|
|||
|
|
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);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀγ<C4BF>
|
|||
|
|
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, "<22>ɹ<EFBFBD>");
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
state = string.Format(state, 0, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
json += "]";
|
|||
|
|
Response.Write("({" + state + json + "})");
|
|||
|
|
this.Response.End();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ѧϰ<D1A7><CFB0><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="context"></param>
|
|||
|
|
private void getCode(HttpContext context)
|
|||
|
|
{
|
|||
|
|
//ѧϰ<D1A7><CFB0><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ
|
|||
|
|
string code = WeiSha.Common.Request.Form["card"].String;
|
|||
|
|
string state = "\"state\":{0},\"info\":\"{1}\",";
|
|||
|
|
string json = "\"items\":[";
|
|||
|
|
//û<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
|||
|
|
if (!string.IsNullOrWhiteSpace(code))
|
|||
|
|
{
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC>֤
|
|||
|
|
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, "<22>ɹ<EFBFBD>");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
state = string.Format(state, 0, ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
json += "]";
|
|||
|
|
Response.Write("({" + state + json + "})");
|
|||
|
|
this.Response.End();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ӵ<EFBFBD>ַ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="url"></param>
|
|||
|
|
/// <param name="para"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private string addPara(string url, params string[] para)
|
|||
|
|
{
|
|||
|
|
return WeiSha.Common.Request.Page.AddPara(url, para);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|