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() ); } } }
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"); } }
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"); } }
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() ); } } }
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"); } }
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"); } }
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"); } }
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"); } }
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(); } } }
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"); } }
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()); } } }
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(); }
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() * * * * ); * }*/ }
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(); }