コード例 #1
0
        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 )
            {

                //
            }
        }
コード例 #2
0
        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);
        }