コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: guipaa/PDF.NET
        //测试OQL的统计功能
        private int GetStockCount(string serialNumber)
        {
            SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
            stock.SerialNumber = serialNumber;
            OQL q = new OQL(stock);
            q.Select()
                .Count(stock.Stocks, "")
                .Where(stock.SerialNumber);

            stock = EntityQuery<SuperMarketDAL.Entitys.GoodsStock>.QueryObject(q);
            int stockCount = stock.Stocks;
            return stockCount;
        }
コード例 #2
0
        //测试OQL的统计功能
        private int GetStockCount(string serialNumber)
        {
            SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
            stock.SerialNumber = serialNumber;
            OQL q = new OQL(stock);

            q.Select()
            .Count(stock.Stocks, "")
            .Where(stock.SerialNumber);

            stock = EntityQuery <SuperMarketDAL.Entitys.GoodsStock> .QueryObject(q);

            int stockCount = stock.Stocks;

            return(stockCount);
        }
コード例 #3
0
        /// <summary>
        /// 保存销售信息
        /// </summary>
        /// <param name="customer">客户信息</param>
        /// <param name="integral">要增加的积分</param>
        /// <returns></returns>
        private GoodsSellNote SaveSalesInfo(Customer customer, int integral)
        {
            GoodsSellNote note = new GoodsSellNote();

            note.CustomerID       = customer.CustomerID;
            note.ManchinesNumber  = this.CurrCRManchines.CashRegisterNo;
            note.SalesmanID       = this.CurrCashier.WorkNumber;
            note.SalesType        = "店内销售";
            note.SellDate         = DateTime.Now;
            note.GoodsSellDetails = new List <GoodsSellDetail>();

            AdoHelper db = MyDB.GetDBHelper();

            db.BeginTransaction();
            try
            {
                EntityQuery <GoodsSellNote> query = new EntityQuery <GoodsSellNote>(db);
                if (query.Insert(note) > 0)
                {
                    foreach (Goods goods in customer.Goodss)
                    {
                        if (goods.GoodsNumber > 0)
                        {
                            //处理详单
                            GoodsSellDetail detail = new GoodsSellDetail();
                            detail.GoodsPrice   = goods.GoodsPrice;
                            detail.NoteID       = note.NoteID;
                            detail.SellNumber   = goods.GoodsNumber;
                            detail.SerialNumber = goods.SerialNumber;

                            note.GoodsSellDetails.Add(detail);

                            //更新库存
                            SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
                            stock.GoodsID = goods.GoodsID;
                            stock.Stocks  = goods.GoodsNumber;

                            OQL q = OQL.From(stock)
                                    .UpdateSelf('-', stock.Stocks)
                                    .Where(stock.GoodsID)
                                    .END;
                            EntityQuery <SuperMarketDAL.Entitys.GoodsStock> .ExecuteOql(q, db);
                        }
                    }

                    EntityQuery <GoodsSellDetail> queryDetail = new EntityQuery <GoodsSellDetail>(db);
                    queryDetail.Insert(note.GoodsSellDetails);

                    //更新会员的积分
                    if (integral > 0)
                    {
                        SuperMarketDAL.Entitys.CustomerContactInfo ccInfo = new CustomerContactInfo();
                        ccInfo.CustomerID = customer.CustomerID;
                        ccInfo.Integral   = integral;
                        OQL qc = OQL.From(ccInfo)
                                 .UpdateSelf('+', ccInfo.Integral)
                                 .Where(ccInfo.CustomerID)
                                 .END;
                        EntityQuery <SuperMarketDAL.Entitys.GoodsStock> .ExecuteOql(qc, db);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw new Exception("插入销售记录失败,内部错误原因:" + ex.Message);
            }
            return(note);
        }
コード例 #4
0
ファイル: CashierRegisterBIZ.cs プロジェクト: guipaa/PDF.NET
        /// <summary>
        /// 保存销售信息
        /// </summary>
        /// <param name="customer">客户信息</param>
        /// <param name="integral">要增加的积分</param>
        /// <returns></returns>
        private GoodsSellNote SaveSalesInfo(Customer customer, int integral)
        {
            GoodsSellNote note = new GoodsSellNote();
            note.CustomerID = customer.CustomerID;
            note.ManchinesNumber = this.CurrCRManchines.CashRegisterNo;
            note.SalesmanID = this.CurrCashier.WorkNumber;
            note.SalesType = "店内销售";
            note.SellDate = DateTime.Now;
            note.GoodsSellDetails = new List<GoodsSellDetail>();

            AdoHelper db = MyDB.GetDBHelper();
            db.BeginTransaction();
            try
            {
                EntityQuery<GoodsSellNote> query = new EntityQuery<GoodsSellNote>(db);
                if (query.Insert(note) > 0)
                {
                    foreach (Goods goods in customer.Goodss)
                    {
                        if (goods.GoodsNumber > 0)
                        {
                            //处理详单
                            GoodsSellDetail detail = new GoodsSellDetail();
                            detail.GoodsPrice = goods.GoodsPrice;
                            detail.NoteID = note.NoteID;
                            detail.SellNumber = goods.GoodsNumber;
                            detail.SerialNumber = goods.SerialNumber;

                            note.GoodsSellDetails.Add(detail);

                            //更新库存
                            SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
                            stock.GoodsID = goods.GoodsID;
                            stock.Stocks = goods.GoodsNumber;
                            
                            OQL q = OQL.From(stock)
                                .UpdateSelf ('-', stock.Stocks)
                                .Where(stock.GoodsID)
                                .END;
                            EntityQuery<SuperMarketDAL.Entitys.GoodsStock>.ExecuteOql(q, db);

                        }
                    }

                    EntityQuery<GoodsSellDetail> queryDetail = new EntityQuery<GoodsSellDetail>(db);
                    queryDetail.Insert(note.GoodsSellDetails);

                    //更新会员的积分
                    if (integral > 0)
                    {
                        SuperMarketDAL.Entitys.CustomerContactInfo ccInfo = new CustomerContactInfo();
                        ccInfo.CustomerID = customer.CustomerID;
                        ccInfo.Integral = integral;
                        OQL qc = OQL.From(ccInfo)
                                .UpdateSelf('+', ccInfo.Integral )
                                .Where(ccInfo.CustomerID )
                                .END;
                        EntityQuery<SuperMarketDAL.Entitys.GoodsStock>.ExecuteOql(qc, db);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw new Exception("插入销售记录失败,内部错误原因:" + ex.Message);
            }
            return note;
        }
コード例 #5
0
ファイル: StockInfo.aspx.cs プロジェクト: guipaa/PDF.NET
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.dlCHJLH.Text != "")
     {
         GoodsManageBIZ biz = new GoodsManageBIZ();
         GoodsStock info = new GoodsStock() { GoodsID = int.Parse( this.dlCHJLH.Text) };
         biz.DeleteGoodsStock(info);
         lblMsg.Text = "删除成功!";
         MyWebForm.ClearIBData(this.Controls);
         //重新绑定数据
         this.ProPageToolBar1.ReBindResultData();
     }
     else
     {
         lblMsg.Text = "请先选择一条记录!";
     }
 }
コード例 #6
0
ファイル: GoodsManageBIZ.cs プロジェクト: guipaa/PDF.NET
        /// <summary>
        /// 删除商品存货信息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool DeleteGoodsStock(GoodsStock info)
        {
            return EntityQuery<GoodsStock>.Instance.Delete(info) > 0;

        }
コード例 #7
0
ファイル: GoodsManageBIZ.cs プロジェクト: guipaa/PDF.NET
        //该方法已经废弃,合并在 GetOverDays 中
        private int GetStockCount(int goodsID)
        {
            GoodsStock stock = new GoodsStock();
            stock.GoodsID = goodsID;
            OQL q = new OQL(stock);
            q.Select(stock.Stocks)
                    .Where(stock.GoodsID);

            stock = EntityQuery<GoodsStock>.QueryObject(q);
            int stockCount = stock.Stocks;
            return stockCount;
        }
コード例 #8
0
ファイル: GoodsManageBIZ.cs プロジェクト: guipaa/PDF.NET
        private int GetOverDays(string serialNumber, int goodsID, out decimal goodsPrice, out int stockCount)
        {
            //计算距离过期时间
            GoodsBaseInfo bInfo = new GoodsBaseInfo();
            bInfo.SerialNumber = serialNumber;
            OQL q = OQL.From(bInfo)
                .Select(bInfo.CanUserMonth)
                .Where(bInfo.SerialNumber)
                .END;

            bInfo = EntityQuery<GoodsBaseInfo>.QueryObject(q);
            int canUseMonth = bInfo.CanUserMonth;

            GoodsStock stock = new GoodsStock();
            stock.GoodsID = goodsID;
            EntityQuery<GoodsStock>.Fill(stock);
            goodsPrice = stock.GoodsPrice;
            stockCount = stock.Stocks;
            //距离过期时间
            int overDays = canUseMonth *30 - DateTime.Now.Subtract(stock.MakeOnDate).Days;
            return overDays;
        }
コード例 #9
0
ファイル: GoodsManageBIZ.cs プロジェクト: guipaa/PDF.NET
        /// <summary>
        /// 获取所有的可售商品总数
        /// </summary>
        /// <returns></returns>
        public int GetGoodsStockCount()
        {
            GoodsStock stock = new GoodsStock();
            OQL q = new OQL(stock);
            q.Select()
                .Count(stock.Stocks, "库存数量")
                .Where(q.Condition.AND(stock.Stocks, ">", 0));

            stock = EntityQuery<GoodsStock>.QueryObject(q);
            return stock.Stocks;
        }
コード例 #10
0
ファイル: GoodsManageBIZ.cs プロジェクト: guipaa/PDF.NET
        /// <summary>
        /// 获取商品销售价格信息
        /// </summary>
        /// <returns></returns>
        public IEnumerable<GoodsSaleInfoVM> GetGoodsSaleInfo()
        {
            GoodsBaseInfo bInfo = new GoodsBaseInfo();
            GoodsStock stock = new GoodsStock();
            OQL joinQ = OQL.From(bInfo)
                .Join(stock).On(bInfo.SerialNumber, stock.SerialNumber)
                .Select(bInfo.GoodsName, bInfo.Manufacturer, bInfo.SerialNumber, stock.GoodsPrice, stock.MakeOnDate, bInfo.CanUserMonth, stock.Stocks, stock.GoodsID)
                .OrderBy(bInfo.GoodsName, "asc")
                .END;

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);
            ec.Execute();
            var result = ec.Map<GoodsSaleInfoVM>(e =>
                {
                    e.GoodsName = ec.GetItemValue<string>(0); 
                    e.Manufacturer = ec.GetItemValue<string>(1);
                    e.SerialNumber  = ec.GetItemValue<string>(2);
                    e.GoodsPrice  = ec.GetItemValue<decimal>(3);
                    e.MakeOnDate = ec.GetItemValue<DateTime>(4);
                    e.CanUserMonth = ec.GetItemValue<int>(5);
                    e.Stocks = ec.GetItemValue<int>(6);
                    e.GoodsID = ec.GetItemValue<int>(7);
                    return e;
                }
            );
            return result;
        }