private void btnInseminacion_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtAreteInseminacion.Text) || !string.IsNullOrWhiteSpace(txtAreteInseminacion.Text)) { Swine swine = new Swine(); Main main = new Main(); string arete = txtAreteInseminacion.Text; swine = main.ExisteArete(arete); //Validar fechas anteriores /* * * DateTime fechaFalsaPreniez = dateTimePicker2.Value; * Birth newBirth = new Birth(); * newBirth = swine.partos.Last(); * if (!newBirth.getFechaFalsaPreniez().Equals("") && !newBirth.getFechaParto().Equals("")) * { * newBirth.setFechaFalsaPreniez(fechaFalsaPreniez.Date.ToString("dd-MM-yyyy")); * } */ if (swine.getArete() != null) { if (swine.partos.Count > 0) { DateTime now = DateTime.Now; Birth birth = swine.partos.Last(); string last = birth.getFechaInseminacion(); if (last.Equals("-")) { DateTime dateInseminacion = fechaInseminacion.Value; DateTime fechaConfirmacion21 = dateInseminacion.AddDays(21); DateTime fechaConfirmacion28 = dateInseminacion.AddDays(28); //DateTime fechaPosibleParto = dateInseminacion.AddDays(114); Birth newBirth = new Birth(); txtConfirmacion21.Text = fechaConfirmacion21.Date.ToString("dd-MM-yyyy"); txtConfirmacion28.Text = fechaConfirmacion28.Date.ToString("dd-MM-yyyy"); //txtPosibleParto.Text = fechaPosibleParto.Date.ToString("dd-MM-yyyy"); string lote = txtLote.Text; if (!string.IsNullOrEmpty(txtLote.Text) || !string.IsNullOrWhiteSpace(txtLote.Text)) { newBirth.setFechaInseminacion(dateInseminacion.Date.ToString("dd-MM-yyyy")); newBirth.setLote(lote); newBirth.setFechaConfirmacion21(fechaConfirmacion21.Date.ToString("dd-MM-yyyy")); newBirth.setFechaConfirmacion28(fechaConfirmacion28.Date.ToString("dd-MM-yyyy")); //newBirth.setFechaPosibleParto(fechaPosibleParto.Date.ToString("dd-MM-yyyy")); swine.partos.Add(newBirth); main.Update(swine); MessageBox.Show("Fecha de inseminación ingresada"); } else { MessageBox.Show("Debe ingresar el lote de la hembra"); } } else { MessageBox.Show("La hembra ya está inseminada, verifique fecha de confirmación"); } } else { DateTime dateInseminacion = fechaInseminacion.Value; DateTime fechaConfirmacion21 = dateInseminacion.AddDays(21); DateTime fechaConfirmacion28 = dateInseminacion.AddDays(28); Birth newBirth = new Birth(); txtConfirmacion21.Text = fechaConfirmacion21.Date.ToString("dd-MM-yyyy"); txtConfirmacion28.Text = fechaConfirmacion28.Date.ToString("dd-MM-yyyy"); string lote = txtLote.Text; if (!string.IsNullOrEmpty(txtLote.Text) || !string.IsNullOrWhiteSpace(txtLote.Text)) { newBirth.setFechaInseminacion(dateInseminacion.Date.ToString("dd-MM-yyyy")); newBirth.setLote(lote); newBirth.setFechaConfirmacion21(fechaConfirmacion21.Date.ToString("dd-MM-yyyy")); newBirth.setFechaConfirmacion28(fechaConfirmacion28.Date.ToString("dd-MM-yyyy")); swine.partos.Add(newBirth); main.Update(swine); MessageBox.Show("Fecha de inseminación ingresada"); } else { MessageBox.Show("Debe ingresar el lote de la hembra"); } } } else { MessageBox.Show("El número de arete que ingresó no existe"); } } else { MessageBox.Show("Debe ingresar el arete de una hembra para continuar"); } }