Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Yo_Organize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Yo_Organize set ");
            strSql.Append("FatherOrganize=@FatherOrganize,");
            strSql.Append("OrganizeName=@OrganizeName,");
            strSql.Append("Note=@Note");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FatherOrganize", SqlDbType.Int,        4),
                new SqlParameter("@OrganizeName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Note",           SqlDbType.NVarChar, 250),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FatherOrganize;
            parameters[1].Value = model.OrganizeName;
            parameters[2].Value = model.Note;
            parameters[3].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.Yo_Organize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Yo_Organize(");
            strSql.Append("FatherOrganize,OrganizeName,Note)");
            strSql.Append(" values (");
            strSql.Append("@FatherOrganize,@OrganizeName,@Note)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FatherOrganize", SqlDbType.Int,       4),
                new SqlParameter("@OrganizeName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@Note",           SqlDbType.NVarChar, 250)
            };
            parameters[0].Value = model.FatherOrganize;
            parameters[1].Value = model.OrganizeName;
            parameters[2].Value = model.Note;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Yo_Organize DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Yo_Organize model = new Maticsoft.Model.Yo_Organize();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["FatherOrganize"] != null && row["FatherOrganize"].ToString() != "")
         {
             model.FatherOrganize = int.Parse(row["FatherOrganize"].ToString());
         }
         if (row["OrganizeName"] != null)
         {
             model.OrganizeName = row["OrganizeName"].ToString();
         }
         if (row["Note"] != null)
         {
             model.Note = row["Note"].ToString();
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Yo_Organize GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,FatherOrganize,OrganizeName,Note from Yo_Organize ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }