protected void btnAdd(object sender, EventArgs e) { Button btnAdd = GridView1.FooterRow.FindControl("btnAdd") as Button; if (btnAdd != null) { TextBox txtCodItem = GridView1.FooterRow.FindControl("txtCodItem") as TextBox; string CodItem = txtCodItem.Text; TextBox txtNomItem = GridView1.FooterRow.FindControl("txtNomItem") as TextBox; string NomItem = txtNomItem.Text; TextBox txtDscItem = GridView1.FooterRow.FindControl("txtDscItem") as TextBox; string DscItem = txtDscItem.Text; TextBox txtCantidad = GridView1.FooterRow.FindControl("txtCantidad") as TextBox; int Cantidad = 0; try { Cantidad = Convert.ToInt32(txtCantidad.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe indicar la cantidad de elementos del item"); } DropDownList ddlIndFact = GridView1.FooterRow.FindControl("ddlIndFact") as DropDownList; IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(Convert.ToInt32(ddlIndFact.SelectedValue)); DropDownList ddlUniMed = GridView1.FooterRow.FindControl("ddlUniMed") as DropDownList; UnidadesDeMedida UniMed = LUnidadesDeMedida.BuscarUnidadDeMedida(Convert.ToInt32(ddlUniMed.SelectedValue)); Item_Rem Item = new Item_Rem(((List <Item_Rem>)Session["ItemsRem"]).Count + 1, CodItem, IndFact, NomItem, DscItem, Cantidad, UniMed); ((List <Item_Rem>)Session["ItemsRem"]).Add(Item); BindData(); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtMonto = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMonto"); DropDownList ddlCodRet = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlCodRet") as DropDownList; decimal Monto; try { Monto = Convert.ToDecimal(txtMonto.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe ingresar el monto"); } CodRetType cod = LCodRet.BuscarCodRet(ddlCodRet.SelectedItem.Text); RetencPercepType ret = new RetencPercepType(cod, Monto); DropDownList ddlIndFact = GridView1.Rows[e.RowIndex].FindControl("ddlIndFact") as DropDownList; int idInd = Convert.ToInt32(ddlIndFact.SelectedValue); IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(idInd); List <RetencPercepType> l = new List <EntidadesCompartidas.RetencPercepType>(); l.Add(ret); Item_Resg item = new Item_Resg(((List <Item_Resg>)Session["ItemsRes"]).Count, IndFact, l); GridView1.EditIndex = -1; BindData(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtCodItem = GridView1.Rows[e.RowIndex].FindControl("txtCodItem") as TextBox; if (txtCodItem != null) { string CodItem = txtCodItem.Text; TextBox txtNomItem = GridView1.Rows[e.RowIndex].FindControl("txtNomItem") as TextBox; string NomItem = txtNomItem.Text; TextBox txtDscItem = GridView1.Rows[e.RowIndex].FindControl("txtDscItem") as TextBox; string DscItem = txtDscItem.Text; TextBox txtCantidad = GridView1.Rows[e.RowIndex].FindControl("txtCantidad") as TextBox; int Cantidad = 0; try { Cantidad = Convert.ToInt32(txtCantidad.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe indicar la cantidad de elementos del item"); } TextBox txtPrecioUnitario = GridView1.Rows[e.RowIndex].FindControl("txtPrecioUnitario") as TextBox; decimal PrecioUnitario = 0; try { PrecioUnitario = Convert.ToInt32(txtPrecioUnitario.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe indicar el Precio de el elemento del item"); } DropDownList ddlIndFact = GridView1.Rows[e.RowIndex].FindControl("ddlIndFact") as DropDownList; IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(Convert.ToInt32(ddlIndFact.SelectedValue)); DropDownList ddlUniMed = GridView1.Rows[e.RowIndex].FindControl("ddlUniMed") as DropDownList; UnidadesDeMedida UniMed = LUnidadesDeMedida.BuscarUnidadDeMedida(Convert.ToInt32(ddlUniMed.SelectedValue)); Label lblNroLinDet = GridView1.Rows[e.RowIndex].FindControl("lblNroLinDet") as Label; int NroLinDet = Convert.ToInt32(lblNroLinDet.Text); Item_Det_Fact Item = new Item_Det_Fact(NroLinDet, CodItem, IndFact, NomItem, DscItem, Cantidad, UniMed, PrecioUnitario); ((List <Item_Det_Fact>)Session["ItemsFact"])[e.RowIndex] = Item; GridView1.EditIndex = -1; BindData(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <Item_Det_Fact> ItemsFact = new List <Item_Det_Fact>(); Item_Det_Fact Item = new Item_Det_Fact(0, "", null, "", "", 0, null, 0); ItemsFact.Add(Item); List <IndicadorFacturaType> ListaIndFact = LIndicadorFacturaType.ListarIndicadorFactura(); List <UnidadesDeMedida> ListaUniMed = LUnidadesDeMedida.ListarUnidadesDeMedida(); Session["ListaIndFact"] = ListaIndFact; Session["ItemsFact"] = ItemsFact; Session["ListaUniMed"] = ListaUniMed; BindData(); } }
private void BindData() { GridView1.DataSource = (List <Item_Resg>)Session["ItemsRes"]; GridView1.DataBind(); DropDownList ddlIndFact = GridView1.FooterRow.FindControl("ddlIndFact") as DropDownList; ddlIndFact.DataSource = LIndicadorFacturaType.ListarIndicadorFactura(); ddlIndFact.DataValueField = "Id"; ddlIndFact.DataTextField = "Nombre"; ddlIndFact.DataBind(); TextBox txtMonto = GridView1.FooterRow.FindControl("txtMonto") as TextBox; DropDownList ddlCodRet = GridView1.FooterRow.FindControl("ddlCodRet") as DropDownList; ddlCodRet.DataSource = LCodRet.ListarCodRet(); ddlCodRet.DataValueField = "Tasa"; ddlCodRet.DataTextField = "Id"; }
protected void btnAdd(object sender, EventArgs e) { Button btnAdd = GridView1.FooterRow.FindControl("btnAdd") as Button; if (btnAdd != null) { TextBox txtNewMonto = GridView1.FooterRow.FindControl("txtMonto") as TextBox; if (txtNewMonto != null) { DropDownList ddlCodRetFoot = GridView1.FooterRow.FindControl("ddlCodRet") as DropDownList; if (ddlCodRetFoot != null) { string id = ddlCodRetFoot.SelectedItem.Text; decimal MontoNuevo; try { MontoNuevo = Convert.ToInt32(txtNewMonto.Text); } catch (ExcepcionesPersonalizadas.Presentacion ex) { throw new ExcepcionesPersonalizadas.Presentacion("Debe ingresar el monto nuevo"); } DropDownList ddlIndFact = GridView1.FooterRow.FindControl("ddlIndFact") as DropDownList; int idInd = Convert.ToInt32(ddlIndFact.SelectedValue); IndicadorFacturaType IndFact = LIndicadorFacturaType.BuscarIndicadorFactura(idInd); CodRetType cod = LCodRet.BuscarCodRet(id); RetencPercepType ret = new RetencPercepType(cod, MontoNuevo); List <RetencPercepType> l = new List <EntidadesCompartidas.RetencPercepType>(); l.Add(ret); Item_Resg item = new Item_Resg(((List <Item_Resg>)Session["ItemsRes"]).Count, IndFact, l); BindData(); } } } }