Example #1
0
        /// <summary>
        /// Get saved "Upparbetat" values
        /// </summary>
        /// <param name="month"></param>
        /// <param name="productId"></param>
        /// <returns></returns>
        private int?GetReprocessedValue(DateTime month, string productId)
        {
            string monthID = month.ToString("yyyyMM");

            //Return forecastmonitor (saved row values)
            ForecastMonitor test = db.ForecastMonitor.FirstOrDefault(f => f.IeProductID == productId && f.ForecastMonitorMonthID == monthID);

            return(test != null ? test.Reprocessed : 0);
        }
Example #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (!IsValid(dgForecasts))
            {
                MessageBox.Show("Det finns felaktigt inmatade fält, var god ändra");
                return;
            }

            if (cbMonth.SelectedIndex > 0)
            {
                Months SelectedMonth;
                Enum.TryParse(cbMonth.SelectedValue.ToString(), out SelectedMonth);

                DateTime month = new DateTime(DateTime.Now.Year, (int)SelectedMonth, 1);


                foreach (Forecasting fc in Forecasts)
                {
                    ForecastMonitor fm = (ForecastingManagement.Instance.ForecastMonitorExist(fc.IeProductID, month));
                    if (fm == null)
                    {
                        if (fc.Reprocessed > 0 || fc.Forecast > 0)
                        {
                            ForecastMonitor newfm = new ForecastMonitor
                            {
                                Reprocessed            = fc.Reprocessed,
                                OutcomeAcc             = fc.OutcomeAcc,
                                IeProductName          = fc.IeProductName,
                                IeProductID            = fc.IeProductID,
                                ForecastMonth          = ForecastMonth,
                                ForecastMonitorMonthID = month.ToString("yyyyMM"),
                                ForecastBudget         = fc.Budget.ToString(),
                                Forecast = fc.Forecast
                            };

                            ForecastingManagement.Instance.AddForecastMonitor(newfm);
                        }
                    }
                    else
                    {
                        fm.Reprocessed    = fc.Reprocessed;
                        fm.OutcomeAcc     = fc.OutcomeAcc;
                        fm.ForecastBudget = fc.Budget.ToString();
                        fm.Forecast       = fc.Forecast;
                    }
                    ForecastingManagement.Instance.UpdateForecast();
                }
                MessageBox.Show("Data är sparad");
                //ForecastingManagement.Instance.AddForecast(cbMonth.SelectedIndex);
                saved = true;
            }
        }
Example #3
0
 /// <summary>
 /// Add forecast to database or save changes made to a forecast that is already added to the database
 /// </summary>
 public void AddForecastMonitor(ForecastMonitor obj)
 {
     db.ForecastMonitor.Add(obj);
 }