Exemple #1
0
        protected async void grdTarifa_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label lblCode = (Label)grdTarifa.Rows[e.RowIndex].Cells[0].FindControl("lblCodigoTarifa");

            string tarClase    = (grdTarifa.Rows[e.RowIndex].FindControl("drpClaseEdit") as DropDownList).Text;
            string tarPrecio   = (grdTarifa.Rows[e.RowIndex].FindControl("txtPrecioEdit") as TextBox).Text.Trim();
            string tarImpuesto = (grdTarifa.Rows[e.RowIndex].FindControl("txtImpuestoEdit") as TextBox).Text;
            string tarEstado   = (grdTarifa.Rows[e.RowIndex].FindControl("drpEstadoEdit") as DropDownList).Text;

            if (ValidarModificar(tarClase, tarPrecio, tarImpuesto, tarEstado))
            {
                Models.Tarifa tarifaModificado = new Models.Tarifa();
                Models.Tarifa tarifa           = new Models.Tarifa()
                {
                    TAR_CODIGO   = Convert.ToInt32(lblCode.Text),
                    TAR_CLASE    = tarClase,
                    TAR_PRECIO   = Convert.ToDecimal(tarPrecio),
                    TAR_IMPUESTO = Convert.ToInt32(tarImpuesto),
                    TAR_ESTADO   = tarEstado
                };

                tarifaModificado =
                    await tarifaManager.Actualizar(tarifa, VG.usuarioActual.CadenaToken);

                if (tarifaModificado != null)
                {
                    lblStatus.Text      = "Tarifa modificada correctamente";
                    lblStatus.ForeColor = Color.Green;
                    lblStatus.Visible   = true;
                    InicializarControles();
                }
                else
                {
                    lblStatus.Text      = "Hubo un error al modificar la tarifa";
                    lblStatus.ForeColor = Color.Maroon;
                    lblStatus.Visible   = true;
                }

                grdTarifa.EditIndex = -1;
                InicializarControles();
            }
        }