partial void DeleteGrucoxCPMProgramSession(GrucoxCPMProgramSession instance);
 partial void InsertGrucoxCPMProgramSession(GrucoxCPMProgramSession instance);
 partial void UpdateGrucoxCPMProgramSession(GrucoxCPMProgramSession instance);
        public static bool StoreDataCPM_RemoteDB(DataClasses.CPMProgram CPMProgram, int UserID)
        {
            GrucoxCPMProgramSession CPMProgramSession = new GrucoxCPMProgramSession();
            CPMProgramSession.DeviceUID = (new Grucox.DataManager(CalibrationSettings.Default.DataManagerConnectionString)).GetDeviceMacAddress();
            CPMProgramSession.LiveUserID = UserID;
            CPMProgramSession.SessionDate = DateTime.Now.Subtract(TimeSpan.FromMinutes(10));
            CPMProgramSession.SessionDuration = TimeSpan.FromSeconds(CPMProgram.SessionDuration.Value);
            CPMProgramSession.LeftMaxConcP = Convert.ToDecimal(CPMProgram.LeftMaxConcP);
            CPMProgramSession.LeftMaxEcceP = Convert.ToDecimal(CPMProgram.LeftMaxEcceP);
            CPMProgramSession.RightMaxConcP = Convert.ToDecimal(CPMProgram.RightMaxConcP);
            CPMProgramSession.RightMaxEcceP = Convert.ToDecimal(CPMProgram.RightMaxEcceP);
            CPMProgramSession.LeftAvgConcP = Convert.ToDecimal(CPMProgram.LeftAvgConcP);
            CPMProgramSession.LeftAvgEcceP = Convert.ToDecimal(CPMProgram.LeftAvgEcceP);
            CPMProgramSession.RightAvgConcP = Convert.ToDecimal(CPMProgram.RightAvgConcP);
            CPMProgramSession.RightAvgEcceP = Convert.ToDecimal(CPMProgram.RightAvgEcceP);
            CPMProgramSession.LeftStrengthIndex = Convert.ToDecimal(CPMProgram.LeftStrengthIndex);
            CPMProgramSession.LeftEnduranceIndex = Convert.ToDecimal(CPMProgram.LeftEnduranceIndex);
            CPMProgramSession.RightStrengthIndex = Convert.ToDecimal(CPMProgram.RightStrengthIndex);
            CPMProgramSession.RightEnduranceIndex = Convert.ToDecimal(CPMProgram.RightEnduranceIndex);
            CPMProgramSession.DistConc = Convert.ToDecimal(CPMProgram.DistConc);
            CPMProgramSession.DistEcce = Convert.ToDecimal(CPMProgram.DistEcce);
            CPMProgramSession.EnergyBurned = Convert.ToDecimal(CPMProgram.EnergyBurned);
            CPMProgramSession.SessionDescription = "CPM Program";

            DataClasses.GrucoxDataClassesRemoteDBDataContext dc = new DataClasses.GrucoxDataClassesRemoteDBDataContext();

            var matchedItem = (from sessions in dc.GetTable<DataClasses.GrucoxCPMProgramSession>()           //**************************************
                               where sessions.ItemID == CPMProgramSession.ItemID                               //******Check if customer already exists
                               select sessions).SingleOrDefault();                                 //**************************************

            if (matchedItem == null)                                                //If customer does not exist
            {
                try
                {
                    dc.GrucoxCPMProgramSessions.InsertOnSubmit(CPMProgramSession);
                    dc.GrucoxCPMProgramSessions.Context.SubmitChanges();                      //Add the new customer to the Customers Table
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
            else                                                                    //Customer already exists
            {
                try
                {
                    dc.SubmitChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }