Example #1
0
 /// <summary>
 /// 修改学习卡设置项
 /// </summary>
 /// <param name="entity">业务实体</param>
 public void SetSave(LearningCardSet entity)
 {
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             Song.Entities.LearningCardSet rs = tran.From <LearningCardSet>().Where(LearningCardSet._.Lcs_ID == entity.Lcs_ID).ToFirst <LearningCardSet>();
             LearningCard[] cards             = CardGenerate(entity, tran);
             if (cards != null)
             {
                 foreach (LearningCard c in cards)
                 {
                     Gateway.Default.Save <LearningCard>(c);
                 }
             }
             tran.Update <LearningCard>(new Field[] { LearningCard._.Lc_Price, LearningCard._.Lc_LimitStart, LearningCard._.Lc_LimitEnd },
                                        new object[] { entity.Lcs_Price, entity.Lcs_LimitStart, entity.Lcs_LimitEnd },
                                        LearningCard._.Lcs_ID == entity.Lcs_ID && LearningCard._.Lc_IsUsed == false);
             tran.Save <LearningCardSet>(entity);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
Example #2
0
 void fill()
 {
     Song.Entities.LearningCardSet set = id == 0 ? new Song.Entities.LearningCardSet() : Business.Do <ILearningCard>().SetSingle(id);
     if (id > 0)
     {
         this.EntityBind(set);
         //当前学习卡关联的课程
         Song.Entities.Course[] courses = Business.Do <ILearningCard>().CoursesGet(set);
         if (courses != null)
         {
             rtpCourses.DataSource = courses;
             rtpCourses.DataBind();
             foreach (Song.Entities.Course c in courses)
             {
                 tbCourses.Text += c.Cou_ID + ",";
             }
         }
     }
     if (id < 1)
     {
         //如果是新增
         Lcs_LimitStart.Text = DateTime.Now.ToString("yyyy-MM-dd");
         Lcs_LimitEnd.Text   = DateTime.Now.AddMonths(12).ToString("yyyy-MM-dd");
         Lcs_SecretKey.Text  = getUID();
     }
 }
Example #3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            List <Song.Entities.LearningCard> lcs = Business.Do <ISystemPara>().ForSql <Song.Entities.LearningCard>("select * from LearningCard where Lc_State=1");

            foreach (LearningCard lc in lcs)
            {
                int acid = lc.Ac_ID;   //学员Id
                int span = lc.Lc_Span; //要增加的学习时间
                //获取学习卡关联的课程
                Song.Entities.LearningCardSet lset  = Business.Do <ILearningCard>().SetSingle(lc.Lcs_ID);
                Song.Entities.Course[]        cours = Business.Do <ILearningCard>().CoursesGet(lset);
                foreach (Song.Entities.Course c in cours)
                {
                    Student_Course sc = Business.Do <ISystemPara>()
                                        .ScalarSql <Student_Course>(string.Format("select * from student_course where ac_id={0} and cou_id={1}", acid, c.Cou_ID));
                    if (sc != null)
                    {
                        DateTime end = sc.Stc_StartTime.AddDays(span);  //应该结束的学习时效
                        if (end > sc.Stc_EndTime)
                        {
                            sc.Stc_EndTime = end;
                            Business.Do <ISystemPara>().ExecuteSql(string.Format("update student_course set stc_endtime='{0}' where ac_id={1} and cou_id={2}",
                                                                                 end.ToString("yyyy-MM-dd"), acid, c.Cou_ID));
                        }
                    }
                }
            }
            this.Response.Write(this.Button2.Text + "---操作完成!");
        }
Example #4
0
        /// <summary>
        /// ÐÞ¸ÄÊÇ·ñÏÔʾµÄ״̬
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void sbEnable_Click(object sender, EventArgs e)
        {
            StateButton ub    = (StateButton)sender;
            int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
            int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());

            //
            Song.Entities.LearningCardSet entity = Business.Do <ILearningCard>().SetSingle(id);
            entity.Lcs_IsEnable = !entity.Lcs_IsEnable;
            Business.Do <ILearningCard>().SetSave(entity);
            BindData(null, null);
        }
Example #5
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnEnter_Click(object sender, EventArgs e)
        {
            Song.Entities.LearningCardSet set = id != 0 ? Business.Do <ILearningCard>().SetSingle(id) : new Song.Entities.LearningCardSet();
            set = this.EntityFill(set) as Song.Entities.LearningCardSet;
            //关联的课程
            set = Business.Do <ILearningCard>().CoursesSet(set, tbCourses.Text.Trim());
            try
            {
                if (id == 0)
                {
                    Business.Do <ILearningCard>().SetAdd(set);
                }
                else
                {
                    Business.Do <ILearningCard>().SetSave(set);
                }

                Master.AlertCloseAndRefresh("操作成功!");
            }
            catch (Exception ex)
            {
                Master.Alert(ex.Message);
            }
        }