Ejemplo n.º 1
0
        public PhysicalPersonCardResponse Create(PhysicalPersonCardViewModel PhysicalPersonCard)
        {
            PhysicalPersonCardResponse response = new PhysicalPersonCardResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, PhysicalPersonCard);
                    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);
            }
        }
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new PhysicalPersonCardSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonCardDG.Identifier);

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

                CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
                CurrentPhysicalPersonCardForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Added;

                CurrentPhysicalPersonCardDG = null;

                PhysicalPersonCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayPhysicalPersonCardData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
        private void btnAddNote_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentPhysicalPersonCardForm.Description == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Opis"));
                return;
            }

            #endregion
            Thread th = new Thread(() =>
            {
                SubmitButtonEnabled = false;
                CurrentPhysicalPersonCardForm.PhysicalPerson = CurrentPhysicalPerson;

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

                new PhysicalPersonCardSQLiteRepository().Delete(CurrentPhysicalPersonCardForm.Identifier);

                var response = new PhysicalPersonCardSQLiteRepository().Create(CurrentPhysicalPersonCardForm);
                if (!response.Success)
                {
                    MainWindow.ErrorMessage = response.Message;

                    CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
                    CurrentPhysicalPersonCardForm.Identifier = Guid.NewGuid();
                    CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Added;
                    CurrentPhysicalPersonCardForm.IsSynced   = false;

                    return;
                }

                CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
                CurrentPhysicalPersonCardForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Added;
                CurrentPhysicalPersonCardForm.IsSynced   = false;

                PhysicalPersonCreatedUpdated();
                DisplayPhysicalPersonCardData();

                Application.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(() =>
                {
                    txtNote.Focus();
                })
                    );
                SubmitButtonEnabled = true;
            });
            th.IsBackground = true;
            th.Start();
        }
Ejemplo n.º 4
0
        public static PhysicalPersonCard ConvertToPhysicalPersonCard(this PhysicalPersonCardViewModel employeeCardViewModel)
        {
            PhysicalPersonCard PhysicalPersonCard = new PhysicalPersonCard()
            {
                Id         = employeeCardViewModel.Id,
                Identifier = employeeCardViewModel.Identifier,

                PhysicalPersonId = employeeCardViewModel.PhysicalPerson?.Id ?? null,

                CardDate    = (DateTime)employeeCardViewModel.CardDate,
                Description = employeeCardViewModel.Description,
                PlusMinus   = employeeCardViewModel.PlusMinus,
                ItemStatus  = employeeCardViewModel.ItemStatus,


                Active = employeeCardViewModel.IsActive,

                CreatedById = employeeCardViewModel.CreatedBy?.Id ?? null,
                CompanyId   = employeeCardViewModel.Company?.Id ?? null,

                CreatedAt = employeeCardViewModel.CreatedAt,
                UpdatedAt = employeeCardViewModel.UpdatedAt
            };

            return(PhysicalPersonCard);
        }
Ejemplo n.º 5
0
        public static PhysicalPersonCardViewModel ConvertToPhysicalPersonCardViewModel(this PhysicalPersonCard employeeCard)
        {
            PhysicalPersonCardViewModel PhysicalPersonCardViewModel = new PhysicalPersonCardViewModel()
            {
                Id         = employeeCard.Id,
                Identifier = employeeCard.Identifier,

                PhysicalPerson = employeeCard.PhysicalPerson?.ConvertToPhysicalPersonViewModelLite(),

                CardDate    = employeeCard.CardDate,
                Description = employeeCard.Description,
                PlusMinus   = employeeCard.PlusMinus,
                ItemStatus  = employeeCard.ItemStatus,

                IsActive = employeeCard.Active,

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

                UpdatedAt = employeeCard.UpdatedAt,
                CreatedAt = employeeCard.CreatedAt
            };

            return(PhysicalPersonCardViewModel);
        }
        private void btnEditNote_Click(object sender, RoutedEventArgs e)
        {
            CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
            CurrentPhysicalPersonCardForm.Identifier = CurrentPhysicalPersonCardDG.Identifier;
            CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Edited;

            CurrentPhysicalPersonCardForm.IsSynced    = CurrentPhysicalPersonCardDG.IsSynced;
            CurrentPhysicalPersonCardForm.Description = CurrentPhysicalPersonCardDG.Description;
            CurrentPhysicalPersonCardForm.CardDate    = CurrentPhysicalPersonCardDG.CardDate;
            CurrentPhysicalPersonCardForm.UpdatedAt   = CurrentPhysicalPersonCardDG.UpdatedAt;
        }
Ejemplo n.º 7
0
        private static PhysicalPersonCardViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            PhysicalPersonCardViewModel dbEntry = new PhysicalPersonCardViewModel();

            dbEntry.Id             = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier     = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.PhysicalPerson = SQLiteHelper.GetPhysicalPerson(query, ref counter);
            dbEntry.CardDate       = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.Description    = SQLiteHelper.GetString(query, ref counter);
            dbEntry.PlusMinus      = 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.º 8
0
        public PhysicalPersonCardListResponse GetPhysicalPersonCardsByPhysicalPerson(int companyId, Guid PhysicalPersonIdentifier)
        {
            PhysicalPersonCardListResponse     response            = new PhysicalPersonCardListResponse();
            List <PhysicalPersonCardViewModel> PhysicalPersonCards = new List <PhysicalPersonCardViewModel>();

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

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        PhysicalPersonCardViewModel dbEntry = Read(query);
                        PhysicalPersonCards.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage      = error.Message;
                    response.Success             = false;
                    response.Message             = error.Message;
                    response.PhysicalPersonCards = new List <PhysicalPersonCardViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success             = true;
            response.PhysicalPersonCards = PhysicalPersonCards;
            return(response);
        }
        public PhysicalPerson_Card_AddEdit(PhysicalPersonViewModel physicalPerson)
        {
            physicalPersonService     = DependencyResolver.Kernel.Get <IPhysicalPersonService>();
            physicalPersonNoteService = DependencyResolver.Kernel.Get <IPhysicalPersonCardService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentPhysicalPerson                    = physicalPerson;
            CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
            CurrentPhysicalPersonCardForm.Identifier = Guid.NewGuid();
            CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddNote.Focus();
        }
Ejemplo n.º 10
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, PhysicalPersonCardViewModel PhysicalPersonCard)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", PhysicalPersonCard.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", PhysicalPersonCard.Identifier);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonId", ((object)PhysicalPersonCard.PhysicalPerson.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonIdentifier", ((object)PhysicalPersonCard.PhysicalPerson.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonCode", ((object)PhysicalPersonCard.PhysicalPerson.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonName", ((object)PhysicalPersonCard.PhysicalPerson.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CardDate", ((object)PhysicalPersonCard.CardDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Description", ((object)PhysicalPersonCard.Description) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PlusMinus", ((object)PhysicalPersonCard.PlusMinus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)PhysicalPersonCard.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", PhysicalPersonCard.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)PhysicalPersonCard.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.º 11
0
        public PhysicalPersonCardResponse GetPhysicalPersonCard(Guid identifier)
        {
            PhysicalPersonCardResponse  response           = new PhysicalPersonCardResponse();
            PhysicalPersonCardViewModel PhysicalPersonCard = new PhysicalPersonCardViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        PhysicalPersonCardViewModel dbEntry = Read(query);
                        PhysicalPersonCard = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage     = error.Message;
                    response.Success            = false;
                    response.Message            = error.Message;
                    response.PhysicalPersonCard = new PhysicalPersonCardViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success            = true;
            response.PhysicalPersonCard = PhysicalPersonCard;
            return(response);
        }
 private void btnCancelNote_Click(object sender, RoutedEventArgs e)
 {
     CurrentPhysicalPersonCardForm            = new PhysicalPersonCardViewModel();
     CurrentPhysicalPersonCardForm.Identifier = Guid.NewGuid();
     CurrentPhysicalPersonCardForm.ItemStatus = ItemStatus.Added;
 }