private void ProductFetching()
        {
            if(string.IsNullOrEmpty(txtProductCode.Text))
            {
                _productList.Clear();
                return;
            }

            var searchCriteria = new List<string>();
            if (txtProductCode.Text.Length != 0)
            {
                searchCriteria.Add(
                    "(ProductCode LIKE '%" + txtProductCode.Text + "%') OR " +
                    "(ForeignCode LIKE '%" + txtProductCode.Text + "%')");
            }

            if (_productService == null)
                _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

            _productList.Clear();
            IListToBindingList(
                _productService.GetCatalogs(searchCriteria, true));
        }
Esempio n. 2
0
        private void CtrlSale_Load(object sender, EventArgs e)
        {
            try
            {
                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                if (_customerService == null)
                    _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                if (_saleOrderService == null)
                    _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                if (_depositService == null)
                    _depositService = ServiceFactory.GenerateServiceInstance().GenerateDepositService();

                if (!UserService.AllowToPerform(Resources.PermissionProductAdjustment))
                    btnProductAdjustment.Visible = false;

                //if (!UserService.AllowToPerform(Resources.PermissionViewSalesResultInfo))
                //{
                   // lblResultInfo.Visible = false;
                //}
                //Initialization
                _productList = new BindingList<Product>();
                cmbProduct.DataSource = _productList;
                cmbProduct.DisplayMember = Product.ConstProductCode;
                cmbProduct.ValueMember = Product.ConstProductId;
                cmbProduct.SelectedIndex = -1;

                if (AppContext.ExchangeRate != null)
                    _exchangeRate = AppContext.ExchangeRate.ExchangeValue;

                InitializeSaleItemList();
                ResetProductInfo();
                ScanFocusHandler();

                _depositEnabled = CommonService.IsIntegratedModule(Resources.ModDeposit);
                _saleItemBindingList.ListChanged += SaleItemBindingListChanged;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
        private void FrmProduct_Load(object sender, EventArgs e)
        {
            try
            {
                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                InitializeProductList();

                if (!string.IsNullOrEmpty(_codeProduct))
                {
                    txtProductCode.Text = _codeProduct;
                    ProductFetching();
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 4
0
        private void RetrieveConfiguration()
        {
            try
            {
                SafeCrossCallBackDelegate safeCrossCallBackDelegate = null;

                if (pnlBody_Right.InvokeRequired)
                    safeCrossCallBackDelegate = RetrieveConfiguration;

                if (pnlBody_Right.InvokeRequired)
                    Invoke(safeCrossCallBackDelegate);
                else
                {
                    Thread.Sleep(100);

                    //Loading Service
                    pgbService.Value += 15;
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                    pgbService.Value += 15;
                    _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                    pgbService.Value += 15;
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                    pgbService.Value += 15;
                    _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                    pgbService.Value += 15;
                    _supplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();
                    pgbService.Value += 15;
                    _expenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
                    pgbService.Value += 10;
                    _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService();

                    //Connecting to database
                    pgbGlobalConfig.Value += 50;
                    _commonService.InitializeGlobalConfiguration();
                    pgbGlobalConfig.Value += 50;

                    //Initializing workspace
                    pgbInitialization.Value += 30;
                    _commonService.InitializeWorkSpace();
                    pgbInitialization.Value += 30;
                    if (AppContext.Counter == null)
                    {
                        const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                        var detailMsg = Resources.MsgCounterNotInitialize;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            Close();
                            return;
                        }
                    }
                    pgbInitialization.Value += 40;

                    //Loading configuration
                    pgbCustomizedConfig.Value += 80;
                    Visible = false;

                    using (var frmLogIn = new FrmLogIn())
                    {
                        frmLogIn.UserService = _userService;
                        if (frmLogIn.ShowDialog(this) == DialogResult.OK)
                        {
                            Visible = true;

                            var frmMain = new FrmMain();
                            ApplicationContext.MainForm = frmMain;

                            frmMain.CommonService = _commonService;
                            frmMain.SaleOrderService = _saleOrderService;
                            frmMain.ProductService = _productService;
                            frmMain.CustomerService = _customerService;
                            frmMain.SupplierService = _supplierService;
                            frmMain.ExpenseService = _expenseService;
                            frmMain.UserService = _userService;

                            _commonService.InitializeCustomizedConfiguration(frmLogIn.User);
                            pgbCustomizedConfig.Value += 20;

                            _commonService.InsertOperationLog(
                                AppContext.User.UserId,
                                int.Parse(Resources.OperationLogIn));

                            frmMain.Show();
                            Close();
                        }
                        else
                            ApplicationContext.ExitThread();
                    }
                }
            }
            catch (Exception exception)
            {
                const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                var detailMsg = Resources.MsgConnectionLost;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    Close();
                }
            }
        }
Esempio n. 5
0
        private void BtnProductAdjustmentClick(object sender, EventArgs e)
        {
            ScanFocusHandler();
            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;
                }
            }

            if (_saleItemBindingList == null)
                return;

            if (_saleItemBindingList.Count == 0)
                return;

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

            try
            {
                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>();
                        foreach (var saleItem in _saleItemBindingList)
                        {
                            var product = saleItem.FkProduct;
                            //Save QtyInStock of product
                            saleItem.FkProduct.PublicQty = saleItem.FkProduct.QtyInStock.ToString("N2",
                                                                                                  AppContext.CultureInfo);
                            product.QtyInStock = saleItem.QtySold;
                            listProduct2Export.Add(product);
                        }

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

                        foreach (var saleItem in _saleItemBindingList.Where(saleItem => saleItem != null))
                        {
                            //Restore QtyInStock of product
                            saleItem.FkProduct.QtyInStock = float.Parse(saleItem.FkProduct.PublicQty);
                            //saleItem.QtySold = saleItem.FKProduct.QtyInStock;
                            saleItem.UnitPriceIn = 0;
                            saleItem.UnitPriceOut = 0;
                            saleItem.PublicUpOut = 0;
                            saleItem.SubTotal = 0;
                        }

                        dgvSaleItem.Refresh();
                        CalculateSale();
                        _productService.ProductAdjustmentManagement(
                            Resources.OperationRequestInsert,
                            _saleItemBindingList);
                        DoActivateControls(false);
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 6
0
        private void TsmImportClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionImportExportProduct))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                    return;

                const string briefMsg = "អំពីការលុប";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                _productService.ImportProductFromXml(
                    folderBrowserDialog.SelectedPath,
                    "ProductList.xml");

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
0
        private void TmsGroupClick(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = Resources.ConstExtensionImage;
                openFileDialog.Multiselect = true;
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                if (openFileDialog.FileNames.Length == 0)
                    return;

                const string briefMsg = "អំពីការបង្កើតផលិតផល";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                _productService.ImportGroupCatalog(
                    openFileDialog.FileNames,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 9
0
        private void ImportAllCatalogs()
        {
            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                    return;

                const string briefMsg = "អំពីការលុប";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                _productService.ImportGroupCatalog(
                    folderBrowserDialog.SelectedPath,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 10
0
        private void FrmProduct_Load(object sender, EventArgs e)
        {
            if (_productService == null)
                _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

            if (_commonService == null)
                _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

            if (!UserService.AllowToPerform(Resources.PermissionViewAllProductInfo))
            {
                txtUPIn.Visible = false;
                txtExtraPercentage.Visible = false;
            }

            if (!UserService.AllowToPerform(Resources.PermissionModifyProductQuantity))
                txtQtyInStock.Enabled = false;

            _defaultUnitPriceOut = 0;

            var searchCriteria =
                new List<string>
                {
                    "ParameterTypeId IN (" +
                    Resources.AppParamProductCodeLength + ", " +
                    Resources.AppParamCategory + ", " +
                    Resources.AppParamMark + ", " +
                    Resources.AppParamColor + ", " +
                    Resources.AppParamSize + ")"
                };
            var objectList = _commonService.GetAppParameters(searchCriteria);
            var productCodeLengthList =
                _commonService.GetAppParametersByType(
                    objectList,
                    Int32.Parse(Resources.AppParamProductCodeLength));
            if (productCodeLengthList.Count != 0)
            {
                var productCodeLength = productCodeLengthList[0] as AppParameter;
                if (productCodeLength != null)
                {
                    int codeLength;
                    Int32.TryParse(
                        (string.IsNullOrEmpty(productCodeLength.ParameterLabel) ?
                        string.Empty :
                        productCodeLength.ParameterLabel),
                        out codeLength);

                    txtForeignCode.MaxLength = codeLength;
                }
            }

            _commonService.PopAppParamExtendedCombobox(
                ref cmbCategory, objectList, int.Parse(Resources.AppParamCategory), true);
            cmbCategory.SelectedValue = 364;

            _commonService.PopAppParamExtendedCombobox(
                ref cmbMark, objectList, int.Parse(Resources.AppParamMark), true);

            _commonService.PopAppParamExtendedCombobox(
                ref cmbColor, objectList, int.Parse(Resources.AppParamColor), true);

            _commonService.PopAppParamExtendedCombobox(
                ref cmbSize, objectList, int.Parse(Resources.AppParamSize), true);

            _productList = new BindingList<Product>();
            cmbProduct.DataSource = _productList;
            cmbProduct.DisplayMember = Product.ConstForeignCode;
            cmbProduct.ValueMember = Product.ConstProductId;
            cmbProduct.SelectedIndex = -1;

            SetProductInfo(_product);

            if (_isFromSale)
            {
                SetEnableToComponents(false);
                return;
            }

            txtPhotoPath.TextChanged += TxtPhotoPathTextChanged;
        }
Esempio n. 11
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if ((cmbCategory.SelectedIndex == -1) || (cmbMark.SelectedIndex == -1)
                    || (cmbColor.SelectedIndex == -1) || (cmbSize.SelectedIndex == -1))
                {
                    const string briefMsg = "អំពីពត៌មាន";
                    var detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_product == null)
                    _product = new Product();

                _product.CategoryId = int.Parse(cmbCategory.SelectedValue.ToString());
                _product.CategoryStr = cmbCategory.Text;
                _product.MarkId = int.Parse(cmbMark.SelectedValue.ToString());
                _product.MarkStr = cmbMark.Text;
                _product.ColorId = int.Parse(cmbColor.SelectedValue.ToString());
                _product.ColorStr = cmbColor.Text;
                _product.SizeId = Int32.Parse(cmbSize.SelectedValue.ToString());
                _product.SizeStr = cmbSize.Text;
                _product.ProductName = _product.CategoryStr + @" \ " + _product.MarkStr + @" \ " + _product.ColorStr;
                _product.UnitPriceIn = float.Parse(txtUPIn.Text);
                _product.ExtraPercentage = float.Parse(txtExtraPercentage.Text);
                _product.UnitPriceOut = float.Parse(txtUPOut.Text);
                _product.DiscountPercentage = float.Parse(txtDiscount.Text);
                _product.QtyInStock = float.Parse(txtQtyInStock.Text);
                _product.QtyPromotion = float.Parse(txtQtyPromotion.Text);
                _product.QtyBonus = float.Parse(txtQtyBonus.Text);
                _product.ForeignCode = txtForeignCode.Text;
                _product.Description = txtDescription.Text;
                if (txtPhotoPath.Text.Length == 0)
                {
                    _product.PhotoPath = _product.PhotoPath;
                    _product.ProductPic = Resources.NoImage;
                }
                else
                {
                    var fileInfo = new FileInfo(txtPhotoPath.Text);
                    if (fileInfo.Exists)
                    {
                        _product.PhotoPath = txtPhotoPath.Text;
                        _product.ProductPic = Image.FromFile(_product.PhotoPath);
                    }
                    else
                        _product.ProductPic = Resources.NoImage;
                }

                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                _product.DisplayName = _product.ProductName + "\r" +
                                       "Size: " + _product.SizeStr + "\r" +
                                       "Code: " + _product.ProductCode;
                if (!string.IsNullOrEmpty(_product.ForeignCode))
                    _product.DisplayName += " (" + _product.ForeignCode + ")";

                if (!_isFromSale)
                {
                    _productService.ManageProduct(
                        _product,
                        _product.ProductId != 0 ? Resources.OperationRequestUpdate : Resources.OperationRequestInsert);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 12
0
        private void CtrlCatalog_Load(object sender, EventArgs e)
        {
            try
            {
                if (_productService == null)
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();

                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                if (!UserService.AllowToPerform(Resources.PermissionViewAllProductInfo))
                {
                    UPInLbl.Visible = false;
                    extraPercentageLbl.Visible = false;
                }
                if (!UserService.AllowToPerform(Resources.PermissionViewProdResultInfo))
                {
                    lblResultInfo.Visible = false;
                    //extraPercentageLbl.Visible = false;
                }
                InitializeProductList();

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart) {IsBackground = true};
                thread.Start();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }