예제 #1
0
 public static Project CreateModel(DataRow dr)
 {
     Project project = new Project();
     if (dr.Table.Columns.Contains("Id"))
     {
         project.Id = LibConvert.ObjToInt64(dr["Id"]);
     }
     if (dr.Table.Columns.Contains("ProjectName"))
     {
         project.ProjectName = LibConvert.ObjToStr(dr["ProjectName"]);
     }
     if (dr.Table.Columns.Contains("CategoryIds"))
     {
         project.CategoryIds = LibConvert.ObjToStr(dr["CategoryIds"]);
     }
     if (dr.Table.Columns.Contains("Remark"))
     {
         project.Remark = LibConvert.ObjToStr(dr["Remark"]);
     }
     if (dr.Table.Columns.Contains("CreateTime"))
     {
         project.CreateTime = LibConvert.ObjToDateTime(dr["CreateTime"]);
     }
     return project;
 }
예제 #2
0
 /// <summary>
 /// 根据name读取一条信息
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public Project GetByName(string conn,string name)
 {
     Project project = new Project();
     string sql = "SELECT Id,ProjectName,CategoryIds,Remark,CreateTime FROM Project WHERE ProjectName=@pname";
     SqlParameter[] paramters = new SqlParameter[] { new SqlParameter("@pname", name) };
     DataTable dt = SqlServerHelper.Get(conn, sql, paramters);
     if (dt.Rows.Count > 0)
     {
         project = Project.CreateModel(dt.Rows[0]);
     }
     return project;
 }
예제 #3
0
 /// <summary>
 /// 读取列表
 /// </summary>
 /// <returns></returns>
 public List<Project> GetList(string conn)
 {
     List<Project> list = new List<Project>();
     string sql = "SELECT Id,ProjectName,CategoryIds,Remark,CreateTime FROM Project";
     DataTable dt = SqlServerHelper.Get(conn, sql);
     if (dt.Rows.Count > 0)
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             Project project = new Project();
             project = Project.CreateModel(dt.Rows[i]);
             list.Add(project);
         }
     }
     return list;
 }