Пример #1
0
        /*
         * Llena la grilla del cruzamiento con el año seleccionado
         */
        private void PoblarGrilla()
        {
            CatalogCruzamiento cc = new CatalogCruzamiento();

            this.gdvCruzamiento.DataSource = cc.GetCruzamiento(valorAñoInt32);
            this.gdvCruzamiento.DataBind();
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CatalogCruzamiento cc = new CatalogCruzamiento();

            contFertilidad       = 0;
            contFlor             = 0;
            contCruzamientoVasos = 0;
            //PREGUNTA SI ES DISTINTO DE NULL PORQUE EL USUARIO PUEDE ESCRIBIR DESDE LA URL Y NO TENDRÍA AÑO ASIGNADO
            if (Request.QueryString["valor"] != null)
            {
                valorAñoString = Request.QueryString["valor"];
            }
            else
            {
                valorAñoString = "0";
            }
            valorAñoInt32 = Int32.Parse(valorAñoString);

            this.lblCruzamientoError.Visible = false;
            this.lblCruzamientoError.Text    = "";
            if (!Page.IsPostBack)
            {
                this.lblCruzamientoAño.Text   += "(" + valorAñoInt32.ToString() + ")";
                this.gdvCruzamiento.DataSource = cc.GetCruzamiento(valorAñoInt32);
                this.gdvCruzamiento.DataBind();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CatalogCruzamiento cc = new CatalogCruzamiento();
            List <Project.BusinessRules.Cruzamiento> cruzamiento = cc.GetAñoCruzamiento_fn();

            if (!Page.IsPostBack)
            {
                this.ddlGeneracionAño.DataValueField = "ano_cruzamiento";
                this.ddlGeneracionAño.DataTextField  = "ano_cruzamiento";
                this.ddlGeneracionAño.DataSource     = cruzamiento;
                this.DataBind();
            }
        }
Пример #4
0
        protected void CruzamientoGridView_RowDeleting(Object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CatalogCruzamiento cc             = new CatalogCruzamiento();
                string             id_cruzamiento = HttpUtility.HtmlDecode((string)this.gdvCruzamiento.Rows[e.RowIndex].Cells[2].Text);
                int valor = cc.DeleteCruzamiento(Int32.Parse(id_cruzamiento));
                if (valor == 0)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error! No se pudo eliminar el cruzamiento')</script>");
                }

                PoblarGrilla();
            }
            catch (Exception ex)
            {
            }
        }
Пример #5
0
        /*
         * BOTON QUE CREA UN NUEVO CRUZAMIENTO, OBLIGATORIAMENTE DEBE EXISTIR UNA MADRE Y UN PADRE
         */
        protected void btnMejoramientoCruzamiento_Click(object sender, EventArgs e)
        {
            try
            {
                int cantidad_seleccion_madre = 0;
                foreach (GridViewRow row in gdvCaracteristicaMadre.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox chkMejoramientoSeleccionarMadre = (row.Cells[0].FindControl("chkMejoramientoSeleccionarMadre") as CheckBox);
                        if (chkMejoramientoSeleccionarMadre.Checked)
                        {
                            cantidad_seleccion_madre += 1;
                        }
                    }
                }
                if (cantidad_seleccion_madre == 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Debe seleccionar una madre');</script>");
                }
                if (cantidad_seleccion_madre > 1)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Solo se debe seleccionar una madre');</script>");
                }

                int cantidad_seleccion_padre = 0;
                foreach (GridViewRow row in gdvCaracteristicaPadre.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox chkMejoramientoSeleccionarPadre = (row.Cells[0].FindControl("chkMejoramientoSeleccionarPadre") as CheckBox);
                        if (chkMejoramientoSeleccionarPadre.Checked)
                        {
                            cantidad_seleccion_padre += 1;
                        }
                    }
                }
                if (cantidad_seleccion_padre == 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Debe seleccionar un padre');</script>");
                }
                if (cantidad_seleccion_padre > 1)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Solo se debe seleccionar un padre');</script>");
                }

                if (cantidad_seleccion_madre == 1 && cantidad_seleccion_padre == 1)
                {
                    string codigoMadre = "";
                    foreach (GridViewRow row in gdvCaracteristicaMadre.Rows)
                    {
                        if (row.RowType == DataControlRowType.DataRow)
                        {
                            CheckBox chkMejoramientoSeleccionarMadre = (row.Cells[0].FindControl("chkMejoramientoSeleccionarMadre") as CheckBox);
                            if (chkMejoramientoSeleccionarMadre.Checked)
                            {
                                codigoMadre = HttpUtility.HtmlDecode((string)this.gdvCaracteristicaMadre.Rows[row.RowIndex].Cells[1].Text);
                            }
                        }
                    }
                    string codigoPadre = "";
                    foreach (GridViewRow row in gdvCaracteristicaPadre.Rows)
                    {
                        if (row.RowType == DataControlRowType.DataRow)
                        {
                            CheckBox chkMejoramientoSeleccionarPadre = (row.Cells[0].FindControl("chkMejoramientoSeleccionarPadre") as CheckBox);
                            if (chkMejoramientoSeleccionarPadre.Checked)
                            {
                                codigoPadre = HttpUtility.HtmlDecode((string)this.gdvCaracteristicaPadre.Rows[row.RowIndex].Cells[1].Text);
                            }
                        }
                    }

                    if (!codigoMadre.Equals(""))
                    {
                        if (!codigoPadre.Equals(""))
                        {
                            CatalogCruzamiento cc = new CatalogCruzamiento();
                            cc.AddCruzamiento(codigoMadre, codigoPadre);
                            Response.Redirect("MenuGeneracion.aspx");
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Debe selecionar una variedad padre');</script>");
                        }
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Debe selecionar una variedad madre');</script>");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #6
0
        /*
         * LLENA CON LOS CONTROLES ESPECIFICOS EL GRIDVIEW CRUZAMIENTO
         */
        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                CatalogCruzamiento cc = new CatalogCruzamiento();
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Ecuentra el DropDownList en la fila
                    DropDownList ddlCruzamientoFertilidad = (e.Row.FindControl("ddlCruzamientoFertilidad") as DropDownList);
                    //Llena el dropdown fertilidad
                    CatalogFertilidad cf = new CatalogFertilidad();
                    ddlCruzamientoFertilidad.DataSource     = cf.GetFertilidad();
                    ddlCruzamientoFertilidad.DataTextField  = "nombre_fertilidad";
                    ddlCruzamientoFertilidad.DataValueField = "id_fertilidad";
                    ddlCruzamientoFertilidad.DataBind();

                    //Selecciona la fertilidad de cada cruzamiento
                    int index = cc.GetFertilidadCruzamiento(valorAñoInt32, contFertilidad) - 1;
                    ddlCruzamientoFertilidad.SelectedIndex = index;
                    contFertilidad = contFertilidad + 1;
                }

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Ecuentra el DropDownList en la fila
                    CheckBox chkCruzamientoFlor = (e.Row.FindControl("chkCruzamientoFlor") as CheckBox);

                    bool indexFlor = cc.GetFlorCruzamiento(valorAñoInt32, contFlor);

                    if (indexFlor == true)
                    {
                        chkCruzamientoFlor.Checked = true;
                    }
                    else
                    {
                        chkCruzamientoFlor.Checked = false;
                    }
                    contFlor = contFlor + 1;
                }

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string id_cruzamiento        = e.Row.Cells[2].Text;
                    int    indexCruzamientoVasos = cc.GetCruzamientoEstaEnVasos(Int32.Parse(id_cruzamiento));

                    //Ecuentra el CheckBox en la fila
                    CheckBox chkVasosAgregar = (e.Row.FindControl("chkVasosAgregar") as CheckBox);
                    if (indexCruzamientoVasos == 1)
                    {
                        e.Row.BackColor         = Color.LightGreen;
                        chkVasosAgregar.Enabled = false;
                    }
                    else
                    {
                        e.Row.BackColor         = Color.FromArgb(255, 204, 203);
                        chkVasosAgregar.Enabled = true;
                    }
                    contCruzamientoVasos = contCruzamientoVasos + 1;
                }

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Ecuentra el CheckBox en la fila
                    CheckBox chkCruzamientoFlor = (e.Row.FindControl("chkCruzamientoFlor") as CheckBox);
                    if (this.gdvCruzamiento.EditIndex == -1)
                    {
                        chkCruzamientoFlor.Enabled = false;
                    }
                    else
                    {
                        chkCruzamientoFlor.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #7
0
        protected void CruzamientoGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                this.lblCruzamientoError.Visible = true;
                int invalido                           = 0;
                CatalogCruzamiento cc                  = new CatalogCruzamiento();
                string             id_cruzamiento      = HttpUtility.HtmlDecode((string)this.gdvCruzamiento.Rows[e.RowIndex].Cells[2].Text);
                string             codigo_variedad     = HttpUtility.HtmlDecode((string)this.gdvCruzamiento.Rows[e.RowIndex].Cells[3].Text);
                string             pad_codigo_variedad = HttpUtility.HtmlDecode((string)this.gdvCruzamiento.Rows[e.RowIndex].Cells[5].Text);

                //ubicacion
                string ubicacion_cruzamiento = e.NewValues[0].ToString();
                if (ubicacion_cruzamiento.Length == 3)
                {
                    string ucPrimero = ubicacion_cruzamiento.Substring(0, 1);
                    string ucSegundo = ubicacion_cruzamiento.Substring(1, 1);
                    string ucTercero = ubicacion_cruzamiento.Substring(2, 1);
                    if (EsNumero(ucPrimero) == false || EsNumero(ucSegundo) == true || EsNumero(ucTercero) == false)
                    {
                        this.lblCruzamientoError.Text += "Ubicación incorrecta, Ejemplo '1D1' o '1I1'.<br/>";
                        invalido = 1;
                    }
                }
                else
                {
                    this.lblCruzamientoError.Text += "Ubicación incorrecta, Ejemplo '1D1' o '1I1'.<br/>";
                    invalido = 1;
                }

                //fertilidad
                DropDownList ddlCruzamientoFertilidad = (DropDownList)gdvCruzamiento.Rows[e.RowIndex].FindControl("ddlCruzamientoFertilidad");
                string       id_fertilidad            = ddlCruzamientoFertilidad.SelectedValue;
                //flor
                CheckBox chkCruzamientoFlor = (CheckBox)gdvCruzamiento.Rows[e.RowIndex].FindControl("chkCruzamientoFlor");
                bool     flor;
                if (chkCruzamientoFlor.Checked)
                {
                    flor = true;
                }
                else
                {
                    flor = false;
                    this.lblCruzamientoError.Text += "Las bayas quedarán en 0 debido a que no tiene flor.<br/>";
                }
                //bayas
                int    bayasInt = 0;
                string bayas    = e.NewValues[1].ToString();
                if ((EsNumero(bayas) == true && (Int32.Parse(bayas) < 0 || Int32.Parse(bayas) > 999)) || (EsNumero(bayas) == false))
                {
                    this.lblCruzamientoError.Text += "Las bayas deben ser un número positivo menor a 1000.<br/>";
                    invalido = 1;
                }
                else
                {
                    bayasInt = Int32.Parse(bayas);
                }

                if (invalido == 0)
                {
                    Project.BusinessRules.Cruzamiento cruzamiento = new Project.BusinessRules.Cruzamiento(Int32.Parse(id_cruzamiento),
                                                                                                          codigo_variedad, pad_codigo_variedad, ubicacion_cruzamiento, Int32.Parse(id_fertilidad), flor, bayasInt, valorAñoInt32);
                    int valor = cc.UpdateCruzamiento(cruzamiento);
                    if (valor == 0)
                    {
                        this.lblCruzamientoError.Text += "La ubicación ingresada ya existe, inténtelo nuevamente.<br/>";
                    }
                }
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error al modificar, repare los parámetros que ingresó!')</script>");
            }

            this.gdvCruzamiento.EditIndex = -1;
            PoblarGrilla();
        }