Пример #1
0
        void B_Move_Click(object sender, System.EventArgs e)
        {
            if (!int.TryParse(T_Amount.Text, out int amount) || amount < 1)
            {
                MessageBox.Show(this, Resources.INVALID_SKU_QTY_IS_ENTERED, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (amount > _selectedCell.Amount)
            {
                MessageBox.Show(this, Resources.QTY_TOO_BIG_FOR_GIVEN_CELL, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            PointOfSale pointOfSale = PointOfSale.Restore(((LiteBizItem)CB_PointsOfSale.SelectedItem).Value);

            if (MessageBox.Show(this, string.Format(Resources.CONFIRM_MOVING_GOODS, _skuInStock.Article.Name, amount, pointOfSale.Name), Resources.CONFIRMATION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }

            // TODO: Implement transaction
            SkuInStock skuInDestination = SkuInStock.Restore(_skuInStock.Article, pointOfSale);

            skuInDestination[_selectedCell.X, _selectedCell.Y].Amount += amount;
            skuInDestination.Flush();
            _skuInStock[_selectedCell.X, _selectedCell.Y].Amount -= amount;
            _skuInStock.Flush();
            //_selectedCell.Flush();

            ((PanelViewSku)Parent.Parent.Parent).UpdateWOldSearch();
            MessageBox.Show(this, Resources.GOODS_HAS_BEEN_MOVED, Resources.MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
        public ActionResult LocalSettings(LocalSettings item)
        {
            item.Store       = Store.TryFind(item.StoreId);
            item.PointOfSale = PointOfSale.TryFind(item.PointOfSaleId);
            item.CashDrawer  = CashDrawer.TryFind(item.CashDrawerId.GetValueOrDefault());

            if (!ModelState.IsValid)
            {
                return(View(item));
            }

            Response.Cookies.Add(new HttpCookie(WebConfig.StoreCookieKey)
            {
                Value   = item.Store.Id.ToString(),
                Expires = DateTime.Now.AddYears(100)
            });

            if (item.PointOfSale != null)
            {
                Response.Cookies.Add(new HttpCookie(WebConfig.PointOfSaleCookieKey)
                {
                    Value   = item.PointOfSale.Id.ToString(),
                    Expires = DateTime.Now.AddYears(100)
                });
            }
            else
            {
                if (Request.Cookies [WebConfig.PointOfSaleCookieKey] != null)
                {
                    Response.Cookies.Add(new HttpCookie(WebConfig.PointOfSaleCookieKey)
                    {
                        Value   = string.Empty,
                        Expires = DateTime.Now.AddDays(-1d)
                    });
                }
            }

            if (item.CashDrawer != null)
            {
                Response.Cookies.Add(new HttpCookie(WebConfig.CashDrawerCookieKey)
                {
                    Value   = item.CashDrawer.Id.ToString(),
                    Expires = DateTime.Now.AddYears(100)
                });
            }
            else
            {
                if (Request.Cookies [WebConfig.CashDrawerCookieKey] != null)
                {
                    Response.Cookies.Add(new HttpCookie(WebConfig.CashDrawerCookieKey)
                    {
                        Value   = string.Empty,
                        Expires = DateTime.Now.AddDays(-1d)
                    });
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #3
0
        public async Task <PointOfSale> Create(PointOfSale pos)
        {
            _db.PointOfSales.Add(pos);

            await _db.SaveChangesAsync();

            return(pos);
        }
Пример #4
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            PointOfSale c = new PointOfSale();

            c = cs.Get(t => t.id == id);
            cs.Delete(c);
            cs.Commit();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Index([Bind(Include = "EmployeeKey, SaleDate, ProductKey, SaleDetailPriceCharged,SaleDetailDiscount,SaleKey")] PointOfSale pos)
        {
            db.SaveChanges();

            //Receipt sent through the Message class to result page
            Message msg = new Message("Thank you for your purchase! Total price is " + pos.SaleDetailPriceCharged + " with  discount of " + pos.SaleDetailDiscount + " for item #" + pos.ProductKey);

            return(View("Result", msg));
        }
Пример #6
0
        public void SetPointOfSale(PointOfSale pointOfSale)
        {
            if (pointOfSale == null)
            {
                ValidationService.ValidateExistRequest(pointOfSale, FieldResource.PointOfSale);
            }

            PointOfSale = pointOfSale;
        }
        /// <inheritdoc />
        public PointOfSale CreateOrUpdatePos(PointOfSale request)
        {
            var req = BuildRequest(request.Id == 0 ? "point-of-sales" : $"point-of-sales/{request.Id}/", request.Id == 0 ? Method.POST : Method.PUT);

            req.AddJsonBody(request);
            var res = ExecuteRequestInternal <PointOfSale>(req);

            AssertOk(res);
            return(res.Data);
        }
Пример #8
0
 public Order(int id, Waiter waiter, PointOfSale pointOfSale, Table table,
              DateTime creationDate, StatusOrderEnum statusOrder)
 {
     Id           = id;
     CreationDate = ValidationService.SetDate(creationDate, FieldResource.CreationDate);
     StatusOrder  = statusOrder;
     SetWaiter(waiter);
     SetPointOfSale(pointOfSale);
     SetTable(table);
 }
Пример #9
0
        public PointOfSale MapEntity(PointOfSaleRequest request)
        {
            PointOfSale pointOfSale = new PointOfSale(request.Id, request.Number, request.TypePointOfSale);

            UpdateOrder(pointOfSale);

            UpdateOrderItem(pointOfSale);

            return(pointOfSale);
        }
Пример #10
0
        private PointOfSale ValidatePointOfSale(int id)
        {
            PointOfSale pointOfSale = pointOfSaleRepository.GetInstance().Select(id).FirstOrDefault();

            if (pointOfSale == null || pointOfSale.Id <= 0)
            {
                throw new InvalidRequestException(string.Format(MessageResource.InvalidRequest, FieldResource.PointOfSale.ToLower()));
            }

            return(pointOfSale);
        }
        public IHttpActionResult GetPointOfSale(int id)
        {
            PointOfSale pointOfSale = db.PointOfSales.Find(id);

            if (pointOfSale == null)
            {
                return(NotFound());
            }

            return(Ok(pointOfSale));
        }
Пример #12
0
 public static void Validate(this PointOfSale pointOfSale)
 {
     if (!HasValue(pointOfSale.ValueToPay, pointOfSale.TotalValue))
     {
         throw new PointOfSaleException(HasNotValue);
     }
     if (!IsBigger(pointOfSale.ValueToPay, pointOfSale.TotalValue))
     {
         throw new PointOfSaleException(ValueToPayIsSmaller);
     }
 }
Пример #13
0
        public void Setup()
        {
            _keyPos         = CryptoHelper.LoadKeyFromPem <AsymmetricCipherKeyPair>("pos1.pem").Private;
            _keyInstrument1 = CryptoHelper.LoadKeyFromPem <AsymmetricCipherKeyPair>("source1.pem").Private;
            _keyRegistry    = CryptoHelper.LoadKeyFromPem <AsymmetricCipherKeyPair>("registry.pem").Public;

            _rnd = new Random();

            _womClient  = new Client("dev.wom.social", new ConsoleLoggerFactory(), _keyRegistry);
            _instrument = _womClient.CreateInstrument(_idSource, _keyInstrument1);
            _pos        = _womClient.CreatePos(_idPos, _keyPos);
        }
Пример #14
0
        private void UpdateOrderItem(PointOfSale entity)
        {
            List <OrderItem> list = orderItemRepository.GetInstance().Select().Where(x => x.Order.PointOfSale.Id == entity.Id)
                                    .Select(s => new OrderItem(s.Id, s.Order, s.Product, s.Amount)).ToList();

            foreach (var obj in list)
            {
                obj.Order.SetPointOfSale(entity);

                orderItemRepository.GetInstance().Update(obj);
            }
        }
Пример #15
0
        private void UpdateOrder(PointOfSale entity)
        {
            List <Order> list = orderRepository.GetInstance().Select().Where(x => x.PointOfSale.Id == entity.Id)
                                .Select(s => new Order(s.Id, s.Waiter, s.PointOfSale, s.Table, s.CreationDate, s.StatusOrder)).ToList();

            foreach (var obj in list)
            {
                obj.SetPointOfSale(entity);

                orderRepository.GetInstance().Update(obj);
            }
        }
Пример #16
0
        public Order MapEntity(OrderRequest request)
        {
            Waiter      waiter      = ValidateWaiter(request.IdWaiter);
            PointOfSale pointOfSale = ValidatePointOfSale(request.IdPointOfSale);
            Table       table       = ValidateTable(request.IdTable);

            Order order = new Order(request.Id, waiter, pointOfSale, table, request.CreationDate, request.StatusOrder);

            UpdateOrderItem(order);

            return(order);
        }
Пример #17
0
        public async Task <ChangeComposition> GetChangeAsync(PointOfSale pointOfSale)
        {
            pointOfSale.Validate();
            Bills = await BillService.GetBillsAsync();

            Coins = await CoinService.GetCoinsAsync();

            var result = CalculeChange(Math.Round(pointOfSale.ValueToPay - pointOfSale.TotalValue, 2, MidpointRounding.ToZero), new ChangeComposition());
            await TransactionService.RegisterAsync(pointOfSale, result);

            return(result);
        }
        public IHttpActionResult PostPointOfSale(PointOfSale pointOfSale)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PointOfSales.Add(pointOfSale);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = pointOfSale.ID }, pointOfSale));
        }
Пример #19
0
        void B_Read_Click(object sender, EventArgs e)
        {
            PointOfSale o = GetObject();

            if (o == null)
            {
                Clear();
                return;
            }

            T_Name.Text = o.Name;
        }
Пример #20
0
        public async Task <IActionResult> Create([Bind("Id,Name,EnterpriseId")] PointOfSale pointOfSale)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pointOfSale);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnterpriseId"] = new SelectList(_context.Enterprises, "Id", "Id", pointOfSale.EnterpriseId);
            return(View(pointOfSale));
        }
Пример #21
0
        public async Task RegisterAsync(PointOfSale pointOfSale, ChangeComposition composition)
        {
            using var context = new PointOfSaleContext(_configuration);
            await context.Transactions.AddAsync(new Transactions
            {
                ValueToPay    = pointOfSale.ValueToPay,
                TotalValue    = pointOfSale.TotalValue,
                Change        = composition.TotalChange,
                ChangeMessage = composition.ResponseMessage
            });

            await context.SaveChangesAsync();
        }
Пример #22
0
        public ActionResult DeleteConfirmed(int id)
        {
            var item = PointOfSale.Find(id);

            //PointOfSale item = PointOfSale.Find (id);
            try {
                using (var scope = new TransactionScope()) {
                    item.DeleteAndFlush();
                }
                return(PartialView("_DeleteSuccesful", item));
            } catch (Exception) {
                return(PartialView("DeleteUnsuccessful"));
            }
        }
Пример #23
0
        public ActionResult Create(PointOfSale item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Create", item);

            item.Store = Store.Find (item.StoreId);
            item.Warehouse = Warehouse.Find (item.WarehouseId);

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
Пример #24
0
        public string getTransactionType(string description)
        {
            description = description.ToUpper();

            if (Deposit.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.Deposit.ToString());
            }
            else if (PaymentMade.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.PaymentMade.ToString());
            }
            else if (PaymentReceived.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.PaymentReceived.ToString());
            }
            else if (PointOfSale.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.PointOfSale.ToString());
            }
            else if (Withdrawal.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.Withdrawal.ToString());
            }
            else if (OverseePurchase.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.OverseePurchase.ToString());
            }
            else if (TransactionCharges.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.TransactionCharges.ToString());
            }
            else if (AdminCharges.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.AdminCharges.ToString());
            }
            else if (PrepaidAirtime.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.PrepaidAirtime.ToString());
            }
            else if (MonthlyAccountCharges.Any(n => description.IndexOf(n) != -1))
            {
                return(Enumerators.TransactionType.MonthlyAccountCharges.ToString());
            }
            // Extend transaction type here
            else
            {
                return(Enumerators.TransactionType.Unknown.ToString());
            }
        }
Пример #25
0
        public void GetCartValue_WhenNoClubbedOffer_ShouldReturnOfferValue()
        {
            // Arrange
            var pos = new PointOfSale(this.backOffice);

            pos.AddItemToCart("A", 5);
            pos.AddItemToCart("B", 5);
            pos.AddItemToCart("C", 1);

            // Act
            var cartValue = pos.GetCartValue();

            // Assertions
            Assert.AreEqual(370, cartValue);
        }
Пример #26
0
        private async void DeleteTapGesture_Tapped(object sender, EventArgs e)
        {
            int         ID          = Int32.Parse(((((((sender as Image).Parent as StackLayout).Parent as Grid).Parent as StackLayout).Parent as Grid).Parent as StackLayout).ClassId);
            PointOfSale pointOfSale = pastryShop.PointOfSales.FirstOrDefault(p => p.ID == ID);

            if (pointOfSale != null)
            {
                RestClient <PointOfSale> pointOfSaleRC = new RestClient <PointOfSale>();
                if (!(await pointOfSaleRC.DeleteAsync(pointOfSale.ID)))
                {
                    return;
                }
                load();
            }
        }
        public IHttpActionResult DeletePointOfSale(int id)
        {
            PointOfSale pointOfSale = db.PointOfSales.Find(id);

            if (pointOfSale == null)
            {
                return(NotFound());
            }
            var phoneNumbers = new List <PhoneNumber>(pointOfSale.PhoneNumbers);

            db.PointOfSales.Remove(pointOfSale);
            phoneNumbers.ForEach(p => db.PhoneNumbers.Remove(p));
            db.Addresses.Remove(db.Addresses.Find(pointOfSale.Address_FK));
            db.SaveChanges();
            return(Ok(pointOfSale));
        }
Пример #28
0
        static void Main(string[] args)
        {
            string[]    fruitlist = { "Apple", "Apple", "Orange", "Apple" };
            PointOfSale POS       = new PointOfSale(fruitlist);

            Console.WriteLine("Billing ");
            Console.WriteLine("Item\t\t\tQty\tAmount");
            double totalCost = 0;

            foreach (Bill bill in POS.Bills)
            {
                Console.WriteLine("{0}\t{1}\t{2}", bill.Description, bill.Quantity, bill.Cost);
                totalCost += bill.Cost;
            }
            Console.WriteLine("Total:\t\t\t\t{0}", totalCost);
        }
Пример #29
0
        // GET: PointOfSale/Edit/5
        public ActionResult Edit(int id)
        {
            PointOfSale cm = new PointOfSale();

            cm = cs.Get(t => t.id == id);
            PointOfSaleModel c = new PointOfSaleModel();

            c.id     = cm.id;
            c.nom    = cm.nom;
            c.Adress = cm.Adress;

            c.phone = cm.phone;
            c.Type  = cm.Type;

            return(View(c));
        }
Пример #30
0
        public ActionResult Create(PointOfSale item)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", item));
            }

            item.Store     = Store.Find(item.StoreId);
            item.Warehouse = Warehouse.Find(item.WarehouseId);

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_CreateSuccesful", item));
        }
Пример #31
0
        public ActionResult Edit(int id, PointOfSale cm)
        {
            PointOfSale c = new PointOfSale();

            c    = cs.Get(t => t.id == id);
            c.id = cm.id;

            c.Adress = cm.Adress;
            c.nom    = cm.nom;
            c.phone  = cm.phone;
            c.Type   = cm.Type;


            cs.Update(c);
            cs.Commit();
            return(RedirectToAction("Index"));
        }
Пример #32
0
        public ActionResult Edit(PointOfSale item)
        {
            if (!ModelState.IsValid)
                return PartialView ("_Edit", item);

            var entity = PointOfSale.Find (item.Id);

            entity.Code = item.Code;
            entity.Name = item.Name;
            entity.Comment = item.Comment;

            using (var scope = new TransactionScope ()) {
                entity.UpdateAndFlush ();
            }

            return PartialView ("_Refresh");
        }