private void BindData()
        {
            if (!IsPostBack)
            {
                RetencPercepType ret = new RetencPercepType(LCodRet.BuscarCodRet(((List <CodRetType>)Session["Codigos"])[1].Id), 1);
                ((List <RetencPercepType>)Session["Retenciones"]).Add(ret);

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
                formatter.Serialize(stream, ret);
                stream.Close();
            }

            GridView1.DataSource = ((List <RetencPercepType>)Session["Retenciones"]);
            GridView1.DataBind();

            DropDownList ddlCodRetFoot = GridView1.FooterRow.FindControl("ddlCodRetFoot") as DropDownList;

            if (ddlCodRetFoot != null)
            {
                ddlCodRetFoot.DataSource     = (List <CodRetType>)Session["Codigos"];
                ddlCodRetFoot.DataTextField  = "Id";
                ddlCodRetFoot.DataValueField = "Tasa";
                ddlCodRetFoot.DataBind();
            }
        }
Ejemplo n.º 2
0
        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 Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         List <RetencPercepType> Retenciones = new List <RetencPercepType>();
         List <CodRetType>       Codigos     = LCodRet.ListarCodRet();
         Session["Codigos"]     = Codigos;
         Session["Retenciones"] = Retenciones;
         BindData();
     }
 }
        protected void btnAdd(object sender, EventArgs e)
        {
            Button btnAdd = GridView1.FooterRow.FindControl("btnAdd") as Button;

            if (btnAdd != null)
            {
                TextBox txtNewMonto = GridView1.FooterRow.FindControl("txtNewMonto") as TextBox;
                if (txtNewMonto != null)
                {
                    DropDownList ddlCodRetFoot = GridView1.FooterRow.FindControl("ddlCodRetFoot") 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");
                        }
                        List <RetencPercepType> Retenciones = (List <RetencPercepType>)Session["Retenciones"];

                        bool tiene = false;
                        foreach (RetencPercepType r in Retenciones)
                        {
                            if (r.CodRet.Id == id)
                            {
                                //throw new ExcepcionesPersonalizadas.Presentacion("");
                                tiene = true;
                            }
                        }
                        if (tiene)
                        {
                            Response.Write("  <script language='javascript'> window.alert('El Código de Retención ya fue agregado anteriormente'); </script>");
                        }
                        else
                        {
                            CodRetType       cod = LCodRet.BuscarCodRet(id);
                            RetencPercepType ret = new RetencPercepType(cod, MontoNuevo);
                            ((List <RetencPercepType>)Session["Retenciones"]).Add(ret);
                            BindData();
                        }
                    }
                }
            }
        }
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;

            string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();

            BindData();

            DropDownList ddlCodRet = GridView1.Rows[e.NewEditIndex].FindControl("ddlCodRet") as DropDownList;

            if (ddlCodRet != null)
            {
                ddlCodRet.DataSource     = LCodRet.ListarCodRet();
                ddlCodRet.DataTextField  = "Id";
                ddlCodRet.DataValueField = "Tasa";
                ddlCodRet.DataBind();
            }

            ddlCodRet.SelectedValue = id.ToString();
        }
Ejemplo n.º 6
0
        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 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);

            ((List <RetencPercepType>)Session["Retenciones"])[e.RowIndex] = ret;
            GridView1.EditIndex = -1;
            BindData();
        }
Ejemplo n.º 8
0
        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();
                    }
                }
            }
        }