Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateControlContent()
        {
            if (_SupplierService == null)
                _SupplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();

            SafeCrossCallBackDelegate safeCrossCallBackDelegate = null;
            if (cmbCountry.InvokeRequired)
                safeCrossCallBackDelegate = UpdateControlContent;

            if (cmbCountry.InvokeRequired)
                Invoke(safeCrossCallBackDelegate);
            else
            {
                var searchCriteria = new List<string>
                                         {
                                             "ParameterTypeId IN (" + Resources.AppParamCountry + ")"
                                         };
                var objList = _CommonService.GetAppParameters(searchCriteria);

                _CommonService.PopAppParamExtendedCombobox(
                    ref cmbCountry, objList, int.Parse(Resources.AppParamCountry), true);

                SetSupplierInfo();
                SetModifydStatus(false);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
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();
        }