static void Main()
        {
            Application.EnableVisualStyles();
            Application.DoEvents();

            CustomExceptionHandler eh = new CustomExceptionHandler();

            Application.ThreadException += new ThreadExceptionEventHandler(eh.OnThreadException);

            SplashForm splash = new SplashForm() ;

            try
            {
                splash.Show();
            }
            catch (Exception)
            {
            }

            Thread.Sleep(4000);

            splash.Close() ;

            frm = new MainForm() ;
            Application.Run(frm);
        }
Exemple #2
0
 protected void Application_Error(object sender, EventArgs e)
 {
     using (var customHandler = new CustomExceptionHandler(this,
         "~/500.cshtml"))
     {
         customHandler.HandleError();
     }
 }
Exemple #3
0
 static void Main()
 {
     Control.CheckForIllegalCrossThreadCalls = false;
     Application.EnableVisualStyles();
     CustomExceptionHandler eh = new CustomExceptionHandler();
     Application.ThreadException += eh.OnThreadException;
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new frmMain());
 }
		public ApplicationContext (NavigationController controller, BitMobile.Application.ApplicationSettings settings, CustomExceptionHandler exceptionHandler)
		{
			GlobalVariables = new Dictionary<string, object> ();

			Settings = settings;
			_controller = controller;
			_exceptionHandler = exceptionHandler;

			LocationProvider = new GPSProvider ();
			LocationTracker = new GPSTracker ();
			GalleryProvider = new GalleryProvider (controller, this);
			CameraProvider = new CameraProvider (controller, this);
			DialogProvider = new DialogProvider (this);
			DisplayProvider = new DisplayProvider ();

			var builder = new SolutionBuilder (this);
			builder.Build ();

			StyleSheetContext.Current.Scale = UIScreen.MainScreen.Scale;
		}
Exemple #5
0
        private void BSaveClick(object sender, EventArgs e)
        {
            nudAmount_ValueChanged(sender, e);
            bool pending = cbxPending.Visible && cbxPending.Checked;
            bool?local   = null;

            local = rbxLocal.Visible && rbxLocal.Checked;

            try
            {
                _date = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day, TimeProvider.Now.Hour,
                                     TimeProvider.Now.Minute, TimeProvider.Now.Second);

                AccountServices savingServices = ServicesProvider.GetInstance().GetAccountServices();

                if (_saving.Events.Find(ev => ev.Code == OSavingEvents.SavingClosure &&
                                        ev.Date.Date >= _date.Date && ev is SavingClosureEvent) != null)
                {
                    savingServices.CanPostAfterClosureEvent();
                }

                List <SavingEvent> savingEvents = new List <SavingEvent>();

                if (_date.Date < TimeProvider.Today.Date)
                {
                    savingServices.PerformBackDateOperations(_date);
                }
                else if (_date.Date > TimeProvider.Today.Date)
                {
                    savingServices.PerformFutureDateOperations(_date);
                }

                if (_saving.HasPendingEvents())
                {
                    if (!savingServices.AllowOperationsDuringPendingDeposit())
                    {
                        return;
                    }
                }

                if ((_flatFees.HasValue && updAmountFees.Value != _flatFees) || (_rateFees.HasValue && updAmountFees.Value != (decimal)(_rateFees * 100)))
                {
                    if (!savingServices.AllowSettingSavingsOperationsFeesManually())
                    {
                        return;
                    }
                }

                switch (_bookingDirection)
                {
                case OSavingsOperation.Credit:
                {
                    OSavingsMethods savingsMethod =
                        (OSavingsMethods)
                        Enum.Parse(typeof(OSavingsMethods), "Cash");
                    var paymentMethod = (PaymentMethod)cbSavingsMethod.SelectedItem;
                    if (_saving is SavingBookContract)
                    {
                        if (savingsMethod == OSavingsMethods.Cheque)
                        {
                            ((SavingBookContract)_saving).ChequeDepositFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).DepositFees = updAmountFees.Value;
                        }

                        //modified
                        OCurrency dutyStampFeeMin = Convert.ToDecimal(ApplicationSettings.GetInstance("").GetSpecificParameter(OGeneralSettings.STAMP_DUTY_VALID_ABOVE));
                        if (_amount < dutyStampFeeMin)
                        {
                            ((SavingBookContract)_saving).DutyStampFees = 0;
                        }
                    }

                    savingEvents = savingServices.Deposit(_saving, _date, _amount, _description, _referenceNumber, User.CurrentUser, pending, local,
                                                          savingsMethod, paymentMethod, null, Teller.CurrentTeller);
                    break;
                }

                case OSavingsOperation.Debit:
                {
                    var paymentMethod = (PaymentMethod)cbSavingsMethod.SelectedItem;
                    if (_saving is SavingBookContract)
                    {
                        if (_flatFees.HasValue)
                        {
                            ((SavingBookContract)_saving).FlatWithdrawFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).RateWithdrawFees = (double)(updAmountFees.Value / 100);
                        }


                        OCurrency _feesMin, _feesMax;
                        decimal   value = _flatAMFees.HasValue ? _flatAMFees.Value : ((decimal)(_rateAMFees)) * 100;

                        if (((SavingsBookProduct)_saving.Product).FlatAMFees.HasValue ||
                            ((SavingsBookProduct)_saving.Product).FlatAMFeesMin.HasValue)
                        {
                            if (((SavingsBookProduct)_saving).FlatAMFees.HasValue)
                            {
                                _feesMin = ((SavingsBookProduct)_saving.Product).FlatAMFees;
                                _feesMax = ((SavingsBookProduct)_saving.Product).FlatAMFees;
                            }
                            else
                            {
                                _feesMin = ((SavingsBookProduct)_saving.Product).FlatAMFeesMin;
                                _feesMax = ((SavingsBookProduct)_saving.Product).FlatAMFeesMax;
                            }

                            OCurrency amFee = value <_feesMin || value> _feesMax ? _feesMin : value;
                            ((SavingBookContract)_saving).FlatAMFees = amFee;
                        }
                        else
                        {
                            if (((SavingsBookProduct)_saving.Product).RateAMFees.HasValue)
                            {
                                _feesMin = (decimal)((SavingsBookProduct)_saving.Product).RateAMFees * 100;
                                _feesMax = (decimal)((SavingsBookProduct)_saving.Product).RateAMFees * 100;
                            }
                            else
                            {
                                _feesMin = (decimal)((SavingsBookProduct)_saving.Product).RateAMFeesMin * 100;
                                _feesMax = (decimal)((SavingsBookProduct)_saving.Product).RateAMFeesMax * 100;
                            }

                            var amFee = value <_feesMin || value> _feesMax ? _feesMin : value;
                            ((SavingBookContract)_saving).RateAMFees = (double)(amFee.Value / 100);
                        }
                    }

                    savingEvents = savingServices.Withdraw(_saving, _date, _amount, _description, _referenceNumber, User.CurrentUser,
                                                           Teller.CurrentTeller, paymentMethod);
                    break;
                }

                case OSavingsOperation.Transfer:
                {
                    if (_saving is SavingBookContract)
                    {
                        if (_flatFees.HasValue)
                        {
                            ((SavingBookContract)_saving).FlatTransferFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).RateTransferFees = (double)(updAmountFees.Value / 100);
                        }
                    }
                    decimal fee = nudTotalAmount.Value - nudAmount.Value;
                    savingEvents = savingServices.Transfer(_saving, _savingTarget, _date, _amount, fee, _description, _referenceNumber,
                                                           User.CurrentUser, false);
                    break;
                }

                case OSavingsOperation.SpecialOperation:
                {
                    OSavingsMethods savingsMethod =
                        (OSavingsMethods)
                        Enum.Parse(typeof(OSavingsMethods), ((PaymentMethod)cbSavingsMethod.SelectedItem).Name);
                    if (cbBookings.SelectedItem != null)
                    {
                        Booking booking = (Booking)cbBookings.SelectedItem;
                        booking.Branch = _saving.Branch;
                        savingServices.SpecialOperation(_saving, _date, _amount, _description, User.CurrentUser,
                                                        savingsMethod, rbxCredit.Checked, booking);
                        break;
                    }
                    throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.TransactionInvalid);
                }
                }


                try
                {
                    //slycode
                    MessagingService messagingService = new MessagingService(Person);

                    foreach (SavingEvent savingEvent in savingEvents)
                    {
                        if (!(savingEvent is SavingInstrumentFeeEvent ||
                              savingEvent is SavingSearchFeeEvent
                              //|| savingEvent is SavingDutyStampFeeEvent
                              || savingEvent is SavingAMFeeEvent))
                        {
                            messagingService.SendNotification(savingEvent, _saving, _bookingDirection.Description());
                        }
                    }
                }
                catch (Exception exc)
                {
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(exc)).ShowDialog();
                }

                Close();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemple #6
0
        private void BtnOkClick(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lvContracts.Items)
            {
                if (item == _itemTotal)
                {
                    continue;
                }
                if (!item.Checked)
                {
                    continue;
                }
                var           loan         = item.Tag as Loan;
                VillageMember activeMember = null;
                int           index        = 0;
                foreach (VillageMember member in _village.Members)
                {
                    int tIndex = member.ActiveLoans.IndexOf(loan);
                    if (tIndex > -1)
                    {
                        activeMember = member;
                        index        = tIndex;
                    }
                }

                if (activeMember != null)
                {
                    Person person = activeMember.Tiers as Person;
                    if (loan != null)
                    {
                        int       number = loan.GetFirstUnpaidInstallment().Number;
                        OCurrency total  = (OCurrency)item.SubItems[5].Tag;
                        bool      doProportionPayment = cbItem.SelectedIndex == 2;
                        OCurrency penalties           = (OCurrency)item.SubItems[4].Tag;
                        bool      disableFees         = penalties != loan.CalculateDuePenaltiesForInstallment(number, TimeProvider.Today);
                        string    comment             = item.SubItems[10].Text;

                        PaymentMethod paymentMethod = ServicesProvider.GetInstance().GetPaymentMethodServices().GetPaymentMethodById(1);

                        try
                        {
                            activeMember.ActiveLoans[index] =
                                ServicesProvider.GetInstance().GetContractServices().Repay(loan,
                                                                                           person,
                                                                                           number,
                                                                                           TimeProvider.Today,
                                                                                           total,
                                                                                           disableFees,
                                                                                           penalties,
                                                                                           0,
                                                                                           false,
                                                                                           0,
                                                                                           true,
                                                                                           doProportionPayment,
                                                                                           paymentMethod,
                                                                                           comment,
                                                                                           false);
                        }
                        catch (Exception ex)
                        {
                            new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                        }
                    }
                }

                if (loan != null)
                {
                    if (loan.Closed)
                    {
                        if (activeMember != null)
                        {
                            activeMember.ActiveLoans[index] = null;
                        }
                    }
                }
            }

            if (_AllContractsClosed())
            {
                _village.Active = false;
                ServicesProvider.GetInstance().GetContractServices().UpdateVillageStatus(_village);
            }
        }
Exemple #7
0
        private void BSaveClick(object sender, EventArgs e)
        {
            nudAmount_ValueChanged(sender, e);
            bool            pending       = cbxPending.Visible && cbxPending.Checked;
            OSavingsMethods savingsMethod =
                (OSavingsMethods)Enum.Parse(typeof(OSavingsMethods), cbSavingsMethod.SelectedValue.ToString());

            try
            {
                _date = new DateTime(dtpDate.Value.Year, dtpDate.Value.Month, dtpDate.Value.Day, TimeProvider.Now.Hour,
                                     TimeProvider.Now.Minute, TimeProvider.Now.Second);

                SavingServices savingServices = ServicesProvider.GetInstance().GetSavingServices();

                if (_date.Date < TimeProvider.Today.Date)
                {
                    savingServices.PerformBackDateOperations(_date);
                }
                else if (_date.Date > TimeProvider.Today.Date)
                {
                    savingServices.PerformFutureDateOperations(_date);
                }

                if (_saving.HasPendingEvents())
                {
                    if (!savingServices.AllowOperationsDuringPendingDeposit())
                    {
                        return;
                    }
                }

                if ((_flatFees.HasValue && updAmountFees.Value != _flatFees) || (_rateFees.HasValue && updAmountFees.Value != (decimal)(_rateFees * 100)))
                {
                    if (!savingServices.AllowSettingSavingsOperationsFeesManually())
                    {
                        return;
                    }
                }

                switch (_bookingDirection)
                {
                case OSavingsOperation.Credit:
                {
                    if (_saving is SavingBookContract)
                    {
                        if (savingsMethod == OSavingsMethods.Cheque)
                        {
                            ((SavingBookContract)_saving).ChequeDepositFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).DepositFees = updAmountFees.Value;
                        }
                    }

                    savingServices.Deposit(_saving, _date, _amount, _description, User.CurrentUser, pending,
                                           savingsMethod, null, Teller.CurrentTeller);
                    break;
                }

                case OSavingsOperation.Debit:
                {
                    if (_saving is SavingBookContract)
                    {
                        if (_flatFees.HasValue)
                        {
                            ((SavingBookContract)_saving).FlatWithdrawFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).RateWithdrawFees = (double)(updAmountFees.Value / 100);
                        }
                    }

                    savingServices.Withdraw(_saving, _date, _amount, _description, User.CurrentUser, Teller.CurrentTeller);
                    break;
                }

                case OSavingsOperation.Transfer:
                {
                    if (_saving is SavingBookContract)
                    {
                        if (_flatFees.HasValue)
                        {
                            ((SavingBookContract)_saving).FlatTransferFees = updAmountFees.Value;
                        }
                        else
                        {
                            ((SavingBookContract)_saving).RateTransferFees = (double)(updAmountFees.Value / 100);
                        }
                    }
                    decimal fee = nudTotalAmount.Value - nudAmount.Value;
                    savingServices.Transfer(_saving, _savingTarget, _date, _amount, fee, _description, User.CurrentUser, false);
                    break;
                }

                case OSavingsOperation.SpecialOperation:
                {
                    if (cbBookings.SelectedItem != null)
                    {
                        Booking booking = (Booking)cbBookings.SelectedItem;
                        booking.Branch = _saving.Branch;
                        savingServices.SpecialOperation(_saving, _date, _amount, _description, User.CurrentUser,
                                                        savingsMethod, rbxCredit.Checked, booking);
                        break;
                    }
                    throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.TransactionInvalid);
                }
                }

                Close();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemple #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked)
                    {
                        continue;
                    }
                    var             loan          = item.Tag as Loan;
                    string          comment       = item.SubItems[IdxComment].Text;
                    OContractStatus currentStatus = loan.ContractStatus;
                    OContractStatus status        = (OContractStatus)item.SubItems[IdxStatus].Tag;
                    if (currentStatus == status)
                    {
                        continue;
                    }
                    string   code = item.SubItems[IdxValidationCode].Text;
                    DateTime date = Convert.ToDateTime(item.SubItems[IdxCreditCommitteeDate].Tag);

                    VillageMember activeMember = null;

                    foreach (VillageMember member in _village.Members)
                    {
                        int tIndex = member.ActiveLoans.IndexOf(loan);
                        if (tIndex > -1)
                        {
                            activeMember = member;
                        }
                    }

                    IClient client = activeMember.Tiers;

                    loan.CreditCommiteeDate    = date;
                    loan.ContractStatus        = status;
                    loan.CreditCommitteeCode   = code;
                    loan.CreditCommiteeComment = comment;
                    Project project = client.Projects[0];

                    loan = ServicesProvider.GetInstance().GetContractServices().UpdateContractStatus(loan, project, client, currentStatus == OContractStatus.Validated);
                    if (OContractStatus.Refused == status ||
                        OContractStatus.Abandoned == status ||
                        OContractStatus.Closed == status)
                    {
                        loan.Closed = true;
                        activeMember.ActiveLoans.Remove(loan);
                        if (activeMember.ActiveLoans.Count == 0)
                        {
                            client.Active = false;
                            client.Status = OClientStatus.Inactive;
                        }
                    }
                    else
                    {
                        loan.Closed   = false;
                        client.Active = true;
                        client.Status = OClientStatus.Active;
                    }
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemple #9
0
        private void SavePerson()
        {
            _personSaved = false;
            RecoverDatasFromUserControlsAddress();
            RecoverDataFromCombobox();

            _tempPerson.FirstContact     = dateTimePickerFirstContact.Value;
            _tempPerson.FirstAppointment = dateTimePickerFirstAppointment.Value;
            _tempPerson.Branch           = (Branch)cbBranch.SelectedItem;

            try
            {
                bool save = 0 == _tempPerson.Id;
                if (_tempPerson.FirstName != null)
                {
                    _tempPerson.FirstName = _tempPerson.FirstName.Trim();
                }
                if (_tempPerson.LastName != null)
                {
                    _tempPerson.LastName = _tempPerson.LastName.Trim();
                }
                if (_tempPerson.FatherName != null)
                {
                    _tempPerson.FatherName = _tempPerson.FatherName.Trim();
                }
                if (_tempPerson.IdentificationData != null)
                {
                    _tempPerson.IdentificationData = _tempPerson.IdentificationData.Trim();
                }

                string result = ServicesProvider
                                .GetInstance()
                                .GetClientServices()
                                .SavePerson(ref _tempPerson, (tx, id) =>
                {
                    foreach (var extension in Extensions)
                    {
                        extension.Save(_tempPerson, tx);
                    }
                });

                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                es.LogClientSaveUpdateEvent(_tempPerson, save);

                if (result != string.Empty)
                {
                    MessageBox.Show(result, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                _personSaved    = true;
                buttonSave.Text = MultiLanguageStrings.GetString(Ressource.PersonUserControl, "Update");

                var formatInfo = new NameFormatInfo();
                var settings   = ServicesProvider.GetInstance().GetGeneralSettings();
                //var fnFormat = @"{0:" + settings.FirstNameFormat + @"}";
                //var lnFormat = @"{0:" + settings.LastNameFormat + @"}";
                textBoxFirstName.Text = string.Format(_tempPerson.FirstName);
                textBoxLastname.Text  = string.Format(_tempPerson.LastName);
                if (_tempPerson.FatherName != null)
                {
                    textBoxFatherName.Text = string.Format(_tempPerson.FatherName);
                }
                textBoxIdentificationData.Text = string.Format(_tempPerson.IdentificationData);
                //EnableDocuments();
                ResetImagesFlags();

                if (ApplicationSettings.GetInstance(User.CurrentUser.Md5).UseMandatorySavingAccount&&
                    Person.Savings.Count == 0)
                {
                    Person.Savings.Add(
                        ServicesProvider.GetInstance().GetSavingServices().AddAndActivateDefaultSavingAccount(Person));
                    DisplaySavings(Person.Savings);
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemple #10
0
        static void Main(string[] args)
        {
            CsvFileDescription fileDescription = new CsvFileDescription
            {
                SeparatorChar           = ',',
                FirstLineHasColumnNames = true
            };
            CsvContext cc = new CsvContext();

            var dir = Directory.GetCurrentDirectory();

            string sourceFilePath = dir + "/client_table.csv";

            Console.WriteLine("***********************************************************");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("****************OpenCBS DATABASE MIGRATOR******************");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("                                                           ");
            Console.WriteLine("**   Ensure that a csv file named \"client_table.csv\"     **");
            Console.WriteLine("**   exists in the bin directory of the migrator before  **");
            Console.WriteLine("**                       proceeding.                     **");
            Console.WriteLine("******            Press 'enter' to continue        ********");
            Console.WriteLine("                                                           ");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("***********************************************************");

            Console.ReadKey();
            try
            {
                ApplicationSettingsServices generalSettingsService = ServicesProvider.GetInstance().GetApplicationSettingsServices();
                generalSettingsService.FillGeneralDatabaseParameter();

                SelectDefaultUser();
                SelectDefaultBranch();
                SelectDefaultEconomicActivity();
                SelectDefaultLocation();

                List <FromModel.Client> clients = cc.Read <FromModel.Client>(sourceFilePath, fileDescription).ToList();
                Console.WriteLine("");
                Console.WriteLine("***********************************************************");
                Console.WriteLine(String.Format("Migrating {0} clients data", clients.Count));
                Console.WriteLine("***********************************************************");
                Console.WriteLine("");

                var             _clientService = ServicesProvider.GetInstance().GetClientServices();
                int             count          = 0;
                MigrationResult result         = null;
                foreach (FromModel.Client client in clients)
                {
                    result            = new MigrationResult();
                    result.full_name  = client.full_name;
                    result.surname    = client.surname;
                    result.first_name = client.first_name;

                    try
                    {
                        if (!String.IsNullOrEmpty(client.first_name)
                            ||
                            !String.IsNullOrEmpty(client.surname)
                            ||
                            !String.IsNullOrEmpty(client.full_name))
                        {
                            #region Individual migration
                            if (client.c_type == ClientType.INDIVIDUAL ||
                                client.c_type == ClientType.DIRECTORS ||
                                client.c_type == ClientType.CHILDREN ||
                                client.c_type == ClientType.JOINT ||
                                client.c_type == ClientType.STAFF ||
                                client.c_type == ClientType.CASHIER)
                            {
                                result.type = "INDIVIDUAL";

                                var _query = client.full_name;
                                int onlyActive = 2; //inactive and active
                                int _numbersTotalPage, _numberOfRecords;

                                var results = ServicesProvider.GetInstance().GetClientServices().FindTiers(out _numbersTotalPage, out _numberOfRecords,
                                                                                                           _query, onlyActive, 1, 1, 1, 1);

                                if (results.Count > 0)
                                {
                                    exist.Add(client);

                                    result.migrated       = "no";
                                    result.failure_reason = "duplicate";
                                    dump.Add(result);
                                    continue;
                                }
                                ++count;
                                Console.WriteLine(count + "). Migrating \"INDIVIDUAL\" " + client.full_name);
                                SavePerson(client);
                                result.migrated       = "yes";
                                result.failure_reason = "";
                                dump.Add(result);
                                migrated.Add(client);
                            }
                            #endregion
                            #region Corporate migration
                            else if (client.c_type == ClientType.GOVT ||
                                     client.c_type == ClientType.SOLE_PROPRIETORSHIP ||
                                     client.c_type == ClientType.FINANCIAL_INSTITUTION ||
                                     client.c_type == ClientType.EDUCATIONAL_INSTITUTION ||
                                     client.c_type == ClientType.COMPANY)
                            {
                                result.type = "CORPORATE";

                                var _query = client.full_name;
                                int onlyActive = 2; //inactive and active
                                int _numbersTotalPage, _numberOfRecords;


                                var results = ServicesProvider.GetInstance().GetClientServices().
                                              FindTiersCorporates(onlyActive, 1, out _numbersTotalPage, out _numberOfRecords, _query);

                                if (results.Count > 0)
                                {
                                    exist.Add(client);
                                    result.migrated       = "no";
                                    result.failure_reason = "duplicate";
                                    dump.Add(result);
                                    continue;
                                }

                                ++count;
                                Console.WriteLine(count + "). Migrating \"CORPORATE\" " + client.full_name);
                                SaveCorporate(client);
                                result.migrated       = "yes";
                                result.failure_reason = "";
                                dump.Add(result);
                                migrated.Add(client);
                            }
                            #endregion
                            #region Group migration
                            else if (client.c_type == ClientType.GROUP ||
                                     client.c_type == ClientType.CHURCH_MINISTRIES)
                            {
                                result.type = "GROUP";

                                /*var _query = "";
                                 * int onlyActive = 2; //inactive and active
                                 * int _numbersTotalPage, _numberOfRecords;
                                 *
                                 * var results = ServicesProvider.GetInstance().GetClientServices().FindTiers(out _numbersTotalPage, out _numberOfRecords,
                                 *              _query, onlyActive, 1, 1, 1, 1);
                                 *
                                 * if (results.Count > 0)
                                 * {
                                 *  exist.Add(client);
                                 *  continue;
                                 * }
                                 */
                                //++count;
                                Console.WriteLine(count + "). Migrating \"GROUP\" " + client.full_name);
                                error.Add(client);
                                result.migrated       = "no";
                                result.failure_reason = "Requires group members";
                                dump.Add(result);
                                //SaveGroup(client);
                            }
                            #endregion
                        }
                    }
                    catch (CustomFieldsAreNotFilledCorrectlyException exc)
                    {
                        Console.WriteLine(CustomExceptionHandler.ShowExceptionText(exc));
                        error.Add(client);
                        result.migrated       = "no";
                        result.failure_reason = exc.Message;
                        dump.Add(result);
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(CustomExceptionHandler.ShowExceptionText(exc));
                        error.Add(client);
                        result.migrated       = "no";
                        result.failure_reason = exc.Message;
                        dump.Add(result);
                    }
                    finally
                    {
                        //dump.Add(result);
                    }
                }

                string resultDir = dir + "/result";
                if (!Directory.Exists(resultDir))
                {
                    Directory.CreateDirectory(resultDir);
                }

                string resultFilePath     = resultDir + "/migration.csv";
                string errorFilePath      = resultDir + "/error.csv";
                string successfulFilePath = resultDir + "/successful.csv";
                string duplicatesFilePath = resultDir + "/duplicates.csv";

                cc.Write(dump, resultFilePath, fileDescription);
                cc.Write(error, errorFilePath, fileDescription);
                cc.Write(migrated, successfulFilePath, fileDescription);
                cc.Write(exist, duplicatesFilePath, fileDescription);

                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("***********************************************************");
                //Console.WriteLine(String.Format("Migrated {0} clients data", migrated.Count));
                Console.WriteLine("Results:");
                Console.WriteLine("Total: " + clients.Count);
                Console.WriteLine("Successful: " + migrated.Count);
                Console.WriteLine("Failed: " + error.Count);
                Console.WriteLine("Duplicates: " + exist.Count);
                Console.WriteLine("Migration result saved to " + resultDir);
                Console.WriteLine("***********************************************************");


                Console.ReadLine();
            }
            catch (Exception exc)
            {
                Console.WriteLine("Exception: " + exc);
                Console.ReadLine();
            }
        }
 // Token: 0x0600197B RID: 6523 RVA: 0x0006C0C4 File Offset: 0x0006A2C4
 internal ADDynamicGroupPagedReader(IDirectorySession session, ADObjectId rootId, QueryScope scope, string ldapFilter, int pageSize, CustomExceptionHandler customExceptionHandler, IEnumerable <PropertyDefinition> properties) : base(session, rootId, scope, new CustomLdapFilter(ldapFilter), null, pageSize, properties, false)
 {
     base.CustomExceptionHandler = customExceptionHandler;
 }
Exemple #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!_nsgForm.Save())
            {
                return;
            }

            bool             isError = false;
            ISavingsContract saving  = null;

            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (item == _itemTotal)
                    {
                        continue;
                    }
                    if (!item.Checked)
                    {
                        continue;
                    }
                    var     member = item.Tag as VillageMember;
                    IClient client = member.Tiers;

                    OCurrency initialAmount = (OCurrency)item.SubItems[idxInitialAmount].Tag;
                    double    interestRate  = (double)item.SubItems[idxInterestRate].Tag;
                    OCurrency entryFees     = (OCurrency)item.SubItems[idxEntryFees].Tag;

                    if (_product is SavingsBookProduct)
                    {
                        SavingsBookProduct sbp               = (SavingsBookProduct)_product;
                        decimal            withdrawFees      = (decimal)item.SubItems[idxWithdrawFees].Tag;
                        decimal            transferFees      = (decimal)item.SubItems[idxTransferFees].Tag;
                        decimal            ibtFees           = Convert.ToDecimal(item.SubItems[idxIbtFees].Tag);
                        decimal            depositFees       = (decimal)item.SubItems[idxDepositFees].Tag;
                        decimal            chequeDepositFees = (decimal)item.SubItems[idxChequeDepositFees].Tag;
                        decimal            closeFees         = (decimal)item.SubItems[idxCloseFees].Tag;
                        decimal            managementFees    = (decimal)item.SubItems[idxManagementFees].Tag;
                        decimal            overdraftFees     = (decimal)item.SubItems[idxOverdraftFees].Tag;
                        decimal            agioFees          = (decimal)item.SubItems[idxAgioFees].Tag;
                        decimal            reopenFees        = (decimal)item.SubItems[idxReopenFees].Tag;

                        saving = new SavingBookContract(ServicesProvider.GetInstance().GetGeneralSettings(),
                                                        User.CurrentUser, TimeProvider.Today, sbp, client)
                        {
                            InterestRate = interestRate / 100
                        };
                        SavingBookContract s = (SavingBookContract)saving;

                        if (sbp.WithdrawFeesType == OSavingsFeesType.Flat)
                        {
                            s.FlatWithdrawFees = withdrawFees;
                        }
                        else
                        {
                            s.RateWithdrawFees = (double)withdrawFees / 100;
                        }

                        if (sbp.TransferFeesType == OSavingsFeesType.Flat)
                        {
                            s.FlatTransferFees = transferFees;
                        }
                        else
                        {
                            s.RateTransferFees = (double)transferFees / 100;
                        }

                        if (sbp.InterBranchTransferFee.IsFlat)
                        {
                            s.FlatInterBranchTransferFee = ibtFees;
                        }
                        else
                        {
                            s.RateInterBranchTransferFee = Convert.ToDouble(ibtFees);
                        }

                        s.DepositFees       = depositFees;
                        s.ChequeDepositFees = chequeDepositFees;
                        s.CloseFees         = closeFees;
                        s.ManagementFees    = managementFees;
                        s.OverdraftFees     = overdraftFees;
                        s.AgioFees          = (double)agioFees / 100;
                        s.ReopenFees        = reopenFees;
                    }

                    saving.SavingsOfficer = _village.LoanOfficer;
                    saving.InitialAmount  = initialAmount;
                    saving.EntryFees      = entryFees;
                    saving.NsgID          = _village.Id;
                    saving.Id             = ServicesProvider.GetInstance().GetAccountServices().SaveContract(saving, (Client)member.Tiers);
                    saving = ServicesProvider.GetInstance().GetAccountServices().GetSaving(saving.Id);

                    ServicesProvider.GetInstance().GetAccountServices().FirstDeposit(saving, initialAmount, TimeProvider.Now, entryFees,
                                                                                     User.CurrentUser, Teller.CurrentTeller);
                    ServicesProvider.GetInstance().GetAccountServices().UpdateInitialData(saving.Id, initialAmount, entryFees);

                    saving = ServicesProvider.GetInstance().GetAccountServices().GetSaving(saving.Id);
                    ((Client)member.Tiers).AddSaving(saving);
                }
            }
            catch (Exception ex)
            {
                isError = true;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                InitializeControls();
            }

            if (!isError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemple #13
0
        private void EditDomain()
        {
            try
            {
                if (buttonEdit.Text.Equals(GetString("buttonEdit")))
                {
                    _selectedNode     = tvEconomicActivity.SelectedNode;
                    _economicActivity = (EconomicActivity)_selectedNode.Tag;

                    if (_economicActivity != null)
                    {
                        _economicActivity.Parent = (EconomicActivity)_selectedNode.Parent.Tag;
                        textBoxName.Text         = _economicActivity.Name;
                        _isSame                    = textBoxName.Text;
                        buttonExit.Enabled         = false;
                        buttonAdd.Enabled          = false;
                        buttonDelete.Enabled       = false;
                        tvEconomicActivity.Enabled = false;

                        buttonEdit.Text = GetString("buttonSave");
                    }
                }
                else
                {
                    if (ServicesProvider.GetInstance().GetEconomicActivityServices().NodeEditable(_selectedNode.Tag))
                    {
                        if (_selectedNode.Level == 1)
                        {
                            _economicActivity.Parent = new EconomicActivity(); // no parent
                        }
                        if (_isLoanPurpose)
                        {
                            if (_isSame != textBoxName.Text)
                            {
                                if (ServicesProvider.GetInstance().GetEconomicActivityServices().ChangeDomainOfApplicationName(_economicActivity, textBoxName.Text, _isLoanPurpose))
                                {
                                    tvEconomicActivity.BeginUpdate();
                                    _selectedNode.Tag  = _economicActivity;
                                    _selectedNode.Text = textBoxName.Text;
                                    tvEconomicActivity.EndUpdate();
                                }
                            }
                        }
                        else
                        {
                            if (_isSame != textBoxName.Text)
                            {
                                if (ServicesProvider.GetInstance().GetEconomicActivityServices().ChangeDomainOfApplicationName(_economicActivity, textBoxName.Text))
                                {
                                    tvEconomicActivity.BeginUpdate();
                                    _selectedNode.Tag  = _economicActivity;
                                    _selectedNode.Text = textBoxName.Text;
                                    tvEconomicActivity.EndUpdate();
                                }
                            }
                        }
                    }

                    buttonExit.Enabled         = true;
                    buttonAdd.Enabled          = true;
                    buttonDelete.Enabled       = true;
                    tvEconomicActivity.Enabled = true;
                    textBoxName.Text           = string.Empty;

                    buttonEdit.Text = GetString("buttonEdit");
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            SelectRootNode();

            tvEconomicActivity.Sort();
        }
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string oldpwd     = tb_OldPwd.Text.Trim();
            string newpwd     = tb_NewPwd.Text.Trim();
            string confirmpwd = tb_ConfirmPwd.Text.Trim();

            if (Dal_DevicePwd.DistanceSystemPassword.ID != 0)
            {
                if (oldpwd.Length != tb_OldPwd.MaxLength)
                {
                    DisplayContent("旧口令长度为 6 位数字,请重新输入旧口令。");
                    tb_OldPwd.Focus();
                    return;
                }
                if (oldpwd != Dal_DevicePwd.DistanceSystemPassword.Pwd)
                {
                    DisplayContent("验证旧口令错误,请重新输入旧口令。");
                    tb_OldPwd.Focus();
                    return;
                }
            }
            if (newpwd.Length != tb_NewPwd.MaxLength)
            {
                DisplayContent("新口令长度为 6 位数字,请重新输入新口令。");
                tb_NewPwd.Focus();
                return;
            }
            if (confirmpwd.Length != tb_ConfirmPwd.MaxLength)
            {
                DisplayContent("确认口令长度为 6 位数字,请重新输入确认口令。");
                tb_ConfirmPwd.Focus();
                return;
            }
            if (newpwd != confirmpwd)
            {
                DisplayContent("新口令与确认口令不一致。");
                tb_ConfirmPwd.Focus();
                return;
            }
            try
            {
                if (Dal_DevicePwd.DistanceSystemPassword.ID == 0)
                {
                    //插入新密码
                    CbDevicePwd mDistanceSystemPwd = new CbDevicePwd()
                    {
                        Pwd = newpwd
                    };
                    mDistanceSystemPwd.ID = Dbhelper.Db.Insert <CbDevicePwd>(mDistanceSystemPwd);
                    Dal_DevicePwd.DistanceSystemPassword   = mDistanceSystemPwd;
                    Tab1_Form.GetInstance.btn_Tab3.Enabled = true;
                }
                else
                {
                    //更新新密码
                    Dal_DevicePwd.DistanceSystemPassword.Pwd = newpwd;
                    Dbhelper.Db.Update <CbDevicePwd>(Dal_DevicePwd.DistanceSystemPassword);
                }
                if (PortHelper.IsConnection)
                {
                    byte[] by = PortAgreement.GetDistanceEncryption(newpwd);
                    PortHelper.SerialPortWrite(by);
                }
                else
                {
                    DisplayContent("多功能操作平台口令设置成功,请保管好口令。", Color.Black);
                    ClearTxt();
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isError = false;

            try
            {
                if (_notEnoughMoney)
                {
                    if (!MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "MoneyNotEnoughForAll.Text"), "!",
                                         MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                    {
                        return;
                    }
                }

                //Guarantors and Collaterals Check
                var isGuarantorAndCollateralAmountSufficient = true;
                var message     = "";
                var failedItems = new List <ListViewItem>();

                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked || item == _itemTotal)
                    {
                        continue;
                    }
                    var loan = item.Tag as Loan;
                    if (loan == null)
                    {
                        continue;
                    }
                    var result = ServicesProvider.GetInstance().GetContractServices().CheckIfGuarantorsAndCollateralsAmountIsSufficient(loan);
                    if (result.Key)
                    {
                        continue;
                    }
                    isGuarantorAndCollateralAmountSufficient = false;
                    message = result.Value;
                    failedItems.Add(item);
                }

                if (!isGuarantorAndCollateralAmountSufficient)
                {
                    _isFormStillNeeded = true;
                    foreach (var item in failedItems)
                    {
                        item.BackColor = Color.Red;
                    }

                    Fail(message);
                    return;
                }
                else
                {
                    _isFormStillNeeded = false;
                }
                _doc1 = "";
                _doc2 = "";
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked || item == _itemTotal)
                    {
                        continue;
                    }
                    var           loan         = item.Tag as Loan;
                    var           date         = Convert.ToDateTime(item.SubItems[IdxDDate].Text);
                    VillageMember activeMember = null;

                    int index = 0;
                    foreach (VillageMember member in _village.NonDisbursedMembers)
                    {
                        int tIndex = member.ActiveLoans.IndexOf(loan);
                        if (tIndex > -1)
                        {
                            activeMember = member;
                            index        = tIndex;
                        }
                    }

                    if (loan != null)
                    {
                        loan.CompulsorySavings = ServicesProvider.GetInstance().GetSavingServices().GetSavingForLoan(loan.Id, true);
                        if (loan.Product.UseCompulsorySavings)
                        {
                            if (loan.CompulsorySavings == null)
                            {
                                string text = string.Format("The loan with the code {0} requires a compulsory savings account to be disbursed!", loan.Code);
                                MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                            decimal totalAmountPercentage = 0;
                            decimal savingsBalance        = loan.CompulsorySavings.GetBalance().Value;

                            foreach (Loan assosiatedLoan in loan.CompulsorySavings.Loans)
                            {
                                if (assosiatedLoan.ContractStatus != OContractStatus.Closed &&
                                    assosiatedLoan.ContractStatus != OContractStatus.Abandoned &&
                                    assosiatedLoan.ContractStatus != OContractStatus.Postponed &&
                                    assosiatedLoan.CompulsorySavingsPercentage != null)
                                {
                                    totalAmountPercentage += (assosiatedLoan.Amount.Value * ((decimal)assosiatedLoan.CompulsorySavingsPercentage / 100));
                                }
                            }

                            if (totalAmountPercentage > savingsBalance)
                            {
                                MessageBox.Show(String.Format(
                                                    "The balance on savings account {2} of {0} is not enough to cover total loans amount percentage of {1}.\nClient name: {3}",
                                                    ServicesHelper.ConvertDecimalToString(savingsBalance),
                                                    ServicesHelper.ConvertDecimalToString(totalAmountPercentage),
                                                    loan.CompulsorySavings.Code,
                                                    item.SubItems[0].Text),
                                                @"Insufficient savings balance", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                        }
                    }

                    date = DateTime.Parse(item.SubItems[2].Text);

                    loan.StartDate = date;
                    if (loan.AlignDisbursementDate.Date != DateTime.Parse(item.SubItems[3].Text).Date)
                    {
                        loan.FirstInstallmentDate  = DateTime.Parse(item.SubItems[3].Text).Date;
                        loan.AlignDisbursementDate = loan.CalculateAlignDisbursementDate(DateTime.Parse(item.SubItems[3].Text).Date);
                        if (!loan.ScheduleChangedManually)
                        {
                            loan.InstallmentList = ServicesProvider.GetInstance().GetContractServices().SimulateScheduleCreation(loan);
                            loan.CalculateStartDates();
                        }
                    }
                    loan.CloseDate = loan.InstallmentList[loan.NbOfInstallments - 1].ExpectedDate;

                    if (item.SubItems[IdxPaymentMethod].Tag != null && item.SubItems[IdxPaymentMethod].Tag.ToString() == OPaymentMethods.Savings.ToString())
                    {
                        if (loan.Product.UseCompulsorySavings && loan.CompulsorySavings != null)
                        {
                            if (loan.CompulsorySavings.Status == OSavingsStatus.Active)
                            {
                                ServicesProvider.GetInstance().GetSavingServices().LoanDisbursement(loan.CompulsorySavings, loan,
                                                                                                    loan.AlignDisbursementDate, "Disbursement of the loan: " + loan.Code, User.CurrentUser, false);
                            }
                            else
                            {
                                throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.CompulsorySavingsContractIsNotActive);
                            }
                        }
                        else
                        {
                            string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                            MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    loan.Comments = item.SubItems[IdxComment].Text;
                    _doc1         = item.SubItems[IdxDoc1].Text == "" ? "" : item.SubItems[IdxDoc1].Text;
                    _doc2         = item.SubItems[IdxDoc2].Text == "" ? "" : item.SubItems[IdxDoc2].Text;

                    date += DateTime.Now.TimeOfDay;
                    PaymentMethod method =
                        ServicesProvider.GetInstance().GetPaymentMethodServices().GetPaymentMethodByName(item.SubItems[IdxPaymentMethod].Text);
                    activeMember.ActiveLoans[index] = ServicesProvider.GetInstance().GetContractServices().Disburse(loan, date, true, false, method, _doc1, _doc2);
                }
            }
            catch (Exception ex)
            {
                isError = true;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            if (!isError)
            {
                Close();
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxProductName.Text.Length == 0)
            {
                MessageBox.Show("Please, enter collateral type name!");
                return;
            }
            if (textBoxProductDesc.Text.Length == 0)
            {
                MessageBox.Show("Please, enter collateral type description!");
                return;
            }
            if (myProperties.GetSize() == 0)
            {
                MessageBox.Show("Please, enter at least one property!");
                return;
            }
            try
            {
                if (isAddMode)
                {
                    collateralProduct.Name        = textBoxProductName.Text;
                    collateralProduct.Description = textBoxProductDesc.Text;

                    List <CollateralProperty> propertiesList = new List <CollateralProperty>();

                    foreach (CustomProperty property in myProperties)
                    {
                        CollateralProperty collateralProperty = new CollateralProperty();
                        collateralProperty.Name        = property.Name;
                        collateralProperty.Description = property.Description;

                        if (property.Value is List <string> )
                        {
                            collateralProperty.Type       = OCollateralPropertyTypes.Collection;
                            collateralProperty.Collection = (List <string>)property.Value;
                        }
                        else
                        {
                            //collateralProperty.Type = (OCollateralPropertyTypes) Enum.Parse(typeof(OCollateralPropertyTypes), property.Value.ToString(), true);
                            collateralProperty.Type = (OCollateralPropertyTypes)Enum.Parse(typeof(OCollateralPropertyTypes),
                                                                                           GetString(property.Value.ToString()), true);
                        }

                        propertiesList.Add(collateralProperty);
                    }

                    collateralProduct.Properties = propertiesList;

                    ServicesProvider.GetInstance().GetCollateralProductServices().AddCollateralProduct(collateralProduct);
                }
                else
                {
                    ServicesProvider.GetInstance().GetCollateralProductServices().UpdateCollateralProduct(
                        collateralProduct.Id, collateralProduct.Name, textBoxProductName.Text, textBoxProductDesc.Text);

                    foreach (CollateralProperty property in editPropertyList)
                    {
                        ServicesProvider.GetInstance().GetCollateralProductServices().AddCollateralProperty(collateralProduct.Id, property);
                    }
                }

                Close();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Exemple #17
0
        private void InputRecord()
        {
            List <CbIoRecord> mRecord = new List <CbIoRecord>();

            try
            {
                foreach (string item in _FileNames)
                {
                    if (!CRegex.IsEnterExitRecordFileName(Path.GetFileNameWithoutExtension(item)))
                    {
                        continue;
                    }
                    this.Invoke(new EventHandler(delegate
                    {
                        l_Title.Text = string.Format("正在导入“{0}”", Path.GetFileNameWithoutExtension(item));
                        pBar.PerformStep();
                    }));
                    using (TextFieldParser tfp = new TextFieldParser(item, Encoding.GetEncoding("gb2312")))
                    {
                        tfp.Delimiters    = new string[] { "," };//确认分隔符
                        tfp.TextFieldType = FieldType.Delimited;
                        int number = 0;
                        int state  = 0;
                        int count  = 0;
                        while (!tfp.EndOfData)
                        {
                            string[] str = tfp.ReadFields();//读取行
                            if (str.Length >= 3)
                            {
                                count++;
                                //888883,000000,20140927151922
                                //组合Sql语句
                                CbIoRecord record = new CbIoRecord();
                                record.DeviceNumber = number;
                                record.IOTime       = DateTime.ParseExact(str[2], "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
                                record.IOState      = state;//0进 1出

                                if (str[0] == "FFFFFF" && str[1] == "FFFFFF")
                                {
                                    string[] str2 = tfp.ReadFields();
                                    if (str2[0] == "FFFFFF" && str2[1] == "FFFFFF")
                                    {
                                    }
                                    else if (str2[0] == "FFFFFF")//车牌识别卡
                                    {
                                        record.MasterCardNumber = str2[1];
                                    }
                                    else //IC卡
                                    {
                                        string icnumber = str2[0] + str2[1];
                                        icnumber = icnumber.Remove(0, 4);
                                        record.MasterCardNumber = icnumber;
                                    }
                                    record.SubCardNumber = str2[2];
                                }
                                else
                                {
                                    record.MasterCardNumber = str[0];
                                    record.SubCardNumber    = str[1];
                                }
                                mRecord.Add(record);
                            }
                            else
                            {
                                if (str[0].Contains("!!"))
                                {
                                    number = Utils.StrToInt(str[0].Substring(10, 2), 0);
                                    state  = Utils.StrToInt(str[0].Substring(12, 2), 0);
                                }
                            }
                        }
                    }
                }
                this.Invoke(new EventHandler(delegate
                {
                    l_Title.Text = "正在保存数据";
                    Dbhelper.Db.Insert <CbIoRecord>(mRecord.ToArray());
                    tInputRecord      = null;
                    this.DialogResult = DialogResult.OK;
                }));
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show("导入失败错误数据:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                tInputRecord = null;
                Close();
            }
        }
Exemple #18
0
        public ApplicationContext(NavigationController controller, BitMobile.Application.ApplicationSettings settings, CustomExceptionHandler exceptionHandler)
        {
            GlobalVariables = new Dictionary <string, object> ();

            Settings          = settings;
            _controller       = controller;
            _exceptionHandler = exceptionHandler;

            LocationProvider = new GPSProvider();
            LocationTracker  = new GPSTracker();
            GalleryProvider  = new GalleryProvider(controller, this);
            CameraProvider   = new CameraProvider(controller, this);
            DialogProvider   = new DialogProvider(this);
            DisplayProvider  = new DisplayProvider();

            var builder = new SolutionBuilder(this);

            builder.Build();

            StyleSheetContext.Current.Scale = UIScreen.MainScreen.Scale;
        }
        private void ButtonSaveClick(object sender, EventArgs e)
        {
            List <SavingEvent> savingEvents = new List <SavingEvent>();

            if (!CheckDateChange())
            {
                return;
            }
            _loan.Comments = tbComment.Text;
            try
            {
                DistributeEntryFees();
                // If disbursement goes to savings
                if (cmbPaymentMethod.Text == OPaymentMethods.Savings.ToString())
                {
                    if (_loan.CompulsorySavings == null)
                    {
                        throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.NoCompulsorySavings);
                    }

                    if (_loan.CompulsorySavings.Status == OSavingsStatus.Active)
                    {
                        _loan = ServicesProvider.GetInstance().GetContractServices().Disburse(_loan, _newStartDate,
                                                                                              _alignInstallmentsDatesOnRealDisbursmentDate,
                                                                                              _disableFees,
                                                                                              (PaymentMethod)
                                                                                              cmbPaymentMethod.
                                                                                              SelectedItem);
                        savingEvents = ServicesProvider.GetInstance().GetAccountServices().LoanDisbursement(_loan.CompulsorySavings,
                                                                                                            _loan,
                                                                                                            _newStartDate,
                                                                                                            "Disbursement of the loan: " +
                                                                                                            _loan.Code, User.CurrentUser,
                                                                                                            checkBoxFees.Checked);

                        //slycode
                        MessagingService messagingService = new MessagingService(Person);
                        try
                        {
                            foreach (SavingEvent savingEvent in savingEvents)
                            {
                                messagingService.SendNotification(savingEvent, _loan.CompulsorySavings, "LoanDisburstment");
                            }
                        }
                        catch (Exception exc)
                        {
                            new frmShowError(CustomExceptionHandler.ShowExceptionText(exc)).ShowDialog();
                        }
                    }
                    else
                    {
                        throw new OpenCbsSavingException(OpenCbsSavingExceptionEnum.CompulsorySavingsContractIsNotActive);
                    }
                }
                else
                {
                    _loan = ServicesProvider.GetInstance().GetContractServices().Disburse(_loan, _newStartDate,
                                                                                          _alignInstallmentsDatesOnRealDisbursmentDate,
                                                                                          _disableFees,
                                                                                          (PaymentMethod)
                                                                                          cmbPaymentMethod.SelectedItem);
                }
            }
            catch (Exception ex)
            {
                _loan.Disbursed = false;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                Close();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isError = false;

            if (_CheckIfMoneyIsEnough())
            {
                if (!MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "MoneyNotEnoughForAll.Text"), @"!",
                                     MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                {
                    return;
                }
            }

            if (_product.GracePeriod == null && !_CheckGracePeriod())
            {
                MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriodNotCorrect"),
                                MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriod"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (ListViewItem item in lvMembers.Items)
            {
                if (item == _itemTotal)
                {
                    continue;
                }
                if (!item.Checked)
                {
                    continue;
                }
                if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                {
                    string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                    MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                /*if (item.SubItems[IdxPaymentMethod].Tag != null &&
                 *  item.SubItems[IdxPaymentMethod].Tag.ToString() == OPaymentMethods.Savings.ToString())
                 * {
                 *  if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                 *  {
                 *      string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                 *      MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 *      return;
                 *  }
                 * }*/
            }

            if (!_nsgForm.Save())
            {
                return;
            }

            Loan          loan = null;
            VillageMember member;

            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked || item == _itemTotal)
                    {
                        continue;
                    }
                    member = item.Tag as VillageMember;
                    Project project;
                    if (null == member)
                    {
                        continue;
                    }

                    OCurrency amount       = (OCurrency)item.SubItems[IdxAmount].Tag;
                    decimal   interest     = (decimal)item.SubItems[IdxInterest].Tag;
                    int       gracePeriod  = (int)item.SubItems[IdxGracePeriod].Tag;
                    int       installments = (int)item.SubItems[IdxInstallments].Tag;
                    DateTime  date         = Convert.ToDateTime(item.SubItems[IdxCreationDate].Tag);

                    //creation of loan
                    loan = new Loan(_product,
                                    amount,
                                    interest,
                                    installments,
                                    gracePeriod,
                                    date,
                                    _village.MeetingDay,
                                    User.CurrentUser,
                                    ServicesProvider.GetInstance().GetGeneralSettings(),
                                    ServicesProvider.GetInstance().GetNonWorkingDate(),
                                    CoreDomainProvider.GetInstance().GetProvisioningTable(),
                                    CoreDomainProvider.GetInstance().GetChartOfAccounts())
                    {
                        NonRepaymentPenalties =
                        {
                            InitialAmount    = _product.NonRepaymentPenalties.InitialAmount ?? 0,
                            OLB              = _product.NonRepaymentPenalties.OLB ?? 0,
                            OverDuePrincipal = _product.NonRepaymentPenalties.OverDuePrincipal ?? 0,
                            OverDueInterest  = _product.NonRepaymentPenalties.OverDueInterest ?? 0
                        },
                        InstallmentType = _product.InstallmentType,
                        AnticipatedTotalRepaymentPenalties = 0,
                        FundingLine           = item.SubItems[IdxFundingLine].Tag as FundingLine,
                        LoanOfficer           = (User)item.SubItems[IdxLoanOfficer].Tag,
                        Synchronize           = false,
                        ContractStatus        = OContractStatus.Pending,
                        CreditCommitteeCode   = string.Empty,
                        GracePeriod           = gracePeriod,
                        GracePeriodOfLateFees = _product.GracePeriodOfLateFees,
                        AmountMin             = member.Product.AmountMin,
                        AmountMax             = member.Product.AmountMax,
                        InterestRateMin       = member.Product.InterestRateMin,
                        InterestRateMax       = member.Product.InterestRateMax,
                        NmbOfInstallmentsMin  = member.Product.NbOfInstallmentsMin,
                        NmbOfInstallmentsMax  = member.Product.NbOfInstallmentsMax
                    };
                    loan.InstallmentList =
                        ServicesProvider.GetInstance().GetContractServices().SimulateScheduleCreation(loan);
                    loan.LoanEntryFeesList = new List <LoanEntryFee>();
                    foreach (EntryFee fee in loan.Product.EntryFees)
                    {
                        LoanEntryFee loanEntryFee = new LoanEntryFee();
                        loanEntryFee.ProductEntryFee   = fee;
                        loanEntryFee.ProductEntryFeeId = (int)fee.Id;
                        if (fee.Value.HasValue)
                        {
                            loanEntryFee.FeeValue = (decimal)fee.Value;
                        }
                        else
                        {
                            loanEntryFee.FeeValue = (decimal)fee.Min;
                        }
                        loan.LoanEntryFeesList.Add(loanEntryFee);
                    }

                    var client = member.Tiers;
                    if (0 == client.Projects.Count)
                    {
                        project           = new Project("Village");
                        project.Name      = "Village";
                        project.Code      = "Village";
                        project.Aim       = "Village";
                        project.BeginDate = date;
                        project.Id        = ServicesProvider.GetInstance().GetProjectServices().SaveProject(project, client);
                        member.Tiers.AddProject(project);
                    }
                    project = client.Projects[0];

                    // Compulsory savings
                    if (_product.UseCompulsorySavings)
                    {
                        loan.CompulsorySavings           = (SavingBookContract)item.SubItems[IdxCompulsorySavings].Tag;
                        loan.CompulsorySavingsPercentage = (int)item.SubItems[IdxCompulsoryPercentage].Tag;
                    }
                    var person = client as Person;
                    if (person == null)
                    {
                        throw new ApplicationException("Member can not be other than person.");
                    }
                    loan.EconomicActivity = person.Activity;

                    ServicesProvider.GetInstance().GetContractServices().CheckLoanFilling(loan);
                    loan.NsgID = _village.Id;
                    ServicesProvider.GetInstance().GetContractServices().SaveLoan(ref loan, project.Id, ref client);
                    project.AddCredit(loan, loan.ClientType);
                    if (!_village.Active)
                    {
                        _village.Active = true;
                        ServicesProvider.GetInstance().GetContractServices().UpdateVillageStatus(_village);
                    }
                    loan.Closed   = false;
                    client.Active = true;
                    client.Status = OClientStatus.Active;
                    member.ActiveLoans.Add(loan);
                }
            }
            catch (Exception ex)
            {
                isError             = true;
                loan.ContractStatus = OContractStatus.Pending;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            if (!isError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemple #21
0
 private static void OnException(Exception e)
 {
     new frmShowError(CustomExceptionHandler.ShowExceptionText(e)).ShowDialog();
 }
        private void SaveCorporate(object sender, EventArgs e)
        {
            try
            {
                _corporate.CreationDate       = TimeProvider.Now;
                _corporate.RegistrationDate   = dateTimePickerDateOfCreate.Value;
                _corporate.AgrementSolidarity = false;


                RecoverDatasFromUserControlsAddress();
                _corporate.Name      = textBoxLastNameCorporate.Text;
                _corporate.Sigle     = textBoxSigle.Text;
                _corporate.SmallName = textBoxSmallNameCorporate.Text;

                _corporate.Branch = (Branch)cbBranch.SelectedItem;
                if (_corporate.Name != null)
                {
                    _corporate.Name = _corporate.Name.Trim();
                }

                _corporate.Sigle     = _corporate.Sigle.Trim();
                _corporate.SmallName = _corporate.SmallName.Trim();
                EventProcessorServices es = ServicesProvider.GetInstance().GetEventProcessorServices();
                if (_corporate.Id == 0)
                {
                    _corporate.Id = ServicesProvider
                                    .GetInstance()
                                    .GetClientServices()
                                    .SaveCorporate(_corporate, _fundingLine, tx =>
                    {
                        foreach (var extension in Extensions)
                        {
                            extension.Save(_corporate, tx);
                        }
                    });
                    buttonSave.Text = MultiLanguageStrings.GetString(Ressource.CorporateUserControl, "buttonUpdate.Text");
                    es.LogClientSaveUpdateEvent(_corporate, true);
                }
                else
                {
                    ServicesProvider.
                    GetInstance()
                    .GetClientServices()
                    .SaveCorporate(Corporate, null, tx => Extensions.ForEach(c => c.Save(Corporate, tx)));
                    es.LogClientSaveUpdateEvent(_corporate, false);
                }

                if (SaveCorporateFundingLine != null)
                {
                    SaveCorporateFundingLine(this, e);
                }

                _saved = true;
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
            finally
            {
                _create = false;
                if (CloseCorporate != null)
                {
                    CloseCorporate(this, null);
                }
            }
            if (ButtonSaveClick != null)
            {
                ButtonSaveClick(this, e);
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                _saved = true;

                if (comboBoxDirection.SelectedIndex == -1)
                {
                    throw new OpenCbsFundingLineEventException(OpenCbsFundingLineEventExceptionEnum.DirectionIsEmpty);
                }

                _fundingLineEvent.Movement = (OBookingDirections)((DictionaryEntry)comboBoxDirection.SelectedItem).Value;


                if (textBoxCode.Text == string.Empty)
                {
                    throw new OpenCbsFundingLineEventException(OpenCbsFundingLineEventExceptionEnum.CodeIsEmpty);
                }

                _fundingLineEvent.Code = textBoxCode.Text;

                if (textBoxAmount.Text == string.Empty)
                {
                    throw new OpenCbsFundingLineEventException(OpenCbsFundingLineEventExceptionEnum.AmountIsEmpty);
                }

                decimal amount;

                if (!decimal.TryParse(textBoxAmount.Text, out amount))
                {
                    throw new OpenCbsFundingLineEventException(OpenCbsFundingLineEventExceptionEnum.AmountIsNonCompliant);
                }

                if (amount >= 1000000000000000)
                {
                    throw new OpenCbsFundingLineEventException(OpenCbsFundingLineEventExceptionEnum.AmountIsBigger);
                }

                _fundingLineEvent.Amount = amount;

                if (_exchangeRate == null)
                {
                    throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.ExchangeRateIsNull);
                }
                _fundingLineEvent.CreationDate = dateTimePickerEvent.Value;
                _fundingLineEvent.FundingLine  = _FundingLine;
                _fundingLineEvent.Type         = OFundingLineEventTypes.Entry;


                Close();
            }
            catch (Exception ex)
            {
                _saved = false;
                SetExchangeRate();
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                //if(ex is OpenCbsExchangeRateException)
                //{
                //    ExchangeRateForm _xrForm = new ExchangeRateForm(new DateTime(_fundingLineEvent.CreationDate.Year, _fundingLineEvent.CreationDate.Month, _fundingLineEvent.CreationDate.Day), _fundingLineEvent.FundingLine.Currency);
                //    _xrForm.ShowDialog();
                //    if (_xrForm.ExchangeRate != null)
                //    {
                //        buttonSave.Enabled = true;
                //    }
                //    else buttonSave.Enabled = false;
                //}
            }
        }
 /// <summary>
 /// DGV 单元格的值发生变化事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Dgv_ViceCardList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (_isAddRow)
     {
         return;
     }
     try
     {
         bool   check          = Utils.StrToBool(dgv_ViceCardList[e.ColumnIndex, e.RowIndex].Value, false);
         string vicecardnumber = Utils.ObjectToStr(dgv_ViceCardList["c_ViceCardNumber", e.RowIndex].Value);
         if (check)
         {
             //组合副卡
             CbAssociateCard vicecard = new CbAssociateCard()
             {
                 AssociateCardNumber = vicecardnumber,
                 AssociateCardTime   = DateTime.Now,
                 UpdateTime          = DateTime.Now,
                 SubCardDivision     = 65535,
                 UseState            = 0
             };
             _mAddViceCard.Add(vicecard);
             //查询副卡的计数数据
             CbCardCountingState cardcounting = Dbhelper.Db.FirstDefault <CbCardCountingState>(string.Format(" and UseNumber='{0}' ", vicecardnumber));
             if (cardcounting != null)
             {
                 return;
             }
             //获取副卡参数
             ViceCardParam mViceCardParam = Tab3_Form.SubList[vicecardnumber];
             //组合副卡的计数数据
             cardcounting = new CbCardCountingState()
             {
                 UseCounting = mViceCardParam.Count,
                 UseFunction = 0,
                 UseNumber   = mViceCardParam.ViceCardNumber
             };
             //添加副卡的计数数据
             Dbhelper.Db.Insert <CbCardCountingState>(cardcounting);
             //副卡获取是否须要解锁
             if (mViceCardParam.LockState == 1)
             {
                 //修改状态添加
                 vicecard.UseState = 2;
             }
         }
         else
         {
             foreach (CbAssociateCard item in _mAddViceCard)
             {
                 if (item.AssociateCardNumber.Equals(vicecardnumber))
                 {
                     _mAddViceCard.Remove(item);
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         btn_Enter.Enabled = _mAddViceCard.Count > 0;
     }
 }
Exemple #25
0
        /// <summary>
        /// 解锁
        /// </summary>
        /// <param name="cardnumber"></param>
        /// <param name="flag"></param>
        private void UnlockDistanceCard(int flag)
        {
            int index = -1;

            try
            {
                StopTimeOutThread();
                foreach (KeyValuePair <CbCardInfo, int> item in _mLockList)
                {
                    index++;
                    if (_mLockCardInfo != null && item.Key == _mLockCardInfo)
                    {
                        if (flag == 0) //成功
                        {
                            item.Key.Unlocked = 1;
                            //更新定距卡数据
                            Dbhelper.Db.Update <CbCardInfo>(item.Key);
                            dgv_LockList["c_State", index].Value = Properties.Resources.check;
                            OnLockChange(item);
                        }
                        _mLockCardInfo = null;
                        continue;
                    }
                    if (_mLockCardInfo != null)
                    {
                        continue;
                    }
                    if (item.Key.Unlocked == 1)
                    {
                        continue;
                    }
                    _mLockCardInfo = item.Key;
                    //锁住定距卡
                    DistanceTypeParameter typeparam = new DistanceTypeParameter()
                    {
                        Lock = 1, Distance = item.Key.Distance
                    };
                    int    typebyte = DistanceCardHelper.SetCardTypeByte(typeparam, 1);
                    byte[] by       = PortAgreement.GetDistanceContent(item.Key.CardNumber, typebyte);
                    PortHelper.SerialPortWrite(by);

                    StartTimeOutThread();
                    return;
                }
                foreach (KeyValuePair <CbCardInfo, int> item in _mLockList)
                {
                    if (item.Key.Unlocked != 1)
                    {
                        UseControlEnabled();
                        return;
                    }
                }
                btn_Enter.Enabled = true;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                UseControlEnabled();
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #26
0
        private void PrintReport(Guid guid)
        {
            ReportService rs     = ReportService.GetInstance();
            Report        report = rs.GetReport(guid);

            if (null == report)
            {
                return;
            }

            try
            {
                ReportInitializer(report);

                if (report.DisableIfLoanIsPending)
                {
                    var loan = (Loan)report.GetExtra("loan");
                    if (loan == null || loan.ContractStatus == OContractStatus.None || loan.ContractStatus == OContractStatus.Pending)
                    {
                        MessageBox.Show(
                            MultiLanguageStrings.GetString(Ressource.PrintButton, "pleaseApproveLoan"),
                            MultiLanguageStrings.GetString(Ressource.PrintButton, "warning"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning);
                        return;
                    }
                }

                List <ReportParamV2> additionalParams
                    = report.Params
                      .Where(p => p.Additional && p.Visible)
                      .ToList();
                if (additionalParams.Count != 0)
                {
                    ReportParamsForm reportParamsForm = new ReportParamsForm(additionalParams, report.Title);
                    if (reportParamsForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }

                try
                {
                    StartProgress();
                    rs.LoadReport(report);
                }
                finally
                {
                    StopProgress();
                }
            }
            catch (Exception exception)
            {
                new frmShowError(
                    CustomExceptionHandler.ShowExceptionText(exception)
                    ).ShowDialog();
                throw;
            }

            ReportViewerForm frm = new ReportViewerForm(report);

            frm.Show();
        }
Exemple #27
0
        private void ImportAccounts()
        {
            fileDialog.InitialDirectory = Application.CommonAppDataPath;
            fileDialog.Filter           = @"CSV (*.csv)|*.csv|All files (*.*)|*.*";
            fileDialog.FilterIndex      = 1;
            fileDialog.RestoreDirectory = true;

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    bool deleteRelated = Confirm(MultiLanguageStrings.GetString(Ressource.ChartOfAccountsForm, "ToDeleteTheChartOfAccounts.Text"));

                    CsvImportExport         importer    = new CsvImportExport();
                    string                  filePath    = fileDialog.FileName;
                    List <Account>          accounts    = new List <Account>();
                    ChartOfAccountsServices coaServices = ServicesProvider.GetInstance().GetChartOfAccountsServices();
                    if (deleteRelated)
                    {
                        IEnumerable <string> relatedDatas = coaServices.HasRelatedDatas();
                        if (relatedDatas != null && relatedDatas.Any())
                        {
                            string[] domainObjects =
                                relatedDatas
                                .Select(
                                    r => GetString(string.Format("RelatedData.{0}", r))
                                    ).Distinct().ToArray();

                            string message =
                                string.Format(
                                    GetString("RelatedDataExists.Text"),
                                    string.Join(",", domainObjects));
                            if (!Confirm(message))
                            {
                                return;
                            }
                        }
                    }
                    importer.Import(filePath, items =>
                    {
                        Account account = new Account
                        {
                            Id              = Convert.ToInt32(items[0]),
                            Number          = items[1],
                            Label           = items[2],
                            DebitPlus       = Convert.ToBoolean(items[3]),
                            TypeCode        = items[4],
                            AccountCategory = (OAccountCategories)(Convert.ToInt32(items[5])),
                            Type            = Convert.ToBoolean(items[6]),
                            ParentAccountId = items[5].ToUpper() == "0" ? null : (int?)Convert.ToInt32(items[7]),
                            Left            = Convert.ToInt32(items[8]),
                            Right           = Convert.ToInt32(items[9])
                        };
                        accounts.Add(account);
                    });

                    coaServices.InsertCoa(accounts.ToArray(), deleteRelated);
                    IntializeTreeViewChartOfAccounts();
                }
                catch (Exception ex)
                {
                    new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                }
            }
        }