示例#1
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<DB_TeleBill.Model.m_Role> DataTableToList(DataSet ds)
		{
			List<DB_TeleBill.Model.m_Role> modelList = new List<DB_TeleBill.Model.m_Role>();
			if (ds == null) return modelList;
            DataTable dt = ds.Tables[0];
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				DB_TeleBill.Model.m_Role model;
				for (int n = 0; n < rowsCount; n++)
				{
				  model = new DB_TeleBill.Model.m_Role();	
                  if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
				  {
				      model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
				  }
				  if(dt.Rows[n]["vc_Name"]!=null && dt.Rows[n]["vc_Name"].ToString()!="")
				  {
				     model.vc_Name= dt.Rows[n]["vc_Name"].ToString();
				  }
				  if(dt.Rows[n]["vc_Memo"]!=null && dt.Rows[n]["vc_Memo"].ToString()!="")
				  {
				     model.vc_Memo= dt.Rows[n]["vc_Memo"].ToString();
				  }
				  if(dt.Rows[n]["i_Flag"]!=null && dt.Rows[n]["i_Flag"].ToString()!="")
				  {
				      model.i_Flag=int.Parse(dt.Rows[n]["i_Flag"].ToString());
				  }
				   modelList.Add(model);
				
				}
			}
			return modelList;
		}
示例#2
0
		/// <summary>
		/// 根据条件得到一个对象实体
		/// </summary>
		public DB_TeleBill.Model.m_Role GetModel(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("  select top 1 ");
			strSql.Append("  ID, vc_Name, vc_Memo, i_Flag  ");			
			strSql.Append("  from m_Role ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			DB_TeleBill.Model.m_Role model=new DB_TeleBill.Model.m_Role();
			DataSet ds=GetDataSet(strSql.ToString());
			if(ds!=null && ds.Tables[0].Rows.Count>0)
			{
                model=DataTableToList(ds)[0];						
				return model;
			}
			else
			{
				return null;
			}
		}