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

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

            contFertilidad         = 0;
            contImagen             = 0;
            contClonesCodificacion = 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.lblClonesError.Visible = false;
            this.lblClonesError.Text    = "";
            if (!Page.IsPostBack)
            {
                this.lblClonesAño.Text   += "(" + valorAñoInt32.ToString() + ")";
                this.gdvClones.DataSource = cc.GetClones(valorAñoInt32);
                this.gdvClones.DataBind();
            }
        }
Пример #3
0
        protected void ClonesGridView_RowDeleting(Object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CatalogClones cc        = new CatalogClones();
                string        id_clones = HttpUtility.HtmlDecode((string)this.gdvClones.Rows[e.RowIndex].Cells[1].Text);
                int           valor     = cc.DeleteClones(Int32.Parse(id_clones));
                if (valor == 0)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error! No se pudo eliminar el clon')</script>");
                }

                PoblarGrilla();
            }
            catch (Exception ex)
            {
            }
        }
Пример #4
0
        /*
         * LLENA CON LOS CONTROLES ESPECIFICOS EL GRIDVIEW CLONES
         */
        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                CatalogClones cc = new CatalogClones();
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Ecuentra el DropDownList en la fila
                    DropDownList ddlClonesFertilidad = (e.Row.FindControl("ddlClonesFertilidad") as DropDownList);
                    //Llena el dropdown fertilidad
                    CatalogFertilidad cf = new CatalogFertilidad();
                    ddlClonesFertilidad.DataSource     = cf.GetFertilidad();
                    ddlClonesFertilidad.DataTextField  = "nombre_fertilidad";
                    ddlClonesFertilidad.DataValueField = "id_fertilidad";
                    ddlClonesFertilidad.DataBind();

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

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string id_clones = e.Row.Cells[1].Text;
                    int    indexClonesCodificacion = cc.GetClonesEstaCodificado(Int32.Parse(id_clones));

                    if (indexClonesCodificacion == 1)
                    {
                        e.Row.BackColor = Color.LightGreen;
                    }
                    else
                    {
                        e.Row.BackColor = Color.FromArgb(255, 204, 203);
                    }
                    contClonesCodificacion = contClonesCodificacion + 1;
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #5
0
        /*
         * Recorre todos los CheckBox del GridView para ver los activos y agregarlos a Clones
         */
        protected void btnAgregarClones_Click(object sender, EventArgs e)
        {
            int agrego = 0;

            foreach (GridViewRow row in gdvVasos.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chkClonesAgregar = (row.Cells[0].FindControl("chkClonesAgregar") as CheckBox);

                    if (chkClonesAgregar != null)
                    {
                        if (chkClonesAgregar.Checked)
                        {
                            string id_vasos            = HttpUtility.HtmlDecode((string)this.gdvVasos.Rows[row.RowIndex].Cells[2].Text);
                            string codigo_variedad     = HttpUtility.HtmlDecode((string)this.gdvVasos.Rows[row.RowIndex].Cells[3].Text);
                            string pad_codigo_variedad = HttpUtility.HtmlDecode((string)this.gdvVasos.Rows[row.RowIndex].Cells[5].Text);

                            CatalogClones cc          = new CatalogClones();
                            int           existe_clon = cc.AddClones(Int32.Parse(id_vasos), codigo_variedad, pad_codigo_variedad);
                            if (existe_clon == 1)
                            {
                                Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('El vaso con ID: " + id_vasos + " seleccionado ya tiene un vaso asignado o la cantidad del vaso es igual a 0')</script>");
                            }
                            else
                            {
                                agrego = 1;
                            }
                        }
                    }
                }
            }
            //1 para agregar, 0 cuando no se agrega
            if (agrego == 1)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Agregado Correctamente!')</script>");
                Response.Redirect("MenuGeneracion.aspx");
            }
        }
Пример #6
0
        protected void ClonesGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
        {
            CatalogClones cc = new CatalogClones();

            try
            {
                this.lblClonesError.Visible = true;
                string id_clones = HttpUtility.HtmlDecode((string)this.gdvClones.Rows[e.RowIndex].Cells[1].Text);

                DropDownList ddlClonesFertilidad = (DropDownList)gdvClones.Rows[e.RowIndex].FindControl("ddlClonesFertilidad");
                string       id_fertilidad       = ddlClonesFertilidad.SelectedValue;

                int    suma      = 0;
                string azul_clon = e.NewValues[0].ToString();
                if (EsNumero(azul_clon) == false)
                {
                    this.lblClonesError.Text += "Las azules deben ser un número.<br/>";
                }
                else
                {
                    suma += 1;
                }
                string roja_clon = e.NewValues[1].ToString();
                if (EsNumero(roja_clon) == false)
                {
                    this.lblClonesError.Text += "Las rojas deben ser un número.<br/>";
                }
                else
                {
                    suma += 1;
                }
                string amarilla_clon = e.NewValues[2].ToString();
                if (EsNumero(amarilla_clon) == false)
                {
                    this.lblClonesError.Text += "Las amarillas deben ser un número.<br/>";
                }
                else
                {
                    suma += 1;
                }
                string bicolor_clon = e.NewValues[3].ToString();
                if (EsNumero(bicolor_clon) == false)
                {
                    this.lblClonesError.Text += "Las bicolores deben ser un número.<br/>";
                }
                else
                {
                    suma += 1;
                }

                int id_clon = Int32.Parse(id_clones);
                if (suma == 4)
                {
                    int id_fertilidadInt32 = Int32.Parse(id_fertilidad);
                    int azul = Int32.Parse(azul_clon);
                    if (azul < 0 || azul > 99)
                    {
                        azul = 0;
                        this.lblClonesError.Text += "Las azules deben ser un número positivo menor a 100.<br/>";
                    }
                    int roja = Int32.Parse(roja_clon);
                    if (roja < 0 || roja > 99)
                    {
                        roja = 0;
                        this.lblClonesError.Text += "Las rojas deben ser un número positivo menor a 100.<br/>";
                    }
                    int amarilla = Int32.Parse(amarilla_clon);
                    if (amarilla < 0 || amarilla > 99)
                    {
                        amarilla = 0;
                        this.lblClonesError.Text += "Las amarillas deben ser un número positivo menor a 100.<br/>";
                    }
                    int bicolor = Int32.Parse(bicolor_clon);
                    if (bicolor < 0 || bicolor > 99)
                    {
                        bicolor = 0;
                        this.lblClonesError.Text += "Las bicolores deben ser un número positivo menor a 100.<br/>";
                    }

                    Project.BusinessRules.Clones clon = new Project.BusinessRules.Clones(id_clon, id_fertilidadInt32,
                                                                                         azul, roja, amarilla, bicolor);
                    cc.UpdateClones(clon);
                }
                this.gdvClones.EditIndex = -1;
                PoblarGrilla();
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error al modificar, repare los parámetros que ingresó!')</script>");
            }
        }