private void FrmExchangeRate_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                IList objList = _CommonService.GetAppParametersByType(
                    Int32.Parse(Resources.AppParamCurrency));

                _CommonService.PopAppParamExtendedCombobox(
                    ref cbbFromCurrency, objList, Int32.Parse(Resources.AppParamCurrency), true);
                if (((IList) cbbFromCurrency.DataSource).Count != 0)
                    cbbFromCurrency.SelectedValue = 15;

                _CommonService.PopAppParamExtendedCombobox(
                    ref cbbToCurrency, objList, Int32.Parse(Resources.AppParamCurrency), true);
                if (((IList) cbbToCurrency.DataSource).Count != 0)
                    cbbToCurrency.SelectedValue = 14;

                if (txtExchangeRate.CanFocus)
                    txtExchangeRate.Focus();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
        private void CtrBase_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                IList objectList = _CommonService.GetAppParameterTypes();
                lsbAppParam.DisplayMember = AppParameterType.ConstParameterLabel;
                lsbAppParam.ValueMember = AppParameterType.ConstParameterId;
                lsbAppParam.DataSource = objectList;

                _IsModified = false;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError, exception.Message);
            }
        }
        private void CtrlCustomer_Load(object sender, EventArgs e)
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewCustResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                if (_customerService == null)
                    _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                InitializeCustomerList();

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart) {IsBackground = true};
                thread.Start();

                var discountCardList = _customerService.GetUsedDiscountCards();
                cmbDiscountCard.CustomizedDataBinding(
                    discountCardList,
                    DiscountCard.ConstDiscountCardNumber,
                    DiscountCard.ConstCustomerId,
                    false);

                IListToBindingList(_customerService.GetCustomers());
                dgvCustomer.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Beispiel #4
0
        private void CtrlUser_Load(object sender, EventArgs e)
        {
            if (_UserService == null)
                _UserService = ServiceFactory.GenerateServiceInstance().GenerateUserService();

            if (_CommonService == null)
                _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
            if (!UserService.AllowToPerform(Resources.PermissionViewUserResultInfo))
            {
                lblResultInfo.Visible = false;
            }
            if (!UserService.AllowToPerform(Resources.PermissionViewUserResultInfo))
            {
                lblResultInfo.Visible = false;
            }
            InitializeUserList();

            ThreadStart threadStart = UpdateControlContent;
            var thread = new Thread(threadStart) {IsBackground = true};
            thread.Start();

            IListToBindingList(_UserService.GetUsers());
            dgvUser.Refresh();
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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();
                }
            }
        }
Beispiel #7
0
        private void FrmUser_Load(object sender, EventArgs e)
        {
            if (_userService == null)
                _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService();
            if (_commonService == null)
                _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

            ThreadStart threadStart = UpdateControlContent;
            var thread = new Thread(threadStart);
            thread.Start();

            SetUserInfo();
            txtPhotoPath.TextChanged += TxtPhotoPathTextChanged;
        }
        private void CtrlDiscountCard_Load(object sender, EventArgs e)
        {
            if (_CommonService == null)
                _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
            if (_CustomerService == null)
                _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();

            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewCartResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                if (_CustomerService == null)
                    _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();

                InitialDiscountCardList();

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart) {IsBackground = true};
                thread.Start();

                var objList = _CustomerService.GetCustomers();
                cmbCustomer.CustomizedDataBinding(
                    objList,
                    Customer.ConstCustomerName,
                    Customer.ConstCustomerId,
                    false);

                var customerList = new List<Customer>();
                foreach (Customer customer in objList)
                    customerList.Add(customer);

                cmbCustomerHidden.CustomizedDataBinding(
                    customerList,
                    Customer.ConstCustomerName,
                    Customer.ConstCustomerId,
                    false);

                btnSearch_Click(sender, e);
                //IListToBindingList(
                //    _CustomerService.GetDiscountCards());
                //dgvDiscountCard.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Beispiel #9
0
        private void FrmDeposit_Load(object sender, EventArgs e)
        {
            try
            {
                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                if (_depositService == null)
                    _depositService = ServiceFactory.GenerateServiceInstance().GenerateDepositService();

                if (_saleOrderService == null)
                    _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();

                InitializeDepositList();

                RetrieveDataHandler();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Beispiel #10
0
        private void FrmExpense_Load(object sender, EventArgs e)
        {
            if (ExpenseService == null)
                ExpenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();

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

            ThreadStart threadStart = UpdateControlContent;
            var thread = new Thread(threadStart);
            thread.Start();

            dtpExpenseDate.Enabled = UserService.AllowToPerform(Resources.PermissionChangeExpenseDate);
        }
Beispiel #11
0
        private void CtrlExpense_Load(object sender, EventArgs e)
        {
            if (_CommonService == null)
                _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
            if (_ExpenseService == null)
                _ExpenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();

            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewExpResultInfo))
                {
                    lblResultInfo.Visible = false;
                }

                InitializeExpenseList();

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart) {IsBackground = true};
                thread.Start();

                IListToBindingList(_ExpenseService.GetExpenses());
                dgvExpense.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
        private void CtrlSupplier_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                if (_SupplierService == null)
                    _SupplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();
                if (!UserService.AllowToPerform(Resources.PermissionViewSuppResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                InitialSupplierList();

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart) {IsBackground = true};
                thread.Start();

                //IList objList = _SupplierService.GetSuppliers();
                //cmbCustomer.CustomizedDataBinding(
                //    objList,
                //    Customer.CONST_CUSTOMER_NAME,
                //    Customer.CONST_CUSTOMER_Id,
                //    false);

                //var customerList = new List<Customer>();
                //foreach (Customer customer in objList)
                //    customerList.Add(customer);

                //cmbCustomerHidden.CustomizedDataBinding(
                //    customerList,
                //    Customer.CONST_CUSTOMER_NAME,
                //    Customer.CONST_CUSTOMER_Id,
                //    false);

                //btnSearch_Click(sender, e);
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Beispiel #13
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);
            }
        }
        private void FrmSaleOrderSearch_Load(object sender, EventArgs e)
        {
            try
            {
                if (_commonService == null)
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();

                dtpStartDate.Value = DateTime.Now.AddMonths(-1);
                InitializeSaleOrderReportList();

                ThreadStart threadStart = UpdateControlContent;
                var thread =
                    new Thread(threadStart)
                    {
                        Priority = ThreadPriority.Lowest
                    };
                thread.Start();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Beispiel #15
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;
        }
        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);
            }
        }
Beispiel #17
0
        private void FrmSupplier_Load(object sender, EventArgs e)
        {
            if (_SupplierService == null)
                _SupplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();

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

            ThreadStart threadStart = UpdateControlContent;
            var thread = new Thread(threadStart);
            thread.Start();
        }