コード例 #1
0
ファイル: Sys_Departmentcs.cs プロジェクト: huajianhukai/JSOA
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public JSOA.Model.Sys_Department DataRowToModel(DataRow row)
 {
     JSOA.Model.Sys_Department model = new JSOA.Model.Sys_Department();
     if (row != null)
     {
         if (row["No"] != null)
         {
             model.No = row["No"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["ParentNo"] != null)
         {
             model.ParentNo = row["ParentNo"].ToString();
         }
         if (row["Remarks"] != null)
         {
             model.Remarks = row["Remarks"].ToString();
         }
     }
     return model;
 }
コード例 #2
0
ファイル: Sys_Departmentcs.cs プロジェクト: huajianhukai/JSOA
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JSOA.Model.Sys_Department GetModel(string No)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 No,Name,ParentNo,Remarks from Sys_Department ");
            strSql.Append(" where No=@No ");
            SqlParameter[] parameters = {
                    new SqlParameter("@No", SqlDbType.VarChar,50)			};
            parameters[0].Value = No;

            JSOA.Model.Sys_Department model = new JSOA.Model.Sys_Department();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }