Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.SysConfig model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[SysConfig](");
            strSql.Append("RecordCreateTime,KeyType,KeyName,KeyVal,Description,CreatUserID,RecordUpdateUserID,RecordIsDelete,RecordUpdateTime");
            strSql.Append(") values (");
            strSql.Append("@RecordCreateTime,@KeyType,@KeyName,@KeyVal,@Description,@CreatUserID,@RecordUpdateUserID,@RecordIsDelete,@RecordUpdateTime");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecordCreateTime",   model.RecordCreateTime),
                new SqlParameter("@KeyType",            model.KeyType),
                new SqlParameter("@KeyName",            model.KeyName),
                new SqlParameter("@KeyVal",             model.KeyVal),
                new SqlParameter("@Description",        model.Description),
                new SqlParameter("@CreatUserID",        model.CreatUserID),
                new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID),
                new SqlParameter("@RecordIsDelete",     model.RecordIsDelete),
                new SqlParameter("@RecordUpdateTime",   model.RecordUpdateTime)
            };


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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.SysConfig GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id, RecordCreateTime, KeyType, KeyName, KeyVal, Description, CreatUserID, RecordUpdateUserID, RecordIsDelete, RecordUpdateTime  ");
            strSql.Append("  from dbo.[SysConfig] ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;


            BWJS.Model.SysConfig model = new BWJS.Model.SysConfig();
            DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.SysConfig DataRowToModel(DataRow row)
        {
            BWJS.Model.SysConfig model = new BWJS.Model.SysConfig();

            if (row != null)
            {
                if (row["Id"].ToString() != "")
                {
                    model.Id = int.Parse(row["Id"].ToString());
                }
                if (row["RecordCreateTime"].ToString() != "")
                {
                    model.RecordCreateTime = DateTime.Parse(row["RecordCreateTime"].ToString());
                }
                if (row["KeyType"].ToString() != "")
                {
                    model.KeyType = int.Parse(row["KeyType"].ToString());
                }
                model.KeyName     = row["KeyName"].ToString();
                model.KeyVal      = row["KeyVal"].ToString();
                model.Description = row["Description"].ToString();
                if (row["CreatUserID"].ToString() != "")
                {
                    model.CreatUserID = int.Parse(row["CreatUserID"].ToString());
                }
                if (row["RecordUpdateUserID"].ToString() != "")
                {
                    model.RecordUpdateUserID = int.Parse(row["RecordUpdateUserID"].ToString());
                }
                if (row["RecordIsDelete"].ToString() != "")
                {
                    if ((row["RecordIsDelete"].ToString() == "1") || (row["RecordIsDelete"].ToString().ToLower() == "true"))
                    {
                        model.RecordIsDelete = true;
                    }
                    else
                    {
                        model.RecordIsDelete = false;
                    }
                }
                if (row["RecordUpdateTime"].ToString() != "")
                {
                    model.RecordUpdateTime = DateTime.Parse(row["RecordUpdateTime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.SysConfig model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[SysConfig] set ");

            strSql.Append(" RecordCreateTime = @RecordCreateTime , ");
            strSql.Append(" KeyType = @KeyType , ");
            strSql.Append(" KeyName = @KeyName , ");
            strSql.Append(" KeyVal = @KeyVal , ");
            strSql.Append(" Description = @Description , ");
            strSql.Append(" CreatUserID = @CreatUserID , ");
            strSql.Append(" RecordUpdateUserID = @RecordUpdateUserID , ");
            strSql.Append(" RecordIsDelete = @RecordIsDelete , ");
            strSql.Append(" RecordUpdateTime = @RecordUpdateTime  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",                 model.Id),
                new SqlParameter("@RecordCreateTime",   model.RecordCreateTime),
                new SqlParameter("@KeyType",            model.KeyType),
                new SqlParameter("@KeyName",            model.KeyName),
                new SqlParameter("@KeyVal",             model.KeyVal),
                new SqlParameter("@Description",        model.Description),
                new SqlParameter("@CreatUserID",        model.CreatUserID),
                new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID),
                new SqlParameter("@RecordIsDelete",     model.RecordIsDelete),
                new SqlParameter("@RecordUpdateTime",   model.RecordUpdateTime)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BWJS.Model.SysConfig model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BWJS.Model.SysConfig model)
 {
     return(dal.Add(model));
 }