/* * Llena la grilla de los individuos codificados en el año seleccionado */ private void PoblarGrilla() { CatalogCodificacion cc = new CatalogCodificacion(); this.gdvCodigoIndividuos.DataSource = cc.GetCodificacion(codigo_variedad, pad_codigo_variedad, valorAñoInt32); this.gdvCodigoIndividuos.DataBind(); }
/* * LLENA CON LOS CONTROLES ESPECIFICOS EL GRIDVIEW CODIFICACION */ protected void OnRowDataBound(object sender, GridViewRowEventArgs e) { try { CatalogCodificacion cc = new CatalogCodificacion(); if (e.Row.RowType == DataControlRowType.DataRow) { string codigo_variedad = this.txtCodificacionMadre.Text; string pad_codigo_variedad = this.txtCodificacionPadre.Text; string id_codificacion = e.Row.Cells[1].Text; int indexCodificacionCosecha = cc.GetCodificacionEstaEnCosecha(Int32.Parse(id_codificacion)); //Ecuentra el CheckBox en la fila CheckBox chkAgregar6Papas = (e.Row.FindControl("chkAgregar6Papas") as CheckBox); //Ecuentra el Button en la fila Button btnEdit = (e.Row.FindControl("btnEdit") as Button); if (indexCodificacionCosecha == 1) { e.Row.BackColor = Color.LightGreen; chkAgregar6Papas.Enabled = false; btnEdit.Enabled = false; } else { e.Row.BackColor = Color.FromArgb(255, 204, 203); chkAgregar6Papas.Enabled = true; } contCodificacionCosecha = contCodificacionCosecha + 1; } } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { contCodificacionCosecha = 0; CatalogCodificacion cc = new CatalogCodificacion(); if (Request.QueryString["valorMadre"] != null && Request.QueryString["valorPadre"] != null && Request.QueryString["ano_codificacion"] != null) { codigo_variedad = Request.QueryString["valorMadre"]; pad_codigo_variedad = Request.QueryString["valorPadre"]; valorAñoString = Request.QueryString["ano_codificacion"]; this.txtCodificacionMadre.Text = codigo_variedad; this.txtCodificacionPadre.Text = pad_codigo_variedad; this.txtCodificacionAño.Text = valorAñoString; } else { codigo_variedad = "0"; pad_codigo_variedad = "0"; valorAñoString = "0"; } valorAñoInt32 = Int32.Parse(valorAñoString); this.lblCodificacionError.Visible = false; this.lblCodificacionError.Text = ""; if (!Page.IsPostBack) { this.gdvCodigoIndividuos.DataSource = cc.GetCodificacion(codigo_variedad, pad_codigo_variedad, valorAñoInt32); this.gdvCodigoIndividuos.DataBind(); } }
/* * Llena la grilla de los clones con el año seleccionado */ private void PoblarGrilla() { CatalogCodificacion cc = new CatalogCodificacion(); this.gdvCodificacion.DataSource = cc.GetCodificacionPadres(valorAñoInt32); this.gdvCodificacion.DataBind(); }
protected void CodigoIndividuosGridView_RowDeleting(Object sender, GridViewDeleteEventArgs e) { try { CatalogCodificacion cc = new CatalogCodificacion(); string id_codificacion = HttpUtility.HtmlDecode((string)this.gdvCodigoIndividuos.Rows[e.RowIndex].Cells[1].Text); int valor = cc.DeleteCodificacion(Int32.Parse(id_codificacion)); if (valor == 0) { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error! No se pudo eliminar el código')</script>"); } PoblarGrilla(); } catch (Exception ex) { } }
/* * LLENA CON LOS CONTROLES ESPECIFICOS EL GRIDVIEW ENFERMEDADES */ protected void OnRowDataBound(object sender, GridViewRowEventArgs e) { try { CatalogCodificacion cc = new CatalogCodificacion(); if (e.Row.RowType == DataControlRowType.DataRow) { Button btnEdit = (e.Row.FindControl("btnEdit") as Button); Button btnDelete = (e.Row.FindControl("btnDelete") as Button); if (e.Row.Cells[1].Text.Equals("1")) { btnEdit.Enabled = false; btnDelete.Enabled = false; } } } catch (Exception ex) { } }
/* * Codifica toda la tabla con los colores respectivos de cada clon */ protected void btnAgregarCodificacion_Click(object sender, EventArgs e) { try { CatalogCodificacion cc = new CatalogCodificacion(); int valor = cc.AddCodificacion(valorAñoInt32); if (valor == 1) { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Se agregaron los clones que no tenian codificación! El resto mantienen sus códigos')</script>"); Response.Redirect("Codificacion.aspx?valor=" + valorAñoInt32); } else { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Se generó un problema al intentar codificar clones!')</script>"); Response.Redirect("Codificacion.aspx?valor=" + valorAñoInt32); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡Error al codificar, repare los parámetros que ingresó!')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { CatalogCodificacion cc = new CatalogCodificacion(); //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); if (!Page.IsPostBack) { this.lblCodificacionAño.Text += "(" + valorAñoInt32.ToString() + ")"; this.gdvCodificacion.DataSource = cc.GetCodificacionPadres(valorAñoInt32); this.gdvCodificacion.DataBind(); } }
protected void CodigoIndividuosGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e) { CatalogCodificacion cc = new CatalogCodificacion(); try { this.lblCodificacionError.Visible = true; string id_codificacion = HttpUtility.HtmlDecode((string)this.gdvCodigoIndividuos.Rows[e.RowIndex].Cells[1].Text); string codigo_individuo = e.NewValues[0].ToString().ToLower(); //azul string c = codigo_individuo.Substring(0, 1); string b = codigo_individuo.Substring(1, 1); //roja string r = codigo_individuo.Substring(1, 1); //amarilla string t = codigo_individuo.Substring(0, 1); string y = codigo_individuo.Substring(1, 1); //bicolor string bi = codigo_individuo.Substring(0, 1); string ci = codigo_individuo.Substring(1, 1); //año bool año = EsNumero(codigo_individuo.Substring(2, 4)); //guion string guion = codigo_individuo.Substring(6, 1); //número de color bool num_color1 = EsNumero(codigo_individuo.Substring(7)); bool error = false; //if código azul if ((!codigo_individuo.Equals("") && c.Equals("c") && b.Equals("b")) && (año != true || !guion.Equals("-") || num_color1 != true)) { this.lblCodificacionError.Text += "Código color azul incorrecto, Ejemplo: 'cb2016-001'. "; error = true; } //if código rojo if ((!codigo_individuo.Equals("") && c.Equals("c") && r.Equals("r")) && (año != true || !guion.Equals("-") || num_color1 != true)) { this.lblCodificacionError.Text += "Código color rojo incorrecto, Ejemplo: 'cr2016-001'. "; error = true; } //if código amarilla if ((!codigo_individuo.Equals("") && t.Equals("t") && y.Equals("y")) && (año != true || !guion.Equals("-") || num_color1 != true)) { this.lblCodificacionError.Text += "Código color amarillo incorrecto, Ejemplo: 'ty2016-001'. "; error = true; } //if código bicolor if ((!codigo_individuo.Equals("") && bi.Equals("b") && ci.Equals("c")) && (año != true || !guion.Equals("-") || num_color1 != true)) { this.lblCodificacionError.Text += "Código bicolor incorrecto, Ejemplo: 'bc2016-001'. "; error = true; } //if otro código if (!codigo_individuo.Equals("") && (!c.Equals("c") || !b.Equals("b")) && (!c.Equals("c") || !r.Equals("r")) && (!t.Equals("t") || !y.Equals("y")) && (!bi.Equals("b") || !ci.Equals("c"))) { this.lblCodificacionError.Text += "Código incorrecto. "; error = true; } if (error == false) { string año1 = codigo_individuo.Substring(2, 1); string año2 = codigo_individuo.Substring(3, 1); string año3 = codigo_individuo.Substring(4, 1); string año4 = codigo_individuo.Substring(5, 1); string añoConcatenado = año1 + año2 + año3 + año4; //pregunta si el año seleccionado es el mismo al año del codigo if (!añoConcatenado.Equals(valorAñoString)) { this.lblCodificacionError.Text += "Año incorrecto, debe ser el mismo seleccionado. "; } else { Project.BusinessRules.Codificacion cod = new Project.BusinessRules.Codificacion(Int32.Parse(id_codificacion), codigo_individuo); int valor = cc.UpdateCodificacion(cod); if (valor == 0) { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('¡No se pudo modificar debido a que el código escrito ya existe en el año!')</script>"); } } } this.gdvCodigoIndividuos.EditIndex = -1; PoblarGrilla(); } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(GetType(), "Script", "<script>alert('" + ex.ToString() + "')</script>"); } }