コード例 #1
0
        public void DB_Registrar_SEGUIMIENTO_CULTIVO(EXT_SeguimientoCultivo segC)
        {
            DA_EXT_Seguimiento regC = new DA_EXT_Seguimiento();

            regC.DA_Registrar_SEGUIMIENTO_CULTIVO(segC);
        }
コード例 #2
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
        }
コード例 #3
0
        private void RECUPERAR_REGISTRO_CULTIVO()
        {
            DB_EXT_Seguimiento avsiem = new DB_EXT_Seguimiento();
            DataTable          dt1    = new DataTable();
            DataTable          dt2    = new DataTable();
            DataTable          dt3    = new DataTable();

            DataTable dt = new DataTable();
            DataRow   drnew;

            dt.TableName = "Fenologia";
            dt.Columns.Add(new DataColumn("Id_Fenologia", typeof(int)));
            dt.Columns.Add(new DataColumn("Fenologia", typeof(string)));
            dt.Columns.Add(new DataColumn("EstadoFF", typeof(string)));
            dt.Columns.Add(new DataColumn("Porcentaje", typeof(int)));
            dt.Columns.Add(new DataColumn("Id_Seguimiento_Parcela", typeof(int)));
            drnew = dt.NewRow();
            dt.Rows.Add(drnew);
            ViewState["dtFenologia"] = dt;

            dt1 = avsiem.DB_RECUPERAR_REGISTRO_CULTIVO(lblId_Productor.Text, "3");
            dt2 = avsiem.DB_RECUPERAR_REGISTRO_CULTIVO(lblId_Productor.Text, "VERIFICACION_CULTIVO");
            dt3 = dt1.Clone();
            foreach (DataRow dr in dt2.Rows)
            {
                dt3.ImportRow(dr);
            }
            foreach (DataRow dr in dt1.Rows)
            {
                dt3.ImportRow(dr);
            }
            if (dt3.Rows.Count > 0)
            {
                DataView dv = dt3.DefaultView;
                dv.Sort = "[Id_Seguimiento_Parcela] ASC";
                dt3     = dv.ToTable();
            }
            IList <EXT_SeguimientoCultivo> ColSC = new List <EXT_SeguimientoCultivo>();
            DataTable dtTable = (DataTable)ViewState["dtFenologia"];
            DataRow   drRow   = null;

            foreach (DataRow row in dt3.Rows)
            {
                EXT_SeguimientoCultivo ObjSC = new EXT_SeguimientoCultivo();
                if (dtTable.Rows.Count > 0)
                {
                    drRow = dtTable.NewRow();
                    int id_f = Convert.ToInt16(row["Id_Fenologia"].ToString());
                    switch (id_f)
                    {
                    case 26:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "GERMINACION EMERGENCIA";
                        break;

                    case 27:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "PLANTULA";
                        break;

                    case 28:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "MACOLLAMIENTO";
                        break;

                    case 29:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "EMBUCHE";
                        break;

                    case 30:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "ESPIGAZON";
                        break;

                    case 31:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "FLORACION";
                        break;

                    case 32:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "LLENADO GRANO";
                        break;

                    case 33:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "MADURACION";
                        break;

                    case 34:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "GERMINACION EMERGENCIA";
                        break;

                    case 35:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "PLANTULA";
                        break;

                    case 36:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "FASE VEGETATIVA";
                        break;

                    case 37:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "FASE REPRODUCTIVA";
                        break;

                    case 38:
                        drRow["Id_Fenologia"] = id_f;
                        drRow["Fenologia"]    = "MADURACION DEL GRANO";
                        break;
                    }
                    //drRow["Id_Fenologia"] = DDLFenologia.SelectedValue;
                    //drRow["Fenologia"] = DDLFenologia.SelectedItem.ToString();
                    drRow["EstadoFF"]               = row["Estado"].ToString();
                    drRow["Porcentaje"]             = Convert.ToInt16(row["Porcentaje_FF"].ToString());
                    drRow["Id_Seguimiento_Parcela"] = Convert.ToInt16(row["Id_Seguimiento_Parcela"].ToString());
                }
                if (dtTable.Rows[0][0].ToString() == "")
                {
                    dtTable.Rows[0].Delete();
                    dtTable.AcceptChanges();
                }
                dtTable.Rows.Add(drRow);
                //LR:agregamos en ColSC para poder bloquear el boton eliminar a los datos que se recuperen de la BD
                ObjSC.Id_Seguimiento_Parcela = Convert.ToInt16(row["Id_Seguimiento_Parcela"].ToString());
                ObjSC.Id_Fenologia           = Convert.ToInt16(row["Id_Fenologia"].ToString());
                ObjSC.Estado        = row["Estado"].ToString();
                ObjSC.Porcentaje_FF = Convert.ToInt16(row["Porcentaje_FF"].ToString());
                ColSC.Add(ObjSC);
            }
            ViewState["dtFenologia"] = dtTable;
            IList <EXT_SeguimientoCultivo> ColSeg_Cultivo = new List <EXT_SeguimientoCultivo>();

            foreach (DataRow row in dtTable.Rows)
            {
                EXT_SeguimientoCultivo ObjSegCultivo = new EXT_SeguimientoCultivo();
                string idSegPar    = row["Id_Seguimiento_Parcela"].ToString();
                string idFenologia = row["Id_Fenologia"].ToString();
                string estado      = row["EstadoFF"].ToString();
                string porcentaje  = row["Porcentaje"].ToString();
                ObjSegCultivo.Id_Seguimiento_Parcela = Convert.ToInt16(idSegPar);
                ObjSegCultivo.Id_Fenologia           = Convert.ToInt16(idFenologia);
                ObjSegCultivo.Estado        = estado;
                ObjSegCultivo.Porcentaje_FF = Convert.ToInt16(porcentaje);
                ColSeg_Cultivo.Add(ObjSegCultivo);
            }
            ColSeguimientoCultivo = ColSeg_Cultivo.OrderByDescending(x => x.Id_Seguimiento_Parcela).ToList();
            //ColSeguimientoCultivo = ColSC;
            //GVSegCultivo.DataSource = dtTable;
            //GVSegCultivo.DataBind();
        }
コード例 #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;
            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);
                }
            }
        }
コード例 #5
0
        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);
        }