protected void BtnEnviar_Click(object sender, EventArgs e) { EXT_SeguimientoCoordenadas SegCoo = new EXT_SeguimientoCoordenadas(); DB_EXT_Seguimiento insSeg = new DB_EXT_Seguimiento(); EXT_SeguimientoParcela segParc = new EXT_SeguimientoParcela(); switch (LblEtapa.Text) { //case "VERIFICACION_PARCELA": case "VERIFICACION Y/O GEORREFERENCIACION DE PARCELA": //1. eliminamos las coordenadas insSeg.DB_Registrar_SEGUIMIENTO_COORDENADA_DELETE(Convert.ToInt32(LblIdSegParcela.Text)); //2. volvemos a insertar las coodenadas foreach (GridViewRow row in GVCoordenadas.Rows) { SegCoo.Id_Seguimiento_Parcela = Convert.ToInt32(LblIdSegParcela.Text); SegCoo.Id_Productor = lblId_Productor.Text; TextBox N_Parcela = (TextBox)row.FindControl("TxtNum_Parcela"); SegCoo.Num_Parcela = Convert.ToInt32(N_Parcela.Text); TextBox N_Punto = (TextBox)row.FindControl("TxtNum_Punto"); SegCoo.Num_Punto = Convert.ToInt32(N_Punto.Text); TextBox CoodenadaX = (TextBox)row.FindControl("TxtCoordX"); SegCoo.CoordenadaX = CoodenadaX.Text; TextBox CoodenadaY = (TextBox)row.FindControl("TxtCoordY"); SegCoo.CoordenadaY = CoodenadaY.Text; insSeg.DB_Registrar_SEGUIMIENTO_COORDENADA(SegCoo); } //3. Actualizamos Seguimiento Parcela segParc.Id_Seguimiento = Convert.ToInt32(LblNum.Text); //segParc.Boleta_Numero = Convert.ToInt32(TxtNumBoleta.Text); //segParc.Fecha_Seg = Convert.ToDateTime(TxtFecha.Text); //segParc.Hora_Seg = DDLHora.SelectedValue + ":" + DDLMinuto.SelectedValue; //segParc.Hora_Seg = string.Empty; //segParc.Fecha_Sis = DateTime.Now;//FECHA SE OBTENDRA DEL SERVER AL EJECUTAR SP segParc.Observacion = HttpUtility.HtmlDecode(txtObservacionCoordenadas.Text); segParc.Recomendacion = HttpUtility.HtmlDecode(txtRecomendacionCoordenadas.Text); insSeg.DB_Registrar_SEGUIMIENTO_PARCELA_UPDATE(segParc); break; //case "VERIFICACION_SIEMBRA": case "SEGUIMIENTO AL AVANCE DE SIEMBRA": //1. ELIMINAMOS SEGUIMIENTO SIEMBRA insSeg.DB_SEGUIMIENTO_SIEMBRA_DELETE(Convert.ToInt32(LblIdSegParcela.Text)); //2. volvemos a insertar EXT_SeguimientoSiembra ss = new EXT_SeguimientoSiembra(); //EXT_AdversidadPresentada ad = new EXT_AdversidadPresentada(); //if (GVAdversidadPME.Rows.Count > 0) //{ foreach (GridViewRow row in GVSiembra.Rows) { ss.Id_Seguimiento_Parcela = Convert.ToInt32(LblIdSegParcela.Text); ss.Fecha_SiembraINI = Convert.ToDateTime(((TextBox)row.FindControl("txtFechaINI")).Text); ss.Fecha_SiembraFIN = Convert.ToDateTime(((TextBox)row.FindControl("txtFechaFIN")).Text); ss.Sistema_Siembra = ((DropDownList)row.FindControl("DDLSistemaSiembra")).SelectedValue; ss.Cultivo_Anterior = HttpUtility.HtmlDecode(((TextBox)row.FindControl("txtCultivoAnterior")).Text); ss.Variedad_Semilla = HttpUtility.HtmlDecode(((TextBox)row.FindControl("txtVariedadSemilla")).Text); ss.Avance_Siembra = Convert.ToInt16(((TextBox)row.FindControl("txtAvanceSiembra")).Text); insSeg.DB_Registrar_SEGUIMIENTO_SIEMBRA(ss); } //} //3. Actualizamos Seguimiento Parcela segParc.Id_Seguimiento = Convert.ToInt32(LblNum.Text); //segParc.Boleta_Numero = Convert.ToInt32(TxtNumBoleta.Text); //segParc.Fecha_Seg = Convert.ToDateTime(TxtFecha.Text); //segParc.Hora_Seg = DDLHora.SelectedValue + ":" + DDLMinuto.SelectedValue; //segParc.Hora_Seg = string.Empty; //segParc.Fecha_Sis = DateTime.Now;//FECHA SE OBTENDRA DEL SERVER AL EJECUTAR SP segParc.Observacion = HttpUtility.HtmlDecode(txtObsParcela.Text); segParc.Recomendacion = HttpUtility.HtmlDecode(txtRecParcela.Text); insSeg.DB_Registrar_SEGUIMIENTO_PARCELA_UPDATE(segParc); break; //case "VERIFICACION_CULTIVO": case "SEGUIMIENTO Y/O MONITOREO DE CULTIVO": //***validacion en seleccion de fenologia string valor = ((DropDownList)GVCultivo.Rows[0].FindControl("DDLFaseFenoligia")).SelectedValue; int UltimoIdFenologiaRegistrtado = ColSeguimientoCultivo.FirstOrDefault().Id_Fenologia; if (Convert.ToInt16(valor) < UltimoIdFenologiaRegistrtado) { if (Convert.ToInt16(valor) != Convert.ToInt16(lblId_Fenologia.Text)) { string script = @"<script type='text/javascript'>alert('{0}');</script>"; script = string.Format(script, "NO PUEDE SELECCIONAR FENOLOGICA HACIA ATRAS..!"); ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); return; } } //*** //1. ELIMINAMOS SEGUIMIENTO cultivo insSeg.DB_SEGUIMIENTO_CULTIVO_DELETE(Convert.ToInt32(LblIdSegParcela.Text)); //2. volvemos a insertar EXT_SeguimientoCultivo sc = new EXT_SeguimientoCultivo(); //if (GVCultivo.Rows.Count > 0) //{ foreach (GridViewRow dgi in GVCultivo.Rows) { sc.Id_Seguimiento_Parcela = Convert.ToInt32(LblIdSegParcela.Text); sc.Id_Fenologia = Convert.ToInt16(((DropDownList)dgi.FindControl("DDLFaseFenoligia")).SelectedValue); sc.Estado = "Avance"; sc.Porcentaje_FF = 100; sc.Fecha_Cosecha = insSeg.DB_ObtenerFechaServer(); insSeg.DB_Registrar_SEGUIMIENTO_CULTIVO(sc); } //} //3. Actualizamos Seguimiento Parcela segParc.Id_Seguimiento = Convert.ToInt32(LblNum.Text); //segParc.Boleta_Numero = Convert.ToInt32(TxtNumBoleta.Text); //segParc.Fecha_Seg = Convert.ToDateTime(TxtFecha.Text); //segParc.Hora_Seg = DDLHora.SelectedValue + ":" + DDLMinuto.SelectedValue; //segParc.Hora_Seg = string.Empty; //segParc.Fecha_Sis = DateTime.Now;//FECHA SE OBTENDRA DEL SERVER AL EJECUTAR SP segParc.Observacion = HttpUtility.HtmlDecode(txtObsParcela1.Text); segParc.Recomendacion = HttpUtility.HtmlDecode(txtRecomParcela1.Text); insSeg.DB_Registrar_SEGUIMIENTO_PARCELA_UPDATE(segParc); break; } //GENERAL PARA CUALQUIER ETAPA //4. ELIMINAMOS ADVERSIDAD PRESENTADA insSeg.DB_ADVESIDAD_DELETE(Convert.ToInt32(LblIdSegParcela.Text)); //5. volvemos a insertar Adversidades que esten en el grid. EXT_AdversidadPresentada ad = new EXT_AdversidadPresentada(); if (GCAdversidad.Rows.Count > 0) { foreach (GridViewRow dgi in GCAdversidad.Rows) { ad.Id_Seguimiento_Parcela = Convert.ToInt32(LblIdSegParcela.Text); //if (GCAdversidad.Rows[dgi.RowIndex].Cells[0].Text != string.Empty) //{ string adver = ((DropDownList)dgi.FindControl("DDLAdversidad")).SelectedValue; ad.Adversidad = adver; ad.Intencidad = ((DropDownList)dgi.FindControl("DDLIntensidad")).SelectedValue; string PorInt = ((TextBox)dgi.FindControl("TxtPorcentajeIntensidad")).Text; ad.Porcentage = Convert.ToDecimal(PorInt); string fecha = ((TextBox)dgi.FindControl("txtFechaOcurrencia")).Text; ad.Fecha_Ocurrencia = Convert.ToDateTime(fecha); string ObsRec = ((TextBox)dgi.FindControl("txtObs_Rec")).Text; ad.Descripcion = HttpUtility.HtmlDecode(ObsRec); ad.Tratamiento = string.Empty; insSeg.DB_Registrar_ADVESIDAD(ad); //} } } //6. ELIMINAMOS ADVERSIDAD PRESENTADA PME insSeg.DB_ADVESIDAD_PME_DELETE(Convert.ToInt32(LblIdSegParcela.Text)); //7. volvemos a insertar Adversidades que esten en el grid. EXT_AdversidadPresentada adpme = new EXT_AdversidadPresentada(); if (GVAdversidadPME.Rows.Count > 0) { foreach (GridViewRow row in GVAdversidadPME.Rows) { adpme.Id_Seguimiento_Parcela = Convert.ToInt32(LblIdSegParcela.Text); //if (GVAdversidadPME.Rows[dgi.RowIndex].Cells[0].Text != string.Empty) //{ adpme.Adversidad = ((DropDownList)row.FindControl("DDLAdversidad")).SelectedValue; adpme.Descripcion = HttpUtility.HtmlDecode(((TextBox)row.FindControl("txtDescripcion")).Text); adpme.Intencidad = ((DropDownList)row.FindControl("DDLIntensidad")).SelectedValue; adpme.Tratamiento = HttpUtility.HtmlDecode(((TextBox)row.FindControl("txtTratamiento")).Text); adpme.Porcentage = 0; //no se ingresa en sp DateTime fecha = DateTime.Now; adpme.Fecha_Ocurrencia = fecha; //no se ingresa en sp insSeg.DB_Registrar_ADVESIDAD_PME(adpme); //} } } Response.Redirect("frmListaSegOrg.aspx", true); //Response.Redirect("frmSeguimientoTecnico.aspx",true); }