private void ButtonClick(object sender, EventArgs e) { AutoCompleteTextView textView = FindViewById <AutoCompleteTextView>(Resource.Id.autoCompleteProveedor); AdoProveedor adoProveedor = new AdoProveedor(); string Proveedor = ""; if (textView.Text != "") { Proveedor = textView.Text; } adoProveedor.Proveedor = Proveedor; var Proveedores = adoProveedor.AdoSelectID(); var adapter = new ArrayAdapter <String>(this, Resource.Layout.list_item, Proveedores); textView.Adapter = adapter; ListAdapter = new ArrayAdapter <string>(this, Resource.Layout.list_item, Proveedores); ListView.TextFilterEnabled = true; ListView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args) { Toast.MakeText(Application, ((TextView)args.View).Text, ToastLength.Short).Show(); this.FinishAndRemoveTask(); var intent = new Intent(this, typeof(ProveedorActivity)); intent.PutExtra("Proveedor", ((TextView)args.View).Text); StartActivity(intent); }; }
public override bool OnOptionsItemSelected(IMenuItem item) { TextView textViewDNI = FindViewById <TextView>(Resource.Id.text_DNI); textViewDNI.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewNombre = FindViewById <TextView>(Resource.Id.text_Nombre); textViewNombre.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewCiudad = FindViewById <TextView>(Resource.Id.text_Ciudad); textViewCiudad.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewDireccion = FindViewById <TextView>(Resource.Id.text_Direccion); textViewDireccion.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewTelefono = FindViewById <TextView>(Resource.Id.text_telefono); textViewTelefono.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewCelular = FindViewById <TextView>(Resource.Id.text_celular); textViewCelular.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewEmail = FindViewById <TextView>(Resource.Id.text_Email); textViewEmail.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); TextView textViewSitioWeb = FindViewById <TextView>(Resource.Id.text_sitioWeb); textViewSitioWeb.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); EditText editText_DNI = FindViewById <EditText>(Resource.Id.editText_DNI); EditText editText_Nombre = FindViewById <EditText>(Resource.Id.editText_Nombre); EditText editText_Ciudad = FindViewById <EditText>(Resource.Id.editText_Ciudad); EditText editText_Direccion = FindViewById <EditText>(Resource.Id.editText_Direccion); EditText editText_Telefono = FindViewById <EditText>(Resource.Id.editText_telefono); EditText editText_Celular = FindViewById <EditText>(Resource.Id.editText_Celular); EditText editText_Email = FindViewById <EditText>(Resource.Id.editText_Email); EditText editText_SitioWeb = FindViewById <EditText>(Resource.Id.editText_StiioWeb); AdoProveedor adoProveedor = new AdoProveedor(); switch (item.TitleFormatted.ToString()) { case "Save": Validado = 0; //TextView textViewDNI = FindViewById<TextView>(Resource.Id.text_DNI); if (editText_DNI.Text == "") { Validado++; textViewDNI.SetTextColor(Android.Graphics.Color.ParseColor("#E85434")); } else { //valida existencia de DNI adoProveedor.Proveedor = editText_DNI.Text; var resp = adoProveedor.AdoSelectID(); if (resp[0] != "") { Toast.MakeText(this, "DNI ya existe", ToastLength.Long).Show(); textViewDNI.SetTextColor(Android.Graphics.Color.ParseColor("#E85434")); Validado++; } else { textViewDNI.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); } } //TextView textViewNombre = FindViewById<TextView>(Resource.Id.text_Nombre); if (editText_Nombre.Text == "") { Validado++; textViewNombre.SetTextColor(Android.Graphics.Color.ParseColor("#E85434")); } else { textViewNombre.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); } //TextView textViewCelular = FindViewById<TextView>(Resource.Id.text_celular); if (editText_Celular.Text == "") { Validado++; textViewCelular.SetTextColor(Android.Graphics.Color.ParseColor("#E85434")); } else { textViewCelular.SetTextColor(Android.Graphics.Color.ParseColor("#2C3E50")); } if (Validado == 0) { adoProveedor.DNI = editText_DNI.Text; adoProveedor.Nombre = editText_Nombre.Text; adoProveedor.Ciudad = editText_Ciudad.Text; adoProveedor.Direccion = editText_Direccion.Text; adoProveedor.Telefono = editText_Telefono.Text; adoProveedor.Celular = editText_Celular.Text; adoProveedor.Email = editText_Email.Text; adoProveedor.SitioWeb = editText_SitioWeb.Text; if (Guardar == true) { toast = adoProveedor.AdoCreate(); } else { toast = adoProveedor.AdoEditar(); } if (toast == "Proveedor creado correctamente" || toast == "Proveedor Editado correctamente") { editText_DNI.Text = ""; editText_Nombre.Text = ""; editText_Ciudad.Text = ""; editText_Direccion.Text = ""; editText_Telefono.Text = ""; editText_Celular.Text = ""; editText_Email.Text = ""; editText_SitioWeb.Text = ""; Toast.MakeText(this, toast, ToastLength.Long).Show(); } else { Toast.MakeText(this, toast, ToastLength.Long).Show(); } if (toast == "Cliente Editado correctamente") { this.FinishAndRemoveTask(); var intent2 = new Intent(this, typeof(ViewProveedorActivity)); StartActivity(intent2); } } break; case "Consulta": this.FinishAndRemoveTask(); var intent = new Intent(this, typeof(ViewProveedorActivity)); StartActivity(intent); break; case "Delete": if (Guardar == false) { if (editText_DNI.Text != "") { adoProveedor.DNI = editText_DNI.Text; toast = adoProveedor.AdoEliminar(); Toast.MakeText(this, toast, ToastLength.Long).Show(); if (toast == "Proveedor eliminado correctamente") { this.FinishAndRemoveTask(); var intent2 = new Intent(this, typeof(ViewProveedorActivity)); StartActivity(intent2); } } else { Toast.MakeText(this, "Elije un Proveedor", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Elije un Proveedor", ToastLength.Long).Show(); } break; case "Clear": editText_DNI.Text = ""; editText_Nombre.Text = ""; editText_Ciudad.Text = ""; editText_Direccion.Text = ""; editText_Telefono.Text = ""; editText_Celular.Text = ""; editText_Email.Text = ""; editText_SitioWeb.Text = ""; Guardar = true; break; default: break; } return(base.OnOptionsItemSelected(item)); }