示例#1
0
        /// <summary>
        /// 新建学案,返回学案编号
        /// </summary>
        /// <param name="dtCourse"></param>
        /// <returns></returns>
        private static int CreateCourse(DataTable dtCourse, int cobj, int Hid)
        {
            int newCid = 0;

            LearnSite.Model.Courses cs  = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll = new LearnSite.BLL.Courses();
            cs = bll.GetTableModel(dtCourse);//获得学案的model
            int    thisCid      = cs.Cid;
            string thisCcontent = cs.Ccontent;

            cs.Cterm     = Int32.Parse(LearnSite.Common.XmlHelp.GetTerm());     //替换成当前学期
            cs.Cdate     = DateTime.Now;
            cs.Cobj      = cobj;                                                //替换成当前年级
            cs.Cks       = bll.CksMaxValue(cs.Cterm.Value, cs.Cobj.Value, Hid); //替换成当前年级的最新课节
            cs.Chid      = Hid;
            cs.Cfiletype = "txt";
            newCid       = bll.Add(cs);//获得新增学案的Cid

            string oldstr      = "Store/" + thisCid.ToString();
            string newstr      = "Store/" + newCid.ToString();
            string newCcontent = thisCcontent.Replace(oldstr, newstr); //替换链接地址

            bll.UpdateCcontent(newCid, newCcontent);                   //更新内容

            return(newCid);
        }
示例#2
0
        /// <summary>
        /// 学案xml序列化(不用)
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static bool SerialiazeCourse(int Cid)
        {
            LearnSite.Model.Courses course = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll    = new LearnSite.BLL.Courses();
            course = bll.GetModel(Cid);
            string xmlCoursePath = CourseCidPath(Cid);

            if (!Directory.Exists(xmlCoursePath)) //如果不存在该目录,则创建
            {
                Directory.CreateDirectory(xmlCoursePath);
            }
            string xmlCourseName = xmlCoursePath + @"\" + Cid + ".xml";

            if (File.Exists(xmlCourseName))
            {
                File.Delete(xmlCourseName);
            }
            XmlSerializer xs     = new XmlSerializer(typeof(LearnSite.Model.Courses));
            Stream        stream = new FileStream(xmlCourseName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);

            xs.Serialize(stream, course);
            stream.Close();

            if (File.Exists(xmlCourseName))
            {
                return(true);
            }
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LearnSite.Model.Courses model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Courses set ");
            strSql.Append("Ctitle=@Ctitle,");
            strSql.Append("Cclass=@Cclass,");
            strSql.Append("Ccontent=@Ccontent,");
            strSql.Append("Cdate=@Cdate,");
            strSql.Append("Chit=@Chit,");
            strSql.Append("Cobj=@Cobj,");
            strSql.Append("Cterm=@Cterm,");
            strSql.Append("Cks=@Cks,");
            strSql.Append("Cfiletype=@Cfiletype,");
            strSql.Append("Cupload=@Cupload,");
            strSql.Append("Chid=@Chid,");
            strSql.Append("Cpublish=@Cpublish");
            strSql.Append(" where Cid=@Cid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Cid",       SqlDbType.Int,        4),
                new SqlParameter("@Ctitle",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Cclass",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Ccontent",  SqlDbType.NText),
                new SqlParameter("@Cdate",     SqlDbType.DateTime),
                new SqlParameter("@Chit",      SqlDbType.Int,        4),
                new SqlParameter("@Cobj",      SqlDbType.Int,        4),
                new SqlParameter("@Cterm",     SqlDbType.Int,        4),
                new SqlParameter("@Cks",       SqlDbType.Int,        4),
                new SqlParameter("@Cfiletype", SqlDbType.NVarChar,  50),
                new SqlParameter("@Cupload",   SqlDbType.Bit,        1),
                new SqlParameter("@Chid",      SqlDbType.Int,        4),
                new SqlParameter("@Cpublish",  SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.Cid;
            parameters[1].Value  = model.Ctitle;
            parameters[2].Value  = model.Cclass;
            parameters[3].Value  = model.Ccontent;
            parameters[4].Value  = model.Cdate;
            parameters[5].Value  = model.Chit;
            parameters[6].Value  = model.Cobj;
            parameters[7].Value  = model.Cterm;
            parameters[8].Value  = model.Cks;
            parameters[9].Value  = model.Cfiletype;
            parameters[10].Value = model.Cupload;
            parameters[11].Value = model.Chid;
            parameters[12].Value = model.Cpublish;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LearnSite.Model.Courses model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Courses(");
            strSql.Append("Ctitle,Cclass,Ccontent,Cdate,Chit,Cobj,Cterm,Cks,Cfiletype,Cupload,Chid,Cpublish)");
            strSql.Append(" values (");
            strSql.Append("@Ctitle,@Cclass,@Ccontent,@Cdate,@Chit,@Cobj,@Cterm,@Cks,@Cfiletype,@Cupload,@Chid,@Cpublish)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ctitle",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Cclass",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Ccontent",  SqlDbType.NText),
                new SqlParameter("@Cdate",     SqlDbType.DateTime),
                new SqlParameter("@Chit",      SqlDbType.Int,        4),
                new SqlParameter("@Cobj",      SqlDbType.Int,        4),
                new SqlParameter("@Cterm",     SqlDbType.Int,        4),
                new SqlParameter("@Cks",       SqlDbType.Int,        4),
                new SqlParameter("@Cfiletype", SqlDbType.NVarChar,  50),
                new SqlParameter("@Cupload",   SqlDbType.Bit,        1),
                new SqlParameter("@Chid",      SqlDbType.Int,        4),
                new SqlParameter("@Cpublish",  SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.Ctitle;
            parameters[1].Value  = model.Cclass;
            parameters[2].Value  = model.Ccontent;
            parameters[3].Value  = model.Cdate;
            parameters[4].Value  = model.Chit;
            parameters[5].Value  = model.Cobj;
            parameters[6].Value  = model.Cterm;
            parameters[7].Value  = model.Cks;
            parameters[8].Value  = model.Cfiletype;
            parameters[9].Value  = model.Cupload;
            parameters[10].Value = model.Chid;
            parameters[11].Value = model.Cpublish;

            object obj = SqlHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#5
0
        /// <summary>
        /// 将指定Cid从xml内容读到model中
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static LearnSite.Model.Courses course(int Cid)
        {
            LearnSite.Model.Courses cs = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
            string xmlFile = XmlFilename(Cid);
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            if (xmlFile != "")
            {
                ds.ReadXml(xmlFile);//读取xml文件到ds
                dt = ds.Tables["Course"];
                cs = bll.GetTableModel(dt);
                ds.Dispose();
                return cs;
            }
            else
            {
                ds.Dispose();
                return null;
            }
        }
示例#6
0
        /// <summary>
        /// 将指定Cid从xml内容读到model中
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static LearnSite.Model.Courses course(int Cid)
        {
            LearnSite.Model.Courses cs  = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll = new LearnSite.BLL.Courses();
            string    xmlFile           = XmlFilename(Cid);
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            if (xmlFile != "")
            {
                ds.ReadXml(xmlFile);//读取xml文件到ds
                dt = ds.Tables["Course"];
                cs = bll.GetTableModel(dt);
                ds.Dispose();
                return(cs);
            }
            else
            {
                ds.Dispose();
                return(null);
            }
        }
示例#7
0
 /// <summary>
 /// 新建课程,返回课程编号
 /// </summary>
 /// <param name="dtCourse"></param>
 /// <returns></returns>
 private static int CreateCourse(DataTable dtCourse)
 {
     LearnSite.Model.Courses cs = new LearnSite.Model.Courses();
     LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
     cs = bll.GetTableModel(dtCourse);//获得课程的model
     int thisCid = cs.Cid;
     string thisCcontent = cs.Ccontent;
     int maxCid = bll.GetMaxId();
     string oldstr = "Store/"+thisCid.ToString();
     string newstr = "Store/" + maxCid.ToString();
     cs.Ccontent = thisCcontent.Replace(oldstr, newstr);//替换链接地址
     cs.Cterm =Int32.Parse( LearnSite.Common.XmlHelp.GetTerm());//替换成当前学期
     cs.Cdate = DateTime.Now;
     if (HttpContext.Current.Session["importgrade"] != null)
     {
         cs.Cobj = int.Parse(HttpContext.Current.Session["importgrade"].ToString());//替换成当前年级
         cs.Cks = bll.CksMaxValue(cs.Cterm.Value, cs.Cobj.Value);//替换成当前年级的最新课时
     }
     if (HttpContext.Current.Request.Cookies["TeacherCookies"] != null)
     {
         cs.Chid = Int32.Parse(HttpContext.Current.Request.Cookies["TeacherCookies"].Values["Hid"].ToString());
     }
     int newCid = bll.Add(cs);//获得新增课程的Cid
     return newCid;
 }
示例#8
0
        /// <summary>
        /// 课程xml序列化(不用)
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static bool SerialiazeCourse(int Cid)
        {
            LearnSite.Model.Courses course = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
            course = bll.GetModel(Cid);
            string xmlCoursePath = CourseCidPath(Cid);
            if (!Directory.Exists(xmlCoursePath)) //如果不存在该目录,则创建
                Directory.CreateDirectory(xmlCoursePath);
            string xmlCourseName = xmlCoursePath + @"\" + Cid + ".xml";
            if (File.Exists(xmlCourseName))
                File.Delete(xmlCourseName);
            XmlSerializer xs = new XmlSerializer(typeof(LearnSite.Model.Courses));
            Stream stream = new FileStream(xmlCourseName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            xs.Serialize(stream, course);
            stream.Close();

            if (File.Exists(xmlCourseName))
            {
                return true;
            }
            {
                return false;
            }
        }
示例#9
0
 /// <summary>
 /// �ӱ��е�һ����¼�õ�һ������ʵ��
 /// </summary>
 public LearnSite.Model.Courses GetTableModel(DataTable dt)
 {
     LearnSite.Model.Courses model = new LearnSite.Model.Courses();
     if (dt.Rows.Count > 0)
     {
         if (dt.Rows[0]["Cid"].ToString() != "")
         {
             model.Cid = int.Parse(dt.Rows[0]["Cid"].ToString());
         }
         model.Ctitle = dt.Rows[0]["Ctitle"].ToString();
         model.Cclass = dt.Rows[0]["Cclass"].ToString();
         model.Ccontent = dt.Rows[0]["Ccontent"].ToString();
         if (dt.Rows[0]["Cdate"].ToString() != "")
         {
             model.Cdate = DateTime.Parse(dt.Rows[0]["Cdate"].ToString());
         }
         if (dt.Rows[0]["Chit"].ToString() != "")
         {
             model.Chit = int.Parse(dt.Rows[0]["Chit"].ToString());
         }
         if (dt.Rows[0]["Cobj"].ToString() != "")
         {
             model.Cobj = int.Parse(dt.Rows[0]["Cobj"].ToString());
         }
         if (dt.Rows[0]["Cterm"].ToString() != "")
         {
             model.Cterm = int.Parse(dt.Rows[0]["Cterm"].ToString());
         }
         if (dt.Rows[0]["Cks"].ToString() != "")
         {
             model.Cks = int.Parse(dt.Rows[0]["Cks"].ToString());
         }
         model.Cfiletype = dt.Rows[0]["Cfiletype"].ToString();
         if (dt.Rows[0]["Cupload"].ToString() != "")
         {
             if ((dt.Rows[0]["Cupload"].ToString() == "1") || (dt.Rows[0]["Cupload"].ToString().ToLower() == "true"))
             {
                 model.Cupload = true;
             }
             else
             {
                 model.Cupload = false;
             }
         }
         if (dt.Rows[0]["Chid"].ToString() != "")
         {
             model.Chid = int.Parse(dt.Rows[0]["Chid"].ToString());
         }
         if (dt.Rows[0]["Cpublish"].ToString() != "")
         {
             if ((dt.Rows[0]["Cpublish"].ToString() == "1") || (dt.Rows[0]["Cpublish"].ToString().ToLower() == "true"))
             {
                 model.Cpublish = true;
             }
             else
             {
                 model.Cpublish = false;
             }
         }
         return model;
     }
     else
     {
         return null;
     }
 }
示例#10
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LearnSite.Model.Courses GetModel(int Cid)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Cid,Ctitle,Cclass,Ccontent,Cdate,Chit,Cobj,Cterm,Cks,Cfiletype,Cupload,Chid,Cpublish from Courses ");
            strSql.Append(" where Cid=@Cid ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Cid", SqlDbType.Int,4)};
            parameters[0].Value = Cid;

            LearnSite.Model.Courses model=new LearnSite.Model.Courses();
            DataSet ds =DbHelperSQL.Query(strSql.ToString(), parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["Cid"].ToString()!="")
                {
                    model.Cid=int.Parse(ds.Tables[0].Rows[0]["Cid"].ToString());
                }
                model.Ctitle=ds.Tables[0].Rows[0]["Ctitle"].ToString();
                model.Cclass=ds.Tables[0].Rows[0]["Cclass"].ToString();
                model.Ccontent=ds.Tables[0].Rows[0]["Ccontent"].ToString();
                if(ds.Tables[0].Rows[0]["Cdate"].ToString()!="")
                {
                    model.Cdate=DateTime.Parse(ds.Tables[0].Rows[0]["Cdate"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Chit"].ToString()!="")
                {
                    model.Chit=int.Parse(ds.Tables[0].Rows[0]["Chit"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Cobj"].ToString()!="")
                {
                    model.Cobj=int.Parse(ds.Tables[0].Rows[0]["Cobj"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Cterm"].ToString()!="")
                {
                    model.Cterm=int.Parse(ds.Tables[0].Rows[0]["Cterm"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Cks"].ToString()!="")
                {
                    model.Cks=int.Parse(ds.Tables[0].Rows[0]["Cks"].ToString());
                }
                model.Cfiletype=ds.Tables[0].Rows[0]["Cfiletype"].ToString();
                if(ds.Tables[0].Rows[0]["Cupload"].ToString()!="")
                {
                    if((ds.Tables[0].Rows[0]["Cupload"].ToString()=="1")||(ds.Tables[0].Rows[0]["Cupload"].ToString().ToLower()=="true"))
                    {
                        model.Cupload=true;
                    }
                    else
                    {
                        model.Cupload=false;
                    }
                }
                if(ds.Tables[0].Rows[0]["Chid"].ToString()!="")
                {
                    model.Chid=int.Parse(ds.Tables[0].Rows[0]["Chid"].ToString());
                }
                if(ds.Tables[0].Rows[0]["Cpublish"].ToString()!="")
                {
                    if((ds.Tables[0].Rows[0]["Cpublish"].ToString()=="1")||(ds.Tables[0].Rows[0]["Cpublish"].ToString().ToLower()=="true"))
                    {
                        model.Cpublish=true;
                    }
                    else
                    {
                        model.Cpublish=false;
                    }
                }
                return model;
            }
            else
            {
                return null;
            }
        }
示例#11
0
 /// <summary>
 /// 从表中第一条记录得到一个对象实体
 /// </summary>
 public LearnSite.Model.Courses GetTableModel(DataTable dt)
 {
     LearnSite.Model.Courses model = new LearnSite.Model.Courses();
     if (dt.Rows.Count > 0)
     {
         if (dt.Rows[0]["Cid"].ToString() != "")
         {
             model.Cid = int.Parse(dt.Rows[0]["Cid"].ToString());
         }
         model.Ctitle   = dt.Rows[0]["Ctitle"].ToString();
         model.Cclass   = dt.Rows[0]["Cclass"].ToString();
         model.Ccontent = dt.Rows[0]["Ccontent"].ToString();
         if (dt.Rows[0]["Cdate"].ToString() != "")
         {
             model.Cdate = DateTime.Parse(dt.Rows[0]["Cdate"].ToString());
         }
         if (dt.Rows[0]["Chit"].ToString() != "")
         {
             model.Chit = int.Parse(dt.Rows[0]["Chit"].ToString());
         }
         if (dt.Rows[0]["Cobj"].ToString() != "")
         {
             model.Cobj = int.Parse(dt.Rows[0]["Cobj"].ToString());
         }
         if (dt.Rows[0]["Cterm"].ToString() != "")
         {
             model.Cterm = int.Parse(dt.Rows[0]["Cterm"].ToString());
         }
         if (dt.Rows[0]["Cks"].ToString() != "")
         {
             model.Cks = int.Parse(dt.Rows[0]["Cks"].ToString());
         }
         if (dt.Rows[0]["Cupload"].ToString() != "")
         {
             if ((dt.Rows[0]["Cupload"].ToString() == "1") || (dt.Rows[0]["Cupload"].ToString().ToLower() == "true"))
             {
                 model.Cupload = true;
             }
             else
             {
                 model.Cupload = false;
             }
         }
         if (dt.Rows[0]["Chid"].ToString() != "")
         {
             model.Chid = int.Parse(dt.Rows[0]["Chid"].ToString());
         }
         if (dt.Rows[0]["Cpublish"].ToString() != "")
         {
             if ((dt.Rows[0]["Cpublish"].ToString() == "1") || (dt.Rows[0]["Cpublish"].ToString().ToLower() == "true"))
             {
                 model.Cpublish = true;
             }
             else
             {
                 model.Cpublish = false;
             }
         }
         return(model);
     }
     else
     {
         return(null);
     }
 }
示例#12
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LearnSite.Model.Courses GetModel(int Cid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Cid,Ctitle,Cclass,Ccontent,Cdate,Chit,Cobj,Cterm,Cks,Cfiletype,Cupload,Chid,Cpublish from Courses ");
            strSql.Append(" where Cid=@Cid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Cid", SqlDbType.Int, 4)
            };
            parameters[0].Value = Cid;

            LearnSite.Model.Courses model = new LearnSite.Model.Courses();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Cid"].ToString() != "")
                {
                    model.Cid = int.Parse(ds.Tables[0].Rows[0]["Cid"].ToString());
                }
                model.Ctitle   = ds.Tables[0].Rows[0]["Ctitle"].ToString();
                model.Cclass   = ds.Tables[0].Rows[0]["Cclass"].ToString();
                model.Ccontent = ds.Tables[0].Rows[0]["Ccontent"].ToString();
                if (ds.Tables[0].Rows[0]["Cdate"].ToString() != "")
                {
                    model.Cdate = DateTime.Parse(ds.Tables[0].Rows[0]["Cdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Chit"].ToString() != "")
                {
                    model.Chit = int.Parse(ds.Tables[0].Rows[0]["Chit"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cobj"].ToString() != "")
                {
                    model.Cobj = int.Parse(ds.Tables[0].Rows[0]["Cobj"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cterm"].ToString() != "")
                {
                    model.Cterm = int.Parse(ds.Tables[0].Rows[0]["Cterm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cks"].ToString() != "")
                {
                    model.Cks = int.Parse(ds.Tables[0].Rows[0]["Cks"].ToString());
                }
                model.Cfiletype = ds.Tables[0].Rows[0]["Cfiletype"].ToString();
                if (ds.Tables[0].Rows[0]["Cupload"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Cupload"].ToString() == "1") || (ds.Tables[0].Rows[0]["Cupload"].ToString().ToLower() == "true"))
                    {
                        model.Cupload = true;
                    }
                    else
                    {
                        model.Cupload = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Chid"].ToString() != "")
                {
                    model.Chid = int.Parse(ds.Tables[0].Rows[0]["Chid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cpublish"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Cpublish"].ToString() == "1") || (ds.Tables[0].Rows[0]["Cpublish"].ToString().ToLower() == "true"))
                    {
                        model.Cpublish = true;
                    }
                    else
                    {
                        model.Cpublish = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }