private void AddItem(object sender, RoutedEventArgs e)
        {
            Contact c = Contact.GetNewContact();

            _contacts.Add(c);
            MasterListView.ScrollIntoView(c);

            // Select this item in case that the list is empty
            if (MasterListView.SelectedIndex == -1)
            {
                MasterListView.SelectedIndex = 0;
                _selectedContact             = MasterListView.SelectedItem as Contact;
                // Details view is collapsed, in case there is not items.
                // You should show it just in case.
                DetailContentPresenter.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 2
0
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                try
                {
                    //Save
                    if (flag == 0)
                    {
                        var localidad = new Localidades
                        {
                            Departamento = DepartamentoTextBox.Text,
                            Provincia    = ProvinciaTextBox.Text,
                            Distrito     = DistritoTextBox.Text,
                            Localidad    = LocalidadTextBox.Text,
                            Serviciosid  = (int)ServicioComboBox.SelectedValue,
                            Proyectoid   = (int)ProyectoComboBox.SelectedValue,
                            Vsatid       = Convert.ToInt32(VsatidTextBox.Text),
                            Costo        = double.Parse(CostoTextBox.Text, System.Globalization.CultureInfo.InvariantCulture),
                            Latitud      = double.Parse(LatitudTextBox.Text, System.Globalization.CultureInfo.InvariantCulture),
                            Longitud     = double.Parse(LongitudTextBox.Text, System.Globalization.CultureInfo.InvariantCulture),
                            Telefonos    = TelefonosTextBox.Text,
                        };
                        db.Localidades.Add(localidad);
                        await db.SaveChangesAsync();

                        cvs.Source = await
                                     db.Localidades
                                     .Include(x => x.Proyectos)
                                     .Include(x => x.Servicios)
                                     .GroupBy(x => x.Proyectos.Descripcion)
                                     .ToListAsync();

                        InputModalDialog.IsModal    = false;
                        MasterListView.SelectedItem = localidad;
                        MasterListView.ScrollIntoView(localidad);
                    }
                    //Edit
                    else if (flag == 1)
                    {
                        var itemSelected = (Localidades)MasterListView.SelectedItem;

                        if (MasterListView.SelectedItem != null)
                        {
                            itemSelected.Departamento = DepartamentoTextBox.Text;
                            itemSelected.Provincia    = ProvinciaTextBox.Text;
                            itemSelected.Distrito     = DistritoTextBox.Text;
                            itemSelected.Localidad    = LocalidadTextBox.Text;
                            itemSelected.Serviciosid  = (int)ServicioComboBox.SelectedValue;
                            itemSelected.Proyectoid   = (int)ProyectoComboBox.SelectedValue;
                            itemSelected.Vsatid       = Convert.ToInt32(VsatidTextBox.Text);
                            itemSelected.Costo        = double.Parse(CostoTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                            itemSelected.Latitud      = double.Parse(LatitudTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                            itemSelected.Longitud     = double.Parse(LongitudTextBox.Text, System.Globalization.CultureInfo.InvariantCulture);
                            itemSelected.Telefonos    = TelefonosTextBox.Text;

                            db.Localidades.Update(itemSelected);
                            await db.SaveChangesAsync();

                            cvs.Source = await
                                         db.Localidades
                                         .Include(x => x.Proyectos)
                                         .Include(x => x.Servicios)
                                         .GroupBy(x => x.Proyectos.Descripcion)
                                         .ToListAsync();

                            InputModalDialog.IsModal    = false;
                            MasterListView.SelectedItem = itemSelected;
                            MasterListView.ScrollIntoView(itemSelected);
                        }
                    }
                }
                catch (Exception ex)
                {
                    var message = new MessageDialog(ex.InnerException.ToString());
                    await message.ShowAsync();
                }
                var query = db.Localidades.Count();
                if (query <= 0)
                {
                    EmptyItemsBorder.Visibility  = Visibility.Visible;
                    EmptyItemsBorder2.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
            //Repopulate Print Helper
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new LocalidadesReport());
            }
            //Enable
            SearchAutoSuggestBox.IsEnabled = true;
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
        }
Exemplo n.º 3
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                //Save
                if (flag == 0)
                {
                    var partNumber = new PartNumbers
                    {
                        Categoria   = (Categoria)CategoriaComboBox.SelectedItem,
                        PartNumber  = PartNumberTextBox.Text,
                        Descripcion = DescripcionTextBox.Text
                    };
                    db.PartNumbers.Add(partNumber);
                    await db.SaveChangesAsync();

                    cvs.Source = await
                                 db.PartNumbers
                                 .GroupBy(x => x.Categoria)
                                 .ToListAsync();

                    InputModalDialog.IsModal    = false;
                    MasterListView.SelectedItem = partNumber;
                    MasterListView.ScrollIntoView(partNumber);
                }
                //Edit
                else if (flag == 1)
                {
                    var itemSelected = (PartNumbers)MasterListView.SelectedItem;

                    if (MasterListView.SelectedItem != null)
                    {
                        itemSelected.Categoria   = (Categoria)CategoriaComboBox.SelectedItem;
                        itemSelected.PartNumber  = PartNumberTextBox.Text;
                        itemSelected.Descripcion = DescripcionTextBox.Text;

                        db.PartNumbers.Update(itemSelected);
                        await db.SaveChangesAsync();

                        cvs.Source = await
                                     db.PartNumbers
                                     .GroupBy(x => x.Categoria)
                                     .ToListAsync();

                        InputModalDialog.IsModal    = false;
                        MasterListView.SelectedItem = itemSelected;
                        MasterListView.ScrollIntoView(itemSelected);
                    }
                }
                var query1 = db.PartNumbers.Count();
                if (query1 <= 0)
                {
                    EmptyItemsBorder.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
            //Enable
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
            SearchAutoSuggestBox.IsEnabled = true;
        }
Exemplo n.º 4
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                //Save
                if (flag == 0)
                {
                    var locacion = new Locaciones()
                    {
                        Descripcion = DescripcionTextBox.Text,
                    };
                    string apocope1 = locacion.Descripcion;
                    locacion.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope1.Substring(1, 2).ToUpper();

                    db.Locaciones.Add(locacion);
                    await db.SaveChangesAsync();

                    MasterListView.ItemsSource = await
                                                 db.Locaciones
                                                 .OrderBy(x => x.Descripcion)
                                                 .ToListAsync();

                    InputModalDialog.IsModal    = false;
                    MasterListView.SelectedItem = locacion;
                    MasterListView.ScrollIntoView(locacion);
                }
                //Edit
                else if (flag == 1)
                {
                    var itemSelected = (Locaciones)MasterListView.SelectedItem;

                    if (MasterListView.SelectedItem != null)
                    {
                        itemSelected.Descripcion = DescripcionTextBox.Text;
                        string apocope1 = itemSelected.Descripcion;
                        itemSelected.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope1.Substring(1, 2).ToUpper();

                        db.Locaciones.Update(itemSelected);
                        await db.SaveChangesAsync();

                        MasterListView.ItemsSource = await
                                                     db.Locaciones
                                                     .OrderBy(x => x.Descripcion)
                                                     .ToListAsync();

                        InputModalDialog.IsModal    = false;
                        MasterListView.SelectedItem = itemSelected;
                        MasterListView.ScrollIntoView(itemSelected);
                    }
                }
                //Enable
                MasterListView.IsEnabled       = true;
                ListViewCommandBar.IsEnabled   = true;
                SearchAutoSuggestBox.IsEnabled = true;

                var query1 = db.Locaciones.Count();
                if (query1 <= 0)
                {
                    EmptyItemsBorder.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemplo n.º 5
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new ProjectContext())
                {
                    //Save
                    if (flag == 0)
                    {
                        var invetario = new Inventario
                        {
                            Balance      = Convert.ToInt32(BalanceTextBox.Text),
                            AlmacenesId  = (int)AlmacenComboBox.SelectedValue,
                            LocacionesId = (int)LocacionComboBox.SelectedValue,
                            PartNumberId = await
                                           db.PartNumbers
                                           .Where(x => x.PartNumber == PartNumberAutoSuggestBox.Text)
                                           .Select(x => x.Id)
                                           .SingleOrDefaultAsync(),
                        };

                        var query = db.Inventario
                                    .Include(x => x.Almacenes)
                                    .Include(x => x.Locaciones)
                                    .Include(x => x.PartNumbers)
                                    .Count(x => x.AlmacenesId == invetario.AlmacenesId &&
                                           x.LocacionesId == invetario.LocacionesId &&
                                           x.PartNumberId == invetario.PartNumberId);

                        if (query >= 1)
                        {
                            var message = new MessageDialog("Ya existe el item que usted desea crear", "Advertencia");

                            await message.ShowAsync();

                            SaveButton.IsEnabled = false;
                        }
                        else
                        {
                            db.Inventario.Add(invetario);

                            await db.SaveChangesAsync();

                            cvs.Source = await db.Inventario
                                         .Include(x => x.Almacenes)
                                         .Include(x => x.Locaciones)
                                         .Include(x => x.PartNumbers)
                                         .OrderBy(x => x.Locaciones.Descripcion)
                                         .GroupBy(x => x.Almacenes.Descripcion)
                                         .ToListAsync();

                            InputModalDialog.IsModal = false;

                            MasterListView.SelectedItem = invetario;
                            MasterListView.ScrollIntoView(invetario);
                        }
                    }
                    //Edit
                    else if (flag == 1)
                    {
                        var itemSelected = (Inventario)MasterListView.SelectedItem;

                        if (MasterListView.SelectedItem != null)
                        {
                            itemSelected.PartNumberId =
                                await
                                db.PartNumbers.Where(x => x.PartNumber == PartNumberAutoSuggestBox.Text)
                                .Select(x => x.Id)
                                .SingleOrDefaultAsync();

                            itemSelected.AlmacenesId  = (int)AlmacenComboBox.SelectedValue;
                            itemSelected.LocacionesId = (int)LocacionComboBox.SelectedValue;
                            itemSelected.Balance      = Convert.ToInt32(BalanceTextBox.Text);
                            {
                                db.Inventario.Update(itemSelected);
                                await db.SaveChangesAsync();

                                cvs.Source = await db.Inventario
                                             .Include(x => x.Almacenes)
                                             .Include(x => x.Locaciones)
                                             .Include(x => x.PartNumbers)
                                             .OrderBy(x => x.Locaciones.Descripcion)
                                             .GroupBy(x => x.Almacenes.Descripcion)
                                             .ToListAsync();

                                InputModalDialog.IsModal = false;

                                MasterListView.SelectedItem = itemSelected;
                                MasterListView.ScrollIntoView(itemSelected);
                            }
                        }
                    }
                    var query1 = db.Inventario.Count();
                    if (query1 <= 0)
                    {
                        EmptyItemsBorder.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        EmptyItemsBorder.Visibility = Visibility.Collapsed;
                    }
                }
            }
            catch (Exception ex)
            {
                var message = new MessageDialog(ex.Message);
                await message.ShowAsync();
            }
            //Repopulate Print Helper
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new InventarioReport());
            }

            //Enable
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
            SearchAutoSuggestBox.IsEnabled = true;
        }
Exemplo n.º 6
0
        private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
        {
            using (var db = new ProjectContext())
            {
                //Add
                if (flag == 0)
                {
                    var newTecnico = new Tecnicos
                    {
                        Nombre          = NombreTextBox.Text,
                        Apellido        = ApellidoTextBox.Text,
                        Dni             = DniTextBox.Text,
                        Direccion       = DireccionTextBox.Text,
                        FechaNacimiento = FechaNacimientoDatePicker.Date.LocalDateTime,
                        Email           = EmailTextBox.Text,
                        Telefono        = Int32.Parse(TelefonoTextBox.Text),
                    };
                    string apocope1 = newTecnico.Nombre;
                    string apocope2 = newTecnico.Apellido;
                    newTecnico.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope2.Substring(0, 1).ToUpper();
                    db.Tecnicos.Add(newTecnico);
                    await db.SaveChangesAsync();

                    TecnicosList = await db.Tecnicos.OrderBy(x => x.Nombre).ToListAsync();

                    cvs.Source = GetGroupsByLetter();

                    InputModalDialog.IsModal    = false;
                    MasterListView.SelectedItem = newTecnico;
                    MasterListView.ScrollIntoView(newTecnico);
                }
                //Edit
                else if (flag == 1)
                {
                    var itemSelected = (Tecnicos)MasterListView.SelectedItem;

                    if (MasterListView.SelectedItem != null)
                    {
                        itemSelected.Nombre          = NombreTextBox.Text;
                        itemSelected.Apellido        = ApellidoTextBox.Text;
                        itemSelected.Dni             = DniTextBox.Text;
                        itemSelected.Direccion       = DireccionTextBox.Text;
                        itemSelected.FechaNacimiento = FechaNacimientoDatePicker.Date.LocalDateTime;
                        itemSelected.Email           = EmailTextBox.Text;
                        itemSelected.Telefono        = Int32.Parse(TelefonoTextBox.Text);

                        string apocope1 = itemSelected.Nombre;
                        string apocope2 = itemSelected.Apellido;

                        itemSelected.Apocope = apocope1.Substring(0, 1).ToUpper() + apocope2.Substring(0, 1).ToUpper();

                        db.Tecnicos.Update(itemSelected);

                        await db.SaveChangesAsync();

                        TecnicosList = await db.Tecnicos.OrderBy(x => x.Nombre).ToListAsync();

                        cvs.Source = GetGroupsByLetter();

                        InputModalDialog.IsModal    = false;
                        MasterListView.SelectedItem = itemSelected;
                        MasterListView.ScrollIntoView(itemSelected);
                    }
                }
                var query = db.Tecnicos.Count();
                if (query <= 0)
                {
                    EmptyItemsBorder.Visibility  = Visibility.Visible;
                    EmptyItemsBorder2.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyItemsBorder.Visibility = Visibility.Collapsed;
                }
            }
            if (printHelper != null)
            {
                printHelper.UnregisterForPrinting();
                // Initalize common helper class and register for printing
                printHelper = new PrintHelper(this);
                printHelper.RegisterForPrinting();

                // Initialize print content for this scenario
                printHelper.PreparePrintContent(new TecnicosReport());
            }

            //Enable
            MasterListView.IsEnabled       = true;
            ListViewCommandBar.IsEnabled   = true;
            SearchAutoSuggestBox.IsEnabled = true;
        }