public ConstructionSiteResponse Create(ConstructionSiteViewModel constructionSite) { ConstructionSiteResponse response = new ConstructionSiteResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, constructionSite); 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 static ConstructionSiteViewModel Read(SqliteDataReader query) { int counter = 0; ConstructionSiteViewModel dbEntry = new ConstructionSiteViewModel(); 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.Address = SQLiteHelper.GetString(query, ref counter); dbEntry.NamePartner = SQLiteHelper.GetString(query, ref counter); dbEntry.AddressPartner = SQLiteHelper.GetString(query, ref counter); dbEntry.CityPartner = SQLiteHelper.GetCity(query, ref counter); dbEntry.MaxWorkers = SQLiteHelper.GetInt(query, ref counter); dbEntry.ProContractDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.ContractStart = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.ContractExpiration = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.City = SQLiteHelper.GetCity(query, ref counter); dbEntry.Country = SQLiteHelper.GetCountry(query, ref counter); dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(query, ref counter); dbEntry.Status = SQLiteHelper.GetStatus(query, ref counter); dbEntry.StatusDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.PaymentDate = SQLiteHelper.GetDateTime(query, ref counter); dbEntry.Path = SQLiteHelper.GetString(query, ref counter); dbEntry.PaymentValue = SQLiteHelper.GetDecimal(query, ref counter); dbEntry.Shipment = SQLiteHelper.GetFullShipment(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 static ConstructionSiteViewModel ConvertToConstructionSiteViewModelLite(this ConstructionSite constructionSite) { ConstructionSiteViewModel constructionSiteViewModel = new ConstructionSiteViewModel() { Id = constructionSite.Id, Identifier = constructionSite.Identifier, Code = constructionSite.Code, InternalCode = constructionSite.InternalCode, Name = constructionSite.Name, NamePartner = constructionSite.NamePartner, AddressPartner = constructionSite.AddressPartner, Address = constructionSite.Address, MaxWorkers = constructionSite.MaxWorkers, PaymentDate = constructionSite.PaymentDate, Path = constructionSite.Path, PaymentValue = constructionSite.PaymentValue, ProContractDate = constructionSite.ProContractDate, ContractStart = constructionSite.ContractStart, ContractExpiration = constructionSite.ContractExpiration, StatusDate = constructionSite.StatusDate, IsActive = constructionSite.Active, CreatedAt = constructionSite.CreatedAt, UpdatedAt = constructionSite.UpdatedAt }; return(constructionSiteViewModel); }
public ConstructionSite_ReportWindow(ConstructionSiteViewModel constructionSiteView) { InitializeComponent(); rdlcConstructionSiteReport.LocalReport.DataSources.Clear(); List <ConstructionSitesReportViewModel> constructionSites = new List <ConstructionSitesReportViewModel>(); List <ConstructionSiteViewModel> ConstructionSiteItems = new ConstructionSiteSQLiteRepository().GetConstructionSitesByPage(MainWindow.CurrentCompanyId, ConstructionSiteSearchObject, 1, 50).ConstructionSites; int counter = 1; foreach (var ConstructionSiteItem in ConstructionSiteItems) { constructionSites.Add(new ConstructionSitesReportViewModel() { OrderNumbersForConstructionSites = counter++, ConstructionSiteCode = ConstructionSiteItem?.Code ?? "", InternalCode = ConstructionSiteItem?.InternalCode ?? "", Name = ConstructionSiteItem?.Name ?? "", CityName = ConstructionSiteItem?.City?.Name ?? "", CountryName = ConstructionSiteItem?.Country?.Name ?? "", BusinessPartnerName = ConstructionSiteItem?.BusinessPartner?.Name ?? "", StatusName = ConstructionSiteItem?.Status?.Name ?? "", Address = ConstructionSiteItem?.Address ?? "", MaxWorkers = ConstructionSiteItem?.MaxWorkers.ToString() ?? "", ProContractDate = ConstructionSiteItem?.ProContractDate.ToString("dd.MM.yyyy") ?? "", ContractStart = ConstructionSiteItem?.ContractStart.ToString("dd.MM.yyyy") ?? "", ContractExpiration = ConstructionSiteItem?.ContractExpiration.ToString("dd.MM.yyyy") ?? "", }); } var rpdsModel = new ReportDataSource() { Name = "DataSet1", Value = constructionSites }; rdlcConstructionSiteReport.LocalReport.DataSources.Add(rpdsModel); //List<ReportParameter> reportParams = new List<ReportParameter>(); //string parameterText = "Dana " + (CurrentConstructionSite?.InvoiceDate.ToString("dd.MM.yyyy") ?? "") + " na stočni depo klanice Bioesen primljeno je:"; //reportParams.Add(new ReportParameter("txtConstructionSiteDate", parameterText)); //var businessPartnerList = new List<InvoiceBusinessPartnerViewModel>(); //businessPartnerList.Add(new InvoiceBusinessPartnerViewModel() { Name = "Pera peric " }); //var businessPartnerModel = new ReportDataSource() { Name = "DataSet2", Value = businessPartnerList }; //rdlcOutputNoteReport.LocalReport.DataSources.Add(businessPartnerModel); string exeFolder = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string ContentStart = System.IO.Path.Combine(exeFolder, @"RdlcReports\ConstructionSites\ConstructionSitesReport.rdlc"); rdlcConstructionSiteReport.LocalReport.ReportPath = ContentStart; // rdlcConstructionSiteReport.LocalReport.SetParameters(reportParams); rdlcConstructionSiteReport.SetDisplayMode(DisplayMode.PrintLayout); rdlcConstructionSiteReport.Refresh(); rdlcConstructionSiteReport.ZoomMode = ZoomMode.Percent; rdlcConstructionSiteReport.ZoomPercent = 100; rdlcConstructionSiteReport.RefreshReport(); }
private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, ConstructionSiteViewModel constructionSite) { insertCommand.Parameters.AddWithValue("@ServerId", constructionSite.Id); insertCommand.Parameters.AddWithValue("@Identifier", constructionSite.Identifier); insertCommand.Parameters.AddWithValue("@Code", ((object)constructionSite.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@InternalCode", ((object)constructionSite.InternalCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Name", ((object)constructionSite.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Address", ((object)constructionSite.Address) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@NamePartner", ((object)constructionSite.NamePartner) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@AddressPartner", ((object)constructionSite.AddressPartner) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityPartnerId", ((object)constructionSite.CityPartner?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityPartnerIdentifier", ((object)constructionSite.CityPartner?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityPartnerCode", ((object)constructionSite.CityPartner?.ZipCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityPartnerName", ((object)constructionSite.CityPartner?.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@MaxWorkers", ((object)constructionSite.MaxWorkers) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ProContractDate", ((object)constructionSite.ProContractDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ContractStart", ((object)constructionSite.ContractStart) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ContractExpiration", ((object)constructionSite.ContractExpiration) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityId", ((object)constructionSite.City?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityIdentifier", ((object)constructionSite.City?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityCode", ((object)constructionSite.City?.ZipCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CityName", ((object)constructionSite.City?.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CountryId", ((object)constructionSite.Country?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CountryIdentifier", ((object)constructionSite.Country?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CountryCode", ((object)constructionSite.Country?.Mark) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@CountryName", ((object)constructionSite.Country?.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)constructionSite.BusinessPartner?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)constructionSite.BusinessPartner?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)constructionSite.BusinessPartner?.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)constructionSite.BusinessPartner?.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)constructionSite.BusinessPartner?.InternalCode) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)constructionSite.BusinessPartner?.NameGer) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@StatusId", ((object)constructionSite.Status?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@StatusIdentifier", ((object)constructionSite.Status?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@StatusCode", ((object)constructionSite.Status?.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@StatusName", ((object)constructionSite.Status?.Name) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@StatusDate", ((object)constructionSite.StatusDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PaymentDate", ((object)constructionSite.PaymentDate) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@Path", ((object)constructionSite.Path) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@PaymentValue", ((object)constructionSite.PaymentValue) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentId", ((object)constructionSite.Shipment?.Id) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentIdentifier", ((object)constructionSite.Shipment?.Identifier) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentCode", ((object)constructionSite.Shipment?.Code) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@ShipmentNumber", ((object)constructionSite.Shipment?.ShipmentNumber) ?? DBNull.Value); insertCommand.Parameters.AddWithValue("@IsSynced", constructionSite.IsSynced); insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)constructionSite.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); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { ConstructionSiteViewModel constructionSite = new ConstructionSiteViewModel(); constructionSite.Identifier = Guid.NewGuid(); constructionSite.ContractStart = DateTime.Now; constructionSite.ProContractDate = DateTime.Now; ConstructionSite_List_AddEdit addEditForm = new ConstructionSite_List_AddEdit(constructionSite, true); addEditForm.ConstructionSiteCreatedUpdated += new ConstructionSiteHandler(SyncData); FlyoutHelper.OpenFlyout(this, ((string)Application.Current.FindResource("Podaci_o_gradilistima")), 95, addEditForm); }
public ConstructionSiteListResponse GetConstructionSitesForPopup(int companyId, string filterString) { ConstructionSiteListResponse response = new ConstructionSiteListResponse(); List <ConstructionSiteViewModel> ConstructionSites = new List <ConstructionSiteViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM ConstructionSites " + "WHERE (@Code IS NULL OR @Code = '' OR InternalCode LIKE @Code) " + "AND (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@ShortName IS NULL OR @ShortName = '' OR ShortName LIKE @ShortName) " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC " + "LIMIT @ItemsPerPage;", db); selectCommand.Parameters.AddWithValue("@Code", ((object)filterString) != null ? "%" + filterString + "%" : ""); selectCommand.Parameters.AddWithValue("@Name", ((object)filterString) != null ? "%" + filterString + "%" : ""); selectCommand.Parameters.AddWithValue("@ShortName", ((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()) { ConstructionSiteViewModel dbEntry = Read(query); ConstructionSites.Add(dbEntry); } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.ConstructionSites = new List <ConstructionSiteViewModel>(); return(response); } db.Close(); } response.Success = true; response.ConstructionSites = ConstructionSites; return(response); }
public ConstructionSite_List_AddEdit(ConstructionSiteViewModel constructionSiteViewModel, bool isCreateProcess, bool isPopup = false) { constructionSiteService = DependencyResolver.Kernel.Get <IConstructionSiteService>(); // Initialize form components InitializeComponent(); this.DataContext = this; IsHeaderCreated = !isCreateProcess; CurrentConstructionSite = constructionSiteViewModel; IsCreateProcess = isCreateProcess; IsPopup = isPopup; }
public ConstructionSiteResponse Create(ConstructionSiteViewModel constructionSite) { ConstructionSiteResponse response = new ConstructionSiteResponse(); try { response = WpfApiHandler.SendToApi <ConstructionSiteViewModel, ConstructionSiteResponse>(constructionSite, "Create"); } catch (Exception ex) { response.ConstructionSite = new ConstructionSiteViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public static ConstructionSiteViewModel ConvertToConstructionSiteViewModel(this ConstructionSite constructionSite) { ConstructionSiteViewModel constructionSiteViewModel = new ConstructionSiteViewModel() { Id = constructionSite.Id, Identifier = constructionSite.Identifier, Code = constructionSite.Code, InternalCode = constructionSite.InternalCode, Name = constructionSite.Name, NamePartner = constructionSite.NamePartner, AddressPartner = constructionSite.AddressPartner, Address = constructionSite.Address, MaxWorkers = constructionSite.MaxWorkers, ProContractDate = constructionSite.ProContractDate, ContractStart = constructionSite.ContractStart, ContractExpiration = constructionSite.ContractExpiration, PaymentDate = constructionSite.PaymentDate, Path = constructionSite.Path, PaymentValue = constructionSite.PaymentValue, CityPartner = constructionSite.CityPartner?.ConvertToCityViewModelLite(), City = constructionSite.City?.ConvertToCityViewModelLite(), Country = constructionSite.Country?.ConvertToCountryViewModelLite(), BusinessPartner = constructionSite.BusinessPartner?.ConvertToBusinessPartnerViewModelLite(), Status = constructionSite.Status?.ConvertToStatusViewModelLite(), Shipment = constructionSite.Shipment?.ConvertToShipmentViewModelLite(), StatusDate = constructionSite.StatusDate, IsActive = constructionSite.Active, CreatedBy = constructionSite.CreatedBy?.ConvertToUserViewModelLite(), Company = constructionSite.Company?.ConvertToCompanyViewModelLite(), UpdatedAt = constructionSite.UpdatedAt, CreatedAt = constructionSite.CreatedAt }; return(constructionSiteViewModel); }
public static ConstructionSiteViewModel GetConstructionSiteWithInternalCode(SqliteDataReader query, ref int counter) { if (query.IsDBNull(counter)) { counter += 5; return(null); } else { var viewModel = new ConstructionSiteViewModel(); viewModel.Id = query.GetInt32(counter++); viewModel.Identifier = query.GetGuid(counter++); viewModel.Code = query.IsDBNull(counter++) ? "" : query.GetString(counter - 1); viewModel.Name = query.IsDBNull(counter++) ? "" : query.GetString(counter - 1); viewModel.InternalCode = query.IsDBNull(counter++) ? "" : query.GetString(counter - 1); return(viewModel); } }
public ConstructionSiteResponse Delete(Guid identifier) { ConstructionSiteResponse response = new ConstructionSiteResponse(); try { ConstructionSiteViewModel re = new ConstructionSiteViewModel(); re.Identifier = identifier; response = WpfApiHandler.SendToApi <ConstructionSiteViewModel, ConstructionSiteResponse>(re, "Delete"); } catch (Exception ex) { response.ConstructionSite = new ConstructionSiteViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public JsonResult Delete([FromBody] ConstructionSiteViewModel constructionSite) { ConstructionSiteResponse response = new ConstructionSiteResponse(); try { response = this.constructionSiteService.Delete(constructionSite.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 ConstructionSiteBusinessPartner_List_AddEdit(ConstructionSiteViewModel constructionSiteViewModel) { businessPartnerByConstructionSiteService = DependencyResolver.Kernel.Get <IBusinessPartnerByConstructionSiteService>(); businessPartnerService = DependencyResolver.Kernel.Get <IBusinessPartnerService>(); constructionSiteService = DependencyResolver.Kernel.Get <IConstructionSiteService>(); employeeByConstructionSiteService = DependencyResolver.Kernel.Get <IEmployeeByConstructionSiteService>(); InitializeComponent(); this.DataContext = this; CurrentConstructionSite = constructionSiteViewModel; Thread displayThread = new Thread(() => { Sync(); }); displayThread.IsBackground = true; displayThread.Start(); }
public ConstructionSite_Calculation_AddEdit(ConstructionSiteViewModel constructionSite) { constructionSiteService = DependencyResolver.Kernel.Get <IConstructionSiteService>(); constructionSiteCalculationService = DependencyResolver.Kernel.Get <IConstructionSiteCalculationService>(); InitializeComponent(); this.DataContext = this; CurrentConstructionSite = constructionSite; CurrentConstructionSiteCalculationForm = new ConstructionSiteCalculationViewModel(); CurrentConstructionSiteCalculationForm.Identifier = Guid.NewGuid(); CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Added; Thread displayThread = new Thread(() => DisplayConstructionSiteCalculationData()); displayThread.IsBackground = true; displayThread.Start(); btnAddCalculation.Focus(); }
public static ConstructionSite ConvertToConstructionSite(this ConstructionSiteViewModel constructionSiteViewModel) { ConstructionSite constructionSite = new ConstructionSite() { Id = constructionSiteViewModel.Id, Identifier = constructionSiteViewModel.Identifier, Code = constructionSiteViewModel.Code, InternalCode = constructionSiteViewModel.InternalCode, Address = constructionSiteViewModel.Address, Name = constructionSiteViewModel.Name, NamePartner = constructionSiteViewModel.NamePartner, AddressPartner = constructionSiteViewModel.AddressPartner, MaxWorkers = constructionSiteViewModel.MaxWorkers, ProContractDate = constructionSiteViewModel.ProContractDate, ContractStart = constructionSiteViewModel.ContractStart, ContractExpiration = constructionSiteViewModel.ContractExpiration, PaymentDate = constructionSiteViewModel.PaymentDate, Path = constructionSiteViewModel.Path, PaymentValue = constructionSiteViewModel.PaymentValue, CityPartnerId = constructionSiteViewModel.CityPartner?.Id ?? null, CityId = constructionSiteViewModel.City?.Id ?? null, CountryId = constructionSiteViewModel.Country?.Id ?? null, BusinessPartnerId = constructionSiteViewModel.BusinessPartner?.Id ?? null, StatusId = constructionSiteViewModel.Status?.Id ?? null, ShipmentId = constructionSiteViewModel.Shipment?.Id ?? null, StatusDate = constructionSiteViewModel.StatusDate, CreatedById = constructionSiteViewModel.CreatedBy?.Id ?? null, CompanyId = constructionSiteViewModel.Company?.Id ?? null, CreatedAt = constructionSiteViewModel.CreatedAt, UpdatedAt = constructionSiteViewModel.UpdatedAt }; return(constructionSite); }
public ConstructionSiteResponse GetConstructionSite(Guid identifier) { ConstructionSiteResponse response = new ConstructionSiteResponse(); ConstructionSiteViewModel constructionSite = new ConstructionSiteViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM ConstructionSites " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { ConstructionSiteViewModel dbEntry = Read(query); constructionSite = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.ConstructionSite = new ConstructionSiteViewModel(); return(response); } db.Close(); } response.Success = true; response.ConstructionSite = constructionSite; return(response); }
public ConstructionSiteResponse Create(ConstructionSiteViewModel constructionSite) { ConstructionSiteResponse response = new ConstructionSiteResponse(); try { // Backup items List <ConstructionSiteDocumentViewModel> constructionSiteDocuments = constructionSite.ConstructionSiteDocuments?.ToList() ?? new List <ConstructionSiteDocumentViewModel>(); constructionSite.ConstructionSiteDocuments = null; List <ConstructionSiteNoteViewModel> constructionSiteNotes = constructionSite.ConstructionSiteNotes?.ToList() ?? new List <ConstructionSiteNoteViewModel>(); constructionSite.ConstructionSiteNotes = null; List <ConstructionSiteCalculationViewModel> constructionSiteCalculations = constructionSite.ConstructionSiteCalculations?.ToList() ?? new List <ConstructionSiteCalculationViewModel>(); constructionSite.ConstructionSiteCalculations = null; ConstructionSite createdConstructionSite = unitOfWork.GetConstructionSiteRepository() .Create(constructionSite.ConvertToConstructionSite()); // Update notes if (constructionSiteNotes != null && constructionSiteNotes.Count > 0) { foreach (ConstructionSiteNoteViewModel item in constructionSiteNotes .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <ConstructionSiteNoteViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; item.ItemStatus = ItemStatus.Submited; var createdItem = unitOfWork.GetConstructionSiteNoteRepository().Create(item.ConvertToConstructionSiteNote()); } foreach (ConstructionSiteNoteViewModel item in constructionSiteNotes .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <ConstructionSiteNoteViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; unitOfWork.GetConstructionSiteNoteRepository().Create(item.ConvertToConstructionSiteNote()); unitOfWork.GetConstructionSiteNoteRepository().Delete(item.Identifier); } } // Update documents if (constructionSiteDocuments != null && constructionSiteDocuments.Count > 0) { foreach (ConstructionSiteDocumentViewModel item in constructionSiteDocuments .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <ConstructionSiteDocumentViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; item.ItemStatus = ItemStatus.Submited; var createdItem = unitOfWork.GetConstructionSiteDocumentRepository().Create(item.ConvertToConstructionSiteDocument()); } foreach (ConstructionSiteDocumentViewModel item in constructionSiteDocuments .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <ConstructionSiteDocumentViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; unitOfWork.GetConstructionSiteDocumentRepository().Create(item.ConvertToConstructionSiteDocument()); unitOfWork.GetConstructionSiteDocumentRepository().Delete(item.Identifier); } } // Update calculations if (constructionSiteCalculations != null && constructionSiteCalculations.Count > 0) { foreach (ConstructionSiteCalculationViewModel item in constructionSiteCalculations .Where(x => x.ItemStatus == ItemStatus.Added || x.ItemStatus == ItemStatus.Edited)?.ToList() ?? new List <ConstructionSiteCalculationViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; item.ItemStatus = ItemStatus.Submited; var createdItem = unitOfWork.GetConstructionSiteCalculationRepository().Create(item.ConvertToConstructionSiteCalculation()); } foreach (ConstructionSiteCalculationViewModel item in constructionSiteCalculations .Where(x => x.ItemStatus == ItemStatus.Deleted)?.ToList() ?? new List <ConstructionSiteCalculationViewModel>()) { item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; unitOfWork.GetConstructionSiteCalculationRepository().Create(item.ConvertToConstructionSiteCalculation()); unitOfWork.GetConstructionSiteCalculationRepository().Delete(item.Identifier); } } //// Update items //var ConstructionSiteDocumentsFromDB = unitOfWork.GetConstructionSiteDocumentRepository().GetConstructionSiteDocumentsByConstructionSite(createdConstructionSite.Id); //foreach (var item in ConstructionSiteDocumentsFromDB) // if (!constructionSiteDocuments.Select(x => x.Identifier).Contains(item.Identifier)) // unitOfWork.GetConstructionSiteDocumentRepository().Delete(item.Identifier); //foreach (var item in constructionSiteDocuments) //{ // item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; // unitOfWork.GetConstructionSiteDocumentRepository().Create(item.ConvertToConstructionSiteDocument()); //} //var ConstructionSiteNotesFromDB = unitOfWork.GetConstructionSiteNoteRepository().GetConstructionSiteNotesByConstructionSite(createdConstructionSite.Id); //foreach (var item in ConstructionSiteNotesFromDB) // if (!constructionSiteNotes.Select(x => x.Identifier).Contains(item.Identifier)) // unitOfWork.GetConstructionSiteNoteRepository().Delete(item.Identifier); //foreach (var item in constructionSiteNotes) //{ // item.ConstructionSite = new ConstructionSiteViewModel() { Id = createdConstructionSite.Id }; // unitOfWork.GetConstructionSiteNoteRepository().Create(item.ConvertToConstructionSiteNote()); //} unitOfWork.Save(); response.ConstructionSite = createdConstructionSite.ConvertToConstructionSiteViewModel(); response.Success = true; } catch (Exception ex) { response.ConstructionSite = new ConstructionSiteViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public ConstructionSiteListResponse GetConstructionSitesByPage(int companyId, ConstructionSiteViewModel constructionSiteSearchObject, int currentPage = 1, int itemsPerPage = 50) { ConstructionSiteListResponse response = new ConstructionSiteListResponse(); List <ConstructionSiteViewModel> ConstructionSites = new List <ConstructionSiteViewModel>(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM ConstructionSites " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@City IS NULL OR @City = '' OR CityName LIKE @City) " + "AND (@InternalCode IS NULL OR @InternalCode = '' OR InternalCode LIKE @InternalCode) " + "AND (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR BusinessPartnerName LIKE @BusinessPartnerName) " + "AND CompanyId = @CompanyId " + "ORDER BY IsSynced, Id DESC " + "LIMIT @ItemsPerPage OFFSET @Offset;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)constructionSiteSearchObject.Search_Name) != null ? "%" + constructionSiteSearchObject.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@City", ((object)constructionSiteSearchObject.Search_City) != null ? "%" + constructionSiteSearchObject.Search_City + "%" : ""); selectCommand.Parameters.AddWithValue("@InternalCode", ((object)constructionSiteSearchObject.Search_InternalCode) != null ? "%" + constructionSiteSearchObject.Search_InternalCode + "%" : ""); selectCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)constructionSiteSearchObject.Search_BusinessPartnerName) != null ? "%" + constructionSiteSearchObject.Search_BusinessPartnerName + "%" : ""); selectCommand.Parameters.AddWithValue("@CompanyId", companyId); selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage); selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage); SqliteDataReader query = selectCommand.ExecuteReader(); while (query.Read()) { ConstructionSiteViewModel dbEntry = Read(query); ConstructionSites.Add(dbEntry); } selectCommand = new SqliteCommand( "SELECT Count(*) " + "FROM ConstructionSites " + "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " + "AND (@City IS NULL OR @City = '' OR CityName LIKE @City) " + "AND (@InternalCode IS NULL OR @InternalCode = '' OR InternalCode LIKE @InternalCode) " + "AND (@BusinessPartnerName IS NULL OR @BusinessPartnerName = '' OR BusinessPartnerName LIKE @BusinessPartnerName) " + "AND CompanyId = @CompanyId;", db); selectCommand.Parameters.AddWithValue("@Name", ((object)constructionSiteSearchObject.Search_Name) != null ? "%" + constructionSiteSearchObject.Search_Name + "%" : ""); selectCommand.Parameters.AddWithValue("@City", ((object)constructionSiteSearchObject.Search_City) != null ? "%" + constructionSiteSearchObject.Search_City + "%" : ""); selectCommand.Parameters.AddWithValue("@InternalCode", ((object)constructionSiteSearchObject.Search_InternalCode) != null ? "%" + constructionSiteSearchObject.Search_InternalCode + "%" : ""); selectCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)constructionSiteSearchObject.Search_BusinessPartnerName) != null ? "%" + constructionSiteSearchObject.Search_BusinessPartnerName + "%" : ""); 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.ConstructionSites = new List <ConstructionSiteViewModel>(); return(response); } db.Close(); } response.Success = true; response.ConstructionSites = ConstructionSites; return(response); }
private void btnSave_Click(object sender, RoutedEventArgs e) { Thread th = new Thread(() => { SaveButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SaveButtonEnabled = false; CurrentConstructionSiteCalculation.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentConstructionSiteCalculation.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; CurrentConstructionSiteCalculation.IsSynced = false; CurrentConstructionSiteCalculation.UpdatedAt = DateTime.Now; ConstructionSiteCalculationResponse response = new ConstructionSiteCalculationSQLiteRepository().Delete(CurrentConstructionSiteCalculation.Identifier); response = new ConstructionSiteCalculationSQLiteRepository().Create(CurrentConstructionSiteCalculation); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_lokalnog_čuvanjaUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; return; } response = constructionSiteCalculationService.Create(CurrentConstructionSiteCalculation); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Podaci_su_sačuvani_u_lokaluUzvičnikTačka_Greška_kod_čuvanja_na_serveruUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; } if (response.Success) { ////new ConstructionSiteCalculationSQLiteRepository().UpdateSyncStatus( // response.ConstructionSiteCalculation.Identifier, // response.ConstructionSiteCalculation.UpdatedAt, // response.ConstructionSiteCalculation.Id, // response.ConstructionSiteCalculation.ValueDifference, // response.ConstructionSiteCalculation.NewValue, // true); MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; //ConstructionSiteCalculationCreatedUpdated(); ConstructionSiteViewModel constructionSite = CurrentConstructionSiteCalculation.ConstructionSite; CurrentConstructionSiteCalculation = new ConstructionSiteCalculationViewModel(); CurrentConstructionSiteCalculation.Identifier = Guid.NewGuid(); CurrentConstructionSiteCalculation.ConstructionSite = constructionSite; Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtNumOfEmployees.Focus(); }) ); } }); th.IsBackground = true; th.Start(); }
public static void Show(ConstructionSiteViewModel constructionSite) { //Create excel workbook and sheet Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application(); excel.Visible = true; excel.DisplayFullScreen = true; excel.WindowState = XlWindowState.xlMaximized; Workbook workbook = excel.Workbooks.Add(System.Reflection.Missing.Value); Worksheet sheet1 = (Worksheet)workbook.Sheets[1]; //excel.StandardFont = "Calibri"; //"Arial Narrow" "Times New Roman" "Arial" "Bahnschrift SemiBold Condensed" //excel.StandardFontSize = 8; sheet1.PageSetup.PaperSize = XlPaperSize.xlPaperA4; sheet1.PageSetup.Orientation = XlPageOrientation.xlPortrait; sheet1.PageSetup.FitToPagesTall = false; sheet1.PageSetup.FitToPagesWide = 1; sheet1.PageSetup.Zoom = false; // Set header rows sheet1.PageSetup.PrintTitleRows = "$1:$2"; sheet1.PageSetup.HeaderMargin = 30; sheet1.PageSetup.LeftHeader = "&16&B Gradilište"; sheet1.PageSetup.RightHeader = "&8Stranica &P/&N"; sheet1.PageSetup.CenterHeaderPicture.Filename = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\image005.jpg"; sheet1.PageSetup.CenterHeaderPicture.Width = 150; sheet1.PageSetup.CenterHeaderPicture.Height = 50; sheet1.PageSetup.CenterHeader = "&G"; sheet1.PageSetup.CenterFooterPicture.Filename = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\erp8.png"; sheet1.PageSetup.CenterFooterPicture.Width = 100; sheet1.PageSetup.CenterFooterPicture.Height = 40; sheet1.PageSetup.CenterFooter = "&G"; int leftSideMin = 1; int rightSideMax = 8; int rowCounter = 1; rowCounter++; rowCounter++; rowCounter++; // rowCounter = 26; //top chart area #region Osnovni podaci rowCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].VerticalAlignment = XlVAlign.xlVAlignTop; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Bold = true; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Size = 12; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Merge(); sheet1.Cells[rowCounter, leftSideMin] = "OSNOVNI PODACI/GRUNDDATEN ÜBER DIE BAUSTELLEN"; rowCounter++; //rowCounter++; // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; rowCounter++; int columnCounter = leftSideMin; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Šifra/Code: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.Code; columnCounter += 4; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Šifra gradilišta/Vertragsnummer: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.InternalCode; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; columnCounter = leftSideMin; rowCounter++; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Naziv gradilišta/Baustelle: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.Name; columnCounter += 4; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Država/Land: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.Country?.Name; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; columnCounter = leftSideMin; rowCounter++; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Grad/Stadt: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.City?.Name; columnCounter += 4; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Adresa/Adresse: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.Address; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; columnCounter = leftSideMin; rowCounter++; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Maksimalni broj radnika/Maximale Anzahl der Arbeiter: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.MaxWorkers; columnCounter += 4; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Datum predugovora/Werkvertrages von: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.ProContractDate.ToString("dd.MM.yyyy"); sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; columnCounter = leftSideMin; rowCounter++; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Početak ugovora/Vertragsbeginn: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.ContractStart.ToString("dd.MM.yyyy"); columnCounter += 4; sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter] = "Istek ugovora/Vertragsende: "; sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; sheet1.Cells[rowCounter, columnCounter + 1] = constructionSite.ContractExpiration.ToString("dd.MM.yyyy"); // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; #endregion #region PODACI O DOKUMENTIMA rowCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].VerticalAlignment = XlVAlign.xlVAlignTop; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Bold = true; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Size = 12; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Merge(); sheet1.Cells[rowCounter, leftSideMin] = "DOKUMENTI/DOKUMENTE"; rowCounter++; var constructionSiteDocuments = new ConstructionSiteDocumentSQLiteRepository().GetConstructionSiteDocumentsByConstructionSite(MainWindow.CurrentCompanyId, constructionSite.Identifier)?.ConstructionSiteDocuments ?? new List <ConstructionSiteDocumentViewModel>(); rowCounter++; //sheet1.Cells[rowCounter, columnCounter].Interior.Color = XlRgbColor.rgbLightGray; //sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; //sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; //sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; //sheet1.Cells[rowCounter, columnCounter] = "DATUM: "; //sheet1.Range[sheet1.Cells[rowCounter, columnCounter + 1], sheet1.Cells[rowCounter, columnCounter + 3]].Merge(); //sheet1.Cells[rowCounter, columnCounter + 1].HorizontalAlignment = XlHAlign.xlHAlignCenter; //sheet1.Cells[rowCounter, columnCounter + 1].VerticalAlignment = XlVAlign.xlVAlignCenter; //sheet1.Cells[rowCounter, columnCounter + 1].Font.Size = 10; //sheet1.Cells[rowCounter, columnCounter + 1] = constructionSiteDocuments.; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].VerticalAlignment = XlVAlign.xlVAlignTop; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Bold = true; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Size = 8; sheet1.Cells[rowCounter, leftSideMin] = "RB."; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin + 1], sheet1.Cells[rowCounter, leftSideMin + 2]].Merge(); sheet1.Cells[rowCounter, leftSideMin + 1] = "IME/NAME"; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin + 3], sheet1.Cells[rowCounter, leftSideMin + 6]].Merge(); sheet1.Cells[rowCounter, leftSideMin + 3] = "DATUM"; //sheet1.Cells[rowCounter, leftSideMin + 7] = "PUTANJA"; rowCounter++; //rowCounter++; // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; int columnCounterItem = leftSideMin; for (int i = 0; i < constructionSiteDocuments?.Count; i++) { columnCounterItem = leftSideMin; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Cells[rowCounter, columnCounterItem] = (i + 1) + ". "; columnCounterItem++; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Range[sheet1.Cells[rowCounter, columnCounterItem], sheet1.Cells[rowCounter, columnCounterItem + 1]].Merge(); sheet1.Cells[rowCounter, columnCounterItem] = constructionSiteDocuments[i].Name; columnCounterItem += 2; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Range[sheet1.Cells[rowCounter, columnCounterItem], sheet1.Cells[rowCounter, columnCounterItem + 3]].Merge(); sheet1.Cells[rowCounter, columnCounterItem] = constructionSiteDocuments[i].CreateDate?.ToString("dd.MM.yyyy"); //columnCounterItem += 4; //sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; //sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; //sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; //sheet1.Cells[rowCounter, columnCounterItem] = constructionSiteDocuments[i].Path; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; rowCounter++; } rowCounter--; // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; #endregion #region Napomene rowCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].VerticalAlignment = XlVAlign.xlVAlignTop; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Bold = true; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Size = 12; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Merge(); sheet1.Cells[rowCounter, leftSideMin] = "NAPOMENE/ANMERKUNG"; rowCounter++; var constructionSiteNote = new ConstructionSiteNoteSQLiteRepository().GetConstructionSiteNotesByConstructionSite(MainWindow.CurrentCompanyId, constructionSite.Identifier)?.ConstructionSiteNotes ?? new List <ConstructionSiteNoteViewModel>(); rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Interior.Color = XlRgbColor.rgbLightGray; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].VerticalAlignment = XlVAlign.xlVAlignTop; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Bold = true; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Font.Size = 8; sheet1.Cells[rowCounter, leftSideMin] = "RB."; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin + 1], sheet1.Cells[rowCounter, leftSideMin + 2]].Merge(); sheet1.Cells[rowCounter, leftSideMin + 1] = "NAPOMENA/ANMERKUNG"; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin + 3], sheet1.Cells[rowCounter, leftSideMin + 6]].Merge(); sheet1.Cells[rowCounter, leftSideMin + 3] = "DATUM"; rowCounter++; //rowCounter++; // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; columnCounterItem = leftSideMin; for (int i = 0; i < constructionSiteNote?.Count; i++) { columnCounterItem = leftSideMin; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Cells[rowCounter, columnCounterItem] = (i + 1) + ". "; columnCounterItem++; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Range[sheet1.Cells[rowCounter, columnCounterItem], sheet1.Cells[rowCounter, columnCounterItem + 6]].Merge(); sheet1.Cells[rowCounter, columnCounterItem] = constructionSiteNote[i].Note; columnCounterItem += 2; sheet1.Cells[rowCounter, columnCounterItem].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounterItem].Font.Size = 10; sheet1.Cells[rowCounter, columnCounterItem] = constructionSiteNote[i].NoteDate.ToString("dd.MM.yyyy"); sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; rowCounter++; } rowCounter--; // line sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlContinuous; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].Weight = 2d; #endregion rowCounter++; rowCounter++; rowCounter++; rowCounter++; rowCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, 5], sheet1.Cells[rowCounter, 6]].Merge(); sheet1.Range[sheet1.Cells[rowCounter, 5], sheet1.Cells[rowCounter, 6]].Font.Size = 10; sheet1.Range[sheet1.Cells[rowCounter, 5], sheet1.Cells[rowCounter, 6]] = "Odgovorno lice/Verantwortliches Gesicht"; rowCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter, 5], sheet1.Cells[rowCounter, 7]].Merge(); sheet1.Range[sheet1.Cells[rowCounter, 5], sheet1.Cells[rowCounter, 7]] = "_____________________________"; sheet1.Columns.AutoFit(); }