private BindingList <GoodsBalanceObj> GetCommitList(IEnumerable <sp_sel_PreOrderCommitGoodsByHeaderResult> commitOrders, Guid idPreOrder) { var list = commitOrders.Where(x => x.id_PreOrder == idPreOrder).ToList(); if ((list.Count > 0)) { var ret = new BindingList <GoodsBalanceObj>() { AllowEdit = false, AllowNew = false, AllowRemove = false }; foreach (var i in list) { var gb = new GoodsBalanceObj() { Barcode = i.Barcode, Code = i.Code, Date = i.Date, Group = i.GoodsGroup, Measure = i.Measure, Supplier = i.Supplier, SelfImport = i.SelfImport.GetValueOrDefault(false), Quantity = i.Ordered.GetValueOrDefault(0), Price = i.Price.GetValueOrDefault(0), QuantityInPack = i.QuantityInPack.GetValueOrDefault(0), Name = i.Name, MinOrder = i.MinOrder.GetValueOrDefault(0), }; ret.Add(gb); } return(ret); } return(null); }
void bl_ChangeReqQuantity(object sender, EventChangeReqQuantity e) { GoodsBalanceObj gb = e.GoodsObj; try { gb.ChangeReqQuantity -= new ChangeReqQuantity(bl_ChangeReqQuantity); if ((gb.Ordered + gb.Quantity) < gb.ReqQuantity) { if (XtraMessageBox.Show("Остатки меньше чем заказываемое количество. Заказать?", "Внимание!", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveOrder(gb); } else { gb.ReqQuantity = 0; } } else { SaveOrder(gb); } } finally { gb.ChangeReqQuantity += new ChangeReqQuantity(bl_ChangeReqQuantity); } }
public BindingList <GoodsBalanceObj> GetOrderList() { if (_currentOrderHeader != null) { using (OrderDataContext oc = UnityContainer.Resolve <OrderDataContext>()) { List <vGoodsBalanceOrder> orders; if (StoreHouseType) { orders = oc.DataBaseContext.vGoodsBalanceOrder.Where( or => (((or.id_OrderHeader == _currentOrderHeader.IdOrderHeader) || (or.id_OrderHeader == null)) && (or.GoodsGroup != @"АЛКОГОЛЬНЫЕ НАПИТКИ"))).ToList(); } else { orders = oc.DataBaseContext.vGoodsBalanceOrder.Where( or => (((or.id_OrderHeader == _currentOrderHeader.IdOrderHeader) || (or.id_OrderHeader == null)) && (or.GoodsGroup == @"АЛКОГОЛЬНЫЕ НАПИТКИ"))).ToList(); } BindingList <GoodsBalanceObj> balance = new BindingList <GoodsBalanceObj>(); balance.AllowEdit = _currentOrderHeader.IdOrderState == 1; foreach (var vo in orders) { GoodsBalanceObj bl = new GoodsBalanceObj() { Barcode = vo.Barcode, Code = vo.Code, Date = vo.Date, FreeBalance = vo.FreeBalance.GetValueOrDefault(), Group = vo.GoodsGroup, id = vo.id_GoodsBalance, Measure = vo.Measure, MinOrder = vo.MinOrder.GetValueOrDefault(), Name = vo.Name, Price = vo.Price.GetValueOrDefault(), ReqQuantity = vo.ReqQuantity, Ordered = vo.Ordered.GetValueOrDefault(), Quantity = vo.Balance.GetValueOrDefault(), QuantityInPack = vo.QuantityInPack.GetValueOrDefault(), Reserved = vo.Reserved.GetValueOrDefault(), Supplier = vo.Supplier }; bl.ChangeReqQuantity += new ChangeReqQuantity(bl_ChangeReqQuantity); balance.Add(bl); } return(balance); } } return(null); }
void SaveOrder(GoodsBalanceObj goodsObj) { { using (var oc = UnityContainer.Resolve <OrderDataContext>()) { oc.DataBaseContext.spCreateOrderNew(goodsObj.id, IdOrderHeader, goodsObj.ReqQuantity); UnityContainer.Resolve <IDBLogger>().InsertLog(string.Format("Позиция заказа. товар = '{0}' колво = {1}", goodsObj.id, goodsObj.ReqQuantity), IdOrderHeader.ToString().ToUpper()); var gods = oc.DataBaseContext.sp_sel_OrderBalanceRefresh(IdOrderHeader, goodsObj.id).Single(); goodsObj.Ordered = gods.Ordered; goodsObj.Quantity = gods.Balance.GetValueOrDefault(0); goodsObj.Quota = gods.Quota; } } }
void SaveOrder(GoodsBalanceObj goodsObj) { { using (OrderDataContext oc = UnityContainer.Resolve <OrderDataContext>()) { oc.DataBaseContext.spCreateOrderNew(goodsObj.id, IdOrderHeader, goodsObj.ReqQuantity); IQueryable <vGoodsBalanceOrder> gods = from gd in oc.DataBaseContext.vGoodsBalanceOrder where (gd.id_OrderHeader == IdOrderHeader && gd.id_GoodsBalance == goodsObj.id) select gd; foreach (var gd in gods) { goodsObj.Ordered = gd.Ordered.GetValueOrDefault(0); goodsObj.Quantity = gd.Balance.GetValueOrDefault(0); } } } }
public BindingList <GoodsBalanceObj> GetOrderList() { if (_currentOrderHeader != null) { using (OrderDataContext oc = UnityContainer.Resolve <OrderDataContext>()) { List <vOrderDayAll> orders = oc.DataBaseContext.vOrderDayAll.Where( or => (((or.id_OrderHeader == _currentOrderHeader.IdOrderHeader) ))).ToList(); BindingList <GoodsBalanceObj> balance = new BindingList <GoodsBalanceObj>(); balance.AllowEdit = _currentOrderHeader.IdOrderState == 1; foreach (var vo in orders) { GoodsBalanceObj bl = new GoodsBalanceObj() { Barcode = vo.Barcode, Code = vo.Code, Date = vo.Date, FreeBalance = vo.FreeBalance.GetValueOrDefault(), Group = vo.GoodsGroup, id = vo.id_GoodsBalance, Measure = vo.Measure, MinOrder = vo.MinOrder.GetValueOrDefault(), Name = vo.Name, Price = vo.Price.GetValueOrDefault(), ReqQuantity = vo.ReqQuantity, Ordered = vo.Ordered, Quantity = vo.Balance, QuantityInPack = vo.QuantityInPack.GetValueOrDefault(), Reserved = vo.Reserved.GetValueOrDefault(), Supplier = vo.Supplier }; balance.Add(bl); } return(balance); } } return(null); }
private BindingList <GoodsBalanceObj> GetOrderList() { if (_currentOrderHeader != null) { using (var oc = UnityContainer.Resolve <OrderDataContext>()) { var orders = oc.DataBaseContext.sp_sel_OrderGoodsByHeader(_currentOrderHeader.IdOrderHeader).ToList(); var balance = new BindingList <GoodsBalanceObj> { AllowEdit = _currentOrderHeader.IdOrderState == 1 }; foreach (var vo in orders) { var bl = new GoodsBalanceObj { Barcode = vo.Barcode, Code = vo.Code, Date = vo.Date, FreeBalance = vo.FreeBalance.GetValueOrDefault(), Group = vo.GoodsGroup, id = vo.id_GoodsBalance, Measure = vo.Measure, MinOrder = vo.MinOrder.GetValueOrDefault(), Name = vo.Name, Price = vo.Price.GetValueOrDefault(), ReqQuantity = vo.ReqQuantity, Ordered = vo.Ordered, Quantity = vo.Balance, QuantityInPack = vo.QuantityInPack.GetValueOrDefault(), Reserved = vo.Reserved.GetValueOrDefault(), Supplier = vo.Supplier, SelfImport = vo.SelfImport.GetValueOrDefault(false) }; balance.Add(bl); } return(balance); } } return(null); }
public BindingList <GoodsBalanceObj> GetOrderList() { if (_currentOrderHeader != null) { Cursor.Current = Cursors.WaitCursor; try { using (var oc = UnityContainer.Resolve <OrderDataContext>()) { var balance = new BindingList <GoodsBalanceObj>(); _allowEdit = ((_currentOrderHeader.IdOrderState == 1) && (ServerDate.Date == _currentOrderHeader.CreateDate.Date)); balance.AllowEdit = _allowEdit; var isBalance = UnityContainer.Resolve <IOrderUserInfo>().Property.ContainsKey("SHOP_BALANCE") && !(double.Parse(UnityContainer.Resolve <IOrderUserInfo>().Property["SHOP_BALANCE"]) == 0); var orders = from vo in oc.DataBaseContext.sp_sel_OrderBalance(_currentOrderHeader.IdOrderHeader, Convert.ToInt32(StoreHouseType), _currentOrderHeader.IdOrderState) select new GoodsBalanceObj { Barcode = vo.Barcode, Code = vo.Code, Date = vo.Date, FreeBalance = vo.FreeBalance.GetValueOrDefault(), Group = vo.GoodsGroup, id = vo.id_GoodsBalance, Measure = vo.Measure, MinOrder = vo.MinOrder.GetValueOrDefault(), Name = vo.Name, Price = vo.Price.GetValueOrDefault(), Ordered = vo.Ordered, Quantity = vo.Balance.GetValueOrDefault(), QuantityInPack = vo.QuantityInPack.GetValueOrDefault(), Reserved = vo.Reserved.GetValueOrDefault(), Supplier = vo.Supplier, RreqAssort = vo.IsReqAssort.GetValueOrDefault(false), ReqQuantity = vo.ReqQuantity, ForOrder = vo.ForOrder.GetValueOrDefault(0), AvgSell = vo.AvgSell, ShopBalance = vo.ShopBalance, Quota = vo.Quota, IsQuoted = vo.IsQuoted, SelfImport = vo.SelfImport, OrderMode = GoodsBalanceObj.ConvertToMode(vo.AutoOrderModeId), IsLoaded = true, IsShopBalance = isBalance, LastOrderDate = vo.LastAutoOrderDate.GetValueOrDefault(DateTime.MinValue.Date) }; foreach (var bl in orders) { bl.ChangeReqQuantity += BlChangeReqQuantity; bl.OnAutoOrdeer += bl_OnAutoOrdeer; balance.Add(bl); } BalanceList = balance; return(BalanceList); } } finally { Cursor.Current = Cursors.Default; } } return(null); }