/// <summary> /// 获得数据列表 /// </summary> public List<Model.Member_PlanOverall> DataTableToList(DataTable dt) { List<Model.Member_PlanOverall> modelList = new List<Model.Member_PlanOverall>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Member_PlanOverall model; for (int n = 0; n < rowsCount; n++) { model = new Model.Member_PlanOverall(); if (dt.Rows[n]["PlanId"].ToString() != "") { model.PlanId = int.Parse(dt.Rows[n]["PlanId"].ToString()); } if (dt.Rows[n]["AccountId"].ToString() != "") { model.AccountId = int.Parse(dt.Rows[n]["AccountId"].ToString()); } if (dt.Rows[n]["Result"].ToString() != "") { model.Result = int.Parse(dt.Rows[n]["Result"].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.Member_PlanOverall GetModel(int PlanId, int AccountId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PlanId, AccountId, Result, Delflag, CreateDate "); strSql.Append(" from Member_PlanOverall "); strSql.Append(" where "); strSql.Append(" PlanId = @PlanId and "); strSql.Append(" AccountId = @AccountId "); SqlParameter[] parameters = { new SqlParameter("@PlanId", SqlDbType.Int,4) , new SqlParameter("@AccountId", SqlDbType.Int,4) }; parameters[0].Value = PlanId; parameters[1].Value = AccountId; Model.Member_PlanOverall model = new Model.Member_PlanOverall(); DataSet ds = MSEntLibSqlHelper.ExecuteDataSetBySql(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PlanId"].ToString() != "") { model.PlanId = int.Parse(ds.Tables[0].Rows[0]["PlanId"].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]["Result"].ToString() != "") { model.Result = int.Parse(ds.Tables[0].Rows[0]["Result"].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; } }