示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MyTest.Model.Sys_ItemsModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_Items(");
            strSql.Append("F_Id,F_ParentId,F_EnCode,F_FullName,F_IsTree,F_Layers,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId)");
            strSql.Append(" values (");
            strSql.Append("@F_Id,@F_ParentId,@F_EnCode,@F_FullName,@F_IsTree,@F_Layers,@F_SortCode,@F_DeleteMark,@F_EnabledMark,@F_Description,@F_CreatorTime,@F_CreatorUserId,@F_LastModifyTime,@F_LastModifyUserId,@F_DeleteTime,@F_DeleteUserId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Id",               SqlDbType.VarChar,    50),
                new SqlParameter("@F_ParentId",         SqlDbType.VarChar,    50),
                new SqlParameter("@F_EnCode",           SqlDbType.VarChar,    50),
                new SqlParameter("@F_FullName",         SqlDbType.VarChar,    50),
                new SqlParameter("@F_IsTree",           SqlDbType.Bit,         1),
                new SqlParameter("@F_Layers",           SqlDbType.Int,         4),
                new SqlParameter("@F_SortCode",         SqlDbType.Int,         4),
                new SqlParameter("@F_DeleteMark",       SqlDbType.Bit,         1),
                new SqlParameter("@F_EnabledMark",      SqlDbType.Bit,         1),
                new SqlParameter("@F_Description",      SqlDbType.VarChar,   500),
                new SqlParameter("@F_CreatorTime",      SqlDbType.DateTime),
                new SqlParameter("@F_CreatorUserId",    SqlDbType.VarChar,    50),
                new SqlParameter("@F_LastModifyTime",   SqlDbType.DateTime),
                new SqlParameter("@F_LastModifyUserId", SqlDbType.VarChar,    50),
                new SqlParameter("@F_DeleteTime",       SqlDbType.DateTime),
                new SqlParameter("@F_DeleteUserId",     SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.F_Id;
            parameters[1].Value  = model.F_ParentId;
            parameters[2].Value  = model.F_EnCode;
            parameters[3].Value  = model.F_FullName;
            parameters[4].Value  = model.F_IsTree;
            parameters[5].Value  = model.F_Layers;
            parameters[6].Value  = model.F_SortCode;
            parameters[7].Value  = model.F_DeleteMark;
            parameters[8].Value  = model.F_EnabledMark;
            parameters[9].Value  = model.F_Description;
            parameters[10].Value = model.F_CreatorTime;
            parameters[11].Value = model.F_CreatorUserId;
            parameters[12].Value = model.F_LastModifyTime;
            parameters[13].Value = model.F_LastModifyUserId;
            parameters[14].Value = model.F_DeleteTime;
            parameters[15].Value = model.F_DeleteUserId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MyTest.Model.Sys_ItemsModel GetModel(string F_Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_Id,F_ParentId,F_EnCode,F_FullName,F_IsTree,F_Layers,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId from Sys_Items ");
            strSql.Append(" where F_Id=@F_Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_Id", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = F_Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MyTest.Model.Sys_ItemsModel DataRowToModel(DataRow row)
 {
     MyTest.Model.Sys_ItemsModel model = new MyTest.Model.Sys_ItemsModel();
     if (row != null)
     {
         if (row["F_Id"] != null)
         {
             model.F_Id = row["F_Id"].ToString();
         }
         if (row["F_ParentId"] != null)
         {
             model.F_ParentId = row["F_ParentId"].ToString();
         }
         if (row["F_EnCode"] != null)
         {
             model.F_EnCode = row["F_EnCode"].ToString();
         }
         if (row["F_FullName"] != null)
         {
             model.F_FullName = row["F_FullName"].ToString();
         }
         if (row["F_IsTree"] != null && row["F_IsTree"].ToString() != "")
         {
             if ((row["F_IsTree"].ToString() == "1") || (row["F_IsTree"].ToString().ToLower() == "true"))
             {
                 model.F_IsTree = true;
             }
             else
             {
                 model.F_IsTree = false;
             }
         }
         if (row["F_Layers"] != null && row["F_Layers"].ToString() != "")
         {
             model.F_Layers = int.Parse(row["F_Layers"].ToString());
         }
         if (row["F_SortCode"] != null && row["F_SortCode"].ToString() != "")
         {
             model.F_SortCode = int.Parse(row["F_SortCode"].ToString());
         }
         if (row["F_DeleteMark"] != null && row["F_DeleteMark"].ToString() != "")
         {
             if ((row["F_DeleteMark"].ToString() == "1") || (row["F_DeleteMark"].ToString().ToLower() == "true"))
             {
                 model.F_DeleteMark = true;
             }
             else
             {
                 model.F_DeleteMark = false;
             }
         }
         if (row["F_EnabledMark"] != null && row["F_EnabledMark"].ToString() != "")
         {
             if ((row["F_EnabledMark"].ToString() == "1") || (row["F_EnabledMark"].ToString().ToLower() == "true"))
             {
                 model.F_EnabledMark = true;
             }
             else
             {
                 model.F_EnabledMark = false;
             }
         }
         if (row["F_Description"] != null)
         {
             model.F_Description = row["F_Description"].ToString();
         }
         if (row["F_CreatorTime"] != null && row["F_CreatorTime"].ToString() != "")
         {
             model.F_CreatorTime = DateTime.Parse(row["F_CreatorTime"].ToString());
         }
         if (row["F_CreatorUserId"] != null)
         {
             model.F_CreatorUserId = row["F_CreatorUserId"].ToString();
         }
         if (row["F_LastModifyTime"] != null && row["F_LastModifyTime"].ToString() != "")
         {
             model.F_LastModifyTime = DateTime.Parse(row["F_LastModifyTime"].ToString());
         }
         if (row["F_LastModifyUserId"] != null)
         {
             model.F_LastModifyUserId = row["F_LastModifyUserId"].ToString();
         }
         if (row["F_DeleteTime"] != null && row["F_DeleteTime"].ToString() != "")
         {
             model.F_DeleteTime = DateTime.Parse(row["F_DeleteTime"].ToString());
         }
         if (row["F_DeleteUserId"] != null)
         {
             model.F_DeleteUserId = row["F_DeleteUserId"].ToString();
         }
     }
     return(model);
 }