/// <summary> /// 获得数据列表 /// </summary> public List<Maticsoft.Model.Tao.UserEmailAc> DataTableToList(DataTable dt) { List<Maticsoft.Model.Tao.UserEmailAc> modelList = new List<Maticsoft.Model.Tao.UserEmailAc>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Maticsoft.Model.Tao.UserEmailAc model; for (int n = 0; n < rowsCount; n++) { model = new Maticsoft.Model.Tao.UserEmailAc(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["UserId"] != null && dt.Rows[n]["UserId"].ToString() != "") { model.UserId = int.Parse(dt.Rows[n]["UserId"].ToString()); } if (dt.Rows[n]["Email"] != null && dt.Rows[n]["Email"].ToString() != "") { model.Email = dt.Rows[n]["Email"].ToString(); } if (dt.Rows[n]["IsActive"] != null && dt.Rows[n]["IsActive"].ToString() != "") { if ((dt.Rows[n]["IsActive"].ToString() == "1") || (dt.Rows[n]["IsActive"].ToString().ToLower() == "true")) { model.IsActive = true; } else { model.IsActive = false; } } if (dt.Rows[n]["AvtiveCode"] != null && dt.Rows[n]["AvtiveCode"].ToString() != "") { model.AvtiveCode = dt.Rows[n]["AvtiveCode"].ToString(); } modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Tao.UserEmailAc GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,UserId,Email,IsActive,AvtiveCode from Tao_UserEmailAc "); strSql.Append(" where UserId=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; Maticsoft.Model.Tao.UserEmailAc model = new Maticsoft.Model.Tao.UserEmailAc(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["UserId"] != null && ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } if (ds.Tables[0].Rows[0]["Email"] != null && ds.Tables[0].Rows[0]["Email"].ToString() != "") { model.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["IsActive"] != null && ds.Tables[0].Rows[0]["IsActive"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsActive"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsActive"].ToString().ToLower() == "true")) { model.IsActive = true; } else { model.IsActive = false; } } if (ds.Tables[0].Rows[0]["AvtiveCode"] != null && ds.Tables[0].Rows[0]["AvtiveCode"].ToString() != "") { model.AvtiveCode = ds.Tables[0].Rows[0]["AvtiveCode"].ToString(); } return model; } else { return null; } }