Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Gymnasium_APP.Model.LossCastModel DataRowToModel(DataRow row)
 {
     Gymnasium_APP.Model.LossCastModel model=new Gymnasium_APP.Model.LossCastModel();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["LossCardId"]!=null && row["LossCardId"].ToString()!="")
         {
             model.LossCardId=int.Parse(row["LossCardId"].ToString());
         }
         if(row["PayableAmount"]!=null && row["PayableAmount"].ToString()!="")
         {
             model.PayableAmount=decimal.Parse(row["PayableAmount"].ToString());
         }
         if(row["PaymentAmount"]!=null && row["PaymentAmount"].ToString()!="")
         {
             model.PaymentAmount=decimal.Parse(row["PaymentAmount"].ToString());
         }
         if(row["ChangeAmount"]!=null && row["ChangeAmount"].ToString()!="")
         {
             model.ChangeAmount=decimal.Parse(row["ChangeAmount"].ToString());
         }
         if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
         {
             model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return model;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Gymnasium_APP.Model.LossCastModel GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,LossCardId,PayableAmount,PaymentAmount,ChangeAmount,CreateTime from LossCast ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Gymnasium_APP.Model.LossCastModel model=new Gymnasium_APP.Model.LossCastModel();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }