Esempio n. 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ShowShop.Model.SystemInfo.Deliver GetModelByID(int id)
        {
            ShowShop.Model.SystemInfo.Deliver model = new ShowShop.Model.SystemInfo.Deliver();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,DistributionName,DistributionDescription,InsuredCosts,IsCOD,Author,Version,IsInstallation from " + Pre + "deliverymode ");
            strSql.Append(" where [Id]=@id ");
            SqlParameter[] parameters = (SqlParameter[])this.ValueIDPara(id);
            using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString(), parameters))
            {
                if (reader.Read())
                {
                    model.Id = reader.GetInt32(0);
                    model.Distributionname = reader.GetString(1);
                    model.Distributiondescription = reader["DistributionDescription"].ToString();
                    model.Insuredcosts = float.Parse(reader["InsuredCosts"].ToString());
                    model.IsCOD = reader.GetInt32(4);
                    model.Author = reader["Author"].ToString();
                    model.Version = reader["Version"].ToString();
                    model.Isinstallation = Convert.ToInt32(reader["IsInstallation"]);
                }
                else
                {
                    model = null;
                }

            }
            return model;
        }
Esempio n. 2
0
 /// <summary>
 /// 所有数据集合
 /// </summary>
 /// <returns></returns>
 public List<ShowShop.Model.SystemInfo.Deliver> GetAll()
 {
     List<ShowShop.Model.SystemInfo.Deliver> list = new List<ShowShop.Model.SystemInfo.Deliver>();
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select Id,DistributionName,DistributionDescription,InsuredCosts,IsCOD,Author,Version,IsInstallation from " + Pre + "deliverymode ");
     strSql.Append(" where 1=1");
     strSql.Append(" order by Id asc");
     using (SqlDataReader reader = ChangeHope.DataBase.SQLServerHelper.ExecuteReader(strSql.ToString()))
     {
         while (reader.Read())
         {
             ShowShop.Model.SystemInfo.Deliver model = new ShowShop.Model.SystemInfo.Deliver();
             model.Id = reader.GetInt32(0);
             model.Distributionname = reader.GetString(1);
             model.Distributiondescription = reader["DistributionDescription"].ToString();
             model.Insuredcosts = float.Parse(reader["InsuredCosts"].ToString());
             model.IsCOD = reader.GetInt32(4);
             model.Author = reader["Author"].ToString();
             model.Version = reader["Version"].ToString();
             model.Isinstallation = Convert.ToInt32(reader["IsInstallation"]);
             list.Add(model);
         }
     }
     return list;
     return null;
 }