动易SiteFactory™ 网上商店系统1.0源代码

源代码在线查看: package.cs

软件大小: 9737 K
上传用户: wendaoysh
关键词: SiteFactory 8482 1.0
下载地址: 免注册下载 普通下载 VIP

相关代码

				namespace PowerEasy.SqlServerDal.Shop
				{
				    using PowerEasy.IDal.Shop;
				    using PowerEasy.Model.Shop;
				    using PowerEasy.SqlServerDal;
				    using System;
				    using System.Collections.Generic;
				    using System.Data;
				
				    public class Package : IPackage
				    {
				        public bool Add(PackageInfo packageInfo)
				        {
				            return DBHelper.ExecuteSql("INSERT INTO PE_Package(PackageName,PackageWeight,GoodsWeightMin,GoodsWeightMax) VALUES (@PackageName,@PackageWeight,@GoodsWeightMin,@GoodsWeightMax)", GetParameters(packageInfo));
				        }
				
				        public bool Delete(int id)
				        {
				            return DBHelper.ExecuteSql("Delete From PE_Package where PackageId = @PackageId", new Parameters("@PackageId", DbType.Int32, id));
				        }
				
				        public bool Delete(string id)
				        {
				            return DBHelper.ExecuteSql("Delete From PE_Package where PackageId IN ( " + id + " )");
				        }
				
				        public bool ExistsPackage(string packageName)
				        {
				            return DBHelper.Exists(CommandType.Text, "select top 1 PackageId from PE_package where packageName=@packageName", new Parameters("@packageName", DbType.String, packageName));
				        }
				
				        public bool ExistsPackage(double goodsWeightMin, double goodsWeightMax)
				        {
				            Parameters cmdParams = new Parameters();
				            cmdParams.AddInParameter("@Min", DbType.Double, goodsWeightMin);
				            cmdParams.AddInParameter("@Max", DbType.Double, goodsWeightMax);
				            return DBHelper.Exists(CommandType.Text, "select top 1 * from PE_package where \r\n(goodsweightmin 				        }
				
				        public bool ExistsPackage(string packageName, int currentPackageId)
				        {
				            Parameters cmdParams = new Parameters();
				            cmdParams.AddInParameter("@packageName", DbType.String, packageName);
				            cmdParams.AddInParameter("@packageId", DbType.Int32, currentPackageId);
				            return DBHelper.Exists(CommandType.Text, "select PackageId from PE_package where packageName=@packageName and PackageId@packageId", cmdParams);
				        }
				
				        public bool ExistsPackage(double goodsWeightMin, double goodsWeightMax, int currentPackageId)
				        {
				            Parameters cmdParams = new Parameters();
				            cmdParams.AddInParameter("@Min", DbType.Double, goodsWeightMin);
				            cmdParams.AddInParameter("@Max", DbType.Double, goodsWeightMax);
				            cmdParams.AddInParameter("@packageId", DbType.Int32, currentPackageId);
				            return DBHelper.Exists(CommandType.Text, "select top 1 * from PE_package where PackageID@packageId and\r\n((goodsweightmin 				        }
				
				        public IList GetList()
				        {
				            IList list = new List();
				            using (NullableDataReader reader = DBHelper.ExecuteReaderSql("Select * From PE_Package Order by GoodsWeightMin,GoodsWeightMax"))
				            {
				                while (reader.Read())
				                {
				                    list.Add(PackageFromrdr(reader));
				                }
				            }
				            return list;
				        }
				
				        public PackageInfo GetPackageByGoodsWeight(double goodsWeight)
				        {
				            using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select top 1 * from PE_Package where GoodsWeightMin < @GoodsWeight and GoodsWeightMax >= @GoodsWeight Order by GoodsWeightMin,GoodsWeightMax", new Parameters("@GoodsWeight", DbType.Double, goodsWeight)))
				            {
				                if (reader.Read())
				                {
				                    return PackageFromrdr(reader);
				                }
				                return new PackageInfo(true);
				            }
				        }
				
				        public PackageInfo GetPackageById(int id)
				        {
				            using (NullableDataReader reader = DBHelper.ExecuteReaderSql("select * from PE_Package where PackageId=@PackageId", new Parameters("@PackageId", DbType.Int32, id)))
				            {
				                if (reader.Read())
				                {
				                    return PackageFromrdr(reader);
				                }
				                return new PackageInfo(true);
				            }
				        }
				
				        private static Parameters GetParameters(PackageInfo packageInfo)
				        {
				            Parameters parameters = new Parameters();
				            parameters.AddInParameter("@PackageName", DbType.String, packageInfo.PackageName);
				            parameters.AddInParameter("@PackageWeight", DbType.Double, packageInfo.PackageWeight);
				            parameters.AddInParameter("@GoodsWeightMin", DbType.Double, packageInfo.GoodsWeightMin);
				            parameters.AddInParameter("@GoodsWeightMax", DbType.Double, packageInfo.GoodsWeightMax);
				            return parameters;
				        }
				
				        private static PackageInfo PackageFromrdr(NullableDataReader rdr)
				        {
				            PackageInfo info = new PackageInfo();
				            info.PackageId = rdr.GetInt32("PackageId");
				            info.PackageName = rdr.GetString("PackageName");
				            info.PackageWeight = rdr.GetDouble("PackageWeight");
				            info.GoodsWeightMin = rdr.GetDouble("GoodsWeightMin");
				            info.GoodsWeightMax = rdr.GetDouble("GoodsWeightMax");
				            return info;
				        }
				
				        public bool Update(PackageInfo packageInfo)
				        {
				            Parameters cmdParams = GetParameters(packageInfo);
				            cmdParams.AddInParameter("PackageId", DbType.Int32, packageInfo.PackageId);
				            return DBHelper.ExecuteSql("UPDATE PE_Package SET PackageName=@PackageName,PackageWeight=@PackageWeight,GoodsWeightMin=@GoodsWeightMin,GoodsWeightMax=@GoodsWeightMax WHERE PackageId=@PackageId", cmdParams);
				        }
				    }
				}
				
							

相关资源