Esempio n. 1
0
        public void DB_Registrar_ADVESIDAD(EXT_AdversidadPresentada adevert)
        {
            DA_EXT_Seguimiento regC = new DA_EXT_Seguimiento();

            regC.DA_Registrar_ADVESIDAD(adevert);
        }
        protected void Registrar_SEGUIMIENTO()
        {
            int aux1 = 0;

            DB_EXT_DesignacionProd estadoprod = new DB_EXT_DesignacionProd();
            DB_AP_Registro_Org     aux        = new DB_AP_Registro_Org();
            DB_EXT_Seguimiento     insSeg     = new DB_EXT_Seguimiento();
            EXT_Seguimiento        seg        = new EXT_Seguimiento();
            EXT_SeguimientoParcela segParc    = new EXT_SeguimientoParcela();

            seg.Id_InscripcionOrg = Convert.ToInt32(LblIdInsOrg.Text);
            seg.Id_Usuario        = LblIdUsuario.Text;
            seg.Id_Productor      = LblIdInsProd.Text;
            seg.Id_Campanhia      = Convert.ToInt32(LblIdCamp.Text);
            seg.Id_Regional       = Convert.ToInt32(LblIdReg.Text);
            seg.Programa          = LblProg.Text;
            //seg.Etapa = LblEtapa.Text;
            seg.Etapa           = LblId_Etapa.Text;
            seg.Num_Seg_Cultivo = 0;

            seg.Estado           = "ENVIADO";
            seg.Fecha_Envio      = DateTime.Now;
            seg.Tipo_Seguimiento = Convert.ToInt32(DDLTipoSeg.SelectedValue);
            insSeg.DB_Registrar_SEGUIMIENTO(seg);

            segParc.Id_Seguimiento = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO", "Id_Seguimiento"));
            if (Convert.ToInt32(DDLTipoSeg.SelectedValue) == 1)
            {
                segParc.Boleta_Numero = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela")) + 1;
            }
            else
            {
                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;
            segParc.Observacion   = TxtObser.Text;
            segParc.Recomendacion = TxtRecomen.Text;
            insSeg.DB_Registrar_SEGUIMIENTO_PARCELA(segParc);

            EXT_SeguimientoCoordenadas scor = new EXT_SeguimientoCoordenadas();
            int id = 0;

            id = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            //scor.Id_Seguimiento_Parcela = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            foreach (GridViewRow dgi in GVCoord.Rows)
            {
                scor.Id_Seguimiento_Parcela = id;
                scor.Id_Productor           = LblIdInsProd.Text;
                scor.Num_Parcela            = Convert.ToInt32(GVCoord.Rows[dgi.RowIndex].Cells[0].Text);
                scor.Num_Punto   = Convert.ToInt16(GVCoord.Rows[dgi.RowIndex].Cells[1].Text);
                scor.CoordenadaX = GVCoord.Rows[dgi.RowIndex].Cells[2].Text;
                scor.CoordenadaY = GVCoord.Rows[dgi.RowIndex].Cells[3].Text;
                insSeg.DB_Registrar_SEGUIMIENTO_COORDENADA(scor);
            }
            ///****** inicio nuevo
            //**ADVERSIDAD
            //int id = 0;
            //id = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            EXT_AdversidadPresentada ad = new EXT_AdversidadPresentada();

            if (GVAdversidad.Rows.Count > 0)
            {
                foreach (GridViewRow dgi in GVAdversidad.Rows)
                {
                    ad.Id_Seguimiento_Parcela = id;
                    if (GVAdversidad.Rows[dgi.RowIndex].Cells[0].Text != string.Empty)
                    {
                        ad.Adversidad       = GVAdversidad.Rows[dgi.RowIndex].Cells[0].Text;
                        ad.Intencidad       = GVAdversidad.Rows[dgi.RowIndex].Cells[1].Text;
                        ad.Porcentage       = Convert.ToDecimal(GVAdversidad.Rows[dgi.RowIndex].Cells[2].Text);
                        ad.Fecha_Ocurrencia = Convert.ToDateTime(GVAdversidad.Rows[dgi.RowIndex].Cells[3].Text);
                        //ad.Descripcion = GVAdversidad.Rows[dgi.RowIndex].Cells[4].Text;
                        ad.Descripcion = HttpUtility.HtmlDecode(GVAdversidad.Rows[dgi.RowIndex].Cells[4].Text);
                        ad.Tratamiento = string.Empty;
                        insSeg.DB_Registrar_ADVESIDAD(ad);
                    }
                }
            }
            //*** plaga, maleza, enfermedad
            EXT_AdversidadPresentada adpme = new EXT_AdversidadPresentada();

            if (GV_PlagaMaEnf.Rows.Count > 0)
            {
                foreach (GridViewRow dgi in GV_PlagaMaEnf.Rows)
                {
                    adpme.Id_Seguimiento_Parcela = id;
                    if (GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[0].Text != string.Empty)
                    {
                        adpme.Adversidad  = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[0].Text;
                        adpme.Descripcion = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[1].Text;
                        adpme.Intencidad  = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[2].Text;
                        adpme.Tratamiento = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[3].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);
                    }
                }
            }
            ///*** fin nuevo
            //estadoprod.DB_Cambiar_ESTADO(LblIdInsProd.Text, "DISTRIBUCION_SEMILLA");
            estadoprod.DB_Cambiar_ESTADO(LblIdInsProd.Text, "2");
            Response.Write("<script>window.alert('El Registrado de las coordenadas se realizó  Correctamente…..');</script>");
            Response.Redirect("frmSeguimientoTecnico.aspx");
        }
        protected void Registrar_SEGUIMIENTO()
        {
            int aux1 = 0;
            DB_EXT_DesignacionProd estadoprod = new DB_EXT_DesignacionProd();
            DB_AP_Registro_Org     aux        = new DB_AP_Registro_Org();
            DB_EXT_Seguimiento     insSeg     = new DB_EXT_Seguimiento();
            EXT_Seguimiento        seg        = new EXT_Seguimiento();
            EXT_SeguimientoParcela segParc    = new EXT_SeguimientoParcela();

            seg.Id_InscripcionOrg = Convert.ToInt32(LblIdInsOrg.Text);
            seg.Id_Usuario        = LblIdUsuario.Text;
            seg.Id_Productor      = LblIdInsProd.Text;
            seg.Id_Campanhia      = Convert.ToInt32(LblIdCamp.Text);
            seg.Id_Regional       = Convert.ToInt32(LblIdReg.Text);
            seg.Programa          = LblProg.Text;
            if (DDLFenologia.SelectedItem.Text == "COSECHA Y ACOPIO") /*************HAY QUE TRABAJAR AQUI MAÑANA*********************************/
            {
                LblEtapa.Text = "VERIFICACION_COSECHA";
            }
            seg.Etapa = LblEtapa.Text;
            if (LblEtapa.Text == "VERIFICACION_PARCELA")
            {
                seg.Num_Seg_Cultivo = 0;
            }
            else
            {
                seg.Num_Seg_Cultivo = 1;
            }
            seg.Estado           = "ENVIADO";
            seg.Fecha_Envio      = DateTime.Now;
            seg.Tipo_Seguimiento = Convert.ToInt32(DDLTipoSeg.SelectedValue);
            insSeg.DB_Registrar_SEGUIMIENTO(seg);

            segParc.Id_Seguimiento = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO", "Id_Seguimiento"));
            if (Convert.ToInt32(DDLTipoSeg.SelectedValue) == 1)
            {
                segParc.Boleta_Numero = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela")) + 1;
            }
            else
            {
                segParc.Boleta_Numero = Convert.ToInt32(TxtNumBoleta.Text);
            }
            segParc.Fecha_Seg = Convert.ToDateTime(TxtFecha.Text);
            DateTime t = DateTime.Now;

            segParc.Hora_Seg = t.Hour.ToString() + ":" + t.Minute.ToString();
            //segParc.Hora_Seg = DDLHora.SelectedValue + ":" + DDLMinuto.SelectedValue;
            segParc.Fecha_Sis     = DateTime.Now;
            segParc.Observacion   = TxtObser.Text;
            segParc.Recomendacion = TxtRecomen.Text;
            insSeg.DB_Registrar_SEGUIMIENTO_PARCELA(segParc);

            EXT_SeguimientoCoordenadas scor = new EXT_SeguimientoCoordenadas();
            EXT_SeguimientoSiembra     ss   = new EXT_SeguimientoSiembra();
            EXT_SeguimientoCultivo     sc   = new EXT_SeguimientoCultivo();
            EXT_AdversidadPresentada   ad   = new EXT_AdversidadPresentada();
/***********************************************************************/
            DataTable dt = Session["datos"] as DataTable;
            int       id = 0;

            id = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sc.Id_Seguimiento_Parcela = id;
                sc.Id_Fenologia           = Convert.ToInt32(dt.Rows[i][0].ToString());
                sc.Estado = dt.Rows[i][2].ToString();
                if (dt.Rows[i][1].ToString() == "FECHA COSECHA PROBABLE")
                {
                    sc.Porcentaje_FF = 0;
                    sc.Fecha_Cosecha = Convert.ToDateTime(dt.Rows[i][4].ToString());
                }
                else
                {
                    sc.Porcentaje_FF = Convert.ToInt32(dt.Rows[i][3].ToString());
                    sc.Fecha_Cosecha = Convert.ToDateTime("01/01/1900");
                }
                insSeg.DB_Registrar_SEGUIMIENTO_CULTIVO(sc);
                estadoprod.DB_Cambiar_ESTADO(LblIdInsProd.Text, "VERIFICACION_CULTIVO");
            }
            if (LblEtapa.Text == "VERIFICACION_COSECHA")
            {
                EXT_SeguimientoCosecha cos = new EXT_SeguimientoCosecha();
                cos.Id_Seguimiento_Parcela = id;
                cos.Rendimiento            = Convert.ToDecimal(TxtRedimiento.Text);
                cos.Sup_Sembrada           = Convert.ToDecimal(TxtSupSiem.Text);
                cos.Peso_Aproximado        = Convert.ToDecimal(TxtPesoApro.Text);
                cos.Fecha_Siembra          = Convert.ToDateTime(TxtFechSiem.Text);
                cos.Placa_Camion           = TxtPlacaCam.Text;
                cos.Nom_Chofer             = TxtNomChofer.Text;
                cos.Centro_Acopio          = TxtCentroAco.Text;
                cos.Region = "";
                insSeg.DB_Registrar_DATOS_COSECHA(cos);
            }
            if (GVAdversidad.Rows.Count > 0)
            {
                foreach (GridViewRow dgi in GVAdversidad.Rows)
                {
                    ad.Id_Seguimiento_Parcela = id;
                    ad.Adversidad             = GVAdversidad.Rows[dgi.RowIndex].Cells[0].Text;
                    ad.Descripcion            = GVAdversidad.Rows[dgi.RowIndex].Cells[1].Text;
                    ad.Intencidad             = GVAdversidad.Rows[dgi.RowIndex].Cells[2].Text;
                    ad.Porcentage             = Convert.ToDecimal(GVAdversidad.Rows[dgi.RowIndex].Cells[3].Text);
                    ad.Tratamiento            = GVAdversidad.Rows[dgi.RowIndex].Cells[4].Text;
                    insSeg.DB_Registrar_ADVESIDAD(ad);
                }
            }
        }
Esempio n. 4
0
        protected void Registrar_SEGUIMIENTO()
        {
            int aux1 = 0;
            DB_EXT_DesignacionProd estadoprod = new DB_EXT_DesignacionProd();
            DB_AP_Registro_Org     aux        = new DB_AP_Registro_Org();
            DB_EXT_Seguimiento     insSeg     = new DB_EXT_Seguimiento();
            EXT_Seguimiento        seg        = new EXT_Seguimiento();
            EXT_SeguimientoParcela segParc    = new EXT_SeguimientoParcela();

            seg.Id_InscripcionOrg = Convert.ToInt32(LblIdInsOrg.Text);
            seg.Id_Usuario        = LblIdUsuario.Text;
            seg.Id_Productor      = LblIdInsProd.Text;
            seg.Id_Campanhia      = Convert.ToInt32(LblIdCamp.Text);
            seg.Id_Regional       = Convert.ToInt32(LblIdReg.Text);
            seg.Programa          = LblProg.Text;
            //seg.Etapa = LblEtapa.Text;LR
            seg.Etapa = LblId_Etapa.Text;
            if (LblEtapa.Text == "1")//"VERIFICACION_PARCELA")//LR
            {
                seg.Num_Seg_Cultivo = 0;
            }
            else
            {
                seg.Num_Seg_Cultivo = 1;
            }
            seg.Estado           = "ENVIADO";
            seg.Fecha_Envio      = DateTime.Now;
            seg.Tipo_Seguimiento = Convert.ToInt32(DDLTipoSeg.SelectedValue);
            insSeg.DB_Registrar_SEGUIMIENTO(seg);

            segParc.Id_Seguimiento = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO", "Id_Seguimiento"));
            if (Convert.ToInt32(DDLTipoSeg.SelectedValue) == 1)
            {
                segParc.Boleta_Numero = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela")) + 1;
            }
            else
            {
                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;
            segParc.Observacion   = TxtObser.Text;
            segParc.Recomendacion = TxtRecomen.Text;
            insSeg.DB_Registrar_SEGUIMIENTO_PARCELA(segParc);

            EXT_SeguimientoCoordenadas scor = new EXT_SeguimientoCoordenadas();
            EXT_SeguimientoSiembra     ss   = new EXT_SeguimientoSiembra();
            EXT_SeguimientoCultivo     sc   = new EXT_SeguimientoCultivo();
            //EXT_AdversidadPresentada ad = new EXT_AdversidadPresentada();
            //string auxVariedad = "";
            int id = 0;

            id = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            //ss.Id_Seguimiento_Parcela = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            ss.Id_Seguimiento_Parcela = id;
            ss.Fecha_SiembraINI       = Convert.ToDateTime(TxtFechaIniSiembra.Text);
            ss.Fecha_SiembraFIN       = Convert.ToDateTime(TxtFechaFinSiembra.Text);
            ss.Sistema_Siembra        = DDLSistemaSiembra.SelectedValue;
            ss.Cultivo_Anterior       = TxtCultivoAnt.Text;
            ss.Variedad_Semilla       = TxtVariedad.Text;   /*************** VASRIEDAD DE SEMILLLA CUANTOS SE PUEDE REGISTRAR PERO NO GUARDA OJOJOJOJO***************/
            ss.Avance_Siembra         = Convert.ToInt32(TxtAvanceSiem.Text);
            insSeg.DB_Registrar_SEGUIMIENTO_SIEMBRA(ss);
            sc.Id_Seguimiento_Parcela = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            switch (LblProg.Text)
            {
            case "ARROZ":
                aux1 = 1;
                break;

            case "MAIZ":
                aux1 = 11;
                break;

            case "TRIGO":
                aux1 = 25;
                break;
            }
            sc.Id_Fenologia  = aux1;
            sc.Estado        = "Avance";
            sc.Porcentaje_FF = Convert.ToInt32(TxtAvanceSiem.Text);
            sc.Fecha_Cosecha = Convert.ToDateTime("01/01/1900");
            //insSeg.DB_Registrar_SEGUIMIENTO_CULTIVO(sc);
            //estadoprod.DB_Cambiar_ESTADO(LblIdInsProd.Text, "VERIFICACION_CULTIVO");
            estadoprod.DB_Cambiar_ESTADO(LblIdInsProd.Text, "3");

            ///****** inicio nuevo
            //**ADVERSIDAD
            //int id = 0;
            //id = Convert.ToInt32(aux.DB_MaxId("EXT_SEGUIMIENTO_PARCELA", "Id_Seguimiento_Parcela"));
            EXT_AdversidadPresentada adver = new EXT_AdversidadPresentada();

            if (GVAdversidad.Rows.Count > 0)
            {
                foreach (GridViewRow dgi in GVAdversidad.Rows)
                {
                    adver.Id_Seguimiento_Parcela = id;
                    if (GVAdversidad.Rows[dgi.RowIndex].Cells[0].Text != string.Empty)
                    {
                        adver.Adversidad       = GVAdversidad.Rows[dgi.RowIndex].Cells[0].Text;
                        adver.Intencidad       = GVAdversidad.Rows[dgi.RowIndex].Cells[1].Text;
                        adver.Porcentage       = Convert.ToDecimal(GVAdversidad.Rows[dgi.RowIndex].Cells[2].Text);
                        adver.Fecha_Ocurrencia = Convert.ToDateTime(GVAdversidad.Rows[dgi.RowIndex].Cells[3].Text);
                        //adver.Descripcion = GVAdversidad.Rows[dgi.RowIndex].Cells[4].Text;
                        adver.Descripcion = HttpUtility.HtmlDecode(GVAdversidad.Rows[dgi.RowIndex].Cells[4].Text);
                        adver.Tratamiento = string.Empty;
                        insSeg.DB_Registrar_ADVESIDAD(adver);
                    }
                }
            }
            //*** plaga, maleza, enfermedad
            EXT_AdversidadPresentada adpme = new EXT_AdversidadPresentada();

            if (GV_PlagaMaEnf.Rows.Count > 0)
            {
                foreach (GridViewRow dgi in GV_PlagaMaEnf.Rows)
                {
                    adpme.Id_Seguimiento_Parcela = id;
                    if (GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[0].Text != string.Empty)
                    {
                        adpme.Adversidad  = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[0].Text;
                        adpme.Descripcion = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[1].Text;
                        adpme.Intencidad  = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[2].Text;
                        adpme.Tratamiento = GV_PlagaMaEnf.Rows[dgi.RowIndex].Cells[3].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);
                    }
                }
            }
            ///*** fin nuevo
        }
        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);
        }