Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.FacturaServicio);

            btnPagarFacturaServicio          = FindViewById <Button>(Resource.Id.btnPagarFacturaServicio);
            lblIdentificacionFacturaServicio = FindViewById <TextView>(Resource.Id.lblIdentificacionFacturaServicio);
            lblNombreFacturaServicio         = FindViewById <TextView>(Resource.Id.lblNombreFacturaServicio);
            lblDireccionFacturaServicio      = FindViewById <TextView>(Resource.Id.lblDireccionFacturaServicio);
            lblSuministroFacturaServicio     = FindViewById <TextView>(Resource.Id.lblSuministroFacturaServicio);
            lblTipoFacturaServicio           = FindViewById <TextView>(Resource.Id.lblTipoFacturaServicio);
            lblUbicacionFacturaServicio      = FindViewById <TextView>(Resource.Id.lblUbicacionFacturaServicio);
            mToolBar = FindViewById <SupportToolbar>(Resource.Id.toolbar9);
            SetSupportActionBar(mToolBar);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            SupportActionBar.SetTitle(mPagoServicios);

            //Guardar temporalmente varaibles pantalla
            strIdentificacion  = Intent.GetStringExtra(clsConstantes.strIdentificacionUsuario);
            strCuentaJson      = Intent.GetStringExtra(clsConstantes.strCuentaJson);
            imageUrl           = Intent.GetStringExtra(clsConstantes.strURLImagenUsuario);
            strIdUsuario       = Intent.GetStringExtra(clsConstantes.strIdUsuario);
            strFacturaServicio = Intent.GetStringExtra(clsConstantes.strFacturaServicio);
            strCooperativa     = Intent.GetStringExtra(clsConstantes.strCooperativas);

            clsCabeceraFacturaServicio objCabeceraFacturaServicio = JsonConvert.DeserializeObject <clsCabeceraFacturaServicio>(strFacturaServicio);

            List <clsDetalleFacturaServicio> detalleFacturaItems = objCabeceraFacturaServicio.detalle_factura;

            listView = FindViewById <ListView>(Resource.Id.ListaDetalleFacturaServicio);

            lblIdentificacionFacturaServicio.Text = objCabeceraFacturaServicio.identificacion_cliente;
            lblNombreFacturaServicio.Text         = objCabeceraFacturaServicio.nombre_cliente;
            lblDireccionFacturaServicio.Text      = objCabeceraFacturaServicio.direccion_suministro;
            lblSuministroFacturaServicio.Text     = objCabeceraFacturaServicio.numero_suministro;
            lblTipoFacturaServicio.Text           = objCabeceraFacturaServicio.tipo_suministro;
            lblUbicacionFacturaServicio.Text      = objCabeceraFacturaServicio.ubicacion_suministro;

            if (detalleFacturaItems.Count > 0)
            {
                listView.Adapter = new detalle_factura_adapter(this, detalleFacturaItems);
            }


            btnPagarFacturaServicio.Click += delegate
            {
                var intent = new Intent(this, typeof(ActivityPagoServicios));
                intent.PutExtra(clsConstantes.strIdentificacionUsuario, strIdentificacion);
                intent.PutExtra(clsConstantes.strURLImagenUsuario, imageUrl);
                intent.PutExtra(clsConstantes.strIdUsuario, strIdUsuario);
                intent.PutExtra(clsConstantes.strCuentaJson, strCuentaJson);
                intent.PutExtra(clsConstantes.strCooperativas, strCooperativa);
                intent.PutExtra(clsConstantes.strFacturaServicio, strFacturaServicio);
                StartActivity(intent);
                this.Finish();
            };
        }
Beispiel #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.PagoServicios);

            spinnerCuentaOrigen  = FindViewById <Spinner>(Resource.Id.spiCuentaOrigenPagoServicio);
            txtTipoSuministro    = FindViewById <EditText>(Resource.Id.txtTipoSuministroPagoServicio);
            btnRealizarPagos     = FindViewById <Button>(Resource.Id.btnRealizarPagoServicio);
            txtNumeroSuministro  = FindViewById <EditText>(Resource.Id.txtSuministroPagoServicio);
            txtMontoPago         = FindViewById <EditText>(Resource.Id.txtMontoPagoServicio);
            lblSaldoCuentaOrigen = FindViewById <TextView>(Resource.Id.lblSaldoCuentaPagoServicio);
            mToolBar             = FindViewById <SupportToolbar>(Resource.Id.toolbar4);
            SetSupportActionBar(mToolBar);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            SupportActionBar.SetTitle(mPagoServicios);

            //Guardar temporalmente varaibles pantalla
            strIdentificacion  = Intent.GetStringExtra(clsConstantes.strIdentificacionUsuario);
            strCuentaJson      = Intent.GetStringExtra(clsConstantes.strCuentaJson);
            imageUrl           = Intent.GetStringExtra(clsConstantes.strURLImagenUsuario);
            strIdUsuario       = Intent.GetStringExtra(clsConstantes.strIdUsuario);
            strFacturaServicio = Intent.GetStringExtra(clsConstantes.strFacturaServicio);
            strCooperativa     = Intent.GetStringExtra(clsConstantes.strCooperativas);

            lstCooperativas = JsonConvert.DeserializeObject <List <clsCooperativa> >(strCooperativa);

            string[] arrRespuesta = strCuentaJson.Split('|');
            string   strCuentas   = arrRespuesta[0];
            string   strTarjetas  = arrRespuesta[1];

            lstCuentas = JsonConvert.DeserializeObject <List <clsCuenta> >(strCuentas);

            objCabeceraFacturaServicio = JsonConvert.DeserializeObject <clsCabeceraFacturaServicio>(strFacturaServicio);


            spinnerCuentaOrigen.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            List <string> lstCuentasString = new List <string>();

            foreach (clsCuenta objCuenta in lstCuentas)
            {
                if (!lstCuentasString.Contains(objCuenta.numero_cuenta))
                {
                    lstCuentasString.Add(objCuenta.numero_cuenta);
                }
            }
            var adapter1 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleDropDownItem1Line, lstCuentasString);

            adapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
            spinnerCuentaOrigen.Adapter = adapter1;

            txtTipoSuministro.Text   = objCabeceraFacturaServicio.tipo_suministro;
            txtNumeroSuministro.Text = objCabeceraFacturaServicio.numero_suministro;
            txtMontoPago.Text        = objCabeceraFacturaServicio.detalle_factura.FindLast(x => x.detalle_item.ToLower().Contains("total")).valor_detalle.ToString();

            btnRealizarPagos.Click += async(sender, e) =>
            {
                if (String.IsNullOrEmpty(txtMontoPago.Text) ||
                    String.IsNullOrEmpty(txtNumeroSuministro.Text))
                {
                    Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);

                    alert.SetTitle("Alerta");
                    alert.SetMessage("Faltan campos por llenar");

                    RunOnUiThread(() => {
                        alert.Show();
                    });
                }

                else
                {
                    progress = new Android.App.ProgressDialog(this);
                    progress.Indeterminate = true;
                    progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                    progress.SetMessage("Realizando Pago");
                    progress.SetCancelable(true);
                    progress.Show();

                    string           strNumeroSuministro = objCabeceraFacturaServicio.numero_suministro;
                    string           strTipoServicio     = objCabeceraFacturaServicio.tipo_suministro;
                    clsTransferencia objTransferencia    = llenarDatosTransferencia();
                    string           strRespuesta        = await objServicioTransferencia.realizarPagoServicios(strIdentificacion, strNumeroSuministro, strTipoServicio, objTransferencia, objCooperativa);

                    if (!strRespuesta.ToLower().Contains("Alerta"))
                    {
                        strCuentaJson = await clsActividadesGenericas.modificarCuentaJson(strIdentificacion, strIdUsuario, lstCooperativas);

                        var intent = new Intent(this, typeof(ActivityMenu));
                        intent.PutExtra(clsConstantes.strIdentificacionUsuario, strIdentificacion);
                        intent.PutExtra(clsConstantes.strURLImagenUsuario, imageUrl);
                        intent.PutExtra(clsConstantes.strIdUsuario, strIdUsuario);
                        intent.PutExtra(clsConstantes.strCuentaJson, strCuentaJson);
                        intent.PutExtra(clsConstantes.strCooperativas, strCooperativa);
                        StartActivity(intent);
                        this.Finish();
                    }
                    else
                    {
                        Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                        progress.Cancel();
                        alert.SetTitle("Alerta");
                        alert.SetMessage("No se pudo procesar el pago");

                        RunOnUiThread(() => {
                            alert.Show();
                        });
                    }
                }
            };
        }