Esempio n. 1
0
		public SaleDO(SaleDO obj) : this()
		{
		    SetValues(obj);
		}
 private void checkSalePurpose()
 {
     mySale = new SaleDO(cdDAL.ReadSingleRow<SaleDO>("Sale", null, null));
     //           mySale = cdDAL.ReadSingleRow<SaleDO>("Sale", null, null);
        sUOM = mySale.DefaultUOM;
        String remark = mySale.Remarks;
        if (remark == "Historical Design")
       reconExists = false;
 }
 private void InitializeDatabaseTables()
 {
     // cdStratum = new List<StratumDO>(cdDAL.Read<StratumDO>("Stratum", null, null));
      cdStratumStats = new BindingList<StratumStatsDO>(cdDAL.Read<StratumStatsDO>("StratumStats", "JOIN Stratum ON StratumStats.Stratum_CN = Stratum.Stratum_CN AND StratumStats.Method = Stratum.Method AND StratumStats.Used = 1 ORDER BY Stratum.Code", null));
      mySale = cdDAL.ReadSingleRow<SaleDO>("Sale", null, null);
      myGlobals = cdDAL.Read<GlobalsDO>("Globals", "WHERE Block = ?", "CruiseDesign");
 }
Esempio n. 4
0
		public void SetValues(SaleDO obj)
		{
			if(obj == null) { return; }
			SaleNumber = obj.SaleNumber;
			Name = obj.Name;
			Purpose = obj.Purpose;
			Region = obj.Region;
			Forest = obj.Forest;
			District = obj.District;
			MeasurementYear = obj.MeasurementYear;
			CalendarYear = obj.CalendarYear;
			LogGradingEnabled = obj.LogGradingEnabled;
			Remarks = obj.Remarks;
			DefaultUOM = obj.DefaultUOM;
		}
        public void GoToHistPage()
        {
            // If from UnitPage - get new currentStratumStats
             currentStratumStats = (cdDAL.ReadSingleRow<StratumStatsDO>("StratumStats", "WHERE Stratum_CN = ? AND SgSet = 1", currentStratum.Stratum_CN));

             if (currentStratumStats != null)
             {
            // data already exists for stratum, delete stratum and continue?
            MessageBox.Show("Stratum data already exists for this stratum","Information");
            return;

             }

             currentStratumStats = new StratumStatsDO(cdDAL);
             currentStratumStats.Stratum = currentStratum;
             currentStratumStats.Code = currentStratum.Code;
             currentStratumStats.Description = currentStratum.Description;
             currentStratumStats.SgSet = 1;
             currentStratumStats.SgSetDescription = "";

             float totalAcres = 0;
             foreach (CuttingUnitDO cu in currentStratum.CuttingUnits)
             {
            float acres = cu.Area;
            totalAcres += acres;
             }
             currentStratumStats.TotalAcres = totalAcres;
            //         Owner.currentStratumStats.Save();

             if (openFileDialog1.ShowDialog() == DialogResult.OK)
             {
            histFile = openFileDialog1.FileName;
            //set title bar with file name
            histPage.textBoxFile.Text = openFileDialog1.SafeFileName;
            //open new cruise DAL
            if (histFile.Length > 0)
            {
               try
               {
                  hDAL = new DAL(histFile);
               }
               catch (System.IO.IOException ie)
               {
                  Logger.Log.E(ie);
               }
               catch (System.Exception ie)
               {
                  Logger.Log.E(ie);
               }
            }
            else
            {
               return;
            }

            Sale = new SaleDO(hDAL.ReadSingleRow<SaleDO>("Sale", null, null));
            string sUOM = Sale.DefaultUOM;
            if (sUOM != UOM)
            {
               MessageBox.Show("Cruise does not have same UOM.\nCannot import data.", "Warning");
               return;
            }

            //set binding list for stratum
            histStratum = new BindingList<StratumDO>(hDAL.Read<StratumDO>("Stratum", null, null));
            histPage.bindingSourceStratum.DataSource = histStratum;

            pageHost2.Display(histPage);
             }
        }
        //cancels the cruise wizard diolog and discards all resorurces
        private void setSalePurpose()
        {
            SaleDO sale = new SaleDO (cdDAL.ReadSingleRow<SaleDO>("Sale", null, null));

             if (sale.DefaultUOM == null)
            UOM = "03";
             else
            UOM = sale.DefaultUOM.ToString();
        }
        private void copySaleTable(DAL cDAL)
        {
            //mySale = new List<SaleDO>();
             //open sale table
             SaleDO sale = new SaleDO(cDAL.ReadSingleRow<SaleDO>("Sale", null, null));
             SaleDO fsSale = new SaleDO(fsDAL);

             fsSale.Purpose = "Timber Sale";
             fsSale.SaleNumber = sale.SaleNumber;
             fsSale.Name = sale.Name;
             fsSale.Region = sale.Region;
             fsSale.Forest = sale.Forest;
             fsSale.District = sale.District;
             fsSale.DefaultUOM = sale.DefaultUOM;
             fsSale.CalendarYear = sale.CalendarYear;
             fsSale.LogGradingEnabled = sale.LogGradingEnabled;
             fsSale.MeasurementYear = sale.MeasurementYear;
             fsSale.Remarks = sale.Remarks;

             fsSale.Save();

             logData = sale.LogGradingEnabled;

             myMeth = new List<CruiseMethodsDO>(fsDAL.Read<CruiseMethodsDO>("CruiseMethods",null,null));
             if (myMeth.Count() < 4)
             {
            myMeth.Clear();
            for (int i = 0; i < 12; i++)
            {
               CruiseMethodsDO fsMeth = new CruiseMethodsDO(fsDAL);
               addCruiseMethod(fsMeth, i);
               myMeth.Add(fsMeth);
            }
            fsDAL.Save(myMeth);
             }
        }
 private void copySaleData(dataFiles df)
 {
     SaleDO sale = new SaleDO(df.cdDAL);
      sale.SaleNumber = df.SaleNumber;
      sale.Name = df.Name;
      sale.Purpose = df.Purpose;
      sale.Region = df.Regnum;
      sale.Forest = df.Forest;
      sale.District = df.District;
      sale.DefaultUOM = df.DefaultUOM;
      sale.Remarks = "Historical Design";
      sale.LogGradingEnabled = df.LogEnabled;
      sale.Save();
 }
 public void UpdateSale(SaleDO obj)
 {
     salePage.SaleDOBindingSource.DataSource = obj;
 }
 private bool ShowWizardDialog(DAL database, out SaleDO sale)
 {
     CruiseWizardView view = new CruiseWizardView();
     CruiseWizardPresenter p = new CruiseWizardPresenter(view, this, this.ApplicationController, database);
     DialogResult result = view.ShowDialog((IWin32Window)this.ApplicationController.MainWindow);
     sale = p.Sale;
     if (result == DialogResult.OK)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
        protected String AskSavePath(SaleDO sale)
        {
            bool createSaleFolder = false;
            if (ApplicationController.UserSettings.CreateSaleFolder == null)
            {
                using (var dialog = new CreateSaleFolerDialog())
                {
                    createSaleFolder = (dialog.ShowDialog() == DialogResult.Yes);
                    if (dialog.RememberSelection)
                    {
                        ApplicationController.UserSettings.CreateSaleFolder = createSaleFolder;
                        //ApplicationState.GetHandle().Save();
                    }
                }
            }
            else
            {
                createSaleFolder = ApplicationController.UserSettings.CreateSaleFolder.Value;
            }

            using (var saveFileDialog = new System.Windows.Forms.SaveFileDialog())
            {
                saveFileDialog.AutoUpgradeEnabled = true;
                saveFileDialog.CustomPlaces.Add(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\CruiseFiles");
                saveFileDialog.InitialDirectory = ApplicationController.UserSettings.CruiseSaveLocation;
                saveFileDialog.DefaultExt = "cruise";
                saveFileDialog.Filter = "Cruise files(*.cruise)|*.cruise";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string fileName = saveFileDialog.FileName;
                    string dir = System.IO.Path.GetDirectoryName(fileName);
                    ApplicationController.UserSettings.CruiseSaveLocation = dir;

                    if (createSaleFolder)
                    {
                        dir += sale.ToString("\\[SaleNumber] [Name]\\", null);
                        if (!System.IO.Directory.Exists(dir))
                        {
                            System.IO.Directory.CreateDirectory(dir);
                        }
                        return dir + System.IO.Path.GetFileName(saveFileDialog.FileName);
                    }
                    return saveFileDialog.FileName;
                }
                return null;
            }
        }
        public void getPopulations()
        {
            //MessageBox.Show("getPopulations");
             mySale = new SaleDO(cdDAL.ReadSingleRow<SaleDO>("Sale", null, null));
             if (reconExists)
             {
            // check for TreeDefaultValues - processed cruise
            //List<TreeCalculatedValuesDO> chkValues = new List<TreeCalculatedValuesDO>(rDAL.Read<TreeCalculatedValuesDO>("TreeCalculatedValues", null, null));
            rTreeCalcJoin = new List<TreeCalculatedValuesDO>(rDAL.Read<TreeCalculatedValuesDO>("TreeCalculatedValues", "JOIN Tree T JOIN SampleGroup G WHERE TreeCalculatedValues.Tree_CN = T.Tree_CN AND T.SampleGroup_CN = G.SampleGroup_CN", null));
            if (rTreeCalcJoin.Count() <= 0)
            {
               errFlag = 1;
               getDefaultData();
               // default values calc
               return;
            }
             }
             else
             {
            getDefaultData();
            return;
             }
             //get recon tree calculated list
             myPlots = new List<PlotDO>(rDAL.Read<PlotDO>("Plot", null, null));

             // get stratum definitions
             stratum = new List<StratumDO>(cdDAL.Read<StratumDO>("Stratum", null, null));

             // loop through stratum
             foreach (StratumDO curStr in stratum)
             {
            // check if Stratum needs to be re-calculated (if method = 100, then it needs to be recalculated)
            strStats = (cdDAL.ReadSingleRow<StratumStatsDO>("StratumStats", "WHERE Stratum_CN = ? AND SgSet = 1 AND Method = ?", curStr.Stratum_CN, "100"));
            if (curStr.Method == "100" && strStats.Used == 2)
            {
               curStr.CuttingUnits.Populate();
               // get total strata acres

               removePopulations(curStr.Stratum_CN);

               totalAcres = 0;
               foreach (CuttingUnitDO cu in curStr.CuttingUnits)
               {
                  float acres = cu.Area;
                  totalAcres += acres;
               }

               selectStratumStats = new List<StratumStatsDO>(cdDAL.Read<StratumStatsDO>("StratumStats", "WHERE Stratum_CN = ?", curStr.Stratum_CN));
               // loop by stratumstats for multiple SgSets
               foreach (StratumStatsDO curStrStats in selectStratumStats)
               {
                  useDefaultFix = false;
                  useDefaultTree = false;
                  useDefaultPnt = false;
                  curPlotFixSize = 0;
                  curPlotPntSize = 0;

                  // add methods to the StratumStats table (FIX,FCM,F3P,STR,3P,S3P,PNT,P3P,PCM,3PPNT)
                  //setupPopulations(curStrStats.Stratum_CN, curStrStats.Code, curStrStats.Description, curStrStats.SgSet, curStrStats.SgSetDescription, curStrStats.TotalAcres);

                  selectSgStats = new List<SampleGroupStatsDO>(cdDAL.Read<SampleGroupStatsDO>("SampleGroupStats", "Where StratumStats_CN = ?", curStrStats.StratumStats_CN));
                  // loop through sample groups
                  foreach (SampleGroupStatsDO curSgStats in selectSgStats)
                  {
                     //Get all statistics from FIX plots  **************
                     sgPlotSize = 0;
                     //find data from Recon file
                     int iReturn = getSgReconData(curStrStats, curSgStats, "FIX");

                     if (iReturn > 0)
                     {
                        useDefaultFix = true;
                        useDefaultTree = true;
                     }

                     if (curPlotFixSize == 0) curPlotFixSize = sgPlotSize;
                     // check plot sizes are not different across sample groups
                     if (curPlotFixSize != sgPlotSize)
                     {
                        // plot sizes are different across sample groups, cannot calculate Fix statistics
                        useDefaultFix = true;
                     }

                     // calc Fixed
                     getFixSgStats(curStrStats, curSgStats, useDefaultFix);

                     //Get all statistics from PNT plots  **************
                     curPlotFixSize = 0;
                     sgPlotSize = 0;
                     //find data from Recon file
                     iReturn = getSgReconData(curStrStats, curSgStats, "PNT");

                     if (iReturn > 0)
                     {
                        useDefaultPnt = true;
                     }

                     if (curPlotPntSize == 0) curPlotPntSize = sgPlotSize;
                     // check plot sizes are not different across sample groups
                     if (curPlotPntSize != sgPlotSize)
                     {
                        // plot sizes are different across sample groups, cannot calculate Fix statistics
                        useDefaultPnt = true;
                     }
                     getPntSgStats(curStrStats, curSgStats, useDefaultPnt);
                  }
               }
               //calculate StratumStats from the SampleGroupStats
               getStratumStats(curStr.Stratum_CN);

            }
            else
            {
              // selectStratumStats = new List<StratumStatsDO>(cdDAL.Read<StratumStatsDO>("StratumStats", "WHERE Stratum_CN = ?", curStr.Stratum_CN));
               // check for historical data
              // foreach (StratumStatsDO curStrStats in selectStratumStats)
              // {
                  // check for error equal to zero
              //    if (curStrStats.StrError == 0)
              //    {
              //       selectSgStats = new List<SampleGroupStatsDO>(cdDAL.Read<SampleGroupStatsDO>("SampleGroupStats", "Where StratumStats_CN = ?", curStrStats.StratumStats_CN));
                     // loop through sample groups
              //       foreach (SampleGroupStatsDO curSgStats in selectSgStats)
              //       {
              //          getDefaultStats(curStrStats, curSgStats);
              //       }
               //      getStratumStats(curStr.Stratum_CN);
               //   }
               //}
            }
             }
        }
Esempio n. 13
0
 public SaleVM(SaleDO sale)
     : base(sale)
 {
 }