Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(JMP.MDL.jmp_Help_Content model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into jmp_Help_Content(");
            strSql.Append("ClassId,Title,Content,Count,CreateById,CreateByName,CreateOn,ISOverhead,UpdateById,UpdateByName,UpdateOn,PrentID,State,Type");
            strSql.Append(") values (");
            strSql.Append("@ClassId,@Title,@Content,@Count,@CreateById,@CreateByName,@CreateOn,@ISOverhead,@UpdateById,@UpdateByName,@UpdateOn,@PrentID,@State,@Type");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ClassId",      SqlDbType.Int,         4),
                new SqlParameter("@Title",        SqlDbType.NVarChar,  300),
                new SqlParameter("@Content",      SqlDbType.Text),
                new SqlParameter("@Count",        SqlDbType.Int,         4),
                new SqlParameter("@CreateById",   SqlDbType.Int,         4),
                new SqlParameter("@CreateByName", SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateOn",     SqlDbType.DateTime),
                new SqlParameter("@ISOverhead",   SqlDbType.Bit,         1),
                new SqlParameter("@UpdateById",   SqlDbType.Int,         4),
                new SqlParameter("@UpdateByName", SqlDbType.NVarChar,  100),
                new SqlParameter("@UpdateOn",     SqlDbType.DateTime),
                new SqlParameter("@PrentID",      SqlDbType.Int,         4),
                new SqlParameter("@State",        SqlDbType.Int,         4),
                new SqlParameter("@Type",         SqlDbType.Int, 4)
            };

            parameters[0].Value  = model.ClassId;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.Content;
            parameters[3].Value  = model.Count;
            parameters[4].Value  = model.CreateById;
            parameters[5].Value  = model.CreateByName;
            parameters[6].Value  = model.CreateOn;
            parameters[7].Value  = model.ISOverhead;
            parameters[8].Value  = model.UpdateById;
            parameters[9].Value  = model.UpdateByName;
            parameters[10].Value = model.UpdateOn;
            parameters[11].Value = model.PrentID;
            parameters[12].Value = model.State;
            parameters[13].Value = model.Type;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <JMP.MDL.jmp_Help_Content> DataTableToList(DataTable dt)
        {
            List <JMP.MDL.jmp_Help_Content> modelList = new List <JMP.MDL.jmp_Help_Content>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                JMP.MDL.jmp_Help_Content model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new JMP.MDL.jmp_Help_Content();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["ClassId"].ToString() != "")
                    {
                        model.ClassId = int.Parse(dt.Rows[n]["ClassId"].ToString());
                    }
                    model.Title   = dt.Rows[n]["Title"].ToString();
                    model.Content = dt.Rows[n]["Content"].ToString();
                    if (dt.Rows[n]["Count"].ToString() != "")
                    {
                        model.Count = int.Parse(dt.Rows[n]["Count"].ToString());
                    }
                    if (dt.Rows[n]["CreateById"].ToString() != "")
                    {
                        model.CreateById = int.Parse(dt.Rows[n]["CreateById"].ToString());
                    }
                    model.CreateByName = dt.Rows[n]["CreateByName"].ToString();
                    if (dt.Rows[n]["CreateOn"].ToString() != "")
                    {
                        model.CreateOn = DateTime.Parse(dt.Rows[n]["CreateOn"].ToString());
                    }
                    if (dt.Rows[n]["ISOverhead"].ToString() != "")
                    {
                        if ((dt.Rows[n]["ISOverhead"].ToString() == "1") || (dt.Rows[n]["ISOverhead"].ToString().ToLower() == "true"))
                        {
                            model.ISOverhead = true;
                        }
                        else
                        {
                            model.ISOverhead = false;
                        }
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(JMP.MDL.jmp_Help_Content model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(JMP.MDL.jmp_Help_Content model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(JMP.MDL.jmp_Help_Content model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update jmp_Help_Content set ");
            strSql.Append(" UpdateById = @UpdateById , ");
            strSql.Append(" UpdateByName = @UpdateByName , ");
            strSql.Append(" UpdateOn = @UpdateOn , ");
            strSql.Append(" ISOverhead = @ISOverhead , ");
            strSql.Append(" State = @State , ");
            strSql.Append(" PrentID = @PrentID , ");
            strSql.Append(" ClassId = @ClassId , ");
            strSql.Append(" Title = @Title , ");
            strSql.Append(" Content = @Content ,");
            strSql.Append(" Count = @Count ,");
            strSql.Append(" CreateById = @CreateById ,");
            strSql.Append(" CreateByName = @CreateByName ,");
            strSql.Append(" CreateOn = @CreateOn, ");
            strSql.Append(" Type = @Type  ");
            strSql.Append(" where ID=@ID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.Int,         4),
                new SqlParameter("@UpdateById",   SqlDbType.Int,         4),
                new SqlParameter("@UpdateByName", SqlDbType.NVarChar,  100),
                new SqlParameter("@UpdateOn",     SqlDbType.DateTime),
                new SqlParameter("@ISOverhead",   SqlDbType.Bit,         1),
                new SqlParameter("@State",        SqlDbType.Int,         4),
                new SqlParameter("@PrentID",      SqlDbType.Int,         4),
                new SqlParameter("@ClassId",      SqlDbType.Int,         4),
                new SqlParameter("@Title",        SqlDbType.NVarChar,  300),
                new SqlParameter("@Content",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@Count",        SqlDbType.Int,         4),
                new SqlParameter("@CreateById",   SqlDbType.Int,         4),
                new SqlParameter("@CreateByName", SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateOn",     SqlDbType.DateTime),
                new SqlParameter("@Type",         SqlDbType.Int, 4)
            };

            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.UpdateById;
            parameters[2].Value  = model.UpdateByName;
            parameters[3].Value  = model.UpdateOn;
            parameters[4].Value  = model.ISOverhead;
            parameters[5].Value  = model.State;
            parameters[6].Value  = model.PrentID;
            parameters[7].Value  = model.ClassId;
            parameters[8].Value  = model.Title;
            parameters[9].Value  = model.Content;
            parameters[10].Value = model.Count;
            parameters[11].Value = model.CreateById;
            parameters[12].Value = model.CreateByName;
            parameters[13].Value = model.CreateOn;
            parameters[14].Value = model.Type;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JMP.MDL.jmp_Help_Content GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID, ClassId,PrentID, Title, Content, Count, CreateById, CreateByName, CreateOn, ISOverhead ,PrentID,Type,State ");
            strSql.Append("  from jmp_Help_Content ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;


            JMP.MDL.jmp_Help_Content model = new JMP.MDL.jmp_Help_Content();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "")
                {
                    model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PrentID"].ToString() != "")
                {
                    model.PrentID = int.Parse(ds.Tables[0].Rows[0]["PrentID"].ToString());
                }
                model.Title   = ds.Tables[0].Rows[0]["Title"].ToString();
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["Count"].ToString() != "")
                {
                    model.Count = int.Parse(ds.Tables[0].Rows[0]["Count"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateById"].ToString() != "")
                {
                    model.CreateById = int.Parse(ds.Tables[0].Rows[0]["CreateById"].ToString());
                }
                model.CreateByName = ds.Tables[0].Rows[0]["CreateByName"].ToString();
                if (ds.Tables[0].Rows[0]["CreateOn"].ToString() != "")
                {
                    model.CreateOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreateOn"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ISOverhead"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["ISOverhead"].ToString() == "1") || (ds.Tables[0].Rows[0]["ISOverhead"].ToString().ToLower() == "true"))
                    {
                        model.ISOverhead = true;
                    }
                    else
                    {
                        model.ISOverhead = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["PrentID"].ToString() != "")
                {
                    model.PrentID = int.Parse(ds.Tables[0].Rows[0]["PrentID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
                {
                    model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
                }
                if (ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }