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(); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new BusinessPartnerDocumentSQLiteRepository().SetStatusDeleted(CurrentBusinessPartnerDocumentDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentDG = null; BusinessPartnerCreatedUpdated(); Thread displayThread = new Thread(() => DisplayBusinessPartnerDocumentData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public BusinessPartnerDocumentResponse Create(BusinessPartnerDocumentViewModel BusinessPartnerDocument) { BusinessPartnerDocumentResponse response = new BusinessPartnerDocumentResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, BusinessPartnerDocument); 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 btnEditDocument_Click(object sender, RoutedEventArgs e) { CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = CurrentBusinessPartnerDocumentDG.Identifier; CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Edited; CurrentBusinessPartnerDocumentForm.IsSynced = CurrentBusinessPartnerDocumentDG.IsSynced; CurrentBusinessPartnerDocumentForm.Name = CurrentBusinessPartnerDocumentDG.Name; CurrentBusinessPartnerDocumentForm.CreateDate = CurrentBusinessPartnerDocumentDG.CreateDate; CurrentBusinessPartnerDocumentForm.Path = CurrentBusinessPartnerDocumentDG.Path; CurrentBusinessPartnerDocumentForm.UpdatedAt = CurrentBusinessPartnerDocumentDG.UpdatedAt; }
public BusinessPartnerDocumentListResponse GetFilteredBusinessPartnerDocuments(int companyId, BusinessPartnerDocumentViewModel filterObject) { BusinessPartnerDocumentListResponse response = new BusinessPartnerDocumentListResponse(); List <BusinessPartnerDocumentViewModel> BusinessPartnerDocuments = new List <BusinessPartnerDocumentViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartnerDocuments " + "WHERE (" + " (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR BusinessPartnerName LIKE @BusinessPartnerName) OR " + " (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR Name LIKE @BusinessPartnerName) " + ") " + "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("@BusinessPartnerName", (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()) { BusinessPartnerDocumentViewModel dbEntry = Read(query); BusinessPartnerDocuments.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartnerDocuments = new List <BusinessPartnerDocumentViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartnerDocuments = BusinessPartnerDocuments; return(response); }
public static BusinessPartnerDocumentViewModel ConvertToBusinessPartnerDocumentViewModelLite(this BusinessPartnerDocument businessPartnerDocument) { BusinessPartnerDocumentViewModel BusinessPartnerDocumentViewModel = new BusinessPartnerDocumentViewModel() { Id = businessPartnerDocument.Id, Identifier = businessPartnerDocument.Identifier, Name = businessPartnerDocument.Name, CreateDate = businessPartnerDocument.CreateDate, Path = businessPartnerDocument.Path, ItemStatus = businessPartnerDocument.ItemStatus, IsActive = businessPartnerDocument.Active, UpdatedAt = businessPartnerDocument.UpdatedAt, CreatedAt = businessPartnerDocument.CreatedAt }; return(BusinessPartnerDocumentViewModel); }
private BusinessPartnerDocumentViewModel Read(SqliteDataReader query) { int counter = 0; BusinessPartnerDocumentViewModel dbEntry = new BusinessPartnerDocumentViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(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); return(dbEntry); }
public BusinessPartnerDocumentListResponse GetBusinessPartnerDocumentsByBusinessPartner(int companyId, Guid BusinessPartnerIdentifier) { BusinessPartnerDocumentListResponse response = new BusinessPartnerDocumentListResponse(); List <BusinessPartnerDocumentViewModel> BusinessPartnerDocuments = new List <BusinessPartnerDocumentViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartnerDocuments " + "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()) { BusinessPartnerDocumentViewModel dbEntry = Read(query); BusinessPartnerDocuments.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartnerDocuments = new List <BusinessPartnerDocumentViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartnerDocuments = BusinessPartnerDocuments; return(response); }
public BusinessPartner_Document_AddEdit(BusinessPartnerViewModel businessPartner) { businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); businessPartnerDocumentService = DependencyResolver.Kernel.Get <IBusinessPartnerDocumentService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartner; CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => DisplayBusinessPartnerDocumentData()); displayThread.IsBackground = true; displayThread.Start(); txtBusinessPartnerDocumentName.Focus(); }
public BusinessPartnerDocumentResponse GetBusinessPartnerDocument(Guid identifier) { BusinessPartnerDocumentResponse response = new BusinessPartnerDocumentResponse(); BusinessPartnerDocumentViewModel BusinessPartnerDocument = new BusinessPartnerDocumentViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartnerDocuments " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { BusinessPartnerDocumentViewModel dbEntry = Read(query); BusinessPartnerDocument = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartnerDocument = new BusinessPartnerDocumentViewModel(); return(response); } db.Close(); } response.Success = true; response.BusinessPartnerDocument = BusinessPartnerDocument; return(response); }
private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, BusinessPartnerDocumentViewModel BusinessPartnerDocument) { insertCommand.Parameters.AddWithValue("@ServerId", BusinessPartnerDocument.Id); insertCommand.Parameters.AddWithValue("@Identifier", BusinessPartnerDocument.Identifier); insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)BusinessPartnerDocument.BusinessPartner.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)BusinessPartnerDocument.BusinessPartner.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)BusinessPartnerDocument.BusinessPartner.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)BusinessPartnerDocument.BusinessPartner.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)BusinessPartnerDocument.BusinessPartner.InternalCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)BusinessPartnerDocument.BusinessPartner.NameGer) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Name", BusinessPartnerDocument.Name); insertCommand.Parameters.AddWithValue("@CreateDate", ((object)BusinessPartnerDocument.CreateDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Path", ((object)BusinessPartnerDocument.Path) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)BusinessPartnerDocument.ItemStatus) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", BusinessPartnerDocument.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)BusinessPartnerDocument.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 static BusinessPartnerDocument ConvertToBusinessPartnerDocument(this BusinessPartnerDocumentViewModel businessPartnerDocumentViewModel) { BusinessPartnerDocument BusinessPartnerDocument = new BusinessPartnerDocument() { Id = businessPartnerDocumentViewModel.Id, Identifier = businessPartnerDocumentViewModel.Identifier, BusinessPartnerId = businessPartnerDocumentViewModel.BusinessPartner?.Id ?? null, Name = businessPartnerDocumentViewModel.Name, CreateDate = businessPartnerDocumentViewModel.CreateDate, Path = businessPartnerDocumentViewModel.Path, ItemStatus = businessPartnerDocumentViewModel.ItemStatus, Active = businessPartnerDocumentViewModel.IsActive, CreatedById = businessPartnerDocumentViewModel.CreatedBy?.Id ?? null, CompanyId = businessPartnerDocumentViewModel.Company?.Id ?? null, CreatedAt = businessPartnerDocumentViewModel.CreatedAt, UpdatedAt = businessPartnerDocumentViewModel.UpdatedAt }; return(BusinessPartnerDocument); }
private void btnCancelDocument_Click(object sender, RoutedEventArgs e) { CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; }
private void btnAddDocument_Click(object sender, RoutedEventArgs e) { #region Validation if (CurrentBusinessPartnerDocumentForm.Name == null) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv")); return; } #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentBusinessPartnerDocumentForm.BusinessPartner = CurrentBusinessPartner; CurrentBusinessPartnerDocumentForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentBusinessPartnerDocumentForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; new BusinessPartnerDocumentSQLiteRepository().Delete(CurrentBusinessPartnerDocumentForm.Identifier); var response = new BusinessPartnerDocumentSQLiteRepository().Create(CurrentBusinessPartnerDocumentForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentForm.IsSynced = false; return; } CurrentBusinessPartnerDocumentForm = new BusinessPartnerDocumentViewModel(); CurrentBusinessPartnerDocumentForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerDocumentForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerDocumentForm.IsSynced = false; BusinessPartnerCreatedUpdated(); DisplayBusinessPartnerDocumentData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtBusinessPartnerDocumentName.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }