Ejemplo n.º 1
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, BusinessPartnerBankViewModel businessPartnerBank)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", businessPartnerBank.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", businessPartnerBank.Identifier);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)businessPartnerBank.BusinessPartner.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)businessPartnerBank.BusinessPartner.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)businessPartnerBank.BusinessPartner.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)businessPartnerBank.BusinessPartner.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)businessPartnerBank.BusinessPartner.InternalCode) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)businessPartnerBank.BusinessPartner.NameGer) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BankId", ((object)businessPartnerBank.Bank.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BankIdentifier", ((object)businessPartnerBank.Bank.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BankCode", ((object)businessPartnerBank.Bank.Swift) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BankName", ((object)businessPartnerBank.Bank.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryId", ((object)businessPartnerBank.Country.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryIdentifier", ((object)businessPartnerBank.Country.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryCode", ((object)businessPartnerBank.Country.Mark) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryName", ((object)businessPartnerBank.Country.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@AccountNumber", ((object)businessPartnerBank.AccountNumber) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)businessPartnerBank.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", businessPartnerBank.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)businessPartnerBank.UpdatedAt) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id);
            insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName);
            insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id);
            insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName);

            return(insertCommand);
        }
Ejemplo n.º 2
0
        public BusinessPartnerBankResponse Create(BusinessPartnerBankViewModel businessPartnerBank)
        {
            BusinessPartnerBankResponse response = new BusinessPartnerBankResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, businessPartnerBank);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
Ejemplo n.º 3
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new BusinessPartnerBankSQLiteRepository().SetStatusDeleted(CurrentBusinessPartnerBankDG.Identifier);

            if (response.Success)
            {
                MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik"));

                CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
                CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid();
                CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added;

                CurrentBusinessPartnerBankDG = null;

                BusinessPartnerCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayBusinessPartnerBankData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
Ejemplo n.º 4
0
        private void btnEditBank_Click(object sender, RoutedEventArgs e)
        {
            CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
            CurrentBusinessPartnerBankForm.Identifier = CurrentBusinessPartnerBankDG.Identifier;
            CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Edited;

            CurrentBusinessPartnerBankForm.IsSynced      = CurrentBusinessPartnerBankDG.IsSynced;
            CurrentBusinessPartnerBankForm.Country       = CurrentBusinessPartnerBankDG.Country;
            CurrentBusinessPartnerBankForm.Bank          = CurrentBusinessPartnerBankDG.Bank;
            CurrentBusinessPartnerBankForm.AccountNumber = CurrentBusinessPartnerBankDG.AccountNumber;
            CurrentBusinessPartnerBankForm.UpdatedAt     = CurrentBusinessPartnerBankDG.UpdatedAt;
        }
        public BusinessPartnerBankResponse Create(BusinessPartnerBankViewModel businessPartnerBankViewModel)
        {
            BusinessPartnerBankResponse response = new BusinessPartnerBankResponse();

            try
            {
                response = WpfApiHandler.SendToApi <BusinessPartnerBankViewModel, BusinessPartnerBankResponse>(businessPartnerBankViewModel, "Create");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerBank = new BusinessPartnerBankViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }
            return(response);
        }
        public static BusinessPartnerBankViewModel ConvertToBusinessPartnerBankViewModelLite(this BusinessPartnerBank businessPartnerBank)
        {
            BusinessPartnerBankViewModel businessPartnerBankViewModel = new BusinessPartnerBankViewModel()
            {
                Id         = businessPartnerBank.Id,
                Identifier = businessPartnerBank.Identifier,

                AccountNumber = businessPartnerBank.AccountNumber,
                ItemStatus    = businessPartnerBank.ItemStatus,
                IsActive      = businessPartnerBank.Active,

                UpdatedAt = businessPartnerBank.UpdatedAt,
                CreatedAt = businessPartnerBank.CreatedAt,
            };

            return(businessPartnerBankViewModel);
        }
        public BusinessPartnerBankResponse Delete(Guid identifier)
        {
            BusinessPartnerBankResponse response = new BusinessPartnerBankResponse();

            try
            {
                BusinessPartnerBankViewModel viewModel = new BusinessPartnerBankViewModel();
                viewModel.Identifier = identifier;
                response             = WpfApiHandler.SendToApi <BusinessPartnerBankViewModel, BusinessPartnerBankResponse>(viewModel, "Delete");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerBank = new BusinessPartnerBankViewModel();
                response.Success             = false;
                response.Message             = ex.Message;
            }
            return(response);
        }
Ejemplo n.º 8
0
        private BusinessPartnerBankViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            BusinessPartnerBankViewModel dbEntry = new BusinessPartnerBankViewModel();

            dbEntry.Id              = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier      = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(query, ref counter);
            dbEntry.Bank            = SQLiteHelper.GetBank(query, ref counter);
            dbEntry.Country         = SQLiteHelper.GetCountry(query, ref counter);
            dbEntry.AccountNumber   = SQLiteHelper.GetString(query, ref counter);
            dbEntry.ItemStatus      = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.IsSynced        = SQLiteHelper.GetBoolean(query, ref counter);
            dbEntry.UpdatedAt       = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.CreatedBy       = SQLiteHelper.GetCreatedBy(query, ref counter);
            dbEntry.Company         = SQLiteHelper.GetCompany(query, ref counter);

            return(dbEntry);
        }
Ejemplo n.º 9
0
        public BusinessPartnerBankListResponse GetBusinessPartnerBanksByBusinessPartner(int companyId, Guid businessPartnerIdentifier)
        {
            BusinessPartnerBankListResponse     response             = new BusinessPartnerBankListResponse();
            List <BusinessPartnerBankViewModel> businessPartnerBanks = new List <BusinessPartnerBankViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM BusinessPartnerBanks " +
                        "WHERE BusinessPartnerIdentifier = @BusinessPartnerIdentifier " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC;", db);

                    selectCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", businessPartnerIdentifier);
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);

                    SqliteDataReader query = selectCommand.ExecuteReader();
                    while (query.Read())
                    {
                        BusinessPartnerBankViewModel dbEntry = Read(query);
                        businessPartnerBanks.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage       = error.Message;
                    response.Success              = false;
                    response.Message              = error.Message;
                    response.BusinessPartnerBanks = new List <BusinessPartnerBankViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.BusinessPartnerBanks = businessPartnerBanks;
            return(response);
        }
Ejemplo n.º 10
0
        public BusinessPartner_Bank_AddEdit(BusinessPartnerViewModel businessPartner)
        {
            businessPartnerService     = DependencyResolver.Kernel.Get <IBusinessPartnerService>();
            businessPartnerBankService = DependencyResolver.Kernel.Get <IBusinessPartnerBankService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentBusinessPartner                    = businessPartner;
            CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
            CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid();
            CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added;

            Thread displayThread = new Thread(() => DisplayBusinessPartnerBankData());

            displayThread.IsBackground = true;
            displayThread.Start();

            btnAddBank.Focus();
        }
Ejemplo n.º 11
0
        public BusinessPartnerBankResponse GetBusinessPartnerBank(Guid identifier)
        {
            BusinessPartnerBankResponse  response            = new BusinessPartnerBankResponse();
            BusinessPartnerBankViewModel businessPartnerBank = new BusinessPartnerBankViewModel();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM BusinessPartnerBanks " +
                        "WHERE Identifier = @Identifier;", db);
                    selectCommand.Parameters.AddWithValue("@Identifier", identifier);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        BusinessPartnerBankViewModel dbEntry = Read(query);
                        businessPartnerBank = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage      = error.Message;
                    response.Success             = false;
                    response.Message             = error.Message;
                    response.BusinessPartnerBank = new BusinessPartnerBankViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success             = true;
            response.BusinessPartnerBank = businessPartnerBank;
            return(response);
        }
        public static BusinessPartnerBank ConvertToBusinessPartnerBank(this BusinessPartnerBankViewModel businessPartnerBankViewModel)
        {
            BusinessPartnerBank businessPartnerBank = new BusinessPartnerBank()
            {
                Id         = businessPartnerBankViewModel.Id,
                Identifier = businessPartnerBankViewModel.Identifier,

                BusinessPartnerId = businessPartnerBankViewModel.BusinessPartner?.Id ?? null,

                BankId        = businessPartnerBankViewModel.Bank?.Id ?? 0,
                CountryId     = businessPartnerBankViewModel.Country?.Id ?? 0,
                AccountNumber = businessPartnerBankViewModel.AccountNumber,
                ItemStatus    = businessPartnerBankViewModel.ItemStatus,

                Active      = businessPartnerBankViewModel.IsActive,
                CreatedById = businessPartnerBankViewModel.CreatedBy?.Id ?? null,
                CompanyId   = businessPartnerBankViewModel.Company?.Id ?? null,

                UpdatedAt = businessPartnerBankViewModel.UpdatedAt,
                CreatedAt = businessPartnerBankViewModel.CreatedAt,
            };

            return(businessPartnerBank);
        }
        public static BusinessPartnerBankViewModel ConvertToBusinessPartnerBankViewModel(this BusinessPartnerBank businessPartnerBank)
        {
            BusinessPartnerBankViewModel businessPartnerBankViewModel = new BusinessPartnerBankViewModel()
            {
                Id         = businessPartnerBank.Id,
                Identifier = businessPartnerBank.Identifier,

                BusinessPartner = businessPartnerBank.BusinessPartner?.ConvertToBusinessPartnerViewModelLite(),

                Bank          = businessPartnerBank.Bank?.ConvertToBankViewModelLite(),
                Country       = businessPartnerBank.Country?.ConvertToCountryViewModelLite(),
                AccountNumber = businessPartnerBank.AccountNumber,
                ItemStatus    = businessPartnerBank.ItemStatus,
                IsActive      = businessPartnerBank.Active,

                CreatedBy = businessPartnerBank.CreatedBy?.ConvertToUserViewModelLite(),
                Company   = businessPartnerBank.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = businessPartnerBank.UpdatedAt,
                CreatedAt = businessPartnerBank.CreatedAt,
            };

            return(businessPartnerBankViewModel);
        }
Ejemplo n.º 14
0
 private void btnCancelBank_Click(object sender, RoutedEventArgs e)
 {
     CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
     CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid();
     CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added;
 }
Ejemplo n.º 15
0
        private void btnAddBank_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentBusinessPartnerBankForm.Bank?.Name == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Ime_banke"));
                return;
            }

            #endregion

            Thread th = new Thread(() =>
            {
                SubmitButtonEnabled = false;


                CurrentBusinessPartnerBankForm.BusinessPartner = CurrentBusinessPartner;


                CurrentBusinessPartnerBankForm.Company = new CompanyViewModel()
                {
                    Id = MainWindow.CurrentCompanyId
                };
                CurrentBusinessPartnerBankForm.CreatedBy = new UserViewModel()
                {
                    Id = MainWindow.CurrentUserId
                };

                new BusinessPartnerBankSQLiteRepository().Delete(CurrentBusinessPartnerBankForm.Identifier);
                var response = new BusinessPartnerBankSQLiteRepository().Create(CurrentBusinessPartnerBankForm);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = response.Message;

                    CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
                    CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid();
                    CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added;
                    CurrentBusinessPartnerBankForm.IsSynced   = false;
                    return;
                }

                CurrentBusinessPartnerBankForm            = new BusinessPartnerBankViewModel();
                CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid();
                CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added;
                CurrentBusinessPartnerBankForm.IsSynced   = false;
                BusinessPartnerCreatedUpdated();

                DisplayBusinessPartnerBankData();

                Application.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(() =>
                {
                    txtAccountNumber.Focus();
                })
                    );

                SubmitButtonEnabled = true;
            });
            th.IsBackground = true;
            th.Start();
        }