示例#1
0
        public static void eliminar(DataGridView DGV)
        {
            bool hayPredet = false;

            if (DGV.SelectedRows.Count > 0)
            {
                if (MessageBox.Show("¿Desea borrar el/los registro/s?", "Eliminar", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    foreach (DataGridViewRow fila in DGV.SelectedRows)
                    {
                        if (((Equipo)fila.DataBoundItem).EsPredet)
                        {
                            hayPredet = true;
                        }
                        DGV.Rows.Remove(fila);
                    }
                    if (hayPredet && DGV.RowCount > 0)
                    {
                        ((Equipo)DGV.Rows[0].DataBoundItem).EsPredet = true;
                    }
                    IO.writeObjectAsJson(file, DGV.DataSource);
                }
                ;
            }
        }
示例#2
0
        public static void guardar(SistemaDosimetrico _nuevo, bool edita, int indice)
        {
            var auxLista = lista();

            if (edita)
            {
                bool   auxPredet = auxLista[indice].EsPredet;
                string IDvieja   = auxLista[indice].ID;
                auxLista.RemoveAt(indice);
                _nuevo.ID = IDvieja;
                auxLista.Insert(indice, _nuevo);
                auxLista[indice].EsPredet = auxPredet;
                IO.writeObjectAsJson(file, auxLista);
                if (auxLista.Count() == 1) //está solo este elemento, ya debería ser predeterminado. No debería hacer falta
                {
                    _nuevo.EsPredet = true;
                }
            }
            else
            {
                if (auxLista.Count() == 0)
                {
                    _nuevo.EsPredet = true;
                }
                _nuevo.ID = _nuevo.Etiqueta;
                auxLista.Add(_nuevo);
                IO.writeObjectAsJson(file, auxLista);
            }
        }
示例#3
0
        public static bool guardar(CalibracionFot _nuevo, bool esRef)
        {
            var auxLista = lista();

            auxLista.Add(_nuevo);
            if (esRef)
            {
                if (hayReferencia(_nuevo.Equipo, _nuevo.Energia, _nuevo.DFSoISO))
                {
                    if (MessageBox.Show("Ya existe una referencia \n ¿Desea continuar?", "Establecer Referencia", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        establecerComoReferencia(_nuevo, auxLista);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    establecerComoReferencia(_nuevo, auxLista);
                }
            }
            IO.writeObjectAsJson(file, auxLista);
            return(true);
        }
示例#4
0
        public static void hacerPredeterminado(DataGridView DGV)
        {
            if (DGV.SelectedRows.Count == 1)
            {
                foreach (DataGridViewRow fila in DGV.Rows)
                {
                    ((Equipo)fila.DataBoundItem).EsPredet = false;
                }

                ((Equipo)DGV.SelectedRows[0].DataBoundItem).EsPredet = true;
                IO.writeObjectAsJson(file, DGV.DataSource);
            }
        }
示例#5
0
        public static void exportarUnaCalibracion(CalibracionFot _nuevo)
        {
            try
            {
                string fileName = IO.GetUniqueFilename(@"..\..\", "calibracionesExportadas");
                IO.writeObjectAsJson(fileName, _nuevo);

                MessageBox.Show("Se ha exportado la calibracion correctamente", "Exportar");
            }
            catch (Exception e)
            {
                MessageBox.Show("Ha ocurrido un error. No se ha podido exportar: " + e.ToString());
            }
        }
示例#6
0
        public static void agregarImportados(BindingList <CalibracionFot> listaFiltrada)
        {
            BindingList <CalibracionFot> listaAux = lista();

            try
            {
                foreach (CalibracionFot cali in listaFiltrada)
                {
                    cali.EsReferencia = false; //las calibraciones importadas no entran como referencia
                    listaAux.Add(cali);
                }
                MessageBox.Show("Se han agregado " + listaFiltrada.Count().ToString() + " calibraciones");
                IO.writeObjectAsJson(file, listaAux);
            }
            catch (Exception)
            {
                MessageBox.Show("Ha ocurrido un error. No se han podido importar");
                throw;
            }
        }
示例#7
0
 public static void exportar(DataGridView DGV)
 {
     try
     {
         if (DGV.SelectedRows.Count > 0)
         {
             List <Equipo> listaAExportar = new List <Equipo>();
             string        fileName       = IO.GetUniqueFilename(@"..\..\", "equiposExportados");
             foreach (DataGridViewRow fila in DGV.SelectedRows)
             {
                 listaAExportar.Add((Equipo)fila.DataBoundItem);
             }
             IO.writeObjectAsJson(fileName, listaAExportar);
         }
         MessageBox.Show("Se han exportado " + DGV.SelectedRows.Count.ToString() + " equipos correctamente", "Exportar");
     }
     catch (Exception e)
     {
         MessageBox.Show("Ha ocurrido un error. No se ha podido exportar\n" + e.ToString());
     }
 }
示例#8
0
 public static void agregarImportados(BindingList <Equipo> listaFiltrada, DataGridView DGV)
 {
     try
     {
         foreach (Equipo eq in listaFiltrada)
         {
             eq.EsPredet = false;
             ((BindingList <Equipo>)DGV.DataSource).Add(eq);
         }
         if (DGV.Rows.Count == listaFiltrada.Count()) //no había elementos antes
         {
             ((BindingList <Equipo>)DGV.DataSource).ElementAt(0).EsPredet = true;
         }
         MessageBox.Show("Se han agregado " + listaFiltrada.Count().ToString() + " equipos");
         IO.writeObjectAsJson(file, DGV.DataSource);
     }
     catch (Exception)
     {
         MessageBox.Show("Ha ocurrido un error. No se han podido importar");
         throw;
     }
 }
示例#9
0
 public static void guardar(Camara _nuevo, bool edita, DataGridView DGV)
 {
     if (edita)
     {
         int indice = DGV.SelectedRows[0].Index;
         DGV.Rows.Remove(DGV.SelectedRows[0]); IO.writeObjectAsJson(file, DGV.DataSource);
         var auxLista = lista();
         auxLista.Insert(indice, _nuevo);
         IO.writeObjectAsJson(file, auxLista);
         DGV.DataSource = lista();
         DGV.ClearSelection();
         DGV.Rows[indice].Selected = true;
         edita = false;
     }
     else
     {
         var auxLista = lista();
         auxLista.Add(_nuevo);
         IO.writeObjectAsJson(file, auxLista);
         DGV.DataSource = lista();
     }
 }
示例#10
0
        public static void hacerReferencia(DataGridView DGV)
        {
            var            auxLista = lista();
            CalibracionFot cali     = (CalibracionFot)DGV.SelectedRows[0].DataBoundItem;

            if (cali.EsReferencia)
            {
                return;
            }
            if (hayReferencia(cali.Equipo, cali.Energia, cali.DFSoISO))
            {
                if (MessageBox.Show("Ya existe una referencia \n ¿Desea continuar?", "Establecer Referencia", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    establecerComoReferencia(cali, auxLista);
                }
            }
            else
            {
                establecerComoReferencia(cali, auxLista);
            }
            IO.writeObjectAsJson(file, auxLista);
        }
示例#11
0
 public static void guardar(Equipo _nuevo, bool edita, DataGridView DGV)
 {
     if (edita)
     {
         string IDvieja = ((Equipo)DGV.SelectedRows[0].DataBoundItem).ID;
         int    indice  = DGV.SelectedRows[0].Index;
         if (((Equipo)DGV.SelectedRows[0].DataBoundItem).EsPredet)
         {
             _nuevo.EsPredet = true;
         }
         DGV.Rows.Remove(DGV.Rows[indice]); IO.writeObjectAsJson(file, DGV.DataSource);
         var auxLista = lista();
         if (auxLista.Count() == 0)
         {
             _nuevo.EsPredet = true;
         }
         _nuevo.ID = IDvieja;
         auxLista.Insert(indice, _nuevo);
         IO.writeObjectAsJson(file, auxLista);
         DGV.DataSource = lista();
         DGV.ClearSelection();
         DGV.Rows[indice].Selected = true;
         edita = false;
     }
     else
     {
         var auxLista = lista();
         if (auxLista.Count() == 0)
         {
             _nuevo.EsPredet = true;
         }
         _nuevo.ID = _nuevo.Etiqueta;
         auxLista.Add(_nuevo);
         IO.writeObjectAsJson(file, auxLista);
         DGV.DataSource = lista();
     }
 }
示例#12
0
        public static void eliminar(DataGridView DGV)
        {
            string mensaje = "¿Desea borrar el/los registro/s?";

            if (DGV.SelectedRows.Count > 0)
            {
                foreach (DataGridViewRow fila in DGV.SelectedRows)
                {
                    if (SistemaDosimetrico.lista().FirstOrDefault(s => s.camara.Equals(lista()[fila.Index])) != null)
                    {
                        mensaje = "Al menos una de las cámaras seleccionadas pertenece a un sistema dosimétrico \n ¿Desea borrar el/los registro/s?";
                    }
                }
                if (MessageBox.Show(mensaje, "Eliminar", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    foreach (DataGridViewRow fila in DGV.SelectedRows)
                    {
                        DGV.Rows.Remove(fila);
                    }
                    IO.writeObjectAsJson(file, DGV.DataSource);
                }
                ;
            }
        }
示例#13
0
 private void escribirArchivoJson(List <Camaras398FotyElec> lista, string path)
 {
     IO.writeObjectAsJson(path, lista);
 }