/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.ReservationInfoModel DataRowToModel(DataRow row) { Gymnasium_APP.Model.ReservationInfoModel model=new Gymnasium_APP.Model.ReservationInfoModel(); if (row != null) { if(row["ID"]!=null && row["ID"].ToString()!="") { model.ID=int.Parse(row["ID"].ToString()); } if(row["ReservationNum"]!=null) { model.ReservationNum=row["ReservationNum"].ToString(); } if(row["TypeName"]!=null) { model.TypeName=row["TypeName"].ToString(); } if(row["Position"]!=null) { model.Position=row["Position"].ToString(); } if(row["Times"]!=null) { model.Times=row["Times"].ToString(); } if(row["Money"]!=null) { model.Money=row["Money"].ToString(); } if(row["Name"]!=null) { model.Name=row["Name"].ToString(); } if(row["Peoples"]!=null) { model.Peoples=row["Peoples"].ToString(); } if(row["Phone"]!=null) { model.Phone=row["Phone"].ToString(); } if(row["PriceAmount"]!=null) { model.PriceAmount=row["PriceAmount"].ToString(); } if(row["PaymentAmount"]!=null) { model.PaymentAmount=row["PaymentAmount"].ToString(); } if(row["ChangeAmount"]!=null) { model.ChangeAmount=row["ChangeAmount"].ToString(); } if(row["AddTime"]!=null) { model.AddTime=row["AddTime"].ToString(); } if(row["AddUserName"]!=null) { model.AddUserName=row["AddUserName"].ToString(); } if(row["Des"]!=null) { model.Des=row["Des"].ToString(); } if(row["PayType"]!=null) { model.PayType=row["PayType"].ToString(); } if(row["RState"]!=null) { model.RState=row["RState"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Gymnasium_APP.Model.ReservationInfoModel GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,ReservationNum,TypeName,Position,Times,Money,Name,Peoples,Phone,PriceAmount,PaymentAmount,ChangeAmount,AddTime,AddUserName,Des,PayType,RState from ReservationInfo "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4) }; parameters[0].Value = ID; Gymnasium_APP.Model.ReservationInfoModel model=new Gymnasium_APP.Model.ReservationInfoModel(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }