Ejemplo n.º 1
0
        //borrado con un deslizamiento
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, Foundation.NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:
                // remove the item from the underlying data source
                var fileName         = "dbCRM.db3";
                var documentsPath    = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                var libraryPath      = Path.Combine(documentsPath, "..", "Library");
                var path             = Path.Combine(libraryPath, fileName);
                IContactRepository a = new SQLiteContactRepository(path);

                Contact c = TableItems[indexPath.Row];
                a.Delete(c);
                // delete the row from the table
                TableItems.RemoveAt(indexPath.Row);
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine("Borrar: " + TableItems[indexPath.Row].contactName);
                break;
            }
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var fileName      = "dbCRM.db3";
            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var libraryPath   = Path.Combine(documentsPath, "..", "Library");
            var path          = Path.Combine(libraryPath, fileName);

            IContactRepository connection = new SQLiteContactRepository(path);

            tableItems = connection.Read();
            tvContact  = new UITableView
            {
                Frame  = new CoreGraphics.CGRect(10, 0, View.Bounds.Width, View.Bounds.Height),
                Source = new TableSourceViewController(tableItems, this)
            };
            View.AddSubview(tvContact);
            btnAdd.TouchUpInside += delegate
            {
                addViewController next = this.Storyboard.InstantiateViewController("addViewController") as addViewController;
                //	next.id = tableItems[0].contactId;
                this.NavigationController.PushViewController(next, true);
                //tableView.DeselectRow(indexPath, true);
                //owner.PresentViewController(okAlertController, true, null)
            };
        }
Ejemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //lblNombreBlanco.Text = nombre;
            var fileName      = "dbCRM.db3";
            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var libraryPath   = Path.Combine(documentsPath, "..", "Library");
            var path          = Path.Combine(libraryPath, fileName);

            IContactRepository connection = new SQLiteContactRepository(path);

            //contacto = connection.readById(id);
            txtEdad.Hidden = true;
            //Accion al boton
            btnAddDetalle.TouchUpInside += delegate {
                Contact c1 = new Contact();
                c1.contactName      = txtNombre.Text;
                c1.contactCellphone = txtTelefono.Text;
                c1.contactClass     = "3";
                c1.contactEmail     = txtCorreo.Text;
                c1.contactStreet    = txtDireccion.Text;
                c1.contactState     = txtEstado.Text;
                c1.contactCountry   = txtPais.Text;
                connection.Crear(c1);
                UIAlertController okAlertController = UIAlertController.Create("Contacto Agregado", txtNombre.Text, UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(okAlertController, true, null);
                this.NavigationController.PopViewController(true);
            };
        }
Ejemplo n.º 4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var fileName      = "dbCRM.db3";
            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var libraryPath   = Path.Combine(documentsPath, "..", "Library");
            var path          = Path.Combine(libraryPath, fileName);

            IContactRepository connection = new SQLiteContactRepository(path);

            List <Contact> tableUpdated = connection.Read();

            //creamos tableview con sus parametros
            tvContact.Source = new TableSourceViewController(tableUpdated, this);
            tvContact.ReloadData();
        }
Ejemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var fileName      = "dbCRM.db3";
            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var libraryPath   = Path.Combine(documentsPath, "..", "Library");
            var path          = Path.Combine(libraryPath, fileName);

            IContactRepository connection = new SQLiteContactRepository(path);

            contacto = connection.readById(id);

            txtNombre.Text    = contacto.contactName;
            txtCorreo.Text    = contacto.contactEmail;
            txtPuesto.Text    = contacto.contactClass;
            txtPuesto.Enabled = false;
            txtEdad.Text      = "No asignado";
            txtEdad.Hidden    = true;
            txtDireccion.Text = contacto.contactStreet;
            txtPais.Text      = contacto.contactCountry;
            txtEstado.Text    = contacto.contactState;
            txtTelefono.Text  = contacto.contactCellphone;

            //Accion al boton
            btnEdi.TouchUpInside += delegate {
                Contact c2 = connection.readById(id);

                c2.contactName      = txtNombre.Text;
                c2.contactCellphone = txtTelefono.Text;
                c2.contactClass     = txtPuesto.Text;
                c2.contactCountry   = txtPais.Text;
                c2.contactEmail     = txtCorreo.Text;
                c2.contactStreet    = txtDireccion.Text;
                c2.contactState     = txtEstado.Text;



                connection.Update(c2);

                UIAlertController okAlertController = UIAlertController.Create("Contacto Editado", txtNombre.Text, UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(okAlertController, true, null);
                this.NavigationController.PopViewController(true);
            };

            btnPromover.TouchUpInside += delegate
            {
                Contact c3 = connection.readById(id);
                if (c3.contactClass == "3")
                {
                    c3.contactClass = "2";

                    UIAlertController okAlertController = UIAlertController.Create("Contacto Promovido", txtNombre.Text, UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    this.PresentViewController(okAlertController, true, null);
                    this.NavigationController.PopViewController(true);
                }

                else if (c3.contactClass == "2")
                {
                    c3.contactClass = "1";
                    UIAlertController okAlertController = UIAlertController.Create("Contacto Promovido", txtNombre.Text, UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    this.PresentViewController(okAlertController, true, null);
                    this.NavigationController.PopViewController(true);
                }

                else if (c3.contactClass == "1")
                {
                    UIAlertController okAlertController = UIAlertController.Create("El usuario no se puede promover porque es nivel 1", txtNombre.Text, UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    this.PresentViewController(okAlertController, true, null);
                }
                else if (c3.contactClass == "0")
                {
                    UIAlertController okAlertController = UIAlertController.Create("El usuario no se puede promover porque ya ha sido descartado", txtNombre.Text, UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    this.PresentViewController(okAlertController, true, null);
                }



                connection.Update(c3);
            };

            btndescartar.TouchUpInside += delegate
            {
                Contact c3 = connection.readById(id);
                c3.contactClass = "0";

                connection.Update(c3);

                UIAlertController okAlertController = UIAlertController.Create("Contacto descartado exitosamente", txtNombre.Text, UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                this.PresentViewController(okAlertController, true, null);
                this.NavigationController.PopViewController(true);
            };
        }