Exemple #1
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<Maticsoft.Model.Tao.CourseModule> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Tao.CourseModule> modelList = new List<Maticsoft.Model.Tao.CourseModule>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Maticsoft.Model.Tao.CourseModule model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Maticsoft.Model.Tao.CourseModule();
             if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
             {
                 model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
             }
             if (dt.Rows[n]["CourseID"] != null && dt.Rows[n]["CourseID"].ToString() != "")
             {
                 model.CourseID = int.Parse(dt.Rows[n]["CourseID"].ToString());
             }
             if (dt.Rows[n]["ModuleID"] != null && dt.Rows[n]["ModuleID"].ToString() != "")
             {
                 model.ModuleID = int.Parse(dt.Rows[n]["ModuleID"].ToString());
             }
             if (dt.Rows[n]["ModuleIndex"] != null && dt.Rows[n]["ModuleIndex"].ToString() != "")
             {
                 model.ModuleIndex = int.Parse(dt.Rows[n]["ModuleIndex"].ToString());
             }
             if (dt.Rows[n]["CreateDate"] != null && dt.Rows[n]["CreateDate"].ToString() != "")
             {
                 model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
             }
             if (dt.Rows[n]["Status"] != null && dt.Rows[n]["Status"].ToString() != "")
             {
                 model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
             }
             if (dt.Rows[n]["UpdateDate"] != null && dt.Rows[n]["UpdateDate"].ToString() != "")
             {
                 model.UpdateDate = DateTime.Parse(dt.Rows[n]["UpdateDate"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Exemple #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Tao.CourseModule GetModel(string strWhere)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select  top 1 * from Tao_CourseModule ");
     if (!string.IsNullOrEmpty(strWhere))
     {
         strSql.Append(" where " + strWhere);
     }
     Maticsoft.Model.Tao.CourseModule model = new Maticsoft.Model.Tao.CourseModule();
     DataSet ds = DbHelperSQL.Query(strSql.ToString());
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
         {
             model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CourseID"] != null && ds.Tables[0].Rows[0]["CourseID"].ToString() != "")
         {
             model.CourseID = int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ModuleID"] != null && ds.Tables[0].Rows[0]["ModuleID"].ToString() != "")
         {
             model.ModuleID = int.Parse(ds.Tables[0].Rows[0]["ModuleID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ModuleIndex"] != null && ds.Tables[0].Rows[0]["ModuleIndex"].ToString() != "")
         {
             model.ModuleIndex = int.Parse(ds.Tables[0].Rows[0]["ModuleIndex"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
         }
         if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
         {
             model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
         }
         if (ds.Tables[0].Rows[0]["UpdateDate"] != null && ds.Tables[0].Rows[0]["UpdateDate"].ToString() != "")
         {
             model.UpdateDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Tao.CourseModule GetFirstModel(int cid)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("SELECT TOP 1 A.* FROM dbo.Tao_CourseModule A ");
     strSql.Append("LEFT JOIN dbo.Tao_Courses B ON A.CourseID=b.CourseID ");
     strSql.Append("LEFT JOIN dbo.Tao_Modules C ON A.ModuleID=C.ModuleID ");
     strSql.AppendFormat("WHERE A.CourseID={0} AND C.Status=3  ", cid);
     strSql.Append("ORDER BY A.ModuleIndex ASC ");
     Maticsoft.Model.Tao.CourseModule model = new Maticsoft.Model.Tao.CourseModule();
     DataSet ds = DbHelperSQL.Query(strSql.ToString());
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
         {
             model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CourseID"] != null && ds.Tables[0].Rows[0]["CourseID"].ToString() != "")
         {
             model.CourseID = int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ModuleID"] != null && ds.Tables[0].Rows[0]["ModuleID"].ToString() != "")
         {
             model.ModuleID = int.Parse(ds.Tables[0].Rows[0]["ModuleID"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ModuleIndex"] != null && ds.Tables[0].Rows[0]["ModuleIndex"].ToString() != "")
         {
             model.ModuleIndex = int.Parse(ds.Tables[0].Rows[0]["ModuleIndex"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
         }
         if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
         {
             model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
         }
         if (ds.Tables[0].Rows[0]["UpdateDate"] != null && ds.Tables[0].Rows[0]["UpdateDate"].ToString() != "")
         {
             model.UpdateDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Tao.CourseModule GetModel(int CourseID, int ModuleID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ID,CourseID,ModuleID,ModuleIndex,CreateDate,Status,UpdateDate from Tao_CourseModule ");
            strSql.Append(" where CourseID=@CourseID and ModuleID=@ModuleID");
            SqlParameter[] parameters = {
                    new SqlParameter("@CourseID", SqlDbType.Int,4),
                                        new SqlParameter("@ModuleID", SqlDbType.Int,4)};
            parameters[0].Value = CourseID;
            parameters[1].Value = ModuleID;

            Maticsoft.Model.Tao.CourseModule model = new Maticsoft.Model.Tao.CourseModule();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CourseID"] != null && ds.Tables[0].Rows[0]["CourseID"].ToString() != "")
                {
                    model.CourseID = int.Parse(ds.Tables[0].Rows[0]["CourseID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ModuleID"] != null && ds.Tables[0].Rows[0]["ModuleID"].ToString() != "")
                {
                    model.ModuleID = int.Parse(ds.Tables[0].Rows[0]["ModuleID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ModuleIndex"] != null && ds.Tables[0].Rows[0]["ModuleIndex"].ToString() != "")
                {
                    model.ModuleIndex = int.Parse(ds.Tables[0].Rows[0]["ModuleIndex"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Status"] != null && ds.Tables[0].Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UpdateDate"] != null && ds.Tables[0].Rows[0]["UpdateDate"].ToString() != "")
                {
                    model.UpdateDate = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateDate"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
        protected void btnSava_Click(object sender, EventArgs e)
        {
            int iCourseId = 0;
            if (Request.QueryString["CourseId"] != null)
            {
                iCourseId = int.Parse(Request.QueryString["CourseId"]);
                cid = iCourseId;
            }
            if (string.IsNullOrEmpty(this.txtModuleName.Text.Trim()))
            {
                this.ErrorMsg.Visible = true;
                this.ErrorMsg.Text = "小节名称不能为空";
                return;
            }
            if (string.IsNullOrEmpty(this.btnSava.CommandArgument))
            {
                module = new Model.Tao.Modules();
            }
            else
            {
                int mId = int.Parse(this.btnSava.CommandArgument);
                module = modulesBll.GetModel(mId);
            }
            //Maticsoft.Model.Tao.Modules module = new Maticsoft.Model.Tao.Modules();
            module.ModuleName = this.txtModuleName.Text.Trim();
            module.Description = this.txtDescription.Text.Trim();

            int iResult = 0;
            //判断是否为新增小节,当this.btnSava.CommandArgument有值,则为”新增“,否则为”修改“
            if (string.IsNullOrEmpty(this.btnSava.CommandArgument))
            {
                //添加课程小节
                module.CreatedDate = DateTime.Now;
                iResult = modulesBll.Add(module);

                if (iResult > 0)
                {
                    Maticsoft.Model.Tao.CourseModule courseModule = new Maticsoft.Model.Tao.CourseModule();
                    courseModule.CourseID = iCourseId;
                    courseModule.ModuleID = iResult;
                    courseModule.ModuleIndex = courseModuleBll.GetMaxModuleIndex(iCourseId);

                    if (courseModuleBll.Add(courseModule) > 0)
                    {
                        this.ErrorMsg.Text = "新增课程成功!";
                    }
                }
                else
                {
                    modulesBll.Delete(iResult);
                    this.ErrorMsg.Text = "新增课程小节失败,请重试!";
                }
            }
            else
            {
                module.ModuleID = int.Parse(this.btnSava.CommandArgument);
                this.btnSava.CommandArgument = null;
                module.UpdatedDate = DateTime.Now;
                modulesBll.Update(module);
            }

            this.txtDescription.Text = string.Empty;
            this.txtModuleName.Text = string.Empty;
            this.ErrorMsg.Visible = false;

            BindData(iCourseId);
        }