/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportTemp DataRowToModel(DataRow row) { Model.ReportTemp model = new Model.ReportTemp(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["SumDate"] != null) { model.SumDate = row["SumDate"].ToString(); } if (row["ChannelID"] != null && row["ChannelID"].ToString() != "") { model.ChannelID = int.Parse(row["ChannelID"].ToString()); } if (row["ChannelName"] != null) { model.ChannelName = row["ChannelName"].ToString(); } if (row["GameID"] != null && row["GameID"].ToString() != "") { model.GameID = int.Parse(row["GameID"].ToString()); } if (row["GameName"] != null) { model.GameName = row["GameName"].ToString(); } if (row["RegisterValue"] != null && row["RegisterValue"].ToString() != "") { model.RegisterValue = decimal.Parse(row["RegisterValue"].ToString()); } if (row["ConsumptionValue"] != null && row["ConsumptionValue"].ToString() != "") { model.ConsumptionValue = decimal.Parse(row["ConsumptionValue"].ToString()); } if (row["Income"] != null && row["Income"].ToString() != "") { model.Income = decimal.Parse(row["Income"].ToString()); } if (row["AddDate"] != null && row["AddDate"].ToString() != "") { model.AddDate = DateTime.Parse(row["AddDate"].ToString()); } if (row["UserID"] != null && row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } if (row["UserName"] != null) { model.UserName = row["UserName"].ToString(); } if (row["Bak1"] != null) { model.Bak1 = row["Bak1"].ToString(); } if (row["Bak2"] != null) { model.Bak2 = row["Bak2"].ToString(); } if (row["Bak3"] != null) { model.Bak3 = row["Bak3"].ToString(); } if (row["Bak4"] != null) { model.Bak4 = row["Bak4"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.ReportTemp GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,SumDate,ChannelID,ChannelName,GameID,GameName,RegisterValue,ConsumptionValue,Income,AddDate,UserID,UserName,Bak1,Bak2,Bak3,Bak4 from ReportTemp "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; Model.ReportTemp model = new Model.ReportTemp(); DataSet ds = DbHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }