示例#1
0
        public BusinessPartnerNoteResponse Create(BusinessPartnerNoteViewModel BusinessPartnerNote)
        {
            BusinessPartnerNoteResponse response = new BusinessPartnerNoteResponse();

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

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

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, BusinessPartnerNote);
                    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 BusinessPartnerNoteSQLiteRepository().SetStatusDeleted(CurrentBusinessPartnerNoteDG.Identifier);

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

                CurrentBusinessPartnerNoteForm            = new BusinessPartnerNoteViewModel();
                CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid();
                CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added;

                CurrentBusinessPartnerNoteDG = null;

                BusinessPartnerCreatedUpdated();

                Thread displayThread = new Thread(() => DisplayBusinessPartnerNoteData());
                displayThread.IsBackground = true;
                displayThread.Start();
            }
            else
            {
                MainWindow.ErrorMessage = response.Message;
            }
        }
示例#3
0
        private void btnEditNote_Click(object sender, RoutedEventArgs e)
        {
            CurrentBusinessPartnerNoteForm            = new BusinessPartnerNoteViewModel();
            CurrentBusinessPartnerNoteForm.Identifier = CurrentBusinessPartnerNoteDG.Identifier;
            CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Edited;

            CurrentBusinessPartnerNoteForm.IsSynced  = CurrentBusinessPartnerNoteDG.IsSynced;
            CurrentBusinessPartnerNoteForm.Note      = CurrentBusinessPartnerNoteDG.Note;
            CurrentBusinessPartnerNoteForm.NoteDate  = CurrentBusinessPartnerNoteDG.NoteDate;
            CurrentBusinessPartnerNoteForm.UpdatedAt = CurrentBusinessPartnerNoteDG.UpdatedAt;
        }
        public static BusinessPartnerNoteViewModel ConvertToBusinessPartnerNoteViewModelLite(this BusinessPartnerNote BusinessPartnerNote)
        {
            BusinessPartnerNoteViewModel BusinessPartnerNoteViewModel = new BusinessPartnerNoteViewModel()
            {
                Id         = BusinessPartnerNote.Id,
                Identifier = BusinessPartnerNote.Identifier,

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

                UpdatedAt = BusinessPartnerNote.UpdatedAt,
                CreatedAt = BusinessPartnerNote.CreatedAt
            };

            return(BusinessPartnerNoteViewModel);
        }
示例#5
0
        private BusinessPartnerNoteViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            BusinessPartnerNoteViewModel dbEntry = new BusinessPartnerNoteViewModel();

            dbEntry.Id              = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier      = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(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);
        }
示例#6
0
        public BusinessPartnerNoteListResponse GetBusinessPartnerNotesByBusinessPartner(int companyId, Guid BusinessPartnerIdentifier)
        {
            BusinessPartnerNoteListResponse     response             = new BusinessPartnerNoteListResponse();
            List <BusinessPartnerNoteViewModel> BusinessPartnerNotes = new List <BusinessPartnerNoteViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM BusinessPartnerNotes " +
                        "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())
                    {
                        BusinessPartnerNoteViewModel dbEntry = Read(query);
                        BusinessPartnerNotes.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage       = error.Message;
                    response.Success              = false;
                    response.Message              = error.Message;
                    response.BusinessPartnerNotes = new List <BusinessPartnerNoteViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.BusinessPartnerNotes = BusinessPartnerNotes;
            return(response);
        }
示例#7
0
        public BusinessPartner_Note_AddEdit(BusinessPartnerViewModel businessPartner)
        {
            businessPartnerService     = DependencyResolver.Kernel.Get <IBusinessPartnerService>();
            businessPartnerNoteService = DependencyResolver.Kernel.Get <IBusinessPartnerNoteService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentBusinessPartner                    = businessPartner;
            CurrentBusinessPartnerNoteForm            = new BusinessPartnerNoteViewModel();
            CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid();
            CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added;

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

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

            txtNote.Focus();
        }
        public static BusinessPartnerNote ConvertToBusinessPartnerNote(this BusinessPartnerNoteViewModel BusinessPartnerNoteViewModel)
        {
            BusinessPartnerNote BusinessPartnerNote = new BusinessPartnerNote()
            {
                Id         = BusinessPartnerNoteViewModel.Id,
                Identifier = BusinessPartnerNoteViewModel.Identifier,

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

                Note        = BusinessPartnerNoteViewModel.Note,
                NoteDate    = BusinessPartnerNoteViewModel.NoteDate,
                ItemStatus  = BusinessPartnerNoteViewModel.ItemStatus,
                Active      = BusinessPartnerNoteViewModel.IsActive,
                CreatedById = BusinessPartnerNoteViewModel.CreatedBy?.Id ?? null,
                CompanyId   = BusinessPartnerNoteViewModel.Company?.Id ?? null,

                CreatedAt = BusinessPartnerNoteViewModel.CreatedAt,
                UpdatedAt = BusinessPartnerNoteViewModel.UpdatedAt
            };

            return(BusinessPartnerNote);
        }
示例#9
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, BusinessPartnerNoteViewModel BusinessPartnerNote)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", BusinessPartnerNote.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", BusinessPartnerNote.Identifier);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)BusinessPartnerNote.BusinessPartner.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)BusinessPartnerNote.BusinessPartner.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)BusinessPartnerNote.BusinessPartner.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)BusinessPartnerNote.BusinessPartner.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)BusinessPartnerNote.BusinessPartner.InternalCode) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)BusinessPartnerNote.BusinessPartner.NameGer) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Note", BusinessPartnerNote.Note);
            insertCommand.Parameters.AddWithValue("@NoteDate", ((object)BusinessPartnerNote.NoteDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)BusinessPartnerNote.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", BusinessPartnerNote.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)BusinessPartnerNote.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);
        }
示例#10
0
        public BusinessPartnerNoteResponse GetBusinessPartnerNote(Guid identifier)
        {
            BusinessPartnerNoteResponse  response            = new BusinessPartnerNoteResponse();
            BusinessPartnerNoteViewModel BusinessPartnerNote = new BusinessPartnerNoteViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        BusinessPartnerNoteViewModel dbEntry = Read(query);

                        BusinessPartnerNote = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage      = error.Message;
                    response.Success             = false;
                    response.Message             = error.Message;
                    response.BusinessPartnerNote = new BusinessPartnerNoteViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success             = true;
            response.BusinessPartnerNote = BusinessPartnerNote;
            return(response);
        }
        public static BusinessPartnerNoteViewModel ConvertToBusinessPartnerNoteViewModel(this BusinessPartnerNote BusinessPartnerNote)
        {
            BusinessPartnerNoteViewModel BusinessPartnerNoteViewModel = new BusinessPartnerNoteViewModel()
            {
                Id         = BusinessPartnerNote.Id,
                Identifier = BusinessPartnerNote.Identifier,

                BusinessPartner = BusinessPartnerNote.BusinessPartner?.ConvertToBusinessPartnerViewModelLite(),

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

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

                UpdatedAt = BusinessPartnerNote.UpdatedAt,
                CreatedAt = BusinessPartnerNote.CreatedAt
            };

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

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

            #endregion

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


                CurrentBusinessPartnerNoteForm.BusinessPartner = CurrentBusinessPartner;


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

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

                    CurrentBusinessPartnerNoteForm            = new BusinessPartnerNoteViewModel();
                    CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid();
                    CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added;
                    CurrentBusinessPartnerNoteForm.IsSynced   = false;
                    return;
                }

                CurrentBusinessPartnerNoteForm            = new BusinessPartnerNoteViewModel();
                CurrentBusinessPartnerNoteForm.Identifier = Guid.NewGuid();
                CurrentBusinessPartnerNoteForm.ItemStatus = ItemStatus.Added;
                CurrentBusinessPartnerNoteForm.IsSynced   = false;
                BusinessPartnerCreatedUpdated();

                DisplayBusinessPartnerNoteData();

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

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