示例#1
0
        /*
         * Devuelve el clon completo, con el nombre de fertilidad en vez de la id
         */
        public List <Clones> GetClones(int año)
        {
            try
            {
                DataAccess.DataBase bd = new DataBase();
                bd.Connect();                           //método conectar
                List <Clones> clones = new List <Clones>();
                string        salida = "clonesObtener"; //comando sql
                bd.CreateCommandSP(salida);
                bd.CreateParameter("@ano_clones", DbType.Int32, año);

                DbDataReader resultado = bd.Query();//disponible resultado

                while (resultado.Read())
                {
                    Clones clon = new Clones(resultado.GetInt32(0), resultado.GetString(1), resultado.GetString(2), resultado.GetString(3),
                                             resultado.GetString(4), resultado.GetString(5), resultado.GetInt32(6),
                                             resultado.GetInt32(7), resultado.GetInt32(8), resultado.GetInt32(9));
                    clones.Add(clon);
                }
                resultado.Close();
                bd.Close();

                return(clones);
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }
示例#2
0
 /*
  * Actualizar clon
  */
 public void UpdateClones(Clones c)
 {
     try
     {
         DataAccess.DataBase bd = new DataBase();
         bd.Connect(); //método conectar
         string sql = "clonesActualizar";
         bd.CreateCommandSP(sql);
         bd.CreateParameter("@id_clones", DbType.Int32, c.Id_clones);
         bd.CreateParameter("@id_fertilidad", DbType.Int32, c.Id_fertilidad);
         bd.CreateParameter("@azul_clon", DbType.Int32, c.Azul_clon);
         bd.CreateParameter("@roja_clon", DbType.Int32, c.Roja_clon);
         bd.CreateParameter("@amarilla_clon", DbType.Int32, c.Amarilla_clon);
         bd.CreateParameter("@bicolor_clon", DbType.Int32, c.Bicolor_clon);
         bd.Execute();
         bd.Close();
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
示例#3
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>");
            }
        }