示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.vehicle_editor_activity);

            mInteractor = new VehicleEditorInteractor(ApplicationContext);
            mViewModel  = new VehicleEditorViewModel(this, mInteractor);

            mVehicleId = Intent.GetIntExtra(EXTRA_VEHICLE_ID, -1);
            Log.Info(TAG, "El ID es: " + mVehicleId);
            mFunction = Intent.GetIntExtra(EXTRA_FUNCTION, -1);
            Log.Info(TAG, "La Funcion es: " + mFunction);

            mPlaca         = FindViewById <EditText>(Resource.Id.ET_Placa);
            mMarca         = FindViewById <EditText>(Resource.Id.ET_Marca);
            mModelo        = FindViewById <EditText>(Resource.Id.ET_Modelo);
            mResponsable   = FindViewById <AutoCompleteTextView>(Resource.Id.ET_Responsable);
            LISTA_USUARIOS = mViewModel.obtenerListaUsuariosBDI();
            ArrayAdapter adaptador = new ArrayAdapter <string>(BaseContext, Android.Resource.Layout.SimpleDropDownItem1Line, LISTA_USUARIOS);

            mResponsable.Adapter = adaptador;
            mArea        = FindViewById <EditText>(Resource.Id.ET_Area);
            mEncargado   = FindViewById <EditText>(Resource.Id.ET_Encargado);
            mUMantto     = FindViewById <EditText>(Resource.Id.ET_UMantto);
            mFUMantto    = FindViewById <EditText>(Resource.Id.ET_FUMantto);
            mKilometraje = FindViewById <EditText>(Resource.Id.ET_Kilometraje);
            mCentral     = FindViewById <EditText>(Resource.Id.ET_Central);
            mEstado      = FindViewById <View>(Resource.Id.V_Estado);

            mTablaEdicion = FindViewById <View>(Resource.Id.tabla_edicion);
            mProgreso     = FindViewById <ProgressBar>(Resource.Id.pb_progreso);

            mAccept = FindViewById <Button>(Resource.Id.b_accept);
            mCancel = FindViewById <Button>(Resource.Id.b_cancel);

            mFUMantto.Click += (o, e) =>
            {
                DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time)
                {
                    mFUMantto.Text = DateToString(time);
                });
                frag.Show(FragmentManager, DatePickerFragment.TAG);
            };

            mAccept.Click += (o, e) =>
            {
                if (Bandera_Edicion == 1)
                {
                    Vehicle vehiculo = new Vehicle();

                    vehiculo.IdVehiculo  = mVehicleId;
                    vehiculo.Placa       = mPlaca.Text;
                    vehiculo.Marca       = mMarca.Text;
                    vehiculo.Modelo      = mModelo.Text;
                    vehiculo.Responsable = mResponsable.Text;
                    vehiculo.Area        = mArea.Text;
                    vehiculo.Encargado   = mEncargado.Text;
                    vehiculo.KUMantto    = Convert.ToUInt32(mUMantto.Text);
                    vehiculo.FUMantto    = StringToDate(mFUMantto.Text);
                    vehiculo.Kilometraje = Convert.ToUInt32(mKilometraje.Text);
                    vehiculo.Central     = mCentral.Text;
                    mViewModel.EvaluarEstadoVehiculoYAgregarBDE(mVehicleId, vehiculo);
                }
                else
                {
                    prepearEdition(1);
                    mAccept.Text = "Actualizar";
                }
            };

            mCancel.Click += (o, e) =>
            {
                Finish();
            };

            prepearEdition(mFunction);

            prepearData(mVehicleId);
        }
示例#2
0
 public void setViewModel(VehicleEditorViewModel viewModel)
 {
     mViewModel = viewModel;
 }