Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        public static ConstructionSiteCalculationViewModel ConvertToConstructionSiteCalculationViewModelLite(this ConstructionSiteCalculation constructionSiteCalculation)
        {
            ConstructionSiteCalculationViewModel constructionSiteCalculationViewModel = new ConstructionSiteCalculationViewModel()
            {
                Id         = constructionSiteCalculation.Id,
                Identifier = constructionSiteCalculation.Identifier,

                StatusDate     = constructionSiteCalculation.StatusDate,
                NumOfEmployees = constructionSiteCalculation.NumOfEmployees,
                EmployeePrice  = constructionSiteCalculation.EmployeePrice,
                NumOfMonths    = constructionSiteCalculation.NumOfMonths,

                OldValue        = constructionSiteCalculation.OldValue,
                NewValue        = constructionSiteCalculation.NewValue,
                ValueDifference = constructionSiteCalculation.ValueDifference,

                PlusMinus     = constructionSiteCalculation.PlusMinus,
                ItemStatus    = constructionSiteCalculation.ItemStatus,
                IsPaid        = constructionSiteCalculation.IsPaid,
                IsRefunded    = constructionSiteCalculation.IsRefunded,
                DateCondition = constructionSiteCalculation.DateCondition,
                IsActive      = constructionSiteCalculation.Active,

                UpdatedAt = constructionSiteCalculation.UpdatedAt,
                CreatedAt = constructionSiteCalculation.CreatedAt
            };

            return(constructionSiteCalculationViewModel);
        }
Beispiel #3
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, ConstructionSiteCalculationViewModel constructionSiteCalculation)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", constructionSiteCalculation.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", constructionSiteCalculation.Identifier);
            insertCommand.Parameters.AddWithValue("@ConstructionSiteId", ((object)constructionSiteCalculation.ConstructionSite.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ConstructionSiteIdentifier", ((object)constructionSiteCalculation.ConstructionSite.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ConstructionSiteCode", ((object)constructionSiteCalculation.ConstructionSite.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ConstructionSiteName", ((object)constructionSiteCalculation.ConstructionSite.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@StatusDate", ((object)constructionSiteCalculation.StatusDate) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@NumOfEmployees", ((object)constructionSiteCalculation.NumOfEmployees) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@EmployeePrice", ((object)constructionSiteCalculation.EmployeePrice) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@NumOfMonths", ((object)constructionSiteCalculation.NumOfMonths) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@OldValue", ((object)constructionSiteCalculation.OldValue) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@NewValue", ((object)constructionSiteCalculation.NewValue) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ValueDifference", ((object)constructionSiteCalculation.ValueDifference) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@PlusMinus", ((object)constructionSiteCalculation.PlusMinus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ItemStatus", ((object)constructionSiteCalculation.ItemStatus) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsPaid", constructionSiteCalculation.IsPaid);
            insertCommand.Parameters.AddWithValue("@IsRefunded", constructionSiteCalculation.IsRefunded);
            insertCommand.Parameters.AddWithValue("@DateCondition", ((object)constructionSiteCalculation.DateCondition) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", constructionSiteCalculation.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)constructionSiteCalculation.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);
        }
Beispiel #4
0
        private static ConstructionSiteCalculationViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            ConstructionSiteCalculationViewModel dbEntry = new ConstructionSiteCalculationViewModel();

            dbEntry.Id               = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier       = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.ConstructionSite = SQLiteHelper.GetConstructionSite(query, ref counter);
            dbEntry.StatusDate       = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.NumOfEmployees   = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.EmployeePrice    = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.NumOfMonths      = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.OldValue         = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.NewValue         = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.ValueDifference  = SQLiteHelper.GetDecimal(query, ref counter);
            dbEntry.PlusMinus        = SQLiteHelper.GetString(query, ref counter);
            dbEntry.ItemStatus       = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.IsPaid           = SQLiteHelper.GetBoolean(query, ref counter);
            dbEntry.IsRefunded       = SQLiteHelper.GetBoolean(query, ref counter);
            dbEntry.DateCondition    = 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);
            return(dbEntry);
        }
Beispiel #5
0
        public ConstructionSiteCalculationResponse Create(ConstructionSiteCalculationViewModel constructionSiteCalculation)
        {
            ConstructionSiteCalculationResponse response = new ConstructionSiteCalculationResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, constructionSiteCalculation);
                    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 ConstructionSite_List_Calculation_Remove(ConstructionSiteCalculationViewModel constructionSiteCalculation)
        {
            constructionSiteCalculationService = DependencyResolver.Kernel.Get <IConstructionSiteCalculationService>();

            InitializeComponent();

            this.DataContext = this;

            CurrentConstructionSiteCalculation = constructionSiteCalculation;
        }
Beispiel #7
0
        private void btnEditCalculation_Click(object sender, RoutedEventArgs e)
        {
            CurrentConstructionSiteCalculationForm            = new ConstructionSiteCalculationViewModel();
            CurrentConstructionSiteCalculationForm.Identifier = CurrentConstructionSiteCalculationDG.Identifier;
            CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Edited;

            CurrentConstructionSiteCalculationForm.NumOfEmployees = CurrentConstructionSiteCalculationDG.NumOfEmployees;
            CurrentConstructionSiteCalculationForm.EmployeePrice  = CurrentConstructionSiteCalculationDG.EmployeePrice;
            CurrentConstructionSiteCalculationForm.NumOfMonths    = CurrentConstructionSiteCalculationDG.NumOfMonths;
            CurrentConstructionSiteCalculationForm.DateCondition  = CurrentConstructionSiteCalculationDG.DateCondition;
            CurrentConstructionSiteCalculationForm.IsSynced       = CurrentConstructionSiteCalculationDG.IsSynced;
            CurrentConstructionSiteCalculationForm.UpdatedAt      = CurrentConstructionSiteCalculationDG.UpdatedAt;
        }
Beispiel #8
0
        public ConstructionSiteCalculationResponse Create(ConstructionSiteCalculationViewModel constructionSiteCalculationViewModel)
        {
            ConstructionSiteCalculationResponse response = new ConstructionSiteCalculationResponse();

            try
            {
                ConstructionSiteCalculation lastConstructionSiteCalculation = unitOfWork.GetConstructionSiteCalculationRepository()
                                                                              .GetLastConstructionSiteCalculation(constructionSiteCalculationViewModel.Company.Id, constructionSiteCalculationViewModel.ConstructionSite.Id);

                if (constructionSiteCalculationViewModel.PlusMinus == "+")
                {
                    decimal enteredValue = constructionSiteCalculationViewModel.NumOfEmployees * constructionSiteCalculationViewModel.NumOfMonths * constructionSiteCalculationViewModel.EmployeePrice;

                    constructionSiteCalculationViewModel.ValueDifference = (lastConstructionSiteCalculation?.ValueDifference ?? 0) - enteredValue;
                    if (constructionSiteCalculationViewModel.ValueDifference < 0)
                    {
                        constructionSiteCalculationViewModel.ValueDifference = 0;
                    }
                    decimal valueToAdd = enteredValue - (lastConstructionSiteCalculation?.ValueDifference ?? 0);
                    if (valueToAdd < 0)
                    {
                        valueToAdd = 0;
                    }
                    constructionSiteCalculationViewModel.NewValue = (lastConstructionSiteCalculation?.NewValue ?? 0) + valueToAdd;
                }
                else
                {
                    decimal enteredValue = constructionSiteCalculationViewModel.NumOfEmployees * constructionSiteCalculationViewModel.NumOfMonths * constructionSiteCalculationViewModel.EmployeePrice;

                    constructionSiteCalculationViewModel.ValueDifference = (lastConstructionSiteCalculation?.ValueDifference ?? 0) + enteredValue;
                    constructionSiteCalculationViewModel.NewValue        = lastConstructionSiteCalculation?.NewValue ?? 0;
                }

                constructionSiteCalculationViewModel.UpdatedAt = DateTime.Now.AddMilliseconds(1);

                ConstructionSiteCalculation addedConstructionSiteCalculation = unitOfWork.GetConstructionSiteCalculationRepository()
                                                                               .Create(constructionSiteCalculationViewModel.ConvertToConstructionSiteCalculation());
                unitOfWork.Save();
                response.ConstructionSiteCalculation = addedConstructionSiteCalculation.ConvertToConstructionSiteCalculationViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.ConstructionSiteCalculation = new ConstructionSiteCalculationViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Beispiel #9
0
        public ConstructionSiteCalculationResponse Create(ConstructionSiteCalculationViewModel ConstructionSiteCalculationViewModel)
        {
            ConstructionSiteCalculationResponse response = new ConstructionSiteCalculationResponse();

            try
            {
                response = WpfApiHandler.SendToApi <ConstructionSiteCalculationViewModel, ConstructionSiteCalculationResponse>(ConstructionSiteCalculationViewModel, "Create");
            }
            catch (Exception ex)
            {
                response.ConstructionSiteCalculation = new ConstructionSiteCalculationViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public JsonResult Create([FromBody] ConstructionSiteCalculationViewModel c)
        {
            ConstructionSiteCalculationResponse response = new ConstructionSiteCalculationResponse();

            try
            {
                response = this.ConstructionSiteCalculationService.Create(c);
            }
            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
            }));
        }
Beispiel #11
0
        public ConstructionSiteCalculationListResponse GetConstructionSiteCalculationsByConstructionSite(int companyId, Guid ConstructionSiteIdentifier)
        {
            ConstructionSiteCalculationListResponse     response = new ConstructionSiteCalculationListResponse();
            List <ConstructionSiteCalculationViewModel> ConstructionSiteCalculations = new List <ConstructionSiteCalculationViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM ConstructionSiteCalculations " +
                        "WHERE ConstructionSiteIdentifier = @ConstructionSiteIdentifier " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC;", db);
                    selectCommand.Parameters.AddWithValue("@ConstructionSiteIdentifier", ConstructionSiteIdentifier);
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        ConstructionSiteCalculationViewModel dbEntry = Read(query);
                        ConstructionSiteCalculations.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.ConstructionSiteCalculations = new List <ConstructionSiteCalculationViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.ConstructionSiteCalculations = ConstructionSiteCalculations;
            return(response);
        }
Beispiel #12
0
        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();
        }
Beispiel #13
0
        public ConstructionSiteCalculationResponse GetConstructionSiteCalculation(Guid identifier)
        {
            ConstructionSiteCalculationResponse  response = new ConstructionSiteCalculationResponse();
            ConstructionSiteCalculationViewModel ConstructionSiteCalculation = new ConstructionSiteCalculationViewModel();

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

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        ConstructionSiteCalculationViewModel dbEntry = Read(query);
                        ConstructionSiteCalculation = dbEntry;
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.ConstructionSiteCalculation = new ConstructionSiteCalculationViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.ConstructionSiteCalculation = ConstructionSiteCalculation;
            return(response);
        }
Beispiel #14
0
        public static ConstructionSiteCalculation ConvertToConstructionSiteCalculation(this ConstructionSiteCalculationViewModel constructionSiteCalculationViewModel)
        {
            ConstructionSiteCalculation constructionSiteCalculation = new ConstructionSiteCalculation()
            {
                Id         = constructionSiteCalculationViewModel.Id,
                Identifier = constructionSiteCalculationViewModel.Identifier,

                ConstructionSiteId = constructionSiteCalculationViewModel.ConstructionSite?.Id ?? null,

                StatusDate     = constructionSiteCalculationViewModel.StatusDate,
                NumOfEmployees = constructionSiteCalculationViewModel.NumOfEmployees,
                EmployeePrice  = constructionSiteCalculationViewModel.EmployeePrice,
                NumOfMonths    = constructionSiteCalculationViewModel.NumOfMonths,

                OldValue        = constructionSiteCalculationViewModel.OldValue,
                NewValue        = constructionSiteCalculationViewModel.NewValue,
                ValueDifference = constructionSiteCalculationViewModel.ValueDifference,

                PlusMinus     = constructionSiteCalculationViewModel.PlusMinus,
                ItemStatus    = constructionSiteCalculationViewModel.ItemStatus,
                IsPaid        = constructionSiteCalculationViewModel.IsPaid,
                IsRefunded    = constructionSiteCalculationViewModel.IsRefunded,
                DateCondition = constructionSiteCalculationViewModel.DateCondition,
                CreatedById   = constructionSiteCalculationViewModel.CreatedBy?.Id ?? null,
                CompanyId     = constructionSiteCalculationViewModel.Company?.Id ?? null,

                CreatedAt = constructionSiteCalculationViewModel.CreatedAt,
                UpdatedAt = constructionSiteCalculationViewModel.UpdatedAt
            };

            return(constructionSiteCalculation);
        }
        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();
        }
Beispiel #16
0
 private void btnCancelCalculation_Click(object sender, RoutedEventArgs e)
 {
     CurrentConstructionSiteCalculationForm            = new ConstructionSiteCalculationViewModel();
     CurrentConstructionSiteCalculationForm.Identifier = Guid.NewGuid();
     CurrentConstructionSiteCalculationForm.ItemStatus = ItemStatus.Added;
 }
Beispiel #17
0
        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();
        }