private void Button_Clicked(object sender, EventArgs e) { Cosecha cosecha = new Cosecha(); cosecha.id = "0"; Navigation.PushAsync(new RegistrarCosecha(asociado, cosecha, cultivo.id_cultivo)); }
public async Task <ApiResponse> update(string token, string id, string cultivoIdCultivo, string asociadoIdAsociado, DateTime fecha_inicio_cosecha, DateTime fecha_fin_cosecha, float kg_cosechados, float kg_cosechados_bien, float costo_total_cosecha) { Cosecha cosecha = new Cosecha() { id = id, cultivoIdCultivo = cultivoIdCultivo, asociadoIdAsociado = asociadoIdAsociado, fecha_inicio_cosecha = fecha_inicio_cosecha, fecha_fin_cosecha = fecha_fin_cosecha, kg_cosechados = kg_cosechados, kg_cosechados_bien = kg_cosechados_bien, costo_total_cosecha = costo_total_cosecha }; HttpClient client = await get(); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var response = await client.PutAsync(url + "/UpdateCosecha/" + id, new StringContent(JsonConvert.SerializeObject(cosecha), Encoding.UTF8, "application/json")); ApiResponse apiResponse = new ApiResponse(); apiResponse.code = response.StatusCode.ToString(); apiResponse.message = await response.Content.ReadAsStringAsync(); return(apiResponse); }
public RegistrarCosecha(LoginResponseDto aso, Cosecha cose, string idCultivo) { InitializeComponent(); asociado = aso; cosecha = cose; cultivoId = idCultivo; if (cosecha.id != "0") { llenarDatosCultivo(); } }
protected void btn6papasGuardar_Click(object sender, EventArgs e) { try { this.lbl6papasError.Visible = true; int invalido = 0; int selected = this.gdv6papas.SelectedIndex; string id_cosecha = HttpUtility.HtmlDecode((string)this.gdv6papas.Rows[selected].Cells[2].Text); string cantidad_papas = this.txt6papasCantidadPapas.Text; if ((EsNumero(cantidad_papas) == true && (Int32.Parse(cantidad_papas) < 0 || Int32.Parse(cantidad_papas) > 6)) || (EsNumero(cantidad_papas) == false)) { invalido = 1; } //Reemplaza las comas por los puntos para agregar el valor tipo double en la base de datos string posicion_cosecha = this.txt6papasPosicion.Text.Replace(",", "."); try { double posicion_cosechaDouble = double.Parse(posicion_cosecha, System.Globalization.CultureInfo.InvariantCulture); if (posicion_cosechaDouble < 0 || posicion_cosechaDouble > 99.99) { invalido = 1; } } catch (Exception exTotal) { invalido = 1; } bool flor_cosecha = false; if (this.chk6papasFlor.Checked == true) { flor_cosecha = true; } else { flor_cosecha = false; } bool bayas_cosecha = false; if (this.chk6papasBayas.Checked == true) { bayas_cosecha = true; } else { bayas_cosecha = false; } string id_fertilidad = this.ddl6papasFertilidad.SelectedValue; string id_emergencia40 = this.ddl6papasEmergencia40.SelectedValue; string id_metribuzina = this.ddl6papasMetribuzina.SelectedValue; string id_emergencia = this.ddl6papasEmergencia.SelectedValue; string id_madurez = this.ddl6papasMadurez.SelectedValue; string id_desarrollo = this.ddl6papasDesarrollo.SelectedValue; string id_tipo_hoja = this.ddl6papasTipoHoja.SelectedValue; string id_brotacion = this.ddl6papasBrotacion.SelectedValue; string id_tamaño = this.ddl6papasTamaño.SelectedValue; string id_distribucion = this.ddl6papasDistribucion.SelectedValue; string id_forma = this.ddl6papasForma.SelectedValue; string id_regularidad = this.ddl6papasRegularidad.SelectedValue; string id_profundidad = this.ddl6papasProfundidad.SelectedValue; string id_calidad = this.ddl6papasCalidadPiel.SelectedValue; string id_verdes = this.ddl6papasTuberculosVerdes.SelectedValue; string id_tizon_follaje = this.ddl6papasTizonFollaje.SelectedValue; string id_tizon_tuberculo = this.ddl6papasTizonTuberculo.SelectedValue; string id_numero = this.ddl6papasNumero.SelectedValue; string id_ciudad = this.ddl6papasCiudadPlantacion.SelectedValue; string total_kg = this.txt6papasTotalKg.Text.Replace(",", "."); try { double total_kgDouble = double.Parse(total_kg, System.Globalization.CultureInfo.InvariantCulture); if (total_kgDouble < 0 || total_kgDouble > 99999.99) { invalido = 1; } } catch (Exception exTotal) { invalido = 1; } string tuberculos_planta = this.txt6papasTuberculosPlanta.Text.Replace(",", "."); try { double tuberculos_plantaDouble = double.Parse(tuberculos_planta, System.Globalization.CultureInfo.InvariantCulture); if (tuberculos_plantaDouble < 0 || tuberculos_plantaDouble > 999.99) { invalido = 1; } } catch (Exception exTotal) { invalido = 1; } string toneladas_hectarea = this.txt6papasToneladasHectarea.Text.Replace(",", "."); try { double toneladas_hectareaDouble = double.Parse(toneladas_hectarea, System.Globalization.CultureInfo.InvariantCulture); if (toneladas_hectareaDouble < 0 || toneladas_hectareaDouble > 9999.99) { invalido = 1; } } catch (Exception exTotal) { invalido = 1; } string porcentaje_relacion = this.txt6papasRelacionStandard.Text.Replace("%", ""); if ((EsNumero(porcentaje_relacion) == true && (Int32.Parse(porcentaje_relacion) < 0 || Int32.Parse(porcentaje_relacion) > 999)) || (EsNumero(porcentaje_relacion) == false)) { invalido = 1; } string consumo = this.txt6papasConsumo.Text; if ((EsNumero(consumo) == true && (Int32.Parse(consumo) < 0 || Int32.Parse(consumo) > 99)) || (EsNumero(consumo) == false)) { invalido = 1; } string semillon = this.txt6papasSemillon.Text; if ((EsNumero(semillon) == true && (Int32.Parse(semillon) < 0 || Int32.Parse(semillon) > 99)) || (EsNumero(semillon) == false)) { invalido = 1; } string semilla = this.txt6papasSemilla.Text; if ((EsNumero(semilla) == true && (Int32.Parse(semilla) < 0 || Int32.Parse(semilla) > 99)) || (EsNumero(semilla) == false)) { invalido = 1; } string semillita = this.txt6papasSemillita.Text; if ((EsNumero(semillita) == true && (Int32.Parse(semillita) < 0 || Int32.Parse(semillita) > 99)) || (EsNumero(semillita) == false)) { invalido = 1; } string bajo_calibre = this.txt6papasBajoCalibre.Text; if ((EsNumero(bajo_calibre) == true && (Int32.Parse(bajo_calibre) < 0 || Int32.Parse(bajo_calibre) > 99)) || (EsNumero(bajo_calibre) == false)) { invalido = 1; } string numero_tallos = this.txt6papasNumeroTallos.Text; if ((EsNumero(numero_tallos) == true && (Int32.Parse(numero_tallos) < 0 || Int32.Parse(numero_tallos) > 99)) || (EsNumero(numero_tallos) == false)) { invalido = 1; } string id_sensibildiad_quimica = this.ddl6papasSensibilidadQuimica.SelectedValue; string id_facilidad_muerte = this.ddl6papasFacilidadMuerte.SelectedValue; string dormancia = this.txt6papasDormancia.Text; if ((EsNumero(dormancia) == true && (Int32.Parse(dormancia) < 0 || Int32.Parse(dormancia) > 99)) || (EsNumero(dormancia) == false)) { invalido = 1; } string tolerancia_sequia = this.txt6papasToleranciaSequia.Text; if ((EsNumero(tolerancia_sequia) == true && (Int32.Parse(tolerancia_sequia) < 0 || Int32.Parse(tolerancia_sequia) > 99)) || (EsNumero(tolerancia_sequia) == false)) { invalido = 1; } string tolerancia_calor = this.txt6papasToleranciaCalor.Text; if ((EsNumero(tolerancia_calor) == true && (Int32.Parse(tolerancia_calor) < 0 || Int32.Parse(tolerancia_calor) > 99)) || (EsNumero(tolerancia_calor) == false)) { invalido = 1; } string tolerancia_sal = this.txt6papasToleranciaSal.Text; if ((EsNumero(tolerancia_sal) == true && (Int32.Parse(tolerancia_sal) < 0 || Int32.Parse(tolerancia_sal) > 99)) || (EsNumero(tolerancia_sal) == false)) { invalido = 1; } string daño_cosecha = this.txt6papasDañoCosecha.Text; if ((EsNumero(daño_cosecha) == true && (Int32.Parse(daño_cosecha) < 0 || Int32.Parse(daño_cosecha) > 99)) || (EsNumero(daño_cosecha) == false)) { invalido = 1; } string tizon_hoja = this.txt6papasTizonHoja.Text; if ((EsNumero(tizon_hoja) == true && (Int32.Parse(tizon_hoja) < 0 || Int32.Parse(tizon_hoja) > 99)) || (EsNumero(tizon_hoja) == false)) { invalido = 1; } string putrefaccion_suave = this.txt6papasPutrefaccionSuave.Text; if ((EsNumero(putrefaccion_suave) == true && (Int32.Parse(putrefaccion_suave) < 0 || Int32.Parse(putrefaccion_suave) > 99)) || (EsNumero(putrefaccion_suave) == false)) { invalido = 1; } string putrefaccion_rosa = this.txt6papasPutrefaccionRosa.Text; if ((EsNumero(putrefaccion_rosa) == true && (Int32.Parse(putrefaccion_rosa) < 0 || Int32.Parse(putrefaccion_rosa) > 99)) || (EsNumero(putrefaccion_rosa) == false)) { invalido = 1; } string silver_scurf = this.txt6papasSilverScurf.Text; if ((EsNumero(silver_scurf) == true && (Int32.Parse(silver_scurf) < 0 || Int32.Parse(silver_scurf) > 99)) || (EsNumero(silver_scurf) == false)) { invalido = 1; } string blackleg = this.txt6papasBlackleg.Text; if ((EsNumero(blackleg) == true && (Int32.Parse(blackleg) < 0 || Int32.Parse(blackleg) > 99)) || (EsNumero(blackleg) == false)) { invalido = 1; } if (invalido == 0) { CatalogCosecha cc = new CatalogCosecha(); Cosecha cosecha = new Cosecha(Int32.Parse(id_cosecha), Int32.Parse(cantidad_papas), Double.Parse(posicion_cosecha, CultureInfo.InvariantCulture), flor_cosecha, bayas_cosecha, Int32.Parse(id_fertilidad), Int32.Parse(id_emergencia40), Int32.Parse(id_metribuzina), Int32.Parse(id_emergencia), Int32.Parse(id_madurez), Int32.Parse(id_desarrollo), Int32.Parse(id_tipo_hoja), Int32.Parse(id_brotacion), Int32.Parse(id_tamaño), Int32.Parse(id_distribucion), Int32.Parse(id_forma), Int32.Parse(id_regularidad), Int32.Parse(id_profundidad), Int32.Parse(id_calidad), Int32.Parse(id_verdes), Int32.Parse(id_tizon_follaje), Int32.Parse(id_tizon_tuberculo), Int32.Parse(id_numero), Int32.Parse(id_ciudad), Double.Parse(total_kg, CultureInfo.InvariantCulture), Double.Parse(tuberculos_planta, CultureInfo.InvariantCulture), Double.Parse(toneladas_hectarea, CultureInfo.InvariantCulture), Int32.Parse(porcentaje_relacion), Int32.Parse(consumo), Int32.Parse(semillon), Int32.Parse(semilla), Int32.Parse(semillita), Int32.Parse(bajo_calibre), Int32.Parse(numero_tallos), Int32.Parse(id_sensibildiad_quimica), Int32.Parse(id_facilidad_muerte), Int32.Parse(dormancia), Int32.Parse(tolerancia_sequia), Int32.Parse(tolerancia_calor), Int32.Parse(tolerancia_sal), Int32.Parse(daño_cosecha), Int32.Parse(tizon_hoja), Int32.Parse(putrefaccion_suave), Int32.Parse(putrefaccion_rosa), Int32.Parse(silver_scurf), Int32.Parse(blackleg)); //Modifica Color Carne List <int> selectedCarne = this.lst6papasColorCarne.GetSelectedIndices().ToList(); if ((selectedCarne.Count > 1 && !selectedCarne[0].Equals(0)) || (selectedCarne.Count == 1)) { cc.DeleteCosechaColorCarne(Int32.Parse(id_cosecha)); for (int i = 0; i < selectedCarne.Count; i++) { string id_color_carne = this.lst6papasColorCarne.Items[selectedCarne[i]].Value; cc.UpdateCosechaColorCarne(Int32.Parse(id_color_carne), Int32.Parse(id_cosecha)); } } else { this.lbl6papasError.Text += "No puede seleccionar sin información y colores de la carne a la vez.<br/>"; } //Modifica Color Piel List <int> selectedPiel = this.lst6papasColorPiel.GetSelectedIndices().ToList(); if ((selectedPiel.Count > 1 && !selectedPiel[0].Equals(0)) || (selectedPiel.Count == 1)) { cc.DeleteCosechaColorPiel(Int32.Parse(id_cosecha)); for (int i = 0; i < selectedPiel.Count; i++) { string id_color_piel = this.lst6papasColorPiel.Items[selectedPiel[i]].Value; cc.UpdateCosechaColorPiel(Int32.Parse(id_color_piel), Int32.Parse(id_cosecha)); } } else { this.lbl6papasError.Text += "No puede seleccionar sin información y colores de la piel a la vez.<br/>"; } //Modifica Cosecha 6 papas int valor = cc.UpdateCosecha6papas(cosecha); if (valor == 0) { this.lbl6papasError.Text += "Debe seleccionar una ciudad para la variedad o la posición indicada ya existe.<br/>"; Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Debe seleccionar una ciudad o ya hay una variedad asignada en esa posición!')</script>"); } } else { this.lbl6papasError.Text += "Error al modificar, Revise los parámetros indicados y modifiquelos.<br/>"; Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Datos incorrectos! Revise los parámetros indicados y modifique su valor')</script>"); } } catch (Exception ex) { this.lbl6papasError.Text += "ERROR CRÍTICO, NO SE HA PODIDO MODIFICAR LA VARIEDAD, ARREGLE LOS PARÁMETROS E INTENTELO NUEVAMENTE.<br/>"; Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error al modificar! No se ha podido actualizar la variedad')</script>"); } PoblarGrilla(); }