DAL/ProductService.cs

(开头部分) 16KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class ProductService
    {

        /// <summary>
        /// 根据商品编号获取商品信息
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        public Product GetProductById(string productId)
        {
            string sql = @"SELECT ProductId,ProductName,UnitPrice,Discount,Unit, CategoryName FROM  Products p
             left join ProductCategory pc on pc.CategoryId=p.CategoryId
             WHERE ProductId=@ProductId";
            SqlDataReader reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@ProductId", productId));
            Product product = null;
            if (reader.Read())
            {
                product = new Product()
                {
                    ProductId = reader["ProductId"].ToString(),
                    ProductName = reader["ProductName"].ToString(),
                    UnitPrice = Convert.ToDecimal(reader["UnitPrice"]),
                    Unit = reader["Unit"].ToString(),
                    Discount = Convert.ToInt32(reader["Discount"]),
                    CategoryName = reader["CategoryName"].ToString(),
                };
            }
            reader.Close();

            return product;
        }

        /// <summary>
        /// 启用事务提交购买商品对象 、更新客户积分
        /// </summary>
        /// <param name="objsaleList"></param>
        /// <param name="members"></param>
        /// <returns></returns>
        public int SaveSaleInfo(SalesList objsaleList, SMMembers members)
        {
            List<string> sqlList = new List<string>();
            List<SqlParameter[]> paramList = new List<SqlParameter[]>();
            //插入销售
            sqlList.Add("INSERT INTO [dbo].[SalesList] (SerialNum, TotalMoney, RealReceive, ReturnMoney, SalesPersonId) VALUES  (@SerialNum, @TotalMoney, @RealReceive, @ReturnMoney, @SalesPersonId)");
            paramList.Add(new SqlParameter[] {
                new SqlParameter("@SerialNum", objsaleList.SerialNum),
                 new SqlParameter("@RealReceive", objsaleList.RealReceive),
                  new SqlParameter("@TotalMoney", objsaleList.TotalMoney),
                   new SqlParameter("@ReturnMoney", objsaleList.ReturnMoney),
后面还有 353 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。