Beispiel #1
0
        private void BtnAdjustmentClick(object sender, EventArgs e)
        {
            if (_product == null)
                return;

            try
            {
                string briefMsg, detailMsg;
                if (!UserService.AllowToPerform(Resources.PermissionProductAdjustment))
                {
                    briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                briefMsg = "អំពីការសង";
                detailMsg = "សូម​មេត្តា​ចុច​លើ​ប៊ូតុង យល់​ព្រម ដើម្បី​បញ្ជាក់​ពី​ការ​ដកចេញពីឃ្លាំង​។";
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

                using (var folderBrowserDialog = new FolderBrowserDialog())
                {
                    folderBrowserDialog.ShowNewFolderButton = false;
                    if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (_productService == null)
                            _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                        IList listProduct2Export = new List<Product> {_product};

                        _productService.ExportProductToXml(
                            listProduct2Export,
                            folderBrowserDialog.SelectedPath,
                            "ProductList.xml");

                        var productAdjustment = new ProductAdjustment
                                                    {
                                                        ProductId = _product.ProductId,
                                                        QtyInStock = _product.QtyInStock,
                                                        QtyAdjusted = ((-1)*_product.QtyInStock),
                                                        FkProduct = _product
                                                    };

                        if (_productService == null)
                            _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                        _productService.ProductAdjustmentManagement(
                            Resources.OperationRequestInsert,
                            productAdjustment);

                        _isModified = true;
                        DialogResult = DialogResult.OK;
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
        private void InsertProductAdjustment(ProductAdjustment productAdjustment)
        {
            if (productAdjustment == null)
                throw new ArgumentNullException("productAdjustment", Resources.ConstProductAdjustment);

            _productDataAccess.InsertProductAdjustment(productAdjustment);
        }
        public virtual void ProductAdjustmentManagement(string requestStr, ProductAdjustment productAdjustment)
        {
            if (string.IsNullOrEmpty(requestStr))
                throw new ArgumentNullException("requestStr", Resources.ConstRequestOperation);

            if (productAdjustment == null)
                throw new ArgumentNullException("productAdjustment", Resources.ConstProductAdjustment);

            if (requestStr.Equals(Resources.OperationRequestInsert))
                InsertProductAdjustment(productAdjustment);

            productAdjustment.FkProduct.QtyInStock = productAdjustment.QtyAdjusted;
            ManageProduct(productAdjustment.FkProduct, requestStr);
        }
 public virtual void DeleteProductAdjustment(ProductAdjustment productAdjustment)
 {
     DeleteObject(productAdjustment);
 }
 public virtual void UpdateProductAdjustment(ProductAdjustment productAdjustment)
 {
     UpdateObject(productAdjustment);
 }
 public virtual void InsertProductAdjustment(ProductAdjustment productAdjustment)
 {
     InsertObject(productAdjustment);
 }