protected void bt_editar_Click(object sender, EventArgs e) { int i; GridViewRow row; string chk; string chk_trans; string chk_habil; for (i = 0; i < gr_dato.Rows.Count; i++) { row = gr_dato.Rows[i]; if (row.RowType == DataControlRowType.DataRow) { Int16 id_tipogasto = Convert.ToInt16(this.gr_dato.Rows[i].Cells[0].Text); TextBox t_valor = ((TextBox)(row.FindControl("txt_valor_gasto"))); TextBox t_nombre = ((TextBox)(row.FindControl("txt_nombre_gasto"))); TextBox t_cuenta = ((TextBox)(row.FindControl("cuenta"))); TextBox t_cuentafac = ((TextBox)(row.FindControl("cuentafac"))); TextBox t_nombrecuenta = ((TextBox)(row.FindControl("nombrecuenta"))); CheckBox t_check = ((CheckBox)(row.FindControl("chk"))); CheckBox t_check_trans = ((CheckBox)(row.FindControl("chk_trans"))); CheckBox t_check_habil = ((CheckBox)(row.FindControl("chk_habilitado"))); chk = "FALSE"; chk_trans = "FALSE"; chk_habil = "FALSE"; if (t_check.Checked == true) { chk = "TRUE"; } if (t_check_trans.Checked == true) { chk_trans = "TRUE"; } if (t_check_habil.Checked == true) { chk_habil = "TRUE"; } string add = new TipogastoBC().add_tipogasto(id_tipogasto, Convert.ToDouble(t_valor.Text), t_nombre.Text, Convert.ToInt16(id_cliente), this.dl_producto.SelectedValue, chk, chk_trans, chk_habil, t_cuenta.Text, t_cuentafac.Text); } } FuncionGlobal.alerta("GASTOS ACTUALIZADOS CON EXITO", Page); getalltipogasto(); }
private void add() { if (this.txt_nombre.Text == "" | this.txt_valor.Text == "") { FuncionGlobal.alerta("INGRESE LOS DATOS CORRESPONDIENTES", Page); return; } string add = new TipogastoBC().add_tipogasto(0, Convert.ToDouble(this.txt_valor.Text), this.txt_nombre.Text, Convert.ToInt16(id_cliente), this.dl_producto.SelectedValue, Convert.ToString(this.chk_gasto.Checked), Convert.ToString(this.chk_transferencia.Checked), "true", "", ""); FuncionGlobal.alerta("TIPO GASTO INGRESADO CON EXITO", Page); this.txt_nombre.Text = ""; this.txt_valor.Text = ""; getalltipogasto(); return; }
public void getalltipogasto() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("id_tipogasto")); dt.Columns.Add(new DataColumn("nombre")); dt.Columns.Add(new DataColumn("valor")); dt.Columns.Add(new DataColumn("producto")); dt.Columns.Add(new DataColumn("cuentafac")); dt.Columns.Add(new DataColumn("cuenta")); dt.Columns.Add(new DataColumn("nombrecuenta")); DataColumn col = new DataColumn("cargo_contable"); DataColumn coll = new DataColumn("transferencia"); DataColumn colll = new DataColumn("habilitado"); col.DataType = System.Type.GetType("System.Boolean"); coll.DataType = System.Type.GetType("System.Boolean"); colll.DataType = System.Type.GetType("System.Boolean"); dt.Columns.Add(col); dt.Columns.Add(coll); dt.Columns.Add(colll); List <Tipogasto> lTipogasto = new TipogastoBC().getalltipogasto(Convert.ToInt16(id_cliente), this.dl_producto.SelectedValue); if (lTipogasto.Count > 0) { this.bt_editar.Visible = true; } foreach (Tipogasto mtipogasto in lTipogasto) { DataRow dr = dt.NewRow(); dr["id_tipogasto"] = mtipogasto.Id_tipogasto; dr["nombre"] = mtipogasto.Descripcion; dr["valor"] = mtipogasto.Valor; dr["producto"] = mtipogasto.Tipooperacion.Operacion; PlandeCuenta cunenta = new PlandeCuentaBC().getplan(mtipogasto.Cuenta.ToString()); dr["cargo_contable"] = mtipogasto.Cargo_contable; dr["transferencia"] = mtipogasto.Transferencia; dr["habilitado"] = mtipogasto.Habilitado; dr["cuenta"] = mtipogasto.Cuenta; dr["cuentafac"] = mtipogasto.Cuenta_facturacion; if (cunenta != null) { dr["nombrecuenta"] = cunenta.Nombre.ToString(); } else { dr["nombrecuenta"] = ""; } dt.Rows.Add(dr); } this.gr_dato.DataSource = dt; this.gr_dato.DataBind(); }