Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Song.Entities.Organization    org = Business.Do <IOrganization>().OrganCurrent();
            Song.Entities.LearningCardSet mm  = Business.Do <ILearningCard>().SetSingle(id);
            //创建文件
            string name     = string.Format("{0}-学习卡({1}).xls", mm.Lcs_Theme, DateTime.Now.ToString("yyyy-MM-dd hh-mm"));
            string filePath = Upload.Get["Temp"].Physics + name;

            filePath = Business.Do <ILearningCard>().Card4Excel(filePath, org.Org_ID, id);
            if (System.IO.File.Exists(filePath))
            {
                FileInfo fileInfo = new FileInfo(filePath);
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name));
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType     = "application/-excel";
                Response.ContentEncoding = System.Text.Encoding.Default;
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();
                File.Delete(filePath);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            org = Business.Do <IOrganization>().OrganCurrent();
            Song.Entities.LearningCardSet set = Business.Do <ILearningCard>().SetSingle(id);
            if (set != null)
            {
                set.Lsc_UsedCount = Business.Do <ILearningCard>().CardUsedCount(set.Lcs_ID);
            }
            this.EntityBind(set);
            if (set != null)
            {
                this.Title += set.Lcs_Theme;
            }

            //当前学习卡关联的课程
            Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesGet(set);
            if (courses != null)
            {
                dlCourses.DataSource = courses;
                dlCourses.DataBind();
            }
            //当前学习卡的编码
            Song.Entities.LearningCard[] cards = Business.Do <ILearningCard>().CardCount(-1, set.Lcs_ID, true, null, -1);
            if (cards != null)
            {
                //生成二维码的配置
                //各项配置
                WeiSha.Common.CustomConfig config = CustomConfig.Load(org.Org_Config);               //自定义配置项
                string centerImg = Upload.Get["Org"].Virtual + config["QrConterImage"].Value.String; //中心图片
                centerImg = WeiSha.Common.Server.MapPath(centerImg);
                string color = config["QrColor"].Value.String;                                       //二维码前景色
                //生成二维码的字符串
                string[] qrcodes = new string[cards.Length];
                string   url     = lbUrl.Text.Trim();
                string   domain  = this.Request.Url.Scheme + "://" + this.Request.Url.Host + ":" + this.Request.Url.Port;
                for (int i = 0; i < cards.Length; i++)
                {
                    if (cards[i].Lc_IsUsed)
                    {
                        continue;
                    }
                    qrcodes[i] = string.Format(url, domain, cards[i].Lc_Code, cards[i].Lc_Pw);
                }
                //批量生成二维码
                System.Drawing.Image[] images = WeiSha.Common.QrcodeHepler.Encode(qrcodes, 200, centerImg, color, "#fff");
                for (int i = 0; i < cards.Length; i++)
                {
                    if (images[i] == null)
                    {
                        cards[i].Lc_QrcodeBase64 = lbUsedImg.Text;
                        continue;
                    }
                    cards[i].Lc_QrcodeBase64 = "data:image/JPG;base64," + WeiSha.Common.Images.ImageTo.ToBase64(images[i]);
                }
                rtpCode.DataSource = cards;
                rtpCode.DataBind();
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     //学习卡
     Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardSingle(code, pw);
     if (card == null)
     {
         return;
     }
     this.EntityBind(card);
     //学习卡设置项
     Song.Entities.LearningCardSet set = Business.Do <ILearningCard>().SetSingle(card.Lcs_ID);
     this.EntityBind(set);
     //输出关联的课程
     Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesGet(set);
     rptCourses.DataSource = courses;
     rptCourses.DataBind();
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardSingle(code, pw);
     if (card == null)
     {
         return;
     }
     //时效
     lbLimit.Text = card.Lc_LimitStart.ToString("yyyy/M/d") + " - " + card.Lc_LimitEnd.ToString("yyyy/M/d");
     //使用人,使用时间
     lbAccname.Text = card.Ac_AccName;
     lbUsetime.Text = card.Lc_CrtTime.ToString();
     lbState.Text   = card.Lc_State == 1 ? "使用" : "";
     //关联课程
     Song.Entities.LearningCardSet set     = Business.Do <ILearningCard>().SetSingle(card.Lcs_ID);
     Song.Entities.Course[]        courses = Business.Do <ILearningCard>().CoursesGet(set);
     rptCourse.DataSource = courses;
     rptCourse.DataBind();
 }
        protected override void InitPageTemplate(HttpContext context)
        {
            //学习卡
            Song.Entities.LearningCard card = Business.Do <ILearningCard>().CardSingle(code, pw);
            if (card == null)
            {
                return;
            }
            //学习卡设置项
            Song.Entities.LearningCardSet set = Business.Do <ILearningCard>().SetSingle(card.Lcs_ID);
            //输出关联的课程
            Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesGet(set);
            this.Document.SetValue("card", card);
            this.Document.SetValue("set", set);
            this.Document.SetValue("courses", courses);
            //是否已经领用
            int accid = Extend.LoginState.Accounts.CurrentUserId;

            if (accid > 0)
            {
                //如果当前学员账号id,与学习卡的归属一致,表示已经领用
                this.Document.SetValue("isget", accid == card.Ac_ID);
            }
        }