public static BusinessPartner ConvertToBusinessPartner(this BusinessPartnerViewModel businessPartnerViewModel) { BusinessPartner businessPartner = new BusinessPartner() { Id = businessPartnerViewModel.Id, Identifier = businessPartnerViewModel.Identifier, Code = businessPartnerViewModel.Code, Name = businessPartnerViewModel.Name, Director = businessPartnerViewModel.Director, Address = businessPartnerViewModel.Address, InoAddress = businessPartnerViewModel.InoAddress, PIB = businessPartnerViewModel.PIB, MatCode = businessPartnerViewModel.MatCode, Mobile = businessPartnerViewModel.Mobile, Phone = businessPartnerViewModel.Phone, Email = businessPartnerViewModel.Email, ActivityCode = businessPartnerViewModel.ActivityCode, BankAccountNumber = businessPartnerViewModel.BankAccountNumber, OpeningDate = businessPartnerViewModel.OpeningDate, BranchOpeningDate = businessPartnerViewModel.BranchOpeningDate, CreatedById = businessPartnerViewModel.CreatedBy?.Id ?? null, CreatedAt = businessPartnerViewModel.CreatedAt }; return(businessPartner); }
public static BusinessPartnerViewModel ConvertToBusinessPartnerViewModel(this BusinessPartner businessPartner) { BusinessPartnerViewModel businessPartnerViewModel = new BusinessPartnerViewModel() { Id = businessPartner.Id, Identifier = businessPartner.Identifier, Code = businessPartner.Code, InternalCode = businessPartner.InternalCode, Name = businessPartner.Name, PIB = businessPartner.PIB, PIO = businessPartner.PIO, IdentificationNumber = businessPartner.IdentificationNumber, Address = businessPartner.Address, DueDate = businessPartner.DueDate, WebSite = businessPartner.WebSite, ContactPerson = businessPartner.ContactPerson, IsInPDV = businessPartner.IsInPDV, JBKJS = businessPartner.JBKJS, NameGer = businessPartner.NameGer, IsInPDVGer = businessPartner.IsInPDVGer, TaxAdministration = businessPartner.TaxAdministration?.ConvertToTaxAdministrationViewModelLite(), IBAN = businessPartner.IBAN, BetriebsNumber = businessPartner.BetriebsNumber, Customer = businessPartner.Customer, Country = businessPartner.Country?.ConvertToCountryViewModelLite(), CountrySrb = businessPartner.CountrySrb?.ConvertToCountryViewModelLite(), CitySrb = businessPartner.CitySrb?.ConvertToCityViewModelLite(), City = businessPartner.City?.ConvertToCityViewModelLite(), AddressGer = businessPartner.AddressGer, Sector = businessPartner.Sector?.ConvertToSectorViewModelLite(), Agency = businessPartner.Agency?.ConvertToAgencyViewModelLite(), Vat = businessPartner.Vat?.ConvertToVatViewModelLite(), Discount = businessPartner.Discount?.ConvertToDiscountViewModelLite(), TaxNr = businessPartner.TaxNr, CommercialNr = businessPartner.CommercialNr, ContactPersonGer = businessPartner.ContactPersonGer, VatDeductionFrom = businessPartner.VatDeductionFrom, VatDeductionTo = businessPartner.VatDeductionTo, PdvType = businessPartner.PdvType, Path = businessPartner.Path, IsActive = businessPartner.Active, CreatedBy = businessPartner.CreatedBy?.ConvertToUserViewModelLite(), Company = businessPartner.Company?.ConvertToCompanyViewModelLite(), UpdatedAt = businessPartner.UpdatedAt, CreatedAt = businessPartner.CreatedAt, }; return(businessPartnerViewModel); }
public BusinessPartnerResponse Create(BusinessPartnerViewModel businessPartner) { BusinessPartnerResponse response = new BusinessPartnerResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, businessPartner); 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); } }
public static BusinessPartnerViewModel ConvertToBusinessPartnerViewModelLite(this BusinessPartner businessPartner) { BusinessPartnerViewModel businessPartnerViewModel = new BusinessPartnerViewModel() { Id = businessPartner.Id, Identifier = businessPartner.Identifier, Code = businessPartner.Code, Name = businessPartner.Name, Director = businessPartner.Director, Address = businessPartner.Address, InoAddress = businessPartner.InoAddress, PIB = businessPartner.PIB, MatCode = businessPartner.MatCode, Mobile = businessPartner.Mobile, Phone = businessPartner.Phone, Email = businessPartner.Email, ActivityCode = businessPartner.ActivityCode, BankAccountNumber = businessPartner.BankAccountNumber, OpeningDate = businessPartner.OpeningDate, BranchOpeningDate = businessPartner.BranchOpeningDate, UpdatedAt = businessPartner.UpdatedAt, CreatedAt = businessPartner.CreatedAt }; return(businessPartnerViewModel); }
public BusinessPartnerResponse GetBusinessPartner(Guid identifier) { BusinessPartnerResponse response = new BusinessPartnerResponse(); BusinessPartnerViewModel BusinessPartner = new BusinessPartnerViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartners " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { int counter = 0; BusinessPartnerViewModel dbEntry = new BusinessPartnerViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.Code = SQLiteHelper.GetString(query, ref counter); dbEntry.Name = SQLiteHelper.GetString(query, ref counter); dbEntry.Director = SQLiteHelper.GetString(query, ref counter); dbEntry.Address = SQLiteHelper.GetString(query, ref counter); dbEntry.InoAddress = SQLiteHelper.GetString(query, ref counter); dbEntry.PIB = SQLiteHelper.GetString(query, ref counter); dbEntry.MatCode = SQLiteHelper.GetString(query, ref counter); dbEntry.Mobile = SQLiteHelper.GetString(query, ref counter); dbEntry.Phone = SQLiteHelper.GetString(query, ref counter); dbEntry.Email = SQLiteHelper.GetString(query, ref counter); dbEntry.ActivityCode = SQLiteHelper.GetString(query, ref counter); dbEntry.BankAccountNumber = SQLiteHelper.GetString(query, ref counter); dbEntry.OpeningDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.BranchOpeningDate = SQLiteHelper.GetDateTime(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); BusinessPartner = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartner = new BusinessPartnerViewModel(); return(response); } db.Close(); } response.Success = true; response.BusinessPartner = BusinessPartner; return(response); }
public static BusinessPartner ConvertToBusinessPartner(this BusinessPartnerViewModel businessPartnerViewModel) { BusinessPartner businessPartner = new BusinessPartner() { Id = businessPartnerViewModel.Id, Identifier = businessPartnerViewModel.Identifier, Code = businessPartnerViewModel.Code, InternalCode = businessPartnerViewModel.InternalCode, Name = businessPartnerViewModel.Name, PIB = businessPartnerViewModel.PIB, PIO = businessPartnerViewModel.PIO, IdentificationNumber = businessPartnerViewModel.IdentificationNumber, Address = businessPartnerViewModel.Address, DueDate = businessPartnerViewModel.DueDate, WebSite = businessPartnerViewModel.WebSite, ContactPerson = businessPartnerViewModel.ContactPerson, IsInPDV = businessPartnerViewModel.IsInPDV, JBKJS = businessPartnerViewModel.JBKJS, AddressGer = businessPartnerViewModel.AddressGer, NameGer = businessPartnerViewModel.NameGer, IsInPDVGer = businessPartnerViewModel.IsInPDVGer, TaxAdministrationId = businessPartnerViewModel.TaxAdministration?.Id ?? null, IBAN = businessPartnerViewModel.IBAN, BetriebsNumber = businessPartnerViewModel.BetriebsNumber, Customer = businessPartnerViewModel.Customer, CountryId = businessPartnerViewModel.Country?.Id ?? null, CountrySrbId = businessPartnerViewModel.CountrySrb?.Id ?? null, CitySrbId = businessPartnerViewModel.CitySrb?.Id ?? null, CityId = businessPartnerViewModel.City?.Id ?? null, SectorId = businessPartnerViewModel.Sector?.Id ?? null, AgencyId = businessPartnerViewModel.Agency?.Id ?? null, VatId = businessPartnerViewModel.Vat?.Id ?? null, DiscountId = businessPartnerViewModel.Discount?.Id ?? null, TaxNr = businessPartnerViewModel.TaxNr, CommercialNr = businessPartnerViewModel.CommercialNr, ContactPersonGer = businessPartnerViewModel.ContactPersonGer, VatDeductionFrom = businessPartnerViewModel.VatDeductionFrom, VatDeductionTo = businessPartnerViewModel.VatDeductionTo, PdvType = businessPartnerViewModel.PdvType, Path = businessPartnerViewModel.Path, Active = businessPartnerViewModel.IsActive, CreatedById = businessPartnerViewModel.CreatedBy?.Id ?? null, CompanyId = businessPartnerViewModel.Company?.Id ?? null, UpdatedAt = businessPartnerViewModel.UpdatedAt, CreatedAt = businessPartnerViewModel.CreatedAt, }; return(businessPartner); }
private void btnAddBusinessPartner_Click(object sender, RoutedEventArgs e) { BusinessPartnerViewModel businessPartnerViewModel = new BusinessPartnerViewModel(); businessPartnerViewModel.Identifier = Guid.NewGuid(); BusinessPartner_List_AddEdit addEditForm = new BusinessPartner_List_AddEdit(businessPartnerViewModel, false); addEditForm.BusinessPartnerCreatedUpdated += new BusinessPartnerHandler(DisplayData); FlyoutHelper.OpenFlyout(this, ((string)Application.Current.FindResource("Podaci_o_poslovnim_partnerima")), 95, addEditForm); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { BusinessPartnerViewModel businessPartner = new BusinessPartnerViewModel(); businessPartner.Code = new BusinessPartnerSQLiteRepository().GetNewCodeValue(); businessPartner.Identifier = Guid.NewGuid(); BusinessPartnerAddEdit addEditForm = new BusinessPartnerAddEdit(businessPartner, true); addEditForm.BusinessPartnerCreatedUpdated += new BusinessPartnerHandler(PopulateData); FlyoutHelper.OpenFlyout(this, "Podaci o poslovnim partnerima", 95, addEditForm); }
public BusinessPartner_List_AddEdit(BusinessPartnerViewModel businessPartnerViewModel, bool itemsEnabled, bool isPopup = false) { this.businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); this.businessPartnerTypeService = DependencyResolver.Kernel.Get <IBusinessPartnerTypeService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartnerViewModel; ItemsEnabled = itemsEnabled; IsPopup = isPopup; }
/// <summary> /// BusinessPartnerAddEdit constructor /// </summary> /// <param name="businessPartnerViewModel"></param> public BusinessPartnerAddEdit(BusinessPartnerViewModel businessPartnerViewModel, bool isCreateProcess) { // Initialize service businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); // Draw all components InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartnerViewModel; IsCreateProcess = isCreateProcess; }
private BusinessPartnerViewModel Read(SqliteDataReader query) { int counter = 0; BusinessPartnerViewModel dbEntry = new BusinessPartnerViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.Code = SQLiteHelper.GetString(query, ref counter); dbEntry.InternalCode = SQLiteHelper.GetString(query, ref counter); dbEntry.Name = SQLiteHelper.GetString(query, ref counter); dbEntry.PIB = SQLiteHelper.GetString(query, ref counter); dbEntry.PIO = SQLiteHelper.GetString(query, ref counter); dbEntry.IdentificationNumber = SQLiteHelper.GetString(query, ref counter); dbEntry.DueDate = SQLiteHelper.GetInt(query, ref counter); dbEntry.WebSite = SQLiteHelper.GetString(query, ref counter); dbEntry.ContactPerson = SQLiteHelper.GetString(query, ref counter); dbEntry.IsInPDV = SQLiteHelper.GetBoolean(query, ref counter); dbEntry.JBKJS = SQLiteHelper.GetString(query, ref counter); dbEntry.CountrySrb = SQLiteHelper.GetCountry(query, ref counter); dbEntry.CitySrb = SQLiteHelper.GetCity(query, ref counter); dbEntry.Address = SQLiteHelper.GetString(query, ref counter); dbEntry.NameGer = SQLiteHelper.GetString(query, ref counter); dbEntry.IsInPDVGer = SQLiteHelper.GetBoolean(query, ref counter); dbEntry.TaxAdministration = SQLiteHelper.GetTaxAdministration(query, ref counter); dbEntry.IBAN = SQLiteHelper.GetString(query, ref counter); dbEntry.BetriebsNumber = SQLiteHelper.GetString(query, ref counter); dbEntry.Customer = SQLiteHelper.GetString(query, ref counter); dbEntry.TaxNr = SQLiteHelper.GetString(query, ref counter); dbEntry.CommercialNr = SQLiteHelper.GetString(query, ref counter); dbEntry.ContactPersonGer = SQLiteHelper.GetString(query, ref counter); dbEntry.Country = SQLiteHelper.GetCountry(query, ref counter); dbEntry.City = SQLiteHelper.GetCity(query, ref counter); dbEntry.AddressGer = SQLiteHelper.GetString(query, ref counter); dbEntry.Sector = SQLiteHelper.GetSector(query, ref counter); dbEntry.Vat = SQLiteHelper.GetVat(query, ref counter); dbEntry.Discount = SQLiteHelper.GetDiscount(query, ref counter); dbEntry.Agency = SQLiteHelper.GetAgency(query, ref counter); dbEntry.VatDeductionFrom = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.VatDeductionTo = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.PdvType = SQLiteHelper.GetIntNullable(query, ref counter); dbEntry.Path = SQLiteHelper.GetString(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 BusinessPartnerResponse Create(BusinessPartnerViewModel businessPartnerViewModel) { BusinessPartnerResponse response = new BusinessPartnerResponse(); try { response = WpfApiHandler.SendToApi <BusinessPartnerViewModel, BusinessPartnerResponse>(businessPartnerViewModel, "Create"); } catch (Exception ex) { response.BusinessPartner = new BusinessPartnerViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public static BusinessPartnerViewModel ConvertToBusinessPartnerViewModelLite(this BusinessPartner businessPartner) { BusinessPartnerViewModel businessPartnerViewModel = new BusinessPartnerViewModel() { Id = businessPartner.Id, Identifier = businessPartner.Identifier, Code = businessPartner.Code, InternalCode = businessPartner.InternalCode, Name = businessPartner.Name, PIB = businessPartner.PIB, PIO = businessPartner.PIO, IdentificationNumber = businessPartner.IdentificationNumber, Address = businessPartner.Address, DueDate = businessPartner.DueDate, WebSite = businessPartner.WebSite, ContactPerson = businessPartner.ContactPerson, IsInPDV = businessPartner.IsInPDV, JBKJS = businessPartner.JBKJS, AddressGer = businessPartner.AddressGer, NameGer = businessPartner.NameGer, IsInPDVGer = businessPartner.IsInPDVGer, IBAN = businessPartner.IBAN, BetriebsNumber = businessPartner.BetriebsNumber, Customer = businessPartner.Customer, TaxNr = businessPartner.TaxNr, CommercialNr = businessPartner.CommercialNr, ContactPersonGer = businessPartner.ContactPersonGer, VatDeductionFrom = businessPartner.VatDeductionFrom, VatDeductionTo = businessPartner.VatDeductionTo, PdvType = businessPartner.PdvType, Path = businessPartner.Path, IsActive = businessPartner.Active, UpdatedAt = businessPartner.UpdatedAt, CreatedAt = businessPartner.CreatedAt, }; return(businessPartnerViewModel); }
public BusinessPartnerListResponse GetBusinessPartnersForPopup(int companyId, string filterString) { BusinessPartnerListResponse response = new BusinessPartnerListResponse(); List <BusinessPartnerViewModel> businessPartners = new List <BusinessPartnerViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartners " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name OR NameGer LIKE @Name) " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC " + "LIMIT @ItemsPerPage;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)filterString) != null ? "%" + filterString + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", ((object)filterString) != null ? companyId : 0); selectCommand.Parameters.AddWithValue("@ItemsPerPage", 100); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { BusinessPartnerViewModel dbEntry = Read(query); businessPartners.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartners = new List <BusinessPartnerViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartners = businessPartners; return(response); }
public BusinessPartnerResponse Delete(Guid identifier) { BusinessPartnerResponse response = new BusinessPartnerResponse(); try { BusinessPartnerViewModel viewModel = new BusinessPartnerViewModel(); viewModel.Identifier = identifier; response = WpfApiHandler.SendToApi <BusinessPartnerViewModel, BusinessPartnerResponse>(viewModel, "Delete"); } catch (Exception ex) { response.BusinessPartner = new BusinessPartnerViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public BusinessPartnerEmployee_List_AddEdit(BusinessPartnerViewModel businessPartnerViewModel) { employeeByBusinessPartnerService = DependencyResolver.Kernel.Get <IEmployeeByBusinessPartnerService>(); employeeService = DependencyResolver.Kernel.Get <IEmployeeService>(); businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartnerViewModel; Thread displayThread = new Thread(() => { Sync(); }); displayThread.IsBackground = true; displayThread.Start(); }
public void CreateBusinessPartner(String customerCode, String name, String iban) { var customerVM = GetCustomer(customerCode); BusinessPartnerViewModel partner = new BusinessPartnerViewModel(); partner.Title = name; partner.Iban = iban; //partner.IsNew = true; var result = customerVM.UpdatePartner(partner); //wait for the asynchronous method to finish result.AsyncWaitHandle.WaitOne(); //wait for the callback to finish while (customerVM.InProgress) { Thread.Sleep(20); } }
public JsonResult Delete([FromBody] BusinessPartnerViewModel c) { BusinessPartnerResponse response = new BusinessPartnerResponse(); try { response = this.businessPartnerService.Delete(c.Identifier); } 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 })); }
public BusinessPartnerResponse Create(BusinessPartnerViewModel businessPartner) { BusinessPartnerResponse response = new BusinessPartnerResponse(); try { BusinessPartner addedBusinessPartner = unitOfWork.GetBusinessPartnerRepository().Create(businessPartner.ConvertToBusinessPartner()); unitOfWork.Save(); response.BusinessPartner = addedBusinessPartner.ConvertToBusinessPartnerViewModel(); response.Success = true; } catch (Exception ex) { response.BusinessPartner = new BusinessPartnerViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public BusinessPartner_Types_AddEdit(BusinessPartnerViewModel businessPartner) { businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); businessPartnerTypeService = DependencyResolver.Kernel.Get <IBusinessPartnerTypeService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartner; CurrentBusinessPartnerTypeDG = new BusinessPartnerTypeViewModel(); CurrentBusinessPartnerTypeDG.Identifier = Guid.NewGuid(); CurrentBusinessPartnerTypeDG.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => PopulateBusinessPartnerTypeData()); displayThread.IsBackground = true; displayThread.Start(); btnSaveType.Focus(); }
public BusinessPartner_Bank_AddEdit(BusinessPartnerViewModel businessPartner) { businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); businessPartnerBankService = DependencyResolver.Kernel.Get <IBusinessPartnerBankService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartner; CurrentBusinessPartnerBankForm = new BusinessPartnerBankViewModel(); CurrentBusinessPartnerBankForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerBankForm.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => DisplayBusinessPartnerBankData()); displayThread.IsBackground = true; displayThread.Start(); btnAddBank.Focus(); }
public BusinessPartnerResponse Create(BusinessPartnerViewModel businessPartner) { BusinessPartnerResponse response = new BusinessPartnerResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = new SqliteCommand(); insertCommand.Connection = db; //Use parameterized query to prevent SQL injection attacks insertCommand.CommandText = SqlCommandInsertPart; insertCommand.Parameters.AddWithValue("@ServerId", businessPartner.Id); insertCommand.Parameters.AddWithValue("@Identifier", businessPartner.Identifier); insertCommand.Parameters.AddWithValue("@Code", businessPartner.Code); insertCommand.Parameters.AddWithValue("@Name", ((object)businessPartner.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", businessPartner.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", businessPartner.UpdatedAt); insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id); insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName); try { insertCommand.ExecuteReader(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public BusinessPartner_Phone_AddEdit(BusinessPartnerViewModel businessPartner) { businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); businessPartnerPhoneService = DependencyResolver.Kernel.Get <IBusinessPartnerPhoneService>(); InitializeComponent(); this.DataContext = this; CurrentBusinessPartner = businessPartner; CurrentBusinessPartnerPhoneForm = new BusinessPartnerPhoneViewModel(); CurrentBusinessPartnerPhoneForm.Identifier = Guid.NewGuid(); CurrentBusinessPartnerPhoneForm.ItemStatus = ItemStatus.Added; CurrentBusinessPartnerPhoneForm.IsSynced = false; Thread displayThread = new Thread(() => DisplayBusinessPartnerPhoneData()); displayThread.IsBackground = true; displayThread.Start(); txtPhoneContactPersonFirstName.Focus(); }
public BusinessPartnerResponse GetBusinessPartner(Guid identifier) { BusinessPartnerResponse response = new BusinessPartnerResponse(); BusinessPartnerViewModel businessPartner = new BusinessPartnerViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartners " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { BusinessPartnerViewModel dbEntry = Read(query); businessPartner = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartner = new BusinessPartnerViewModel(); return(response); } db.Close(); } response.Success = true; response.BusinessPartner = businessPartner; return(response); }
public async Task <int> SaveBusinessPartner(BusinessPartnerViewModel businessPartnerViewModel) { var businessPartner = Mapper.Map <BusinessPartner>(businessPartnerViewModel); _businessPartnerRepository.UnitOfWork.Begin(); try { var rowsAffected = await _businessPartnerRepository.SaveBusinessPartner(businessPartner); if (rowsAffected > 0 && businessPartner.BusinessPartnerDetails != null) { foreach (var businessPartnerDetail in businessPartner.BusinessPartnerDetails) { if (businessPartnerDetail.BusinessPartnerDetailId == null) { // NEW BusinessPartnerDetail businessPartnerDetail.BusinessPartnerDetailId = await _businessPartnerRepository.CreateBusinessPartnerDetail(businessPartnerDetail.UserId); var newBusinessPartnerDetail = await _businessPartnerRepository.GetBusinessPartnerDetail(businessPartnerDetail.BusinessPartnerDetailId); businessPartnerDetail.VersionTimeStamp = newBusinessPartnerDetail.VersionTimeStamp; } await _businessPartnerRepository.SaveBusinessPartnerDetail(businessPartnerDetail); } } _businessPartnerRepository.UnitOfWork.Commit(); return(rowsAffected); } catch (Exception ex) { _businessPartnerRepository.UnitOfWork.Rollback(); throw ex; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { #region Validation if (String.IsNullOrEmpty(CurrentBusinessPartner.Mobile)) { MainWindow.WarningMessage = "Morate uneti mobilni!"; return; } #endregion Thread th = new Thread(() => { SaveButtonContent = " Čuvanje u toku... "; SaveButtonEnabled = false; CurrentBusinessPartner.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; CurrentBusinessPartner.IsSynced = false; CurrentBusinessPartner.UpdatedAt = DateTime.Now; BusinessPartnerResponse response = new BusinessPartnerSQLiteRepository().Delete(CurrentBusinessPartner.Identifier); response = new BusinessPartnerSQLiteRepository().Create(CurrentBusinessPartner); if (!response.Success) { MainWindow.ErrorMessage = "Greška kod lokalnog čuvanja!"; SaveButtonContent = " Sačuvaj "; SaveButtonEnabled = true; return; } response = businessPartnerService.Create(CurrentBusinessPartner); if (!response.Success) { MainWindow.ErrorMessage = "Podaci su sačuvani u lokalu!. Greška kod čuvanja na serveru!"; SaveButtonContent = " Sačuvaj "; SaveButtonEnabled = true; } if (response.Success) { new BusinessPartnerSQLiteRepository().UpdateSyncStatus(response.BusinessPartner.Identifier, response.BusinessPartner.Id, true); MainWindow.SuccessMessage = "Podaci su uspešno sačuvani!"; SaveButtonContent = " Sačuvaj "; SaveButtonEnabled = true; BusinessPartnerCreatedUpdated(); if (IsCreateProcess) { CurrentBusinessPartner = new BusinessPartnerViewModel(); CurrentBusinessPartner.Identifier = Guid.NewGuid(); CurrentBusinessPartner.Code = new BusinessPartnerSQLiteRepository().GetNewCodeValue(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtName.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { FlyoutHelper.CloseFlyout(this); }) ); } } }); th.IsBackground = true; th.Start(); }
public BusinessPartnerListResponse GetBusinessPartnersByPage(int companyId, BusinessPartnerViewModel businessPartnerSearchObject, int currentPage = 1, int itemsPerPage = 50) { BusinessPartnerListResponse response = new BusinessPartnerListResponse(); List <BusinessPartnerViewModel> businessPartners = new List <BusinessPartnerViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( "SELECT bp.ServerId, bp.Identifier, bp.Code, bp.InternalCode, bp.Name, bp.PIB, bp.PIO, bp.IdentificationNumber, " + "bp.DueDate, bp.WebSite, bp.ContactPerson, bp.IsInPdv, bp.JBKJS, " + "bp.CountrySrbId, bp.CountrySrbIdentifier, bp.CountrySrbCode, bp.CountrySrbName, " + "bp.CitySrbId, bp.CitySrbIdentifier, bp.CitySrbCode, bp.CitySrbName, " + "bp.Address, " + "bp.NameGer, bp.IsInPDVGer, bp.TaxAdministrationId, bp.TaxAdministrationIdentifier, bp.TaxAdministrationCode, bp.TaxAdministrationName, " + "bp.IBAN, bp.BetriebsNumber, bp.Customer, bp.TaxNr, bp.CommercialNr, bp.ContactPersonGer, " + "bp.CountryId, bp.CountryIdentifier, bp.CountryCode, bp.CountryName, " + "bp.CityId, bp.CityIdentifier, bp.CityCode, bp.CityName, " + "bp.AddressGer, " + "bp.SectorId, bp.SectorIdentifier, bp.SectorCode, bp.SectorName, " + "bp.VatId, bp.VatIdentifier, bp.VatCode, bp.VatDescription, bp.VatAmount, " + "bp.DiscountId, bp.DiscountIdentifier, bp.DiscountCode, bp.DiscountName, bp.DiscountAmount, " + "bp.AgencyId, bp.AgencyIdentifier, bp.AgencyCode, bp.AgencyName, bp.VatDeductionFrom, bp.VatDeductionTo, bp.PdvType, bp.Path, " + "bp.IsSynced, bp.UpdatedAt, bp.CreatedById, bp.CreatedByName, bp.CompanyId, bp.CompanyName " + "FROM BusinessPartners bp " + "WHERE (@Name IS NULL OR @Name = '' OR bp.Name LIKE @Name OR bp.NameGer LIKE @Name) " + "AND (@PIB IS NULL OR @PIB = '' OR ((SELECT GROUP_CONCAT(cities.CityName) FROM BusinessPartnerLocations cities Where bp.Identifier = cities.BusinessPartnerIdentifier) LIKE @PIB)) " + "AND (@InternalCode IS NULL OR @InternalCode = '' OR bp.InternalCode LIKE @InternalCode) " + "AND (@AgencyName IS NULL OR @AgencyName = '' OR bp.AgencyName LIKE @AgencyName) " + "AND bp.CompanyId = @CompanyId " + "ORDER BY bp.IsSynced, bp.Id DESC " + "LIMIT @ItemsPerPage OFFSET @Offset;", db); selectCommand.Parameters.AddWithValue("@Name", (((object)businessPartnerSearchObject?.Search_Name) != null && businessPartnerSearchObject?.Search_Name != "") ? "%" + businessPartnerSearchObject?.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@PIB", (((object)businessPartnerSearchObject?.Search_PIB) != null && businessPartnerSearchObject?.Search_PIB != "") ? "%" + businessPartnerSearchObject?.Search_PIB + "%" : ""); selectCommand.Parameters.AddWithValue("@InternalCode", ((object)businessPartnerSearchObject?.Search_Code) != null ? "%" + businessPartnerSearchObject?.Search_Code + "%" : ""); selectCommand.Parameters.AddWithValue("@AgencyName", ((object)businessPartnerSearchObject?.Search_Agency) != null ? "%" + businessPartnerSearchObject?.Search_Agency + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage); selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { BusinessPartnerViewModel dbEntry = Read(query); businessPartners.Add(dbEntry); } selectCommand = new SqliteCommand( "SELECT Count(*) " + "FROM BusinessPartners " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@PIB IS NULL OR @PIB = '' OR PIB LIKE @PIB) " + "AND (@InternalCode IS NULL OR @InternalCode = '' OR InternalCode LIKE @InternalCode) " + "AND (@AgencyName IS NULL OR @AgencyName = '' OR AgencyName LIKE @AgencyName) " + "AND CompanyId = @CompanyId;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)businessPartnerSearchObject?.Search_Name) != null ? "%" + businessPartnerSearchObject?.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@PIB", ((object)businessPartnerSearchObject?.Search_PIB) != null ? "%" + businessPartnerSearchObject?.Search_PIB + "%" : ""); selectCommand.Parameters.AddWithValue("@InternalCode", ((object)businessPartnerSearchObject?.Search_Code) != null ? "%" + businessPartnerSearchObject?.Search_Code + "%" : ""); selectCommand.Parameters.AddWithValue("@AgencyName", ((object)businessPartnerSearchObject?.Search_Agency) != null ? "%" + businessPartnerSearchObject?.Search_Agency + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); query = selectCommand.ExecuteReader(); if (query.Read()) { response.TotalItems = query.GetInt32(0); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartners = new List <BusinessPartnerViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartners = businessPartners; return(response); }
public BusinessPartnerListResponse GetBusinessPartnersOnConstructionSiteByPage(int companyId, Guid constructionSiteIdentifier, BusinessPartnerViewModel BusinessPartnerSearchObject, int currentPage = 1, int itemsPerPage = 50) { BusinessPartnerListResponse response = new BusinessPartnerListResponse(); List <BusinessPartnerViewModel> BusinessPartners = new List <BusinessPartnerViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartners " + "WHERE Identifier IN (SELECT BusinessPartnerIdentifier FROM BusinessPartnerByConstructionSites WHERE ConstructionSiteIdentifier = @ConstructionSiteIdentifier) " + "AND (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@PIB IS NULL OR @PIB = '' OR PIB LIKE @PIB) " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC " + "LIMIT @ItemsPerPage OFFSET @Offset;", db); selectCommand.Parameters.AddWithValue("@ConstructionSiteIdentifier", constructionSiteIdentifier); selectCommand.Parameters.AddWithValue("@Name", ((object)BusinessPartnerSearchObject.Search_Name) != null ? "%" + BusinessPartnerSearchObject.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@PIB", ((object)BusinessPartnerSearchObject.Search_PIB) != null ? "%" + BusinessPartnerSearchObject.Search_PIB + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage); selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { BusinessPartnerViewModel dbEntry = Read(query); BusinessPartners.Add(dbEntry); } response.BusinessPartners = BusinessPartners; selectCommand = new SqliteCommand( "SELECT Count(*) " + "FROM BusinessPartners " + "WHERE Identifier IN (SELECT BusinessPartnerIdentifier FROM BusinessPartnerByConstructionSites WHERE ConstructionSiteIdentifier = @ConstructionSiteIdentifier) " + "AND (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@PIB IS NULL OR @PIB = '' OR PIB LIKE @PIB) " + "AND CompanyId = @CompanyId;", db); selectCommand.Parameters.AddWithValue("@ConstructionSiteIdentifier", constructionSiteIdentifier); selectCommand.Parameters.AddWithValue("@Name", ((object)BusinessPartnerSearchObject.Search_Name) != null ? "%" + BusinessPartnerSearchObject.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@PIB", ((object)BusinessPartnerSearchObject.Search_PIB) != null ? "%" + BusinessPartnerSearchObject.Search_PIB + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); query = selectCommand.ExecuteReader(); if (query.Read()) { response.TotalItems = query.GetInt32(0); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartners = new List <BusinessPartnerViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartners = BusinessPartners; return(response); }
public BusinessPartner_ReportWindow(BusinessPartnerViewModel businessPartnerView) { InitializeComponent(); string path = ""; try { rdlcBusinessPartnerReport.LocalReport.DataSources.Clear(); List <BusinessPartnersReportViewModel> businessPartner = new List <BusinessPartnersReportViewModel>(); List <BusinessPartnerViewModel> BusinessPartnerItems = new BusinessPartnerSQLiteRepository().GetBusinessPartnersByPage(MainWindow.CurrentCompanyId, BusinessPartnerSearchObject, 1, 50).BusinessPartners; int counter = 1; foreach (var BusinessPartnerItem in BusinessPartnerItems) { businessPartner.Add(new BusinessPartnersReportViewModel() { OrderNumbersForBusinessPartners = counter++, InternalCode = BusinessPartnerItem?.InternalCode ?? "", Name = BusinessPartnerItem?.Name ?? "", NameGer = BusinessPartnerItem?.NameGer ?? "", TaxNr = BusinessPartnerItem?.TaxNr ?? "", Valuta = BusinessPartnerItem?.DueDate.ToString("#.00") ?? "", VatDescription = BusinessPartnerItem?.Vat?.Amount.ToString() ?? "", PIO = BusinessPartnerItem?.PIO ?? "", Customer = BusinessPartnerItem?.Customer ?? "", DiscountName = BusinessPartnerItem?.Discount?.Amount.ToString("#.00") ?? "", IsInPDV = BusinessPartnerItem?.IsInPDV.ToString() ?? "" }); } var rpdsModel = new ReportDataSource() { Name = "DataSet1", Value = businessPartner }; rdlcBusinessPartnerReport.LocalReport.DataSources.Add(rpdsModel); //List<ReportParameter> reportParams = new List<ReportParameter>(); //string parameterText = "Dana " + (CurrentInputInvoice?.InvoiceDate.ToString("dd.MM.yyyy") ?? "") + " na stočni depo klanice Bioesen primljeno je:"; //reportParams.Add(new ReportParameter("txtInputInvoiceDate", parameterText)); //var businessPartnerList = new List<InvoiceBusinessPartnerViewModel>(); //businessPartnerList.Add(new InvoiceBusinessPartnerViewModel() { Name = "Pera peric " }); //var businessPartnerModel = new ReportDataSource() { Name = "DataSet2", Value = businessPartnerList }; //rdlcInputNoteReport.LocalReport.DataSources.Add(businessPartnerModel); string exeFolder = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string ContentStart = System.IO.Path.Combine(exeFolder, @"RdlcReports\BusinessPartners\BusinessPartnersReport.rdlc"); rdlcBusinessPartnerReport.LocalReport.ReportPath = ContentStart; // rdlcBusinessPartnerReport.LocalReport.SetParameters(reportParams); rdlcBusinessPartnerReport.SetDisplayMode(DisplayMode.PrintLayout); rdlcBusinessPartnerReport.Refresh(); rdlcBusinessPartnerReport.ZoomMode = ZoomMode.Percent; rdlcBusinessPartnerReport.ZoomPercent = 100; rdlcBusinessPartnerReport.RefreshReport(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public BusinessPartnerListResponse GetBusinessPartnersByPage(BusinessPartnerViewModel businessPartnerSearchObject, int currentPage = 1, int itemsPerPage = 50) { BusinessPartnerListResponse response = new BusinessPartnerListResponse(); List <BusinessPartnerViewModel> BusinessPartners = new List <BusinessPartnerViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartners " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "ORDER BY IsSynced, Id DESC " + "LIMIT @ItemsPerPage OFFSET @Offset;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)businessPartnerSearchObject.SearchBy_BusinessPartnerName) != null ? "%" + businessPartnerSearchObject.SearchBy_BusinessPartnerName + "%" : ""); selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage); selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { int counter = 0; BusinessPartnerViewModel dbEntry = new BusinessPartnerViewModel(); dbEntry.Id = SQLiteHelper.GetInt(query, ref counter); dbEntry.Identifier = SQLiteHelper.GetGuid(query, ref counter); dbEntry.Code = SQLiteHelper.GetString(query, ref counter); dbEntry.Name = SQLiteHelper.GetString(query, ref counter); dbEntry.Director = SQLiteHelper.GetString(query, ref counter); dbEntry.Address = SQLiteHelper.GetString(query, ref counter); dbEntry.InoAddress = SQLiteHelper.GetString(query, ref counter); dbEntry.PIB = SQLiteHelper.GetString(query, ref counter); dbEntry.MatCode = SQLiteHelper.GetString(query, ref counter); dbEntry.Mobile = SQLiteHelper.GetString(query, ref counter); dbEntry.Phone = SQLiteHelper.GetString(query, ref counter); dbEntry.Email = SQLiteHelper.GetString(query, ref counter); dbEntry.ActivityCode = SQLiteHelper.GetString(query, ref counter); dbEntry.BankAccountNumber = SQLiteHelper.GetString(query, ref counter); dbEntry.OpeningDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.BranchOpeningDate = SQLiteHelper.GetDateTime(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); BusinessPartners.Add(dbEntry); } selectCommand = new SqliteCommand( "SELECT Count(*) " + "FROM BusinessPartners " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)businessPartnerSearchObject.SearchBy_BusinessPartnerName) != null ? "%" + businessPartnerSearchObject.SearchBy_BusinessPartnerName + "%" : ""); query = selectCommand.ExecuteReader(); if (query.Read()) { response.TotalItems = query.GetInt32(0); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartners = new List <BusinessPartnerViewModel>(); return(response); } db.Close(); } response.Success = true; response.BusinessPartners = BusinessPartners; return(response); }