Esempio n. 1
0
 private void BtnActualizar_Click(object sender, EventArgs e)
 {
     if (BtnActualizar.Text == "Actualizar")
     {
         BtnActualizar.Text = "ActualizarDG";
         Limpiar();
         LLenardg();
         Blackouts.Blackouts = Blackouts.Blackouts.OrderBy(x => x.BlackoutBeginning).ToList();
         JsonLoader <ListOfBlackouts> .UpdateData(Blackouts, Path);
     }
     else if (BtnActualizar.Text == "ActualizarDG")
     {
         BtnActualizar.Text = "Actualizar";
         Limpiar();
         Llenar();
         Blackouts.Blackouts = Blackouts.Blackouts.OrderBy(x => x.BlackoutBeginning).ToList();
         JsonLoader <ListOfBlackouts> .UpdateData(Blackouts, Path);
     }
 }
Esempio n. 2
0
        private void BtnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "Blackout Calendar", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (Opcion == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in DGFechas.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            if (row.Cells[1].Value.ToString() != "")
                            {
                                int codigo = int.Parse(Convert.ToString(row.Cells[1].Value));

                                Blackouts.Blackouts.RemoveAt(codigo);
                                Blackouts.Blackouts = Blackouts.Blackouts.OrderBy(x => x.BlackoutBeginning).ToList();
                                JsonLoader <ListOfBlackouts> .UpdateData(Blackouts, Path);

                                Limpiar();
                                Llenar();

                                MessageBox.Show("Se Eliminó Correctamente el registro");
                            }
                            else
                            {
                                MessageBox.Show("Los dias que no tienen registrado un apagon no se pueden eliminar");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 3
0
        private void BtnNuevo_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.InitialDirectory = @"C:\";
                sfd.RestoreDirectory = true;
                sfd.FileName         = "*.json";
                sfd.DefaultExt       = "json";
                sfd.Filter           = "Json Files (*.json)|*.json";

                String Jsonstring = JsonConvert.SerializeObject(VoidBlackouts);

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    using (FileStream fs = (FileStream)sfd.OpenFile())
                    {
                        Byte[] Info = new UTF8Encoding(true).GetBytes(Jsonstring);
                        fs.Write(Info, 0, Info.Length);
                    }

                    MessageBox.Show("The json file has been created in  " +
                                    sfd.FileName);

                    Blackouts = JsonLoader <ListOfBlackouts> .LoadData(sfd.FileName);

                    Calendario Frm = new Calendario();
                    Frm.Blackouts = Blackouts;
                    Frm.Path      = sfd.FileName;
                    Frm.Show();
                    Hide();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }