Ejemplo n.º 1
0
        /*
         * Llena la grilla de los vasos con el año seleccionado
         */
        private void PoblarGrilla()
        {
            CatalogVasos cv = new CatalogVasos();

            this.gdvVasos.DataSource = cv.GetVasos(valorAñoInt32);
            this.gdvVasos.DataBind();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CatalogVasos cv = new CatalogVasos();

            contFertilidad  = 0;
            contVasosClones = 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.lblVasosError.Visible = false;
            this.lblVasosError.Text    = "";
            if (!Page.IsPostBack)
            {
                this.txtCantidadTotalVasos.Text = cv.GetCantidadTotalVasos_fn(valorAñoInt32).ToString() + " Vasos";
                this.lblVasosAño.Text          += "(" + valorAñoInt32.ToString() + ")";
                this.gdvVasos.DataSource        = cv.GetVasos(valorAñoInt32);
                this.gdvVasos.DataBind();
            }
        }
Ejemplo n.º 3
0
        protected void VasosGridView_RowEditing(Object sender, GridViewEditEventArgs e)
        {
            gdvVasos.EditIndex = e.NewEditIndex;
            PoblarGrilla();
            CatalogVasos cv = new CatalogVasos();
            List <Project.BusinessRules.Vasos> listVasos = cv.GetVasosColores(valorAñoInt32);

            this.txtVasosAzul.Text     = listVasos[e.NewEditIndex].Azul_vasos.ToString();
            this.txtVasosRoja.Text     = listVasos[e.NewEditIndex].Roja_vasos.ToString();
            this.txtVasosAmarilla.Text = listVasos[e.NewEditIndex].Amarilla_vasos.ToString();
            this.txtVasosBicolor.Text  = listVasos[e.NewEditIndex].Bicolor_vasos.ToString();
        }
Ejemplo n.º 4
0
        /*
         * LLENA CON LOS CONTROLES ESPECIFICOS EL GRIDVIEW VASOS
         */
        protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                CatalogVasos cv = new CatalogVasos();
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Ecuentra el DropDownList en la fila
                    DropDownList ddlVasosFertilidad = (e.Row.FindControl("ddlVasosFertilidad") as DropDownList);
                    //Llena el dropdown fertilidad
                    CatalogFertilidad cf = new CatalogFertilidad();
                    ddlVasosFertilidad.DataSource     = cf.GetFertilidad();
                    ddlVasosFertilidad.DataTextField  = "nombre_fertilidad";
                    ddlVasosFertilidad.DataValueField = "id_fertilidad";
                    ddlVasosFertilidad.DataBind();

                    //Selecciona la fertilidad de cada vaso
                    int index = cv.GetFertilidadVasos(valorAñoInt32, contFertilidad) - 1;
                    ddlVasosFertilidad.SelectedIndex = index;
                    contFertilidad = contFertilidad + 1;
                }

                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    string id_vasos         = e.Row.Cells[2].Text;
                    int    indexVasosClones = cv.GetVasosEstaEnClones(Int32.Parse(id_vasos));

                    //Ecuentra el CheckBox en la fila
                    CheckBox chkClonesAgregar = (e.Row.FindControl("chkClonesAgregar") as CheckBox);
                    if (indexVasosClones == 1)
                    {
                        e.Row.BackColor          = Color.LightGreen;
                        chkClonesAgregar.Enabled = false;
                    }
                    else
                    {
                        e.Row.BackColor          = Color.FromArgb(255, 204, 203);
                        chkClonesAgregar.Enabled = true;
                    }
                    contVasosClones = contVasosClones + 1;
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 5
0
        /*
         * Recorre todos los CheckBox del GridView para ver los activos y agregarlos a Vasos
         */
        protected void btnAgregarVasos_Click(object sender, EventArgs e)
        {
            try
            {
                int agrego = 0;
                foreach (GridViewRow row in gdvCruzamiento.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox chkVasosAgregar = (row.Cells[0].FindControl("chkVasosAgregar") as CheckBox);

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

                                CatalogVasos cv          = new CatalogVasos();
                                int          existe_vaso = cv.AddVasos(Int32.Parse(id_cruzamiento), codigo_variedad, pad_codigo_variedad);
                                if (existe_vaso == 1)
                                {
                                    Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('El cruzamiento con ID: " + id_cruzamiento + " seleccionado ya tiene un vaso asignado o no tiene bayas')</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");
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 6
0
        protected void VasosGridView_RowDeleting(Object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CatalogVasos cv       = new CatalogVasos();
                string       id_vasos = HttpUtility.HtmlDecode((string)this.gdvVasos.Rows[e.RowIndex].Cells[2].Text);
                int          valor    = cv.DeleteVasos(Int32.Parse(id_vasos));
                if (valor == 0)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error! No se pudo eliminar el vaso')</script>");
                }

                this.txtCantidadTotalVasos.Text = cv.GetCantidadTotalVasos_fn(valorAñoInt32).ToString() + " Vasos";
                PoblarGrilla();
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 7
0
        protected void VasosGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
        {
            CatalogVasos cv = new CatalogVasos();

            try
            {
                this.lblVasosError.Visible = true;
                int    invalido = 0;
                string id_vasos = HttpUtility.HtmlDecode((string)this.gdvVasos.Rows[e.RowIndex].Cells[2].Text);

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

                //cantidad papas
                int    cantidad       = 0;
                string cantidad_vasos = e.NewValues[1].ToString();
                if ((EsNumero(cantidad_vasos) == true && (Int32.Parse(cantidad_vasos) < 0 || Int32.Parse(cantidad_vasos) > 999)) || (EsNumero(cantidad_vasos) == false))
                {
                    this.lblVasosError.Text += "La cantidad de vasos debe ser un número positivo menor a 999.<br/>";
                    invalido = 1;
                }
                else
                {
                    cantidad = Int32.Parse(cantidad_vasos);
                }

                //fertilidad
                DropDownList ddlVasosFertilidad = (DropDownList)gdvVasos.Rows[e.RowIndex].FindControl("ddlVasosFertilidad");
                string       id_fertilidad      = ddlVasosFertilidad.SelectedValue;

                //azules
                int    azul       = 0;
                string azul_vasos = this.txtVasosAzul.Text;
                if ((EsNumero(azul_vasos) == true && (Int32.Parse(azul_vasos) < 0 || Int32.Parse(azul_vasos) > 99)) || (EsNumero(azul_vasos) == false))
                {
                    this.lblVasosError.Text += "Las azules deben ser un número positivo menor a 100.<br/>";
                    invalido = 1;
                }
                else
                {
                    azul = Int32.Parse(azul_vasos);
                }

                //rojas
                int    roja       = 0;
                string roja_vasos = this.txtVasosRoja.Text;
                if ((EsNumero(roja_vasos) == true && (Int32.Parse(roja_vasos) < 0 || Int32.Parse(roja_vasos) > 99)) || (EsNumero(roja_vasos) == false))
                {
                    this.lblVasosError.Text += "Las rojas deben ser un número positivo menor a 100.<br/>";
                    invalido = 1;
                }
                else
                {
                    roja = Int32.Parse(roja_vasos);
                }

                //amarillas
                int    amarilla       = 0;
                string amarilla_vasos = this.txtVasosAmarilla.Text;
                if ((EsNumero(amarilla_vasos) == true && (Int32.Parse(amarilla_vasos) < 0 || Int32.Parse(amarilla_vasos) > 99)) || (EsNumero(amarilla_vasos) == false))
                {
                    this.lblVasosError.Text += "Las amarillas deben ser un número positivo menor a 100.<br/>";
                    invalido = 1;
                }
                else
                {
                    amarilla = Int32.Parse(amarilla_vasos);
                }

                //bicolores
                int    bicolor       = 0;
                string bicolor_vasos = this.txtVasosBicolor.Text;
                if ((EsNumero(bicolor_vasos) == true && (Int32.Parse(bicolor_vasos) < 0 || Int32.Parse(bicolor_vasos) > 99)) || (EsNumero(bicolor_vasos) == false))
                {
                    this.lblVasosError.Text += "Las bicolores deben ser un número positivo menor a 100.<br/>";
                    invalido = 1;
                }
                else
                {
                    bicolor = Int32.Parse(bicolor_vasos);
                }

                if (invalido == 0)
                {
                    int suma = azul + roja + amarilla + bicolor;
                    if (suma > cantidad)
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('La suma de azules, rojas, amarillas y bicolores(" + suma + ") no debe ser mayor a la cantidad total(" + cantidad + ") del vaso')</script>");
                    }

                    Project.BusinessRules.Vasos vasos = new Project.BusinessRules.Vasos(Int32.Parse(id_vasos),
                                                                                        ubicacion_vasos, cantidad, Int32.Parse(id_fertilidad),
                                                                                        azul, roja, amarilla, bicolor, valorAñoInt32);
                    int valor = cv.UpdateVasos(vasos);
                    if (valor == 0)
                    {
                        this.lblVasosError.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.txtVasosAzul.Text          = "";
            this.txtVasosRoja.Text          = "";
            this.txtVasosAmarilla.Text      = "";
            this.txtVasosBicolor.Text       = "";
            gdvVasos.EditIndex              = -1;
            this.txtCantidadTotalVasos.Text = cv.GetCantidadTotalVasos_fn(valorAñoInt32).ToString() + " Vasos";
            PoblarGrilla();
        }