Esempio n. 1
0
 /// <summary>
 /// 出库保存
 /// </summary>
 /// <param name="st"></param>
 public void OutBoundItem(StoreTable st)
 {
     using (var dbContext = new StoreDbContext())
     {
         dbContext.Update <StoreTable>(st);
     }
 }
        public ActionResult InBoundEdit(FormCollection collection)
        {
            var model = new StoreTable();
            //this.TryUpdateModel<StoreTable>(model);
            InBoundRecord ibr = new InBoundRecord();

            if (collection.AllKeys.Contains("DictionaryProperty.dpid"))
            {
                Guid proid = new Guid(collection["clID"]);
                int  temp  = 0;
                if (!int.TryParse(collection["InBoundCount"], out temp))
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                    return(PartialView());
                }

                model.number = int.Parse(collection["InBoundCount"]);

                DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]);
                model.store_item_id = dp.dpid;

                //插入数据到入库记录表
                ibr.inbound_id = dp.dpid;
                ibr.rkid       = Guid.NewGuid();
                ibr.number     = model.number;
                ibr.boundtype  = "入库";
                ibr.khmc       = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
                this.StoreService.InsertInboundRecord(ibr);
                ///入库
                this.StoreService.InsertStoreItem(model);
            }

            return(this.RefreshParent());
        }
Esempio n. 3
0
        /// <summary>
        /// 入库,如果有增加数量,如果没有新增
        /// </summary>
        /// <param name="st"></param>
        public void InsertStoreItem(StoreTable st)
        {
            using (var dbContext = new StoreDbContext())
            {
                var item = dbContext.StoreTable.Where(u => u.store_item_id == st.store_item_id).FirstOrDefault();

                if (item == null)
                {
                    st.kcid = Guid.NewGuid();
                    dbContext.Insert <StoreTable>(st);
                }
                else
                {
                    decimal totalnumber = item.number.Value;
                    string  guid        = item.kcid.ToString();
                    Guid    tempguid    = new Guid(guid);
                    st.number += totalnumber;
                    st.kcid    = tempguid;

                    ///问题的原因在于,我们之前已经附加过当前实体,如果再进行Attach的时候,就会报这样的错。
                    // 解决办法:1.销毁之前的上下文,重新开启上下文。(等于白说)
                    //2.更改当前上下文的实体的状态。(这个是问题关键)
                    var entry = dbContext.Set <StoreTable>().Find(tempguid);
                    if (entry != null)
                    {
                        dbContext.Entry <StoreTable>(entry).State = System.Data.EntityState.Detached; //这个是在同一个上下文能修改的关键
                    }
                    dbContext.Update <StoreTable>(st);
                }
            }
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (String.IsNullOrEmpty(Session["Username"].ToString()))
            {
                Response.Redirect("StartPage.aspx");
            }

            this.Welcome.InnerText = "Welcome " + Session["Username"].ToString(); //This is from JavaScript!

            string          constring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("App_Data/Database.accdb");
            OleDbConnection con       = new OleDbConnection(constring);
            con.Open();

            string           sql = string.Format("select * from [Products]");
            OleDbDataAdapter cmd = new OleDbDataAdapter(sql, con);

            DataTable dt = new DataTable();
            cmd.Fill(dt);
            con.Close();

            StoreTable.DataSource = dt;
            StoreTable.DataBind();
        }
        catch (Exception error)
        {
            Response.Redirect("StartPage.aspx");
        }
    }
Esempio n. 5
0
        /// <summary>
        /// 初始化出库edit框
        /// </summary>
        /// <returns></returns>
        public ActionResult Create()
        {
            var OrderList = this.StoreService.GetOrderList(new OrderRequest());

            this.ViewBag.OrderType = new SelectList(OrderList, "dt_id", "name");

            //获取组织机构列表(领用人)
            BranchRequest brequest = new BranchRequest();

            brequest.PageSize = 10000;
            var lyr = this.OAService.GetBranchList(brequest);

            List <string> clmcs = new List <string>();

            clmcs.Add("请选择领用人...");
            foreach (Branch branchItem in lyr)
            {
                clmcs.Add(branchItem.Name);
            }

            this.ViewBag.employment = new SelectList(clmcs);
            var model = new StoreTable();

            return(View("OutBoundEdit", model));
        }
 private void UpdateSelected(StoreTable product)
 {
     _selectedCost         = product.Cost;
     PositionSmall.Content = product.GoodName;
     CodeSmall.Content     = product.Code;
     PriceSmall.Content    = $"{product.Cost:f2}  руб.";
     QtySmall.Content      = $"{product.Qty:f2}  шт.";
     SumSmall.Content      = $"{product.Cost:f2} руб.";
 }
Esempio n. 7
0
        /// <summary>
        /// 环库EDIT初始化
        /// </summary>
        /// <returns></returns>
        public ActionResult ReturnOrder()
        {
            var OrderList = this.StoreService.GetOrderList(new OrderRequest());

            this.ViewBag.OrderType = new SelectList(OrderList, "dt_id", "name");
            var model = new StoreTable();

            return(View("ReturnOrderEdit", model));
        }
Esempio n. 8
0
        public void DeleteStore(int id)
        {
            StoreTable store = storeEntities.StoreTables.FirstOrDefault(e => e.ID == id);

            if (store != null)
            {
                storeEntities.StoreTables.Remove(store);
            }
            storeEntities.SaveChanges();
        }
Esempio n. 9
0
        public StoreTable GetStore(int store_id)
        {
            StoreTable store = storeEntities.StoreTables.FirstOrDefault(e => e.ID == store_id);

            if (store != null)
            {
                return(store);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
        public StoreTable GetStoreWithAddress(String address)
        {
            StoreTable store = storeEntities.StoreTables.Where(e => e.Address == address).FirstOrDefault();

            if (store != null)
            {
                return(store);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 11
0
        public Boolean isExist(String name, String address)
        {
            StoreTable store = storeEntities.StoreTables.Where(e => e.StoreName == name || e.Address == address).FirstOrDefault();

            if (store != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
 public StoreTable addStore([FromBody] StoreTable store)
 {
     if (store != null)
     {
         storeEntities.StoreTables.Add(store);
         storeEntities.SaveChanges();
         return(store);
     }
     else
     {
         return(null);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 初始化入库edit框
        /// </summary>
        /// <returns></returns>
        public ActionResult InBoundEdit()
        {
            var OrderList = this.StoreService.GetOrderList(new OrderRequest());

            this.ViewBag.OrderType = new SelectList(OrderList, "dt_id", "name");
            List <string> clmcs = new List <string>();

            clmcs.Add("请选择材料...");
            this.ViewBag.Materialnames = new SelectList(clmcs);

            var model = new StoreTable();

            return(View("InBoundEdit", model));
        }
Esempio n. 14
0
        public StoreTable updateStore(String store_name, String store_address, StoreTable store)
        {
            StoreTable entity = storeEntities.StoreTables.FirstOrDefault(e => e.StoreName == store_name && e.Address == store_address);

            if (entity != null)
            {
                entity.StoreName            = store.StoreName;
                entity.City                 = store.City;
                entity.Address              = store.Address;
                entity.PointsLimit          = store.PointsLimit;
                entity.PaymentToGetOnePoint = store.PaymentToGetOnePoint;
                entity.PercentageDiscount   = store.PercentageDiscount;
            }
            storeEntities.SaveChanges();
            return(entity);
        }
        // SHOW goods on the stock:
        private void SelectGood_Click(object sender, RoutedEventArgs e)
        {
            var storeList = new List <StoreTable>();

            _goodsInStore = ContextFactory.Instance.StoreTable.Where(x => x.Qty != 0);
            var dynamicId = 1;

            Products.ItemsSource = null;
            foreach (var good in _goodsInStore)
            {
                var newGood = new StoreTable(dynamicId, good.GoodName, good.Cost, good.Qty, good.Code);
                if (!_sessionOpened)
                {
                    storeList.Add(newGood); // FIRST click
                }
                if (_sessionOpened && _sessionGoods.All(x => x.Code != newGood.Code))
                {
                    storeList.Add(newGood); // NEXT adding
                }
                dynamicId++;
            }
            if (storeList.Count == 0)
            {
                Products.ItemsSource = _sessionGoods;
                Products.Items.Refresh();
                _isStockOpened = false;
                MessageBox.Show("Склад пуст или вами выбраны все доступные в нем товары.",
                                "Предупреждение",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            Products.ItemsSource = storeList;

            // SESSION open trigger:
            if (!_sessionOpened)
            {
                _sessionOpened = true;
                _sessionGoods  = new List <StoreTable>();
                InterfaceReInit();
            }
            _selectedCost  = 0;
            _isStockOpened = true;
        }
Esempio n. 16
0
        public ActionResult StoreEdit(string id, FormCollection collection)
        {
            StoreTable st = this.StoreService.GetStoreItem(new Guid(id));

            st.number = decimal.Parse(collection["number"]);
            InBoundRecord ibr = new InBoundRecord();

            //插入数据到入库记录表
            ibr.inbound_id = st.store_item_id;
            ibr.rkid       = Guid.NewGuid();
            ibr.number     = st.number;
            ibr.boundtype  = "库存修改";
            ibr.khmc       = this.StoreService.GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value);
            this.StoreService.InsertInboundRecord(ibr);

            this.StoreService.OutBoundItem(st);
            return(this.RefreshParent());
        }
Esempio n. 17
0
        /// <summary>
        /// 初始化修改库房数量
        /// </summary>
        /// <returns></returns>
        public ActionResult StoreEdit(string id)
        {
            StoreTable         st         = this.StoreService.GetStoreItem(new Guid(id));
            DictionaryProperty dp         = this.StoreService.GetDictionaryProperty(st.store_item_id.Value);
            string             leafname   = this.StoreService.GetTreeName(dp.leaf_id.Value);
            string             parentname = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
            StoreWindowModel   swm        = new StoreWindowModel();

            swm.clmc   = dp.clmc;
            swm.ddlx   = leafname;
            swm.khmc   = parentname;
            swm.pm     = dp.pm;
            swm.mf     = dp.mf;
            swm.js     = dp.js.ToString();
            swm.number = st.number.Value.ToString();

            return(View("StoreEdit", swm));
        }
Esempio n. 18
0
        public ActionResult Create(FormCollection collection)
        {
            if (collection.AllKeys.Contains("DictionaryProperty.dpid"))
            {
                StoreTableRequest request = new StoreTableRequest();
                request.PageSize = 1000;
                request.Gid      = new Guid(collection["DictionaryProperty.dpid"]);
                int OutProductNumber;
                if (!int.TryParse(collection["OutBoundCount"], out OutProductNumber))
                {
                    var model = new StoreTable();
                    return(View("OutBoundEdit", model));
                }
                //OutProductNumber = int.Parse(collection["OutBoundCount"]); //出库订单件数
                var  result = this.StoreService.GetStoreList(request);
                Guid tempid = new Guid();
                foreach (StoreTable st in result)
                {
                    if (st.DictionaryProperty.leaf_id == request.Gid)
                    {
                        st.number = st.number - (st.DictionaryProperty.js.Value * Convert.ToDecimal(OutProductNumber));
                        InBoundRecord ibr = new InBoundRecord();
                        //插入数据到入库记录表
                        ibr.inbound_id = st.store_item_id;
                        ibr.rkid       = Guid.NewGuid();
                        ibr.number     = st.number;
                        ibr.boundtype  = "出库材料";
                        ibr.khmc       = this.StoreService.GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value);
                        this.StoreService.InsertInboundRecord(ibr);

                        tempid = st.DictionaryProperty.leaf_id.Value;
                        //出库
                        this.StoreService.OutBoundItem(st);
                    }
                }
                //插入到出库记录表
                OutBoundRecord obr = new OutBoundRecord();
                obr.ckid    = Guid.NewGuid();
                obr.node_id = tempid;
                obr.number  = OutProductNumber;
                this.StoreService.InsertOutBoundRecord(obr);
            }
            return(this.RefreshParent());
        }
Esempio n. 19
0
        /// <summary>
        /// 插入库存操作记录
        /// </summary>
        /// <param name="ibr"></param>
        public void InsertInboundRecord(InBoundRecord ibr)
        {
            using (var dbContext = new StoreDbContext())
            {
                StoreTable st = dbContext.StoreTable.Include("DictionaryProperty.DictionaryTree").Where(u => u.store_item_id == ibr.inbound_id).FirstOrDefault();

                if (st == null)
                {
                    ibr.before_number = 0;
                }
                else
                {
                    ibr.before_number = st.number;
                    ibr.khmc          = GetParentNameByLeafID(st.DictionaryProperty.leaf_id.Value);
                }

                dbContext.Insert <InBoundRecord>(ibr);
            }
        }
Esempio n. 20
0
        public ActionResult Add(StoreTable storeTable)
        {
            ModelContainer context = new ModelContainer();
            List <Link>    link    = new List <Link> {
                new Link
                {
                    addDate   = DateTime.Now,
                    lastVisit = DateTime.Now.AddDays(-20),
                    status    = true,
                    link      = "http://" + storeTable.baseURL,
                }
            };

            List <BadWords> badwords = new List <BadWords>();
            List <string>   bwords   = storeTable.badwords[0].Split(',').ToList();

            foreach (string badword in bwords)
            {
                BadWords bw = new BadWords
                {
                    badWord = badword.Trim()
                };
                badwords.Add(bw);
            }

            Store store = new Store
            {
                name                  = storeTable.storeName,
                baseUrl               = storeTable.baseURL,
                currency              = storeTable.currency,
                titleSelector         = storeTable.titleSelector,
                originalPriceSelector = storeTable.originalPriceSelector,
                salePriceSelector     = storeTable.salePriceSelector,
                Link                  = link,
                BadWords              = badwords
            };

            context.Stores.Add(store);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Esempio n. 21
0
        public ActionResult ReturnOrder(FormCollection collection)
        {
            if (collection.AllKeys.Contains("DictionaryProperty.dpid"))
            {
                StoreTableRequest request = new StoreTableRequest();
                request.PageSize = 1000;
                request.Gid      = new Guid(collection["DictionaryProperty.dpid"]);
                int OutProductNumber = int.Parse(collection["OutBoundCount"]); //出库订单件数
                var result           = this.StoreService.GetStoreList(request);

                //获取订单下所有材料
                StoreTreeNameRequests stnRequest = new StoreTreeNameRequests();
                stnRequest.PageSize = 1000;
                stnRequest.treeID   = request.Gid;
                var clResultList = this.StoreService.GetNodeProperty(stnRequest);
                //循环材料列表,如果在StoreTable中存在更新其数量,如果不在插入数据
                foreach (DictionaryProperty dp in clResultList)
                {
                    StoreTable st = new StoreTable();
                    st.number        = 0;
                    st.number        = st.number + (dp.js.Value * Convert.ToDecimal(OutProductNumber));
                    st.store_item_id = dp.dpid;


                    InBoundRecord ibr = new InBoundRecord();
                    //插入数据到入库记录表
                    ibr.inbound_id = st.store_item_id;
                    ibr.rkid       = Guid.NewGuid();
                    ibr.number     = dp.js.Value * Convert.ToDecimal(OutProductNumber);
                    ibr.boundtype  = "还库材料";
                    ibr.khmc       = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
                    this.StoreService.InsertInboundRecord(ibr);
                    this.StoreService.InsertStoreItem(st);
                }
            }
            return(this.RefreshParent());
        }
Esempio n. 22
0
        public async Task <bool> ProcessOrderAsync(Order order)
        {
            //Recupera o ID da loja e os dados de cada produto
            StoreTable storeTable = await _storeTableQueryService.GetStoreTableAsync(order.TableId);

            order.StoreId = storeTable.StoreId;

            foreach (var item in order.OrderItems)
            {
                Product prod = await _productQueryService.GetProductAsync(item.ProductId);

                item.Price       = prod.Price;
                item.ProductName = prod.Name;
            }

            _uow.BeginTransaction();
            await _orderRepository.CreateAsync(order);

            _orderStatusService.AddTracking(order.Id, order.OrderStatus);
            await _uow.SaveChangesAsync();

            var paidInvoiceId = await _paymentService.ExecutePayment(order.Id, order.CustomerId, getOrderTotal(order));

            if (paidInvoiceId != null)
            {
                //Invoice paid. Lets change order status
                order.PaymentApproved = true;
                order.PaymentId       = paidInvoiceId.ToString();
                _orderRepository.Update(order);
                await _uow.SaveChangesAsync();
                await SetOrderStatus(order.StoreId, order.Id, OrderStatus.PaymentConfirmed);

                return(true);
            }
            return(false);
        }
Esempio n. 23
0
        public ActionResult Create(FormCollection collection)
        {
            if (collection.AllKeys.Contains("DictionaryProperty.dpid"))
            {
                StoreTableRequest request = new StoreTableRequest();
                request.PageSize = 10000;
                request.Gid      = new Guid(collection["DictionaryProperty.dpid"]);
                int OutProductNumber;
                if (!int.TryParse(collection["OutBoundCount"], out OutProductNumber))
                {
                    var model = new StoreTable();
                    return(View("OutBoundEdit", model));
                }
                var lydw = collection["employment"];
                ///
                var  result = this.StoreService.GetStoreList(request);
                Guid tempid = new Guid();//订单ID,出库记录表用
                //获取订单下所有材料
                StoreTreeNameRequests stnRequest = new StoreTreeNameRequests();
                stnRequest.PageSize = 1000;
                stnRequest.treeID   = request.Gid;
                var dpLists = this.StoreService.GetNodeProperty(stnRequest);
                foreach (DictionaryProperty dp in dpLists)
                {
                    var storeItem = this.StoreService.ExistDPInStore(dp);
                    tempid = dp.leaf_id.Value;
                    //判断store里是否有dp
                    if (storeItem == null)
                    {
                        StoreTable st = new StoreTable();
                        st.number        = 0;
                        st.number        = st.number - (dp.js.Value * Convert.ToDecimal(OutProductNumber));
                        st.store_item_id = dp.dpid;

                        InBoundRecord ibr = new InBoundRecord();
                        //插入数据到入库记录表
                        ibr.inbound_id = st.store_item_id;
                        ibr.rkid       = Guid.NewGuid();
                        ibr.number     = dp.js.Value * Convert.ToDecimal(OutProductNumber);
                        ibr.boundtype  = "出库材料";
                        ibr.employment = lydw;
                        ibr.khmc       = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
                        this.StoreService.InsertInboundRecord(ibr);

                        //出库
                        this.StoreService.InsertStoreItem(st);
                    }
                    else//有StoreItem
                    {
                        storeItem.number = storeItem.number - (dp.js.Value * Convert.ToDecimal(OutProductNumber));

                        InBoundRecord ibr = new InBoundRecord();
                        //插入数据到入库记录表
                        ibr.inbound_id = storeItem.store_item_id;
                        ibr.rkid       = Guid.NewGuid();
                        ibr.number     = dp.js.Value * Convert.ToDecimal(OutProductNumber);
                        ibr.boundtype  = "出库材料";
                        ibr.employment = lydw;
                        ibr.khmc       = this.StoreService.GetParentNameByLeafID(storeItem.DictionaryProperty.leaf_id.Value);
                        this.StoreService.InsertInboundRecord(ibr);

                        //出库
                        this.StoreService.OutBoundItem(storeItem);
                    }
                    //
                }
                //插入到出库记录表
                OutBoundRecord obr = new OutBoundRecord();
                obr.ckid       = Guid.NewGuid();
                obr.node_id    = tempid;
                obr.employment = lydw;
                obr.number     = OutProductNumber;
                this.StoreService.InsertOutBoundRecord(obr);
            }
            return(this.RefreshParent());
        }
Esempio n. 24
0
        public ActionResult InBoundEdit(FormCollection collection)
        {
            var model         = new StoreTable();
            var inBoundCounts = collection["InBoundCounts"];
            //this.TryUpdateModel<StoreTable>(model);
            InBoundRecord ibr = new InBoundRecord();

            if (bool.Parse(collection["pllr"].Split(',')[0]))
            {
                //批量添加材料
                //var tempdpids = TempData["dpids"];
                string   dpids        = collection["cllb"];
                string[] arrTemp      = dpids.Split(',');
                string[] arrCountTemp = inBoundCounts.Split(',');
                for (int i = 1; i < arrTemp.Length; i++)
                {
                    decimal temp = 0;
                    if (!decimal.TryParse(arrCountTemp[i - 1], out temp))
                    {
                        temp = 0;
                    }
                    var           modelTemp = new StoreTable();
                    InBoundRecord ibrTemp   = new InBoundRecord();
                    Guid          proid     = new Guid(arrTemp[i]);
                    modelTemp.number = temp;
                    DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]);
                    modelTemp.store_item_id = dp.dpid;

                    //插入数据到入库记录表
                    ibrTemp.inbound_id = dp.dpid;
                    ibrTemp.rkid       = Guid.NewGuid();
                    ibrTemp.number     = modelTemp.number;
                    ibrTemp.boundtype  = "入库";
                    ibrTemp.khmc       = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
                    this.StoreService.InsertInboundRecord(ibrTemp);
                    ///入库
                    this.StoreService.InsertStoreItem(modelTemp);
                }
                return(this.RefreshParent());
            }
            if (collection.AllKeys.Contains("DictionaryProperty.dpid"))
            {
                Guid    proid = new Guid(collection["clID"]);
                decimal temp  = 0;
                if (!decimal.TryParse(collection["InBoundCount"], out temp))
                {
                    temp = 0;
                }

                model.number = temp;

                DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]);
                model.store_item_id = dp.dpid;

                //插入数据到入库记录表
                ibr.inbound_id = dp.dpid;
                ibr.rkid       = Guid.NewGuid();
                ibr.number     = model.number;
                ibr.boundtype  = "入库";
                ibr.khmc       = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value);
                this.StoreService.InsertInboundRecord(ibr);
                ///入库
                this.StoreService.InsertStoreItem(model);
            }

            return(this.RefreshParent());
        }