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(); } } }
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 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); } }