Esempio n. 1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new PhysicalPersonLicenceSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonLicenceDG.Identifier);

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

                CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
                CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added;

                CurrentPhysicalPersonLicenceDG = null;

                PhysicalPersonCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayPhysicalPersonLicenceData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
        public static PhysicalPersonLicenceViewModel ConvertToPhysicalPersonLicenceViewModel(this PhysicalPersonLicence PhysicalPersonItem)
        {
            PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel = new PhysicalPersonLicenceViewModel()
            {
                Id         = PhysicalPersonItem.Id,
                Identifier = PhysicalPersonItem.Identifier,

                PhysicalPerson = PhysicalPersonItem.PhysicalPerson?.ConvertToPhysicalPersonViewModelLite(),
                Licence        = PhysicalPersonItem.Licence?.ConvertToLicenceTypeViewModelLite(),
                Country        = PhysicalPersonItem.Country?.ConvertToCountryViewModelLite(),

                ValidFrom  = PhysicalPersonItem.ValidFrom,
                ValidTo    = PhysicalPersonItem.ValidTo,
                ItemStatus = PhysicalPersonItem.ItemStatus,

                IsActive = PhysicalPersonItem.Active,

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

                UpdatedAt = PhysicalPersonItem.UpdatedAt,
                CreatedAt = PhysicalPersonItem.CreatedAt
            };

            return(PhysicalPersonItemViewModel);
        }
Esempio n. 3
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, PhysicalPersonLicenceViewModel PhysicalPersonItem)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", PhysicalPersonItem.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", PhysicalPersonItem.Identifier);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonId", ((object)PhysicalPersonItem.PhysicalPerson.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonIdentifier", ((object)PhysicalPersonItem.PhysicalPerson.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonCode", ((object)PhysicalPersonItem.PhysicalPerson.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonName", ((object)PhysicalPersonItem.PhysicalPerson.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@LicenceId", ((object)PhysicalPersonItem.Licence.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@LicenceIdentifier", ((object)PhysicalPersonItem.Licence.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@LicenceCode", ((object)PhysicalPersonItem.Licence.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@LicenceCategory", ((object)PhysicalPersonItem.Licence.Category) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@LicenceDescription", ((object)PhysicalPersonItem.Licence.Description) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryId", ((object)PhysicalPersonItem.Country.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryIdentifier", ((object)PhysicalPersonItem.Country.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryCode", ((object)PhysicalPersonItem.Country.Mark) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryName", ((object)PhysicalPersonItem.Country.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ValidFrom", ((object)PhysicalPersonItem.ValidFrom) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ValidTo", ((object)PhysicalPersonItem.ValidTo) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", PhysicalPersonItem.ItemStatus);
            insertCommand.Parameters.AddWithValue("@IsSynced", PhysicalPersonItem.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)PhysicalPersonItem.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);
        }
Esempio n. 4
0
        public PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItem)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

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

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, PhysicalPersonItem);
                    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);
            }
        }
Esempio n. 5
0
        private void btnEditNote_Click(object sender, RoutedEventArgs e)
        {
            CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
            CurrentPhysicalPersonLicenceForm.Identifier = CurrentPhysicalPersonLicenceDG.Identifier;
            CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Edited;

            CurrentPhysicalPersonLicenceForm.Country   = CurrentPhysicalPersonLicenceDG.Country;
            CurrentPhysicalPersonLicenceForm.Licence   = CurrentPhysicalPersonLicenceDG.Licence;
            CurrentPhysicalPersonLicenceForm.ValidFrom = CurrentPhysicalPersonLicenceDG.ValidFrom;
            CurrentPhysicalPersonLicenceForm.ValidTo   = CurrentPhysicalPersonLicenceDG.ValidTo;
            CurrentPhysicalPersonLicenceForm.IsSynced  = CurrentPhysicalPersonLicenceDG.IsSynced;
            CurrentPhysicalPersonLicenceForm.UpdatedAt = CurrentPhysicalPersonLicenceDG.UpdatedAt;
        }
        public PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                response = WpfApiHandler.SendToApi <PhysicalPersonLicenceViewModel, PhysicalPersonLicenceResponse>(PhysicalPersonItemViewModel, "Create");
            }
            catch (Exception ex)
            {
                response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public PhysicalPersonLicenceResponse Create(PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                var addedPhysicalPersonItem = unitOfWork.GetPhysicalPersonLicenceRepository().Create(PhysicalPersonItemViewModel.ConvertToPhysicalPersonLicence());
                unitOfWork.Save();
                response.PhysicalPersonLicence = addedPhysicalPersonItem.ConvertToPhysicalPersonLicenceViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public static PhysicalPersonLicenceViewModel ConvertToPhysicalPersonLicenceViewModelLite(this PhysicalPersonLicence PhysicalPersonItem)
        {
            PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel = new PhysicalPersonLicenceViewModel()
            {
                Id         = PhysicalPersonItem.Id,
                Identifier = PhysicalPersonItem.Identifier,

                ValidFrom  = PhysicalPersonItem.ValidFrom,
                ValidTo    = PhysicalPersonItem.ValidTo,
                ItemStatus = PhysicalPersonItem.ItemStatus,

                IsActive = PhysicalPersonItem.Active,

                UpdatedAt = PhysicalPersonItem.UpdatedAt,
                CreatedAt = PhysicalPersonItem.CreatedAt
            };

            return(PhysicalPersonItemViewModel);
        }
Esempio n. 9
0
        public PhysicalPersonLicenceListResponse GetPhysicalPersonLicencesByPhysicalPerson(int companyId, Guid PhysicalPersonIdentifier)
        {
            PhysicalPersonLicenceListResponse     response = new PhysicalPersonLicenceListResponse();
            List <PhysicalPersonLicenceViewModel> PhysicalPersonLicences = new List <PhysicalPersonLicenceViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM  PhysicalPersonLicences " +
                        "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())
                    {
                        PhysicalPersonLicenceViewModel dbEntry = Read(query);
                        PhysicalPersonLicences.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage         = error.Message;
                    response.Success                = false;
                    response.Message                = error.Message;
                    response.PhysicalPersonLicences = new List <PhysicalPersonLicenceViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonLicences = PhysicalPersonLicences;
            return(response);
        }
        public JsonResult Create([FromBody] PhysicalPersonLicenceViewModel c)
        {
            PhysicalPersonLicenceResponse response = new PhysicalPersonLicenceResponse();

            try
            {
                response = this.PhysicalPersonItemService.Create(c);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
Esempio n. 11
0
        private static PhysicalPersonLicenceViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            PhysicalPersonLicenceViewModel dbEntry = new PhysicalPersonLicenceViewModel();

            dbEntry.Id             = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier     = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.PhysicalPerson = SQLiteHelper.GetPhysicalPerson(query, ref counter);
            dbEntry.Licence        = SQLiteHelper.GetLicence(query, ref counter);
            dbEntry.ValidFrom      = SQLiteHelper.GetDateTimeNullable(query, ref counter);
            dbEntry.ValidTo        = SQLiteHelper.GetDateTimeNullable(query, ref counter);
            dbEntry.ItemStatus     = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Country        = SQLiteHelper.GetCountry(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);
        }
Esempio n. 12
0
        public PhysicalPerson_Licence_AddEdit(PhysicalPersonViewModel physicalPerson)
        {
            physicalPersonService        = DependencyResolver.Kernel.Get <IPhysicalPersonService>();
            physicalPersonLicenceService = DependencyResolver.Kernel.Get <IPhysicalPersonLicenceService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentPhysicalPerson                       = physicalPerson;
            CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
            CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid();
            CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddNote.Focus();
        }
Esempio n. 13
0
        public PhysicalPersonLicenceResponse GetPhysicalPersonLicence(Guid identifier)
        {
            PhysicalPersonLicenceResponse  response           = new PhysicalPersonLicenceResponse();
            PhysicalPersonLicenceViewModel PhysicalPersonItem = new PhysicalPersonLicenceViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        PhysicalPersonLicenceViewModel dbEntry = Read(query);
                        PhysicalPersonItem = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage        = error.Message;
                    response.Success               = false;
                    response.Message               = error.Message;
                    response.PhysicalPersonLicence = new PhysicalPersonLicenceViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonLicence = PhysicalPersonItem;
            return(response);
        }
        public static PhysicalPersonLicence ConvertToPhysicalPersonLicence(this PhysicalPersonLicenceViewModel PhysicalPersonItemViewModel)
        {
            PhysicalPersonLicence PhysicalPersonItem = new PhysicalPersonLicence()
            {
                Id         = PhysicalPersonItemViewModel.Id,
                Identifier = PhysicalPersonItemViewModel.Identifier,

                PhysicalPersonId = PhysicalPersonItemViewModel.PhysicalPerson?.Id ?? null,
                LicenceId        = PhysicalPersonItemViewModel.Licence?.Id ?? null,
                CountryId        = PhysicalPersonItemViewModel.Country?.Id ?? null,

                ValidFrom  = PhysicalPersonItemViewModel.ValidFrom,
                ValidTo    = PhysicalPersonItemViewModel.ValidTo,
                ItemStatus = PhysicalPersonItemViewModel.ItemStatus,

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

                CreatedAt = PhysicalPersonItemViewModel.CreatedAt,
                UpdatedAt = PhysicalPersonItemViewModel.UpdatedAt
            };

            return(PhysicalPersonItem);
        }
Esempio n. 15
0
 private void btnCancelNote_Click(object sender, RoutedEventArgs e)
 {
     CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
     CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid();
     CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added;
 }
Esempio n. 16
0
        private void btnAddNote_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentPhysicalPersonLicenceForm.Country == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_drzava"));
                return;
            }

            if (CurrentPhysicalPersonLicenceForm.Licence == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_polje_licenca"));
                return;
            }

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

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

                new PhysicalPersonLicenceSQLiteRepository().Delete(CurrentPhysicalPersonLicenceForm.Identifier);

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

                    CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
                    CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid();
                    CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added;
                    CurrentPhysicalPersonLicenceForm.IsSynced   = false;

                    return;
                }

                CurrentPhysicalPersonLicenceForm            = new PhysicalPersonLicenceViewModel();
                CurrentPhysicalPersonLicenceForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonLicenceForm.ItemStatus = ItemStatus.Added;
                CurrentPhysicalPersonLicenceForm.IsSynced   = false;

                PhysicalPersonCreatedUpdated();
                DisplayPhysicalPersonLicenceData();

                Application.Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(() =>
                {
                    //txtNote.Focus();
                })
                    );
                SubmitButtonEnabled = true;
            });
            th.IsBackground = true;
            th.Start();
        }