コード例 #1
0
ファイル: TopicDiscuss.cs プロジェクト: pyteach/Learnsite
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LearnSite.Model.TopicDiscuss GetModel(DataTable dt, int Tsort)
        {
            LearnSite.Model.TopicDiscuss model = new LearnSite.Model.TopicDiscuss();
            int Count = dt.Rows.Count;

            if (Count > 0)
            {
                if (Tsort < Count)
                {
                    if (dt.Rows[Tsort]["Tid"].ToString() != "")
                    {
                        model.Tid = int.Parse(dt.Rows[Tsort]["Tid"].ToString());
                    }
                    if (dt.Rows[Tsort]["Tcid"].ToString() != "")
                    {
                        model.Tcid = int.Parse(dt.Rows[Tsort]["Tcid"].ToString());
                    }
                    model.Ttitle   = dt.Rows[Tsort]["Ttitle"].ToString();
                    model.Tcontent = dt.Rows[Tsort]["Tcontent"].ToString();
                    if (dt.Rows[Tsort]["Tcount"].ToString() != "")
                    {
                        model.Tcount = int.Parse(dt.Rows[Tsort]["Tcount"].ToString());
                    }
                    if (dt.Rows[Tsort]["Tteacher"].ToString() != "")
                    {
                        model.Tteacher = int.Parse(dt.Rows[Tsort]["Tteacher"].ToString());
                    }
                    if (dt.Rows[Tsort]["Tdate"].ToString() != "")
                    {
                        model.Tdate = DateTime.Parse(dt.Rows[Tsort]["Tdate"].ToString());
                    }
                    if (dt.Rows[Tsort]["Tclose"].ToString() != "")
                    {
                        if ((dt.Rows[Tsort]["Tclose"].ToString() == "1") || (dt.Rows[Tsort]["Tclose"].ToString().ToLower() == "true"))
                        {
                            model.Tclose = true;
                        }
                        else
                        {
                            model.Tclose = false;
                        }
                    }
                    model.Tresult = dt.Rows[Tsort]["Tresult"].ToString();
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: TopicDiscuss.cs プロジェクト: pyteach/Learnsite
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LearnSite.Model.TopicDiscuss GetModel(int Tid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Tid,Tcid,Ttitle,Tcontent,Tcount,Tteacher,Tdate,Tclose,Tresult ");
            strSql.Append(" from TopicDiscuss ");
            strSql.Append(" where Tid=" + Tid + "");
            LearnSite.Model.TopicDiscuss model = new LearnSite.Model.TopicDiscuss();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Tid"].ToString() != "")
                {
                    model.Tid = int.Parse(ds.Tables[0].Rows[0]["Tid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Tcid"].ToString() != "")
                {
                    model.Tcid = int.Parse(ds.Tables[0].Rows[0]["Tcid"].ToString());
                }
                model.Ttitle   = ds.Tables[0].Rows[0]["Ttitle"].ToString();
                model.Tcontent = ds.Tables[0].Rows[0]["Tcontent"].ToString();
                if (ds.Tables[0].Rows[0]["Tcount"].ToString() != "")
                {
                    model.Tcount = int.Parse(ds.Tables[0].Rows[0]["Tcount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Tteacher"].ToString() != "")
                {
                    model.Tteacher = int.Parse(ds.Tables[0].Rows[0]["Tteacher"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Tdate"].ToString() != "")
                {
                    model.Tdate = DateTime.Parse(ds.Tables[0].Rows[0]["Tdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Tclose"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Tclose"].ToString() == "1") || (ds.Tables[0].Rows[0]["Tclose"].ToString().ToLower() == "true"))
                    {
                        model.Tclose = true;
                    }
                    else
                    {
                        model.Tclose = false;
                    }
                }
                model.Tresult = ds.Tables[0].Rows[0]["Tresult"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: TopicDiscuss.cs プロジェクト: pyteach/Learnsite
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LearnSite.Model.TopicDiscuss model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TopicDiscuss set ");
            strSql.Append("Tcid=@Tcid,");
            strSql.Append("Ttitle=@Ttitle,");
            strSql.Append("Tcontent=@Tcontent,");
            strSql.Append("Tcount=@Tcount,");
            strSql.Append("Tteacher=@Tteacher,");
            strSql.Append("Tdate=@Tdate,");
            strSql.Append("Tclose=@Tclose,");
            strSql.Append("Tresult=@Tresult");
            strSql.Append(" where Tid=@Tid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Tcid",     SqlDbType.Int,        4),
                new SqlParameter("@Ttitle",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Tcontent", SqlDbType.NText),
                new SqlParameter("@Tcount",   SqlDbType.Int,        4),
                new SqlParameter("@Tteacher", SqlDbType.Int,        4),
                new SqlParameter("@Tdate",    SqlDbType.DateTime),
                new SqlParameter("@Tclose",   SqlDbType.Bit,        1),
                new SqlParameter("@Tresult",  SqlDbType.NText),
                new SqlParameter("@Tid",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Tcid;
            parameters[1].Value = model.Ttitle;
            parameters[2].Value = model.Tcontent;
            parameters[3].Value = model.Tcount;
            parameters[4].Value = model.Tteacher;
            parameters[5].Value = model.Tdate;
            parameters[6].Value = model.Tclose;
            parameters[7].Value = model.Tresult;
            parameters[8].Value = model.Tid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: ImportCourse.cs プロジェクト: pyteach/Learnsite
        /// <summary>
        /// 添加学案讨论ok
        /// </summary>
        /// <param name="dtTopicDiscuss"></param>
        /// <param name="Cid"></param>
        private static void CreateTopicDiscuss(DataTable dt, int Cid, int Hid)
        {
            int dCount = dt.Rows.Count;

            LearnSite.BLL.TopicDiscuss bll = new LearnSite.BLL.TopicDiscuss();
            for (int i = 0; i < dCount; i++)
            {
                LearnSite.Model.TopicDiscuss model = new LearnSite.Model.TopicDiscuss();
                model = bll.GetModel(dt, i);
                int    oldMcid      = model.Tcid.Value;
                string thisMcontent = model.Tcontent;
                model.Tcid     = Cid; //更换成新学案编号
                model.Tteacher = Hid; //换成导入老师
                string oldstr = "Store/" + oldMcid.ToString();
                string newstr = "Store/" + Cid.ToString();
                model.Tcontent = thisMcontent.Replace(oldstr, newstr); //替换链接地址
                bll.Add(model);                                        //增加学案讨论
            }
        }
コード例 #5
0
ファイル: TopicDiscuss.cs プロジェクト: pyteach/Learnsite
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LearnSite.Model.TopicDiscuss model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TopicDiscuss(");
            strSql.Append("Tcid,Ttitle,Tcontent,Tcount,Tteacher,Tdate,Tclose)");
            strSql.Append(" values (");
            strSql.Append("@Tcid,@Ttitle,@Tcontent,@Tcount,@Tteacher,@Tdate,@Tclose)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Tcid",     SqlDbType.Int,        4),
                new SqlParameter("@Ttitle",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Tcontent", SqlDbType.NText),
                new SqlParameter("@Tcount",   SqlDbType.Int,        4),
                new SqlParameter("@Tteacher", SqlDbType.Int,        4),
                new SqlParameter("@Tdate",    SqlDbType.DateTime),
                new SqlParameter("@Tclose",   SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.Tcid;
            parameters[1].Value = model.Ttitle;
            parameters[2].Value = model.Tcontent;
            parameters[3].Value = model.Tcount;
            parameters[4].Value = model.Tteacher;
            parameters[5].Value = model.Tdate;
            parameters[6].Value = model.Tclose;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }