Esempio n. 1
0
        private void deleteVolumeFromPreviusBox()
        {
            var previusBox = BoxDAO.getBox(Item.Container);

            previusBox.RemainVolume += Item.Volume;
            BoxDAO.updateBox(previusBox);
        }
Esempio n. 2
0
        public UIContextualAction clearAction(int row)
        {
            var action = UIContextualAction.FromContextualActionStyle(
                UIContextualActionStyle.Normal, "Svuota",
                (insertAction, view, success) =>
            {
                var source      = Source as BoxViewController;
                var boxSelected = source.Boxes[row];

                var items = itemDAO.getAllItemInBox(boxSelected.Id);
                foreach (var b in items)
                {
                    b.Container = 0;
                    itemDAO.updateItem(b);
                    boxSelected.RemainVolume += b.Volume;
                }
                boxDAO.updateBox(boxSelected);

                var alertController = UIAlertController.Create("Box Vuoto", "Il tuo box è stato svuotato", UIAlertControllerStyle.Alert);

                alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                Source.PresentViewController(alertController, true, null);

                success(true);
            });

            action.BackgroundColor = UIColor.LightGray;

            return(action);
        }
Esempio n. 3
0
        private void updateBox(int idBox, Model.Item item)
        {
            var box = boxDAO.getBox(idBox);
            var remainVolumeBoxSelexted = box.RemainVolume;

            box.RemainVolume = remainVolumeBoxSelexted - item.Volume;
            boxDAO.updateBox(box);
        }
Esempio n. 4
0
        private void deleteItem(NSIndexPath indexPath)
        {
            var index = indexPath.Row;
            var item  = Items[index];

            if (item.Container != 0)
            {
                var box = boxDAO.getBox(item.Container);
                box.RemainVolume += item.Volume;
                boxDAO.updateBox(box);
            }
            Items.Remove(item);
            TableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
            itemDAO.deleteItem(item);
        }
Esempio n. 5
0
        private void insertObjectInBox(NSIndexPath indexPath, Box boxSelected)
        {
            var idBoxSelected           = boxSelected.Id;
            var remainVolumeBoxSelexted = boxSelected.RemainVolume;

            tView.CellAt(indexPath).Accessory = UITableViewCellAccessory.Checkmark;

            Item.Container = idBoxSelected;

            ItemDAO = new ItemDAO();
            ItemDAO.updateItem(Item);

            boxSelected.RemainVolume = remainVolumeBoxSelexted - Item.Volume;
            BoxDAO.updateBox(boxSelected);
            boxes = BoxDAO.getAllBox();
        }
Esempio n. 6
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:
                var item = Items[indexPath.Row];
                var box  = boxDAO.getBox(item.Container);
                box.RemainVolume += item.Volume;
                boxDAO.updateBox(box);
                item.Container = 0;
                itemDAO.updateItem(item);
                Items.Remove(item);
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                break;

            default:
                break;
            }
        }
Esempio n. 7
0
 partial void SaveChanges_TouchUpInside(UIButton sender)
 {
     Box.Name        = nameTextField.Text;
     Box.Description = descriptionTextField.Text;
     boxDAO.updateBox(Box);
 }