Example #1
0
        private void BtnNuevoEvento_Click(object sender, EventArgs e)
        {
            cbUsuarios.Enabled     = true;
            cbTipoCultivo.Enabled  = true;
            cbTipoEvento.Enabled   = true;
            dtpFechaEvento.Enabled = true;


            Persistencia pd = new Persistencia();
            DataTable    ds = pd.BuscarDatos("Usuarios");
            DataTable    dsTiposCultivos = pd.BuscarDatos("Cultivos");

            cbUsuarios.Items.Clear();
            if (ds != null)
            {
                for (int j = 0; j < ds.Rows.Count; j++)
                {
                    cbUsuarios.Items.Add(ds.Rows[j][1].ToString() + ", " + ds.Rows[j][2]);
                }
            }
            if (dsTiposCultivos != null)
            {
                cbTipoCultivo.Items.Clear();
                for (int j = 0; j < dsTiposCultivos.Rows.Count; j++)
                {
                    cbTipoCultivo.Items.Add(
                        dsTiposCultivos.Rows[j][0].ToString()
                        );
                }
            }
        }
Example #2
0
        private void BtnConfirmar_Click(object sender, EventArgs e)
        {
            if (txtCorreo.Text != "" && txtApellido.Text != "" && TxtNombre.Text != "")
            {
                Persistencia pd = new Persistencia();
                DataTable    ds = pd.BuscarDatos("usuarios");
                for (int j = 0; j < ds.Rows.Count; j++)
                {
                    string user     = ds.Rows[j][0].ToString();
                    string apellido = ds.Rows[j][1].ToString();
                    string nombre   = ds.Rows[j][2].ToString();
                    if (txtCorreo.Text.Equals(user) &&
                        txtApellido.Text.Equals(apellido) &&
                        TxtNombre.Text.Equals(nombre))
                    {
                        lblClave.Text = ds.Rows[j][4].ToString();
                    }
                }
            }

            else
            {
                MessageBox.Show("Debe completar los campos");
            }
        }
Example #3
0
        public void ListarEventos()
        {
            Persistencia pd = new Persistencia();
            DataTable    dsTiposCultivos = pd.BuscarDatos("eventos");

            try
            {
                dataGridView1.RowCount = 1;
                for (int j = 0; j < dsTiposCultivos.Rows.Count; j++)
                {
                    dataGridView1.Rows.Add(

                        dsTiposCultivos.Rows[j][0].ToString(),
                        dsTiposCultivos.Rows[j][1].ToString(),
                        dsTiposCultivos.Rows[j][2].ToString(),
                        dsTiposCultivos.Rows[j][3].ToString(),
                        dsTiposCultivos.Rows[j][4].ToString(),
                        dsTiposCultivos.Rows[j][5].ToString(),
                        dsTiposCultivos.Rows[j][6].ToString(),
                        dsTiposCultivos.Rows[j][7].ToString()
                        );
                }
            }
            catch (Exception)
            {
                Console.WriteLine("No se pueden generar eventos sin antes cargar Cultivos");
            }
        }
Example #4
0
        private void Seguimiento_Load(object sender, EventArgs e)
        {
            ListarEventos();
            Persistencia pd = new Persistencia();
            DataTable    ds = pd.BuscarDatos("usuarios");

            cbUsuarios.Items.Clear();
            if (ds != null)
            {
                for (int j = 0; j < ds.Rows.Count; j++)
                {
                    cbUsuarios.Items.Add(ds.Rows[j][1].ToString() + ", " + ds.Rows[j][2]);
                }
            }

            Persistencia persist         = new Persistencia();
            DataTable    dsTiposCultivos = persist.BuscarDatos("cultivos");

            if (dsTiposCultivos != null)
            {
                cbTipoCultivo.Items.Clear();
                for (int j = 0; j < dsTiposCultivos.Rows.Count; j++)
                {
                    cbTipoCultivo.Items.Add(
                        dsTiposCultivos.Rows[j][0].ToString()
                        );
                }
            }
        }
Example #5
0
 private void BtnAceptar_Click(object sender, EventArgs e)
 {
     //Verificar usuario ingresado.
     if (txtCorreo.Text != "" && txtClave.Text != "")
     {
         try
         {
             Persistencia pd = new Persistencia();
             DataTable    ds = pd.BuscarDatos("usuarios");
             for (int j = 0; j < ds.Rows.Count; j++)
             {
                 string user = ds.Rows[j][0].ToString();
                 string pass = ds.Rows[j][4].ToString();
                 if (txtCorreo.Text.Equals(user) &&
                     txtClave.Text.Equals(pass))
                 {
                     MenuInicial mi = new MenuInicial();
                     mi.Show();
                     this.Close();
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Debe generar antes un usuario.");
         }
     }
     else
     {
         MessageBox.Show("Debe ingresar los datos");
     }
 }
Example #6
0
 private void BtnEntrar_Click(object sender, EventArgs e)
 {
     //Verificar usuario ingresado.
     if (txtDNI.Text != "" && txtPass.Text != "")
     {
         Persistencia pd = new Persistencia();
         DataSet      ds = pd.BuscarDatos("Usuarios");
         for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
         {
             string dni  = ds.Tables[0].Rows[j][5].ToString();
             string pass = ds.Tables[0].Rows[j][4].ToString();
             if (txtDNI.Text.Equals(dni) &&
                 txtPass.Text.Equals(pass))
             {
                 MessageBox.Show("Encontrado");
                 //MenuInicial mi = new MenuInicial();
                 //mi.Show();
             }
         }
     }
     else
     {
         MessageBox.Show("Debe ingresar los datos");
     }
 }
Example #7
0
 private void BtnEntrar_Click(object sender, EventArgs e)
 {
     if (txtDNI.Text != "" && txtPass.Text != "")
     {
         Persistencia pd = new Persistencia();
         DataSet      ds = pd.BuscarDatos("Cuentas");
         for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
         {
             string dni  = ds.Tables[0].Rows[j][5].ToString();
             string pass = ds.Tables[0].Rows[j][4].ToString();
             if (txtDNI.Text.Equals(dni) &&
                 txtPass.Text.Equals(pass))
             {
                 this.Dispose();
                 this.Close();
                 frm_plataforma perfil = new frm_plataforma(dni);
                 perfil.ShowDialog();
             }
         }
     }
     else
     {
         MessageBox.Show("Debe ingresar los datos");
     }
 }
Example #8
0
        public void ListarEventos()
        {
            Persistencia pd = new Persistencia();
            DataTable    dsTiposCultivos = pd.BuscarDatos("cultivos");

            try
            {
                dataGridView1.RowCount = 1;
                for (int j = 0; j < dsTiposCultivos.Rows.Count; j++)
                {
                    dataGridView1.Rows.Add(

                        dsTiposCultivos.Rows[j][0].ToString(),
                        dsTiposCultivos.Rows[j][1].ToString(),
                        dsTiposCultivos.Rows[j][2].ToString(),
                        dsTiposCultivos.Rows[j][3].ToString(),
                        dsTiposCultivos.Rows[j][4].ToString(),
                        dsTiposCultivos.Rows[j][5].ToString()
                        );
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Fin de arreglo");
            }
        }
Example #9
0
        public void AlarmasViejas()
        {
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                bool check = (bool)dataGridView1.Rows[i].Cells[4].Value;

                if (check == true)
                {
                    string[] alarmaVieja =
                    {
                        dataGridView1.Rows[i].Cells[0].Value.ToString(),
                        dataGridView1.Rows[i].Cells[1].Value.ToString(),
                        dataGridView1.Rows[i].Cells[2].Value.ToString(),
                        dataGridView1.Rows[i].Cells[3].Value.ToString()
                    };

                    dataGridView2.Rows.Add(alarmaVieja);
                    dataGridView1.Rows.RemoveAt(i);

                    string[]     columnas2 = { "TipoCultivo", "NombreAlerta", "FechaAlerta", "FinAlerta" };
                    Persistencia pdviejo   = new Persistencia(4, columnas2, "alertasViejas");
                    pdviejo.CargaDatos(alarmaVieja, 4, columnas2);
                    Persistencia pd          = new Persistencia("alertas");
                    DataTable    borraAlarma = pd.BuscarDatos("alertas");
                    borraAlarma.Rows.RemoveAt(i);
                    pd.GrabarArchivo();
                }
            }
        }
Example #10
0
        public void ListarAlertas()
        {
            Persistencia pd             = new Persistencia();
            DataTable    dsTiposAlarmas = pd.BuscarDatos("alertas");

            try
            {
                dataGridView1.RowCount = 1;
                for (int j = 0; j < dsTiposAlarmas.Rows.Count; j++)
                {
                    dataGridView1.Rows.Add(

                        dsTiposAlarmas.Rows[j][0].ToString(),
                        dsTiposAlarmas.Rows[j][1].ToString(),
                        dsTiposAlarmas.Rows[j][2].ToString(),
                        dsTiposAlarmas.Rows[j][3].ToString(),
                        false
                        );
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudieron generar las alertas");
            }
        }
Example #11
0
        private void Alarma_Load(object sender, EventArgs e)
        {
            ListarAlertas();

            Persistencia pd2 = new Persistencia();
            DataTable    tableAlarmasViejas = pd2.BuscarDatos("alertasViejas");

            dataGridView2.RowCount = 1;
            if (tableAlarmasViejas != null)
            {
                for (int j = 0; j < tableAlarmasViejas.Rows.Count; j++)
                {
                    dataGridView2.Rows.Add(

                        tableAlarmasViejas.Rows[j][0].ToString(),
                        tableAlarmasViejas.Rows[j][1].ToString(),
                        tableAlarmasViejas.Rows[j][2].ToString(),
                        tableAlarmasViejas.Rows[j][3].ToString()
                        );
                }
            }

            Persistencia pd = new Persistencia();
            DataTable    ds = pd.BuscarDatos("cultivos");

            comboBoxCultivo.Items.Clear();
            if (ds != null)
            {
                for (int j = 0; j < ds.Rows.Count; j++)
                {
                    comboBoxCultivo.Items.Add(ds.Rows[j][0].ToString());
                }
            }
        }
Example #12
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Registros registro = new Registros();

            registro.Usuario.DNI = "aca va el textbox o label con el dato del usuaario";
            Persistencia pd = new Persistencia();
            DataSet      ds = pd.BuscarDatos("Usuarios");

            frm_bienvenida InicioScan = new frm_bienvenida(registro);

            InicioScan.Show();
        }
Example #13
0
        private void Form_Seguimiento_Load(object sender, EventArgs e)
        {
            Persistencia pd = new Persistencia();
            //DataTable ds = pd.BuscarDatos("Usuarios");
            DataTable dsTiposCultivos = pd.BuscarDatos("Cultivos");
            // cbUsuarios.Items.Clear();

            //Comento este ciclo for por que tira error fuera de rango.

/*
 *          for (int j = 0; j < dsTiposCultivos.Rows.Count; j++)
 *          {
 *              dataGridView1.Rows.Add(
 *
 *                      dsTiposCultivos.Rows[j][0].ToString(),
 *                      dsTiposCultivos.Rows[j][1].ToString(),
 *                      dsTiposCultivos.Rows[j][2].ToString(),
 *                      dsTiposCultivos.Rows[j][3].ToString()
 *
 *
 *
 *                    );
 *          }*/
        }
Example #14
0
        private void BtnAgregarEvento_Click(object sender, EventArgs e)
        {
            Persistencia per        = new Persistencia();
            DataTable    dtCultivos = per.BuscarDatos("cultivos");

            try
            {
                for (int j = 0; j < dtCultivos.Rows.Count; j++)
                {
                    if (dtCultivos.Rows[j][0].ToString().Equals(cbTipoCultivo.Text))
                    {
                        riego         = dtCultivos.Rows[j][2].ToString();
                        raleo         = dtCultivos.Rows[j][3].ToString();
                        fertilizacion = dtCultivos.Rows[j][4].ToString();
                        cosecha       = dtCultivos.Rows[j][5].ToString();
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("No se recuperaron los datos del cultivo seleccionado");
            }

            string[] columnas = { "Fecha", "TipoCultivo", "Responsable", "TipoEvento", "Riego", "Raleo", "Fertilización", "Cosecha" };

            DateTime FechaRiego         = DateTime.Now;
            DateTime FechaRaleo         = DateTime.Now;
            DateTime FechaFertilizacion = DateTime.Now;
            DateTime FechaCosecha       = DateTime.Now;

            Persistencia pd = new Persistencia(8, columnas, "eventos");

            string[] datos =
            {
                dtpFechaEvento.Value.ToString(),
                cbTipoCultivo.Text,
                cbUsuarios.Text,
                "Siembra",
                FechaRiego.AddDays(Convert.ToDouble(riego)).ToShortDateString(),
                FechaRaleo.AddDays(Convert.ToDouble(raleo)).ToShortDateString(),
                FechaFertilizacion.AddDays(Convert.ToDouble(fertilizacion)).ToShortDateString(),
                FechaCosecha.AddDays(Convert.ToDouble(cosecha)).ToShortDateString()
            };

            pd.CargaDatos(datos, 8, columnas);



            string[]     columnas2         = { "TipoCultivo", "NombreAlerta", "FechaAlerta", "FinAlerta" };
            Persistencia pd2               = new Persistencia(4, columnas2, "alertas");
            DateTime     DateRiego         = new DateTime();
            DateTime     DateRaleo         = new DateTime();
            DateTime     DateSiembra       = new DateTime();
            DateTime     DateFertilizacion = new DateTime();

            DateRiego         = dtpFechaEvento.Value.AddDays(Convert.ToInt32(riego));
            DateRaleo         = dtpFechaEvento.Value.AddDays(Convert.ToInt32(raleo));
            DateFertilizacion = dtpFechaEvento.Value.AddDays(Convert.ToInt32(fertilizacion));
            DateSiembra       = dtpFechaEvento.Value.AddDays(Convert.ToInt32(cosecha));

            string[] alarma1 =
            {
                cbTipoCultivo.Text,
                "Riego",
                dtpFechaEvento.Value.ToString(),
                DateRiego.ToString(),
            };
            string[] alarma2 =
            {
                cbTipoCultivo.Text,
                "Raleo",
                dtpFechaEvento.Value.ToString(),
                DateRaleo.ToString(),
            };
            string[] alarma3 =
            {
                cbTipoCultivo.Text,
                "Fertilizacion",
                dtpFechaEvento.Value.ToString(),
                DateFertilizacion.ToString(),
            };
            string[] alarma4 =
            {
                cbTipoCultivo.Text,
                "Cosecha",
                dtpFechaEvento.Value.ToString(),
                DateSiembra.ToString(),
            };

            pd2.CargaDatos(alarma1, 4, columnas2);
            pd2.CargaDatos(alarma2, 4, columnas2);
            pd2.CargaDatos(alarma3, 4, columnas2);
            pd2.CargaDatos(alarma4, 4, columnas2);

            MessageBox.Show("Se generaron las alarmas correspondientes");

            ListarEventos();
        }