private void BtnDelete_Click(object sender, RoutedEventArgs e) { var response = new ConstructionSiteCalculationSQLiteRepository().SetStatusDeleted(CurrentConstructionSiteCalculationDG.Identifier); if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Stavka_je_uspešno_obrisanaUzvičnik")); CurrentConstructionSiteCalculationForm = new ConstructionSiteCalculationViewModel(); CurrentConstructionSiteCalculationForm.Identifier = Guid.NewGuid(); CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Added; CurrentConstructionSiteCalculationDG = null; ConstructionSiteCreatedUpdated(); Thread displayThread = new Thread(() => DisplayConstructionSiteCalculationData()); displayThread.IsBackground = true; displayThread.Start(); } else { MainWindow.ErrorMessage = response.Message; } }
public void DisplayConstructionSiteCalculationData() { ConstructionSiteCalculationDataLoading = true; ConstructionSiteCalculationListResponse response = new ConstructionSiteCalculationSQLiteRepository() .GetConstructionSiteCalculationsByConstructionSite(MainWindow.CurrentCompanyId, CurrentConstructionSite.Identifier); if (response.Success) { ConstructionSiteCalculationsFromDB = new ObservableCollection <ConstructionSiteCalculationViewModel>( response.ConstructionSiteCalculations ?? new List <ConstructionSiteCalculationViewModel>()); } else { ConstructionSiteCalculationsFromDB = new ObservableCollection <ConstructionSiteCalculationViewModel>(); } ConstructionSiteCalculationDataLoading = false; }
private void DisplayConstructionSiteCalculationData() { ConstructionSiteCalculationDataLoading = true; ConstructionSiteCalculationListResponse response = new ConstructionSiteCalculationSQLiteRepository() .GetConstructionSiteCalculationsByConstructionSite(MainWindow.CurrentCompanyId, CurrentConstructionSite.Identifier); if (response.Success) { ConstructionSiteCalculationsFromDB = new ObservableCollection <ConstructionSiteCalculationViewModel>(response.ConstructionSiteCalculations ?? new List <ConstructionSiteCalculationViewModel>()); TotalSum = 0; foreach (var item in ConstructionSiteCalculationsFromDB) { TotalSum += item.NewValue; } } else { ConstructionSiteCalculationsFromDB = new ObservableCollection <ConstructionSiteCalculationViewModel>(); MainWindow.ErrorMessage = response.Message; } ConstructionSiteCalculationDataLoading = false; }
public static void Show(List <ConstructionSiteViewModel> constructionSites) { //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; decimal sumOfCalculations = 0; // 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"; //sheet1.PageSetup.LeftFooter = " www.sirmiumerp.com "; //sheet1.PageSetup.CenterFooter = " www.sirmiumerp.com "; int leftSideMin = 1; int rightSideMax = 9; int rowCounter = 1; rowCounter++; rowCounter++; rowCounter++; // rowCounter = 26; //top chart area #region Table 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 = 8; string[,] tabelaNasloviKolona = new string[, ] { { "RB.", "ŠIFRA GRADILIŠTA", "NAZIV GRADILIŠTA", "GRAD", "ADRESA", "MAKSIMALNI BROJ RADNIKA", "POČETAK UGOVORA", "ISTEK UGOVORA", "RAZLIKA VREDNOSTI" } }; sheet1.Range[sheet1.Cells[rowCounter, leftSideMin], sheet1.Cells[rowCounter, rightSideMax]] = tabelaNasloviKolona; 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; for (int i = 0; i < constructionSites?.Count; i++) { columnCounter = leftSideMin; 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] = (i + 1) + ". "; columnCounter++; 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] = constructionSites[i].InternalCode; columnCounter++; 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] = constructionSites[i].Name; columnCounter++; 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] = constructionSites[i].City?.Name; columnCounter++; 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] = constructionSites[i].Address; columnCounter++; 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] = constructionSites[i].MaxWorkers; columnCounter++; 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] = constructionSites[i].ContractStart.ToString("dd.MM.yyyy"); columnCounter++; 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] = constructionSites[i].ContractExpiration.ToString("dd.MM.yyyy"); columnCounter++; sheet1.Cells[rowCounter, columnCounter].HorizontalAlignment = XlHAlign.xlHAlignCenter; sheet1.Cells[rowCounter, columnCounter].VerticalAlignment = XlVAlign.xlVAlignCenter; sheet1.Cells[rowCounter, columnCounter].Font.Size = 10; var calculationsByConstructionSite = new ConstructionSiteCalculationSQLiteRepository().GetConstructionSiteCalculationsByConstructionSite(MainWindow.CurrentCompanyId, constructionSites[i].Identifier); sumOfCalculations += calculationsByConstructionSite?.ConstructionSiteCalculations?.Sum(x => x.ValueDifference) ?? 0; sheet1.Cells[rowCounter, columnCounter] = calculationsByConstructionSite?.ConstructionSiteCalculations?.Sum(x => x.ValueDifference); columnCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter - 1, leftSideMin], sheet1.Cells[rowCounter - 1, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; } columnCounter = 9; 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] = sumOfCalculations; columnCounter++; rowCounter++; sheet1.Range[sheet1.Cells[rowCounter - 1, leftSideMin], sheet1.Cells[rowCounter - 1, rightSideMax]].Borders[XlBordersIndex.xlEdgeBottom].LineStyle = XlLineStyle.xlDash; 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++; 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"; 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(); }
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(); }
private void btnAddCalculation_Click(object sender, RoutedEventArgs e) { #region Validation //if (CurrentConstructionSiteCalculationForm.Note == null) //{ // MainWindow.ErrorMessage = "Obavezno polje: Napomena"; // return; //} #endregion Thread th = new Thread(() => { SubmitButtonEnabled = false; CurrentConstructionSiteCalculationForm.ConstructionSite = CurrentConstructionSite; CurrentConstructionSiteCalculationForm.IsPaid = IsPaid; CurrentConstructionSiteCalculationForm.IsRefunded = IsRefunded; CurrentConstructionSiteCalculationForm.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentConstructionSiteCalculationForm.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; CurrentConstructionSiteCalculationForm.NewValue = CurrentConstructionSiteCalculationForm.NumOfEmployees * CurrentConstructionSiteCalculationForm.EmployeePrice * CurrentConstructionSiteCalculationForm.NumOfMonths; new ConstructionSiteCalculationSQLiteRepository().Delete(CurrentConstructionSiteCalculationForm.Identifier); var response = new ConstructionSiteCalculationSQLiteRepository().Create(CurrentConstructionSiteCalculationForm); if (!response.Success) { MainWindow.ErrorMessage = response.Message; CurrentConstructionSiteCalculationForm = new ConstructionSiteCalculationViewModel(); CurrentConstructionSiteCalculationForm.Identifier = Guid.NewGuid(); CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Added; CurrentConstructionSiteCalculationForm.IsSynced = false; return; } CurrentConstructionSiteCalculationForm = new ConstructionSiteCalculationViewModel(); CurrentConstructionSiteCalculationForm.Identifier = Guid.NewGuid(); CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Added; CurrentConstructionSiteCalculationForm.IsSynced = false; ConstructionSiteCreatedUpdated(); DisplayConstructionSiteCalculationData(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtNumOfEmployees.Focus(); }) ); SubmitButtonEnabled = true; }); th.IsBackground = true; th.Start(); }