示例#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();
                }
            }
        }
示例#2
0
        private void UpdateControlContent()
        {
            if (ExpenseService == null)
                ExpenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();

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

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

                CommonService.PopAppParamExtendedCombobox(
                    ref cmbExpenseType, objList, int.Parse(Resources.AppParamExpense), true);

                SetExpenseInfo();
                SetModifydStatus(false);
            }
        }
示例#3
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);
            }
        }
示例#4
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);
        }
示例#5
0
 private void CmdSearchProductClick(object sender, EventArgs e)
 {
     if (_ExpenseService == null)
         _ExpenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
     var searchCriteria =
         new List<string>
         {
             "ExpenseDate BETWEEN CONVERT(DATETIME, '" +
             dtpStartDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo) +
             "', 103) AND CONVERT(DATETIME, '" +
             dtpStopDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo) +
             "', 103)"
         };
     var expenseList = _ExpenseService.GetExpenses(searchCriteria);
     IListToBindingList(expenseList);
 }