//测试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; }
//测试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); }
/// <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); }
/// <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; }
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 = "请先选择一条记录!"; } }
/// <summary> /// 删除商品存货信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public bool DeleteGoodsStock(GoodsStock info) { return EntityQuery<GoodsStock>.Instance.Delete(info) > 0; }
//该方法已经废弃,合并在 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; }
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; }
/// <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; }
/// <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; }