/// <summary>
        /// Constructor of the view model
        /// </summary>
        /// <param name="currentPage">Page of the view mode</param>
        /// <param name="userServices">Services for the "User" table</param>
        /// <param name="alertServices">Services for the "Alert" table</param>
        /// <param name="materialServices">Services for the "Material" table</param>
        /// <param name="productServices">Services for the "Product" table</param>
        /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param>
        /// <param name="saleServices">Services for the "Sale" table</param>
        /// <param name="countAlerts">Number of alerts</param>
        public BoardViewModel(BoardWindow currentPage, UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, int countAlerts)
        {
            CurrentPage = currentPage;

            CurrentUserName   = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !";
            CurrentUserAdmin  = AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? Visibility.Visible : Visibility.Hidden;
            CurrentUserLambda = AppSettings.CurrentUser.Role == ERole.User.ToString() ? Visibility.Visible : Visibility.Hidden;

            UserServices             = userServices;
            AlertServices            = alertServices;
            MaterialServices         = materialServices;
            ProductServices          = productServices;
            MaterialsProductServices = materialsProductServices;
            SaleServices             = saleServices;

            BadgeAlert = countAlerts;

            GoBackCommand              = new CommandHandler(GoBack, () => true);
            GoToAddUserCommand         = new CommandHandler(GoToAddUser, () => true);
            GoToAlertsCommand          = new AsyncCommand(GoToAlerts, () => true);
            GoToListingElementsCommand = new AsyncCommand(GoToListingElements, () => true);
            GoToStatisticsCommand      = new AsyncCommand(GoToStatistics, () => true);
            GoToUpdateStockCommand     = new AsyncCommand(GoToUpdateStock, () => true);
            GoToAddElementCommand      = new AsyncCommand(GoToAddElement, () => true);
        }
示例#2
0
        /// <summary>
        /// Constructor of the view model
        /// </summary>
        /// <param name="currentPage">Page of the view mode</param>
        /// <param name="userServices">Services for the "User" table</param>
        /// <param name="alertServices">Services for the "Alert" table</param>
        /// <param name="materialServices">Services for the "Material" table</param>
        /// <param name="productServices">Services for the "Product" table</param>
        /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param>
        /// <param name="saleServices">Services for the "Sale" table</param>
        /// <param name="products">List of products</param>
        /// <param name="materials">List of materials</param>
        /// <param name="materialsProducts">List of materials product</param>
        public ListingElementsViewModel(ListingElementsWindow currentPage,
                                        UserServices userServices,
                                        AlertServices alertServices,
                                        MaterialServices materialServices,
                                        ProductServices productServices,
                                        MaterialsProductServices materialsProductServices,
                                        SaleServices saleServices,
                                        List <Product> products,
                                        List <Material> materials,
                                        List <MaterialsProduct> materialsProducts)
        {
            CurrentUserName = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !";
            CurrentPage     = currentPage;

            UserServices             = userServices;
            AlertServices            = alertServices;
            MaterialServices         = materialServices;
            ProductServices          = productServices;
            MaterialsProductServices = materialsProductServices;
            SaleServices             = saleServices;

            Products          = products;
            Materials         = materials;
            MaterialsProducts = materialsProducts;

            GenerateDatagrid();

            GoBackCommand = new AsyncCommand(GoBack, () => true);
        }
示例#3
0
        public HttpResponseMessage UpdaleSale(int saleID, Sale sale)
        {
            var updatedSale = SaleServices.UpdateSale(saleID, sale);

            var response = Request.CreateResponse(HttpStatusCode.OK, updatedSale, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("Response-Type", "JSON");
            response.Headers.Add("Updated-Product-URL", Request.RequestUri.AbsoluteUri);

            if (updatedSale == null)
            {
                var notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound,
                                                              "(404) Sale Not Found",
                                                              Configuration.Formatters.JsonFormatter);

                notFoundResponse.Headers.Add("API-Version", apiVersion);

                return(notFoundResponse);
            }
            else
            {
                return(response);
            }
        }
        public SaleReportViewModel()
        {
            _saleServ = new SaleServices();

            _key       = "";
            _isFocused = true;
            _dateFrom  = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            _dateTo    = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            Load();
        }
 /// <summary>
 /// This window is for adding a element
 /// </summary>
 /// <param name="userServices"></param>
 /// <param name="alertServices"></param>
 /// <param name="materialServices"></param>
 /// <param name="productServices"></param>
 /// <param name="materialsProductServices"></param>
 /// <param name="saleServices"></param>
 /// <param name="materials"></param>
 public AddElementWindow(UserServices userServices,
                         AlertServices alertServices,
                         MaterialServices materialServices,
                         ProductServices productServices,
                         MaterialsProductServices materialsProductServices,
                         SaleServices saleServices,
                         List <Material> materials)
 {
     InitializeComponent();
     DataContext = new AddElementViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, materials);
 }
示例#6
0
        private bool NewProductIsValid(SaleDetail saleDetail)
        {
            List <SaleDetail> saleDetails = new();

            foreach (SaleDetailUI saleDetailUI in SaleDetailUIs)
            {
                saleDetails.Add(saleDetailUI.SaleDetail);
            }
            saleDetails.Add(saleDetail);
            return(SaleServices.EnoughProductInStock(saleDetails));
        }
 public UpdateStockWindow(UserServices userServices,
                          AlertServices alertServices,
                          MaterialServices materialServices,
                          ProductServices productServices,
                          MaterialsProductServices materialsProductServices,
                          SaleServices saleServices,
                          List <Product> products,
                          List <Material> materials)
 {
     InitializeComponent();
     DataContext = new UpdateStockViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, products, materials);
 }
示例#8
0
        public void ExportToHtml(string outputPath, bool overwrite)
        {
            File.Copy(@".\UI\Resource\HTML_Template\MyPopupStore_ReportTemplate.html", outputPath, overwrite);

            string textHtml = File.ReadAllText(outputPath);

            textHtml = textHtml.Replace("MyPopupStore_Title", InfoServices.GetPopupStoreInfo().PopupStoreName);
            textHtml = textHtml.Replace("MyPopupStore_Interval", $"{Start.ToString("dd MMMM yyyy")} - {End.ToString("dd MMMM yyyy")}");
            textHtml = textHtml.Replace("MyPopupStore_LineProduct", WriteLinesOfTable(CollectProduct()));
            textHtml = textHtml.Replace("MyPopupStore_Total", SaleServices.GetTotal(Start, End).ToString());

            File.WriteAllText(outputPath, textHtml);
        }
        public SalespersonDisplayViewModel()
        {
            _saleServ                     = new SaleServices();
            _salespersonServ              = new SalespersonServices();
            _salespersonAddDialog         = new SalespersonAddDialog();
            _salespersonAccountShowDialog = new SalespersonAccountShowDialog();
            _salespersonUpdateDialog      = new SalespersonUpdateDialog();

            _key       = "";
            _isFocused = true;
            _salespersonsSuggestions = _salespersonServ.GetSalespersonsSuggetions();
            _currentWindow           = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            Load();
        }
示例#10
0
        public SaleDisplayViewModel()
        {
            _saleServ          = new SaleServices();
            _safeServ          = new SafeServices();
            _categoryServ      = new CategoryServices();
            _saleCategoryServ  = new SaleCategoryServices();
            _clientAccountServ = new ClientAccountServices();

            _key           = "";
            _isFocused     = true;
            _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            sales          = _saleServ.GetSales();
            Load();
        }
示例#11
0
        public void LoadListSale()
        {
            List <Sale> sales = SaleServices.getAllSales();

            ListAllSale.Clear();
            foreach (Sale sale in sales)
            {
                listAllSale.Add(new()
                {
                    Sale = sale,
                    QuantityOfProduct = SaleServices.getNumberProductOneSale(sale.SaleId),
                    Total             = SaleServices.getTotalOneSale(sale.SaleId)
                });
            }
        }
示例#12
0
        public IHttpActionResult GetSaleOrder(string order, string orderBy)
        {
            var salesList = SaleServices.GetSaleOrder(order.Trim(), orderBy.Trim());

            HttpContext.Current.Response.AppendHeader("API-Version", apiVersion);
            HttpContext.Current.Response.AppendHeader("Response-Type", "JSON");
            HttpContext.Current.Response.AppendHeader("Response-Object-Length", salesList.Count.ToString() + " Items");
            HttpContext.Current.Response.AppendHeader("List-URL", Request.RequestUri.AbsoluteUri);

            JsonSerializerSettings serializerSettings = new JsonSerializerSettings {
                Formatting = Formatting.Indented
            };

            return(Json(salesList, serializerSettings));
        }
        public void SetSaleDetailUIs(int SaleId)
        {
            List <SaleDetailUI> saleDetailUIs = new();
            List <SaleDetail>   saleDetails   = SaleServices.getSaleDetailsOneSale(SaleId);

            foreach (SaleDetail saleDetail in saleDetails)
            {
                saleDetailUIs.Add(new()
                {
                    Product    = ProductServices.GetProduct(saleDetail.ProductCode),
                    SaleDetail = saleDetail
                });
            }
            ListSaleDetails = saleDetailUIs;
        }
        /// <summary>
        /// déclanche la procédure de cloture du popupstore
        /// </summary>
        public void CloturePopupStore()
        {
            ClosePopupValidation closePopupValidation = new();

            if (closePopupValidation.ShowDialog() == true)
            {
                InfoServices.DeletePopupStoreInfo();
                SaleServices.DeleteSaleAndSaleDetails();
                if (closePopupValidation.DeleteProduct)
                {
                    ProductServices.RemoveAllProduct();
                }
            }

            RefreshInfo();
        }
示例#15
0
        private List <ProductInfo> CollectProduct()
        {
            List <ProductInfo> productInfos = new();
            List <Product>     products     = ProductServices.GetAllProduct();

            foreach (Product product in products)
            {
                productInfos.Add(new ProductInfo {
                    Code         = product.Code,
                    Label        = product.Label,
                    Stock        = product.QuantityStock ?? default(int),
                    SaleQuantity = SaleServices.QuantitySoldOfAProduct(product.Code, Start, End),
                });
            }
            return(productInfos);
        }
示例#16
0
        public SaleShowViewModel()
        {
            _saleServ          = new SaleServices();
            _categoryServ      = new CategoryServices();
            _saleRecallServ    = new SaleRecallServices();
            _saleCategoryServ  = new SaleCategoryServices();
            _clientAccountServ = new ClientAccountServices();
            _saleRecallDialog  = new SaleRecallDialog();

            _state          = "Normal";
            _isFocused      = true;
            _currentWindow  = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            _selectedSale   = _saleServ.GetSale(ID);
            _saleCategories = new ObservableCollection <SaleCategoryVM>(_saleCategoryServ.GetSaleCategoriesVM(ID));
            _categories     = new ObservableCollection <SaleRecallVM>(_saleRecallServ.GetSaleCategoriesVM(ID));
            RecallsQty      = _saleRecallServ.GetSaleRecallsSum(ID);
            Report          = "تقرير الفاتورة";
        }
示例#17
0
        public void SaveSale()
        {
            List <SaleDetail> saleDetails = new();

            foreach (SaleDetailUI saleDetailUi in SaleDetailUIs)
            {
                saleDetails.Add(saleDetailUi.SaleDetail);
            }
            try
            {
                SaleServices.NewSale(saleDetails, PaymentType);
                SaleDetailUIs.Clear();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
示例#18
0
        public SaleUpdateViewModel()
        {
            _safeServ          = new SafeServices();
            _saleServ          = new SaleServices();
            _clientServ        = new ClientServices();
            _categoryServ      = new CategoryServices();
            _salespersonServ   = new SalespersonServices();
            _saleCategoryServ  = new SaleCategoryServices();
            _clientAccountServ = new ClientAccountServices();
            _categoriesDialog  = new CategoriesShowDialog();
            _currentWindow     = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();

            _key            = "";
            _isFocused      = true;
            _selectedSale   = _saleServ.GetSale(ID);
            Salespersons    = new ObservableCollection <Salesperson>(_salespersonServ.GetSalespersons());
            _saleCategories = new ObservableCollection <SaleCategoryVM>(_saleCategoryServ.GetSaleCategoriesVM(ID));
            Report          = "تقرير الفاتورة";
        }
示例#19
0
        public HttpResponseMessage PostSale(Sale sale)
        {
            var createdSale = SaleServices.CreateSale(sale);

            var response = Request.CreateResponse(HttpStatusCode.Created, sale, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("HTTP-Method", "POST");

            if (Request.RequestUri.AbsoluteUri.EndsWith("/"))
            {
                response.Headers.Add("New-Sale-URL", Request.RequestUri.AbsoluteUri + createdSale.ID);
            }
            else
            {
                response.Headers.Add("New-Sale-URL", Request.RequestUri.AbsoluteUri + "/" + createdSale.ID);
            }
            return(response);
        }
        /// <summary>
        /// Constructor of the view model
        /// </summary>
        /// <param name="currentPage">Page of the view mode</param>
        /// <param name="userServices">Services for the "User" table</param>
        /// <param name="alertServices">Services for the "Alert" table</param>
        /// <param name="materialServices">Services for the "Material" table</param>
        /// <param name="productServices">Services for the "Product" table</param>
        /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param>
        /// <param name="saleServices">Services for the "Sale" table</param>
        /// <param name="countBySite">Data to the graphic "Count Sales By Site"</param>
        /// <param name="evolutionByMonth">Data to the graphic "Evolution by month"</param>
        /// <param name="moneyEarned">Money earned until the start</param>
        /// <param name="moneyEarnedByYear">Data to the graphic "Money by year"</param>
        public StatisticsViewModel(StatisticsWindow currentPage, UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, Dictionary <string, int> countBySite, List <Tuple <string, int, int, int> > evolutionByMonth, float moneyEarned, Dictionary <int, float> moneyEarnedByYear)
        {
            CurrentPage     = currentPage;
            CurrentUserName = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !";

            UserServices             = userServices;
            AlertServices            = alertServices;
            MaterialServices         = materialServices;
            ProductServices          = productServices;
            MaterialsProductServices = materialsProductServices;
            SaleServices             = saleServices;

            GenerateCountSalesBySite(countBySite);
            GenerateEvolutionByMonth(evolutionByMonth);
            GenerateMoneyEarnedByYear(moneyEarnedByYear);
            MoneyEarned = $"{moneyEarned:C}";

            GoBackCommand = new AsyncCommand(GoBack, () => true);
        }
示例#21
0
        public IHttpActionResult GetSale(int id)
        {
            Sale sale = SaleServices.GetSale(id);

            HttpContext.Current.Response.AppendHeader("API-Version", apiVersion);

            if (sale == null)
            {
                HttpContext.Current.Response.AppendHeader("ERROR", "(404) Resource Not Found");
                return(NotFound());
            }
            else
            {
                HttpContext.Current.Response.AppendHeader("Response-Type", "JSON");
                HttpContext.Current.Response.AppendHeader("Object-URL", Request.RequestUri.AbsoluteUri);
                JsonSerializerSettings serializerSettings = new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                };
                return(Json(sale, serializerSettings));
            }
        }
示例#22
0
        public SaleAddViewModel()
        {
            _safeServ          = new SafeServices();
            _saleServ          = new SaleServices();
            _clientServ        = new ClientServices();
            _categoryServ      = new CategoryServices();
            _salespersonServ   = new SalespersonServices();
            _saleCategoryServ  = new SaleCategoryServices();
            _clientAccountServ = new ClientAccountServices();
            _newSale           = new Sale();
            _categoriesDialog  = new CategoriesShowDialog();
            _saleCategories    = new ObservableCollection <SaleCategoryVM>();

            _key           = "";
            _isFocused     = true;
            _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            Clients        = new ObservableCollection <Client>(_clientServ.GetClients());
            Salespersons   = new ObservableCollection <Salesperson>(_salespersonServ.GetSalespersons());
            NewSale.Date   = DateTime.Now;
            Report         = "تقرير الفاتورة";
        }
示例#23
0
        public HttpResponseMessage DeleteSale(int saleID)
        {
            var deletedSale = SaleServices.DeleteSale(saleID);

            var response = Request.CreateResponse(HttpStatusCode.OK, deletedSale, Configuration.Formatters.JsonFormatter);

            response.Headers.Add("API-Version", apiVersion);
            response.Headers.Add("Response-Type", "JSON");

            if (deletedSale == null)
            {
                var notFoundResponse = Request.CreateResponse(HttpStatusCode.NotFound, "(404) Sale not found",
                                                              Configuration.Formatters.JsonFormatter);

                notFoundResponse.Headers.Add("API-Version", apiVersion);

                return(notFoundResponse);
            }
            else
            {
                return(response);
            }
        }
示例#24
0
        public ActionResult GetStates(long countryId, string subdomain)
        {
            var storeSetting = new SessionHelpers().GetStoreInfo(subdomain);

            if (storeSetting == null || storeSetting.StoreId < 1)
            {
                return(Json(new StoreCustomerTypeObject(), JsonRequestBehavior.AllowGet));
            }
            try
            {
                if (countryId < 1)
                {
                    return(Json(new List <StoreCountryObject>(), JsonRequestBehavior.AllowGet));
                }

                var states = new SaleServices().GetStates(countryId);

                return(Json(states, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new ChartOfAccountObject(), JsonRequestBehavior.AllowGet));
            }
        }
 /// <summary>
 /// Main window of the application.
 /// </summary>
 /// <param name="userServices"></param>
 /// <param name="alertServices"></param>
 public MainWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices)
 {
     InitializeComponent();
     DataContext = new MainWindowViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices);
 }
 /// <summary>
 /// Creates a new window
 /// </summary>
 /// <param name="userServices"></param>
 /// <param name="alertServices"></param>
 /// <param name="countAlerts"></param>
 public BoardWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, int countAlerts)
 {
     InitializeComponent();
     DataContext = new BoardViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, countAlerts);
 }
 /// <summary>
 /// Creates a new window
 /// </summary>
 public StatisticsWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, Dictionary <string, int> countBySite, List <Tuple <string, int, int, int> > evolutionByMonth, float moneyEarned, Dictionary <int, float> moneyEarnedByYear)
 {
     InitializeComponent();
     DataContext = new StatisticsViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, countBySite, evolutionByMonth, moneyEarned, moneyEarnedByYear);
 }