Example #1
0
 /*
  * Add a cow to local database
  */
 public static void AddCow(Cow cowJSON)
 {
     using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString))
     {
         try
         {
             cowDB cow = new cowDB();
             cow.nv = cowJSON.nv;
             cow.nombre = cowJSON.nombre;
             cow.dias_lac = cowJSON.dias_lac;
             cow.hato = cowJSON.hato;
             cow.loc = cowJSON.loc;
             cow.lts_dia = cowJSON.lts_dia;
             cow.partos = cowJSON.partos;
             cow.ultimo_parto = cowJSON.ultimo_parto;
             cow.primer_servicio = cowJSON.primer_servicio;
             System.Diagnostics.Debug.WriteLine("agregando");
             context.cows.InsertOnSubmit(cow);
             context.SubmitChanges();
         }
         catch (Exception e)
         {
             System.Diagnostics.Debug.WriteLine(e);
         }
     }
 }
Example #2
0
 /*
 * get cows from  local database
 */
 public static IList<cowDB> GetAllCows()
 {
     IList<cowDB> list = null;
     using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString))
     {
         IQueryable<cowDB> query = from c in context.cows select c;
         list = query.ToList();
     }
     return list;
 }
Example #3
0
 public static void deleteAllCows()
 {
     using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString))
     {
         IQueryable<cowDB> entityQuery = from c in context.cows select c;
         IList<cowDB> entityToDelete = entityQuery.ToList();
         context.cows.DeleteAllOnSubmit(entityToDelete);
         context.SubmitChanges();
     }
 }
Example #4
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard XAML initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString))
            {
                if (!context.DatabaseExists())
                    context.CreateDatabase();
            }
        }
Example #5
0
 public static Cow getCow(int nvc)
 {
     Cow cowToReturn = null;
     using (CowDataContext context = new CowDataContext(CowDataContext.DBConnectionString))
     {
          IQueryable<cowDB> entityQuery = from c in context.cows where c.nv==nvc select c ;
          cowDB cowDB = entityQuery.FirstOrDefault();
         if(cowDB!=null)
         {
             cowToReturn = new Cow();
             cowToReturn.dias_lac = cowDB.dias_lac;
             cowToReturn.hato = cowDB.dias_lac;
             cowToReturn.loc = cowDB.loc;
             cowToReturn.lts_dia = cowDB.lts_dia;
             cowToReturn.nombre = cowDB.nombre;
             cowToReturn.nv = cowDB.nv;
             cowToReturn.partos = cowDB.partos;
             cowToReturn.primer_servicio = cowDB.primer_servicio;
             cowToReturn.ultimo_parto = cowDB.ultimo_parto;
         }
     }
     return cowToReturn;
 }