Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(YJUI.Model.ui_org model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ui_org set ");
            strSql.Append("fatherid=@fatherid,");
            strSql.Append("orgcode=@orgcode,");
            strSql.Append("orgname=@orgname,");
            strSql.Append("icon=@icon,");
            strSql.Append("attr_a=@attr_a,");
            strSql.Append("attr_b=@attr_b ");
            //  strSql.Append("crdate=@crdate");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fatherid", SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@orgcode",  SqlDbType.NVarChar,         30),
                new SqlParameter("@orgname",  SqlDbType.NVarChar,         50),
                new SqlParameter("@icon",     SqlDbType.VarChar,          20),
                new SqlParameter("@attr_a",   SqlDbType.NVarChar,         30),
                new SqlParameter("@attr_b",   SqlDbType.NVarChar,         30),
                //new SqlParameter("@crdate", SqlDbType.DateTime),
                new SqlParameter("@id",       SqlDbType.UniqueIdentifier, 16)
            };
            if (model.fatherid != new Guid())
            {
                parameters[0].Value = model.fatherid;
            }
            else
            {
                parameters[0].Value = DBNull.Value;
            }
            parameters[1].Value = model.orgcode;
            parameters[2].Value = model.orgname;
            parameters[3].Value = model.icon;
            parameters[4].Value = model.attr_a;
            parameters[5].Value = model.attr_b;
            //  parameters[6].Value = model.crdate;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(YJUI.Model.ui_org model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ui_org(");
            strSql.Append("id,fatherid,orgcode,orgname,icon,attr_a,attr_b,crdate)");
            strSql.Append(" values (");
            strSql.Append("@id,@fatherid,@orgcode,@orgname,@icon,@attr_a,@attr_b,@crdate)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@fatherid", SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@orgcode",  SqlDbType.NVarChar,         30),
                new SqlParameter("@orgname",  SqlDbType.NVarChar,         50),
                new SqlParameter("@icon",     SqlDbType.VarChar,          20),
                new SqlParameter("@attr_a",   SqlDbType.NVarChar,         30),
                new SqlParameter("@attr_b",   SqlDbType.NVarChar,         30),
                new SqlParameter("@crdate",   SqlDbType.DateTime)
            };
            parameters[0].Value = Guid.NewGuid();
            if (model.fatherid != new Guid())
            {
                parameters[1].Value = model.fatherid;
            }
            else
            {
                parameters[1].Value = DBNull.Value;
            }
            // == new Guid() ? DBNull.Value : model.fatherid;

            parameters[2].Value = model.orgcode;
            parameters[3].Value = model.orgname;
            parameters[4].Value = model.icon;
            parameters[5].Value = model.attr_a;
            parameters[6].Value = model.attr_b;
            parameters[7].Value = model.crdate;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YJUI.Model.ui_org DataRowToModel(DataRow row)
 {
     YJUI.Model.ui_org model = new YJUI.Model.ui_org();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = new Guid(row["id"].ToString());
         }
         if (row["fatherid"] != null && row["fatherid"].ToString() != "")
         {
             model.fatherid = new Guid(row["fatherid"].ToString());
         }
         if (row["orgcode"] != null)
         {
             model.orgcode = row["orgcode"].ToString();
         }
         if (row["orgname"] != null)
         {
             model.orgname = row["orgname"].ToString();
         }
         if (row["icon"] != null)
         {
             model.icon = row["icon"].ToString();
         }
         if (row["attr_a"] != null)
         {
             model.attr_a = row["attr_a"].ToString();
         }
         if (row["attr_b"] != null)
         {
             model.attr_b = row["attr_b"].ToString();
         }
         if (row["crdate"] != null && row["crdate"].ToString() != "")
         {
             model.crdate = DateTime.Parse(row["crdate"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public YJUI.Model.ui_org GetModel(Guid id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,fatherid,orgcode,orgname,icon,attr_a,attr_b,crdate from ui_org ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = id;

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

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