/// <summary> /// 获得数据列表 /// </summary> public List<Model.Class_GroupMember> DataTableToList(DataTable dt) { List<Model.Class_GroupMember> modelList = new List<Model.Class_GroupMember>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Class_GroupMember model; for (int n = 0; n < rowsCount; n++) { model = new Model.Class_GroupMember(); if (dt.Rows[n]["GroupId"].ToString() != "") { model.GroupId = int.Parse(dt.Rows[n]["GroupId"].ToString()); } if (dt.Rows[n]["AccountId"].ToString() != "") { model.AccountId = int.Parse(dt.Rows[n]["AccountId"].ToString()); } if (dt.Rows[n]["Delflag"].ToString() != "") { if ((dt.Rows[n]["Delflag"].ToString() == "1") || (dt.Rows[n]["Delflag"].ToString().ToLower() == "true")) { model.Delflag = true; } else { model.Delflag = false; } } if (dt.Rows[n]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Class_GroupMember GetModel(int GroupId, int AccountId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select GroupId, AccountId, Delflag, CreateDate "); strSql.Append(" from Class_GroupMember "); strSql.Append(" where "); strSql.Append(" GroupId = @GroupId and "); strSql.Append(" AccountId = @AccountId "); SqlParameter[] parameters = { new SqlParameter("@GroupId", SqlDbType.Int,4) , new SqlParameter("@AccountId", SqlDbType.Int,4) }; parameters[0].Value = GroupId; parameters[1].Value = AccountId; Model.Class_GroupMember model = new Model.Class_GroupMember(); DataSet ds = MSEntLibSqlHelper.ExecuteDataSetBySql(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["GroupId"].ToString() != "") { model.GroupId = int.Parse(ds.Tables[0].Rows[0]["GroupId"].ToString()); } if (ds.Tables[0].Rows[0]["AccountId"].ToString() != "") { model.AccountId = int.Parse(ds.Tables[0].Rows[0]["AccountId"].ToString()); } if (ds.Tables[0].Rows[0]["Delflag"].ToString() != "") { if ((ds.Tables[0].Rows[0]["Delflag"].ToString() == "1") || (ds.Tables[0].Rows[0]["Delflag"].ToString().ToLower() == "true")) { model.Delflag = true; } else { model.Delflag = false; } } if (ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } return model; } else { return null; } }