Example #1
0
        public InputInvoiceNoteResponse Create(InputInvoiceNoteViewModel InputInvoiceNote)
        {
            InputInvoiceNoteResponse response = new InputInvoiceNoteResponse();

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

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, InputInvoiceNote);
                    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);
            }
        }
Example #2
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            var response = new InputInvoiceNoteSQLiteRepository().SetStatusDeleted(CurrentInputInvoiceNoteDG.Identifier);

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

                CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
                CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
                CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;

                CurrentInputInvoiceNoteDG = null;

                InputInvoiceCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayInputInvoiceNoteData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
Example #3
0
        private void btnEditNote_Click(object sender, RoutedEventArgs e)
        {
            CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
            CurrentInputInvoiceNoteForm.Identifier = CurrentInputInvoiceNoteDG.Identifier;
            CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Edited;

            CurrentInputInvoiceNoteForm.IsSynced  = CurrentInputInvoiceNoteDG.IsSynced;
            CurrentInputInvoiceNoteForm.Note      = CurrentInputInvoiceNoteDG.Note;
            CurrentInputInvoiceNoteForm.NoteDate  = CurrentInputInvoiceNoteDG.NoteDate;
            CurrentInputInvoiceNoteForm.UpdatedAt = CurrentInputInvoiceNoteDG.UpdatedAt;
        }
Example #4
0
        private static InputInvoiceNoteViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            InputInvoiceNoteViewModel dbEntry = new InputInvoiceNoteViewModel();

            dbEntry.Id           = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier   = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.InputInvoice = SQLiteHelper.GetInputInvoice(query, ref counter);
            dbEntry.Note         = SQLiteHelper.GetString(query, ref counter);
            dbEntry.NoteDate     = SQLiteHelper.GetDateTime(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);
        }
Example #5
0
        public static InputInvoiceNoteViewModel ConvertToInputInvoiceNoteViewModelLite(this InputInvoiceNote InputInvoiceNote)
        {
            InputInvoiceNoteViewModel InputInvoiceNoteViewModel = new InputInvoiceNoteViewModel()
            {
                Id         = InputInvoiceNote.Id,
                Identifier = InputInvoiceNote.Identifier,

                Note       = InputInvoiceNote.Note,
                NoteDate   = InputInvoiceNote.NoteDate,
                ItemStatus = InputInvoiceNote.ItemStatus,
                IsActive   = InputInvoiceNote.Active,

                UpdatedAt = InputInvoiceNote.UpdatedAt,
                CreatedAt = InputInvoiceNote.CreatedAt
            };

            return(InputInvoiceNoteViewModel);
        }
Example #6
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, InputInvoiceNoteViewModel InputInvoiceNote)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", InputInvoiceNote.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", InputInvoiceNote.Identifier);
            insertCommand.Parameters.AddWithValue("@InputInvoiceId", ((object)InputInvoiceNote.InputInvoice.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@InputInvoiceIdentifier", ((object)InputInvoiceNote.InputInvoice.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@InputInvoiceCode", ((object)InputInvoiceNote.InputInvoice.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Note", ((object)InputInvoiceNote.Note) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@NoteDate", ((object)InputInvoiceNote.NoteDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)InputInvoiceNote.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", InputInvoiceNote.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)InputInvoiceNote.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);
        }
Example #7
0
        public InputInvoiceNoteListResponse GetInputInvoiceNotesByInputInvoice(int companyId, Guid InputInvoiceIdentifier)
        {
            InputInvoiceNoteListResponse     response          = new InputInvoiceNoteListResponse();
            List <InputInvoiceNoteViewModel> InputInvoiceNotes = new List <InputInvoiceNoteViewModel>();

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

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        InputInvoiceNoteViewModel dbEntry = Read(query);
                        InputInvoiceNotes.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage    = error.Message;
                    response.Success           = false;
                    response.Message           = error.Message;
                    response.InputInvoiceNotes = new List <InputInvoiceNoteViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success           = true;
            response.InputInvoiceNotes = InputInvoiceNotes;
            return(response);
        }
Example #8
0
        public InputInvoice_Note_AddEdit(InputInvoiceViewModel inputInvoice)
        {
            inputInvoiceService     = DependencyResolver.Kernel.Get <IInputInvoiceService>();
            inputInvoiceNoteService = DependencyResolver.Kernel.Get <IInputInvoiceNoteService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentInputInvoice                    = inputInvoice;
            CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
            CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
            CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;

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

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

            btnAddNote.Focus();
        }
Example #9
0
        public InputInvoiceNoteResponse GetInputInvoiceNote(Guid identifier)
        {
            InputInvoiceNoteResponse  response         = new InputInvoiceNoteResponse();
            InputInvoiceNoteViewModel InputInvoiceNote = new InputInvoiceNoteViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        InputInvoiceNoteViewModel dbEntry = Read(query);
                        InputInvoiceNote = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage   = error.Message;
                    response.Success          = false;
                    response.Message          = error.Message;
                    response.InputInvoiceNote = new InputInvoiceNoteViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success          = true;
            response.InputInvoiceNote = InputInvoiceNote;
            return(response);
        }
Example #10
0
        public static InputInvoiceNote ConvertToInputInvoiceNote(this InputInvoiceNoteViewModel InputInvoiceNoteViewModel)
        {
            InputInvoiceNote InputInvoiceNote = new InputInvoiceNote()
            {
                Id         = InputInvoiceNoteViewModel.Id,
                Identifier = InputInvoiceNoteViewModel.Identifier,

                InputInvoiceId = InputInvoiceNoteViewModel.InputInvoice?.Id ?? null,

                Note       = InputInvoiceNoteViewModel.Note,
                NoteDate   = InputInvoiceNoteViewModel.NoteDate,
                ItemStatus = InputInvoiceNoteViewModel.ItemStatus,
                Active     = InputInvoiceNoteViewModel.IsActive,

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

                CreatedAt = InputInvoiceNoteViewModel.CreatedAt,
                UpdatedAt = InputInvoiceNoteViewModel.UpdatedAt
            };

            return(InputInvoiceNote);
        }
Example #11
0
        public static InputInvoiceNoteViewModel ConvertToInputInvoiceNoteViewModel(this InputInvoiceNote InputInvoiceNote)
        {
            InputInvoiceNoteViewModel InputInvoiceNoteViewModel = new InputInvoiceNoteViewModel()
            {
                Id         = InputInvoiceNote.Id,
                Identifier = InputInvoiceNote.Identifier,

                InputInvoice = InputInvoiceNote.InputInvoice?.ConvertToInputInvoiceViewModelLite(),

                Note       = InputInvoiceNote.Note,
                NoteDate   = InputInvoiceNote.NoteDate,
                ItemStatus = InputInvoiceNote.ItemStatus,
                IsActive   = InputInvoiceNote.Active,

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

                UpdatedAt = InputInvoiceNote.UpdatedAt,
                CreatedAt = InputInvoiceNote.CreatedAt
            };

            return(InputInvoiceNoteViewModel);
        }
Example #12
0
 private void btnCancelNote_Click(object sender, RoutedEventArgs e)
 {
     CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
     CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
     CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;
 }
Example #13
0
        private void btnAddNote_Click(object sender, RoutedEventArgs e)
        {
            #region Validation

            if (CurrentInputInvoiceNoteForm.Note == null)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Napomena"));
                return;
            }

            #endregion

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


                CurrentInputInvoiceNoteForm.InputInvoice = CurrentInputInvoice;


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

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

                    CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
                    CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
                    CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;
                    CurrentInputInvoiceNoteForm.IsSynced   = false;
                    return;
                }

                CurrentInputInvoiceNoteForm            = new InputInvoiceNoteViewModel();
                CurrentInputInvoiceNoteForm.Identifier = Guid.NewGuid();
                CurrentInputInvoiceNoteForm.ItemStatus = ItemStatus.Added;
                CurrentInputInvoiceNoteForm.IsSynced   = false;
                InputInvoiceCreatedUpdated();

                DisplayInputInvoiceNoteData();

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

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