public static bool RecursiveDeletePlot(PlotDO plot)
 {
     DatastoreRedux dal = plot.DAL;
     string command = string.Format(@"
     DELETE FROM LogStock;
     DELETE FROM TreeCalculatedValues;
     DELETE FROM Log WHERE EXISTS (SELECT 1 FROM Tree WHERE Tree.Tree_CN = Log.Tree_CN AND Tree.Plot_CN = {0});
     DELETE FROM Tree WHERE Plot_CN = {0};", plot.Plot_CN);
     dal.Execute(command);
     plot.Delete();
     return true;
 }
Beispiel #2
0
        public static bool RecursiveDeletePlot(PlotDO plot)
        {
            Datastore dal     = plot.DAL;
            string    command = string.Format(@"
DELETE FROM LogStock;
DELETE FROM TreeCalculatedValues;
DELETE FROM Log WHERE EXISTS (SELECT 1 FROM Tree WHERE Tree.Tree_CN = Log.Tree_CN AND Tree.Plot_CN = {0});
DELETE FROM Tree WHERE Plot_CN = {0};", plot.Plot_CN);

            dal.Execute(command);
            plot.Delete();
            return(true);
        }
		public void SetValues(PlotDO obj)
		{
			if(obj == null) { return; }
			Plot_GUID = obj.Plot_GUID;
			PlotNumber = obj.PlotNumber;
			IsEmpty = obj.IsEmpty;
			Slope = obj.Slope;
			KPI = obj.KPI;
			Aspect = obj.Aspect;
			Remarks = obj.Remarks;
			XCoordinate = obj.XCoordinate;
			YCoordinate = obj.YCoordinate;
			ZCoordinate = obj.ZCoordinate;
			MetaData = obj.MetaData;
			Blob = obj.Blob;
		}
		public PlotDO(PlotDO obj) : this()
		{
		    SetValues(obj);
		}
 public Plot3PPNT(PlotDO plot)
     : base(plot)
 {
 }
Beispiel #6
0
 public PlotVM(PlotDO obj)
     : base(obj)
 {
 }
        private long? savePlots(PlotDO curPlot, long? stratumCN, bool first)
        {
            PlotDO fsPlot;

             fsPlot = fsDAL.ReadSingleRow<PlotDO>("Plot", "Where CuttingUnit_CN = ? and Stratum_CN = ? and PlotNumber = ?", curPlot.CuttingUnit_CN, thisStrCN, curPlot.PlotNumber);

             if (fsPlot == null)
             {
            // check if plot already exists (stratumCN, plot number and unit code)
            fsPlot = new PlotDO(fsDAL);

            fsPlot.Stratum_CN = thisStrCN;
            fsPlot.CuttingUnit_CN = curPlot.CuttingUnit_CN;
            fsPlot.PlotNumber = curPlot.PlotNumber;
            fsPlot.IsEmpty = curPlot.IsEmpty;
            fsPlot.Slope = curPlot.Slope;
            fsPlot.Aspect = curPlot.Aspect;
            fsPlot.Remarks = curPlot.Remarks;
            fsPlot.XCoordinate = curPlot.XCoordinate;
            fsPlot.YCoordinate = curPlot.YCoordinate;
            fsPlot.ZCoordinate = curPlot.ZCoordinate;
            fsPlot.MetaData = curPlot.MetaData;
            fsPlot.Blob = curPlot.Blob;
            //fsPlot.CreatedBy = curPlot.CreatedBy;
            //fsPlot.CreatedDate = curPlot.CreatedDate;

            fsPlot.Save();
             }
            //         else
            //         {
            //            fsPlot = fsDAL.ReadSingleRow<PlotDO>("Plot", "Where CuttingUnit_CN = ? and Stratum_CN = ? and PlotNumber = ?", curPlot.CuttingUnit_CN, thisStrCN, curPlot.PlotNumber);
            //
            //         }
             return (fsPlot.Plot_CN);
        }
        private long? savePlots(PlotDO curPlot, long? stratumCN, bool first)
        {
            PlotDO fsPlot;
             if (first)
             {
            fsPlot = new PlotDO(fsDAL);

            fsPlot.Stratum_CN = stratumCN;
            fsPlot.CuttingUnit_CN = curPlot.CuttingUnit_CN;
            fsPlot.PlotNumber = curPlot.PlotNumber;
            fsPlot.IsEmpty = curPlot.IsEmpty;
            fsPlot.Slope = curPlot.Slope;
            fsPlot.Aspect = curPlot.Aspect;
            fsPlot.Remarks = curPlot.Remarks;
            fsPlot.XCoordinate = curPlot.XCoordinate;
            fsPlot.YCoordinate = curPlot.YCoordinate;
            fsPlot.ZCoordinate = curPlot.ZCoordinate;
            fsPlot.MetaData = curPlot.MetaData;
            fsPlot.Blob = curPlot.Blob;
            fsPlot.CreatedBy = curPlot.CreatedBy;
            fsPlot.CreatedDate = curPlot.CreatedDate;

            fsPlot.Save();
             }
             else
             {
            fsPlot = fsDAL.ReadSingleRow<PlotDO>("Plot", "Where CuttingUnit_CN = ? and Stratum_CN = ? and PlotNumber = ?", curPlot.CuttingUnit_CN, stratumCN, curPlot.PlotNumber);

             }
             return (fsPlot.Plot_CN);
        }
 //private void _DGV_Plots_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 //{
 //    var plot = e.Row.DataBoundItem as PlotDO;
 //    if (plot == null) { e.Cancel = true; return; }
 //    e.Cancel = !this.DeletePlot(plot);
 //}
 protected bool TryDeletePlot(PlotDO plot)
 {
     plot.DAL.BeginTransaction();
     try
     {
         PlotDO.RecursiveDeletePlot(plot);
         plot.DAL.CommitTransaction();
         TreeDataDirty = true;
         return true;
     }
     catch
     {
         plot.DAL.RollbackTransaction();
         return false;
     }
 }