public StockState()
 {
     InitializeComponent();
     _CategorysClient = new CategorysClient();
     _productManger=new ProductManger();
     cbCategorys.ItemsSource = _CategorysClient.GetCategorysNames();
     cbCategorys_SelectedIndexChanged(null, null);
 }
 public AddProductView(string animationName)
 {
     InitializeComponent();
     _CategorysClient = new CategorysClient();
     _productManger = new ProductManger();
      _measureManager = new MeasureManager();
     if (string.IsNullOrEmpty(animationName)) return;
     var animation = (Storyboard) Application.Current.Resources[animationName];
     LayoutRoot.BeginStoryboard(animation);
 }
 public StockState(string animationName)
 {
     InitializeComponent();
     _CategorysClient = new CategorysClient();
     _productManger = new ProductManger();
     GetCategorys();
     if (string.IsNullOrEmpty(animationName)) return;
     Storyboard animation = (Storyboard)Application.Current.Resources[animationName];
     LayoutRoot.BeginStoryboard(animation);
 }
 public StatisticsView(string animationName)
 {
     InitializeComponent();
     _purchaseClient = new PurchaseClient();
     _orderClient = new OrderClient();
     _productClient = new ProductManger();
     _suppliersManager = new SuppliersManager();
     _customersManager = new CustomersManager();
     if (string.IsNullOrEmpty(animationName)) return;
     Storyboard animation = (Storyboard)Application.Current.Resources[animationName];
     LayoutRoot.BeginStoryboard(animation);
 }
        public ListProductsView(string animationName, TabHelper hlp)
        {
            InitializeComponent();
            _tabHlp = hlp;
            _produit = new Product();
            _productClient = new ProductManger();
            _CategorysClient = new CategorysClient();

            if (string.IsNullOrEmpty(animationName)) return;
            Storyboard animation = (Storyboard) Application.Current.Resources[animationName];
            LayoutRoot.BeginStoryboard(animation);
        }
        public StockView(string animationName)
        {
            InitializeComponent();

            if (!string.IsNullOrEmpty(animationName))
            {
                Storyboard animation = (Storyboard)Application.Current.Resources[animationName];
                LayoutRoot.BeginStoryboard(animation);
            }
            LoadEmptyble();
            _CategorysClient=new CategorysClient();
            _productManger=new ProductManger();
            _stockManager=new StockManager();
        }
        public AddPurchaseView(string animationName, TabHelper hlp)
        {
            InitializeComponent();
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

            Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
            _tabHlp = hlp;
            _productsSelSelected = new List<ProduitsSel>();
            //produit = new Products();
            _productManger = new ProductManger();

            _tvaClient = new TvaClient();
            TvaComboBox.ItemsSource = _tvaClient.GetTvaValues();

            _suppliersManager = new SuppliersManager();
            _productManger.ResetUnitsOnOrder();
            _productSelected = new List<Product>();
            if (string.IsNullOrEmpty(animationName)) return;
            var animation = (Storyboard) Application.Current.Resources[animationName];
            LayoutRoot.BeginStoryboard(animation);
        }
        private void DeleteSupplierBtn_Click(object sender, RoutedEventArgs e)
        {
            if (ProductsDataGrid.VisibleRowCount == 0) return;

            if (MessageBox.Show("Êtes-vous sûr de vouloir supprimer  ce produit?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.No) return;

            int rowHandle = ProductsDataGrid.View.FocusedRowHandle;

            ProductManger pc = new ProductManger();
            Product produit = pc.GetProductByName(ProductsDataGrid.GetCellValue(rowHandle, "ProductName").ToString());

            if (produit == null) return;
            pc.DesactivateProduct(produit);
            LoadProductGridControl();
        }
        private void ProductTableView_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (ProductsDataGrid.VisibleRowCount == 0) return;
                int rowHandle = ProductsDataGrid.View.FocusedRowHandle;
                if (rowHandle < 0) return;
                ProductManger productManger = new ProductManger();
                productId = (int) ProductsDataGrid.GetCellValue(rowHandle, "ProductID");
                Product produit = productManger.GetProductById(productId);

                if (produit == null)
                {
                    productId = -1;
                    return;
                }
                LoadProductFields(produit);
            }
            catch (Exception )
            {

                //
            }
        }
        private void EditSupplierBtn_Click(object sender, RoutedEventArgs e)
        {
            if (productId == -1) return;

            if (DXMessageBox.Show(this,"Êtes-vous sûr de vouloir modifier ce produit?", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.No) return;

            ProductManger productManger = new ProductManger();

            Product produit = productManger.GetProductById(productId);

            if (produit == null) return;

            var image = ImageEdit1.Source as BitmapImage;
            if (image != null)
            {
                BitmapImage bi = image;
                FileStream stream = bi.StreamSource as FileStream;
                if (stream != null)
                {
                    var photoPath = stream.Name;
                    produit.Photo = Validator.ConvertImageToByteArray(photoPath);
                }
            }

            string categoryName = CategorysCbx.Text;
            string subCategoryName = SubCategoryCbx.Text;
            string productName = ProductNameTxtBox.Text;
            string productMeasure = MeasureCbx.Text;
            string productType = ProductTypeCbx.Text;
            string productReference = ProductReferenceTxt.Text;
            int qteMin = (int)ProductQteMinSpin.Value;
            int qteMax = (int)ProductQteMaxSpin.Value;
            string productDesignation = ProductDesignationTxt.Text;
            string productRemarks = ProductRemarksTxt.Text;

            String result = productManger.UpdateProduct(produit,categoryName, subCategoryName, productName, productMeasure, productType,
                productReference, qteMin, qteMax, productDesignation, productRemarks);
            DXMessageBox.Show(this, result);
            RefreshBtn_OnClick(null, null);
        }