public PhysicalPersonDocumentResponse Create(PhysicalPersonDocumentViewModel PhysicalPersonDocument)
        {
            PhysicalPersonDocumentResponse response = new PhysicalPersonDocumentResponse();

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

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, PhysicalPersonDocument);
                    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);
            }
        }
예제 #2
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new PhysicalPersonDocumentSQLiteRepository().SetStatusDeleted(CurrentPhysicalPersonDocumentDG.Identifier);

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

                CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
                CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added;

                CurrentPhysicalPersonDocumentDG = null;

                PhysicalPersonCreatedUpdated();

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

            if (CurrentPhysicalPersonDocumentForm.Name == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Naziv"));
                return;
            }

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

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

                new PhysicalPersonDocumentSQLiteRepository().Delete(CurrentPhysicalPersonDocumentForm.Identifier);

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

                    CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
                    CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid();
                    CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added;
                    CurrentPhysicalPersonDocumentForm.IsSynced   = false;

                    return;
                }

                CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
                CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid();
                CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added;
                CurrentPhysicalPersonDocumentForm.IsSynced   = false;

                PhysicalPersonCreatedUpdated();
                DisplayPhysicalPersonDocumentData();

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

            this.DataContext = this;

            FilterBusinessPartnerDocuments = new BusinessPartnerDocumentViewModel();
            FilterBusinessPartnerDocuments.PropertyChanged += FilterBusinessPartnerDocuments_PropertyChanged;

            FilterConstructionSiteDocuments = new ConstructionSiteDocumentViewModel();
            FilterConstructionSiteDocuments.PropertyChanged += FilterConstructionSiteDocuments_PropertyChanged;

            FilterEmployeeDocuments = new EmployeeDocumentViewModel();
            FilterEmployeeDocuments.PropertyChanged += FilterEmployeeDocuments_PropertyChanged;

            FilterPhysicalPersonDocuments = new PhysicalPersonDocumentViewModel();
            FilterPhysicalPersonDocuments.PropertyChanged += FilterPhysicalPersonDocuments_PropertyChanged;

            DocumentsForMail = new ObservableCollection <DocumentForMailViewModel>();

            Thread td = new Thread(() => {
                DisplayBusinessPartnerDocumentData();

                DisplayConstructionSiteDocumentData();

                DisplayEmployeeDocumentData();

                DisplayPhysicalPersonDocumentData();
            });

            td.IsBackground = true;
            td.Start();
        }
        public static PhysicalPersonDocument ConvertToPhysicalPersonDocument(this PhysicalPersonDocumentViewModel employeeDocumentViewModel)
        {
            PhysicalPersonDocument PhysicalPersonDocument = new PhysicalPersonDocument()
            {
                Id         = employeeDocumentViewModel.Id,
                Identifier = employeeDocumentViewModel.Identifier,

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

                Name       = employeeDocumentViewModel.Name,
                CreateDate = employeeDocumentViewModel.CreateDate,
                Path       = employeeDocumentViewModel.Path,
                ItemStatus = employeeDocumentViewModel.ItemStatus,

                Active = employeeDocumentViewModel.IsActive,

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

                CreatedAt = employeeDocumentViewModel.CreatedAt,
                UpdatedAt = employeeDocumentViewModel.UpdatedAt
            };

            return(PhysicalPersonDocument);
        }
        public static PhysicalPersonDocumentViewModel ConvertToPhysicalPersonDocumentViewModel(this PhysicalPersonDocument employeeDocument)
        {
            PhysicalPersonDocumentViewModel PhysicalPersonDocumentViewModel = new PhysicalPersonDocumentViewModel()
            {
                Id         = employeeDocument.Id,
                Identifier = employeeDocument.Identifier,

                PhysicalPerson = employeeDocument.PhysicalPerson?.ConvertToPhysicalPersonViewModelLite(),

                Name       = employeeDocument.Name,
                CreateDate = employeeDocument.CreateDate,
                Path       = employeeDocument.Path,
                ItemStatus = employeeDocument.ItemStatus,

                IsActive = employeeDocument.Active,

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

                UpdatedAt = employeeDocument.UpdatedAt,
                CreatedAt = employeeDocument.CreatedAt
            };

            return(PhysicalPersonDocumentViewModel);
        }
예제 #7
0
        private void btnEditNote_Click(object sender, RoutedEventArgs e)
        {
            CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
            CurrentPhysicalPersonDocumentForm.Identifier = CurrentPhysicalPersonDocumentDG.Identifier;
            CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Edited;

            CurrentPhysicalPersonDocumentForm.IsSynced   = CurrentPhysicalPersonDocumentDG.IsSynced;
            CurrentPhysicalPersonDocumentForm.Name       = CurrentPhysicalPersonDocumentDG.Name;
            CurrentPhysicalPersonDocumentForm.Path       = CurrentPhysicalPersonDocumentDG.Path;
            CurrentPhysicalPersonDocumentForm.CreateDate = CurrentPhysicalPersonDocumentDG.CreateDate;
            CurrentPhysicalPersonDocumentForm.UpdatedAt  = CurrentPhysicalPersonDocumentDG.UpdatedAt;
        }
        public PhysicalPersonDocumentListResponse GetFilteredPhysicalPersonDocuments(int companyId, PhysicalPersonDocumentViewModel filterObject)
        {
            PhysicalPersonDocumentListResponse     response = new PhysicalPersonDocumentListResponse();
            List <PhysicalPersonDocumentViewModel> PhysicalPersonDocuments = new List <PhysicalPersonDocumentViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        ", phys.PhysPersonName as PhysPersonName, phys.PhysPersonSurname as PhysPersonSurname " +
                        "FROM PhysicalPersonDocuments " +
                        "LEFT JOIN (SELECT Identifier AS PhysPersonIdentifier, Name AS PhysPersonName, Surname AS PhysPersonSurname FROM PhysicalPersons) phys ON phys.PhysPersonIdentifier = PhysicalPersonDocuments.PhysicalPersonIdentifier " +
                        "WHERE (" +
                        "   ((@PhysicalPersonName IS NULL OR @PhysicalPersonName = '' OR PhysPersonName LIKE @PhysicalPersonName) OR (@PhysicalPersonName IS NULL OR @PhysicalPersonName = '' OR PhysPersonSurName LIKE @PhysicalPersonName)) OR " +
                        "   (@PhysicalPersonName IS NULL OR @PhysicalPersonName = '' OR Name LIKE @PhysicalPersonName) " +
                        ") " +
                        "AND (@DateFrom IS NULL OR @DateFrom = '' OR DATE(CreateDate) >= DATE(@DateFrom)) " +
                        "AND (@DateTo IS NULL OR @DateTo = '' OR DATE(CreateDate) <= DATE(@DateTo)) " +
                        "ORDER BY IsSynced, Id DESC;", db);

                    selectCommand.Parameters.AddWithValue("@PhysicalPersonName", (String.IsNullOrEmpty(filterObject.Search_Name) ? "" : "%" + filterObject.Search_Name + "%"));
                    selectCommand.Parameters.AddWithValue("@DateFrom", ((object)filterObject.Search_DateFrom) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@DateTo", ((object)filterObject.Search_DateTo) ?? DBNull.Value);
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        PhysicalPersonDocumentViewModel dbEntry = Read(query, readForMail: true);
                        PhysicalPersonDocuments.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage          = error.Message;
                    response.Success                 = false;
                    response.Message                 = error.Message;
                    response.PhysicalPersonDocuments = new List <PhysicalPersonDocumentViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonDocuments = PhysicalPersonDocuments;
            return(response);
        }
        public PhysicalPersonDocumentListResponse GetPhysicalPersonDocumentsByPhysicalPerson(int companyId, Guid PhysicalPersonIdentifier)
        {
            PhysicalPersonDocumentListResponse     response = new PhysicalPersonDocumentListResponse();
            List <PhysicalPersonDocumentViewModel> PhysicalPersonDocuments = new List <PhysicalPersonDocumentViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM PhysicalPersonDocuments " +
                        "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())
                    {
                        PhysicalPersonDocumentViewModel dbEntry = Read(query);
                        PhysicalPersonDocuments.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage          = error.Message;
                    response.Success                 = false;
                    response.Message                 = error.Message;
                    response.PhysicalPersonDocuments = new List <PhysicalPersonDocumentViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonDocuments = PhysicalPersonDocuments;
            return(response);
        }
예제 #10
0
        public PhysicalPerson_Document_AddEdit(PhysicalPersonViewModel physicalPerson)
        {
            physicalPersonService     = DependencyResolver.Kernel.Get <IPhysicalPersonService>();
            physicalPersonNoteService = DependencyResolver.Kernel.Get <IPhysicalPersonDocumentService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentPhysicalPerson                        = physicalPerson;
            CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
            CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid();
            CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddNote.Focus();
        }
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, PhysicalPersonDocumentViewModel PhysicalPersonDocument)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", PhysicalPersonDocument.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", PhysicalPersonDocument.Identifier);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonId", ((object)PhysicalPersonDocument.PhysicalPerson.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonIdentifier", ((object)PhysicalPersonDocument.PhysicalPerson.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonCode", ((object)PhysicalPersonDocument.PhysicalPerson.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PhysicalPersonName", ((object)PhysicalPersonDocument.PhysicalPerson.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Name", PhysicalPersonDocument.Name);
            insertCommand.Parameters.AddWithValue("@CreateDate", ((object)PhysicalPersonDocument.CreateDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Path", ((object)PhysicalPersonDocument.Path) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)PhysicalPersonDocument.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", PhysicalPersonDocument.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)PhysicalPersonDocument.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);
        }
        public PhysicalPersonDocumentResponse GetPhysicalPersonDocument(Guid identifier)
        {
            PhysicalPersonDocumentResponse  response = new PhysicalPersonDocumentResponse();
            PhysicalPersonDocumentViewModel PhysicalPersonDocument = new PhysicalPersonDocumentViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        PhysicalPersonDocumentViewModel dbEntry = Read(query);
                        PhysicalPersonDocument = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage         = error.Message;
                    response.Success                = false;
                    response.Message                = error.Message;
                    response.PhysicalPersonDocument = new PhysicalPersonDocumentViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.PhysicalPersonDocument = PhysicalPersonDocument;
            return(response);
        }
        private static PhysicalPersonDocumentViewModel Read(SqliteDataReader query, bool readForMail = false)
        {
            int counter = 0;
            PhysicalPersonDocumentViewModel dbEntry = new PhysicalPersonDocumentViewModel();

            dbEntry.Id             = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier     = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.PhysicalPerson = SQLiteHelper.GetPhysicalPerson(query, ref counter);
            dbEntry.Name           = SQLiteHelper.GetString(query, ref counter);
            dbEntry.CreateDate     = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.Path           = 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);

            if (readForMail)
            {
                dbEntry.PhysicalPerson.Name    = SQLiteHelper.GetString(query, ref counter);
                dbEntry.PhysicalPerson.SurName = SQLiteHelper.GetString(query, ref counter);
            }
            return(dbEntry);
        }
예제 #14
0
 private void btnCancelNote_Click(object sender, RoutedEventArgs e)
 {
     CurrentPhysicalPersonDocumentForm            = new PhysicalPersonDocumentViewModel();
     CurrentPhysicalPersonDocumentForm.Identifier = Guid.NewGuid();
     CurrentPhysicalPersonDocumentForm.ItemStatus = ItemStatus.Added;
 }