private void ChangePriority_OK(object sender, RoutedEventArgs e)
        {
            var a = PriorityComboBox.SelectedItem.ToString();

            if (PriorityComboBox.SelectedItem.ToString() == "System.Windows.Controls.ComboBoxItem: Idle")
            {
                (model.SelectedItem as Process).PriorityClass = ProcessPriorityClass.Idle;
            }
            else if (PriorityComboBox.SelectedItem.ToString() == "System.Windows.Controls.ComboBoxItem: Normal")
            {
                (model.SelectedItem as Process).PriorityClass = ProcessPriorityClass.Normal;
            }
            else if (PriorityComboBox.SelectedItem.ToString() == "System.Windows.Controls.ComboBoxItem: High")
            {
                (model.SelectedItem as Process).PriorityClass = ProcessPriorityClass.High;
            }
            else if (PriorityComboBox.SelectedItem.ToString() == "System.Windows.Controls.ComboBoxItem: RealTime")
            {
                (model.SelectedItem as Process).PriorityClass = ProcessPriorityClass.RealTime;
            }
            //  (model.SelectedItem as Process).PriorityClass = PriorityTextBox.Text;
            model.UpdateProcPriorityChanged();
            MasterListView.GetBindingExpression(ListView.ItemsSourceProperty)
            .UpdateTarget();
        }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="subsetModel">The object that holds the subset list.</param>
 /// <param name="control">The <see cref="MasterListView"/> control that we'll be binding to.</param>
 /// <param name="masterModel">The object that holds the master list.</param>
 /// <param name="getMasterList">A delegate that returns the master list.</param>
 /// <param name="getSubsetList">A delegate that returns the subset list.</param>
 /// <param name="getListIdentifier">A delegate that returns the identifier from a list item.</param>
 public MasterListToSubsetBinder(TSubsetModel subsetModel, MasterListView control, TMasterModel masterModel,
                                 Expression <Func <TSubsetModel, IList <TIdentifier> > > getSubsetList,
                                 Expression <Func <TMasterModel, IList <TListModel> > > getMasterList,
                                 Expression <Func <TListModel, TIdentifier> > getListIdentifier)
     : base(masterModel, control, getMasterList)
 {
     _SubsetModel                 = subsetModel;
     _GetSubsetListExpression     = getSubsetList;
     _GetListIdentifierExpression = getListIdentifier;
 }
        /// <summary>
        /// The constructor will create a new QuerryProcessor object upon creation. It writes the
        /// number of 4 database entities in the specified collections. It also querries all the
        /// 4 collections to fill the stack panels.
        /// </summary>
        /// <param name="mongoClient">the client created in the log in page.</param>
        public DiscogsMain(MongoClient mongoClient)
        {
            this.querryProcessor = new QuerryProcessor(mongoClient);
            InitializeComponent();
            //Intitializing the artists tab
            artistsTab.Header = String.Format($"{artistsTab.Header} {querryProcessor.NumArtists}");
            List <Artist> artistOutput = querryProcessor.artistRead(0);

            for (int i = 0; i < artistOutput.Count; i++)
            {
                ArtistListView currentView = new ArtistListView(artistOutput[i], querryProcessor.DiscogsDatabase);
                artistPanel.Children.Add(currentView);
            }
            artistResultSize      = querryProcessor.NumArtists;
            artistCurrentPage     = 0;
            artistPanelStats.Text = String.Format($"Showing {artistCurrentPage + 1} - 20 of {artistResultSize}");
            //Initializing the labels tab
            labelsTab.Header = String.Format($"{labelsTab.Header} {querryProcessor.NumLabels}");
            List <Label> labelOutput = querryProcessor.labelRead(0);

            for (int i = 0; i < labelOutput.Count; i++)
            {
                LabelListView currentView = new LabelListView(labelOutput[i], querryProcessor.DiscogsDatabase);
                labelsPanel.Children.Add(currentView);
            }
            labelResultSize      = querryProcessor.NumLabels;
            labelCurrentPage     = 0;
            labelPanelStats.Text = String.Format($"Showing {labelCurrentPage + 1} - 20 of {labelResultSize}");
            //Intializing the masters tab
            mastersTab.Header = String.Format($"{mastersTab.Header} {querryProcessor.NumMasters}");

            List <Master> masterOutput = querryProcessor.masterRead(0);

            for (int i = 0; i < masterOutput.Count; i++)
            {
                MasterListView currentView = new MasterListView(masterOutput[i], querryProcessor.DiscogsDatabase);
                mastersPanel.Children.Add(currentView);
            }
            masterResultSize      = querryProcessor.NumMasters;
            masterCurrentPage     = 0;
            masterPanelStats.Text = String.Format($"Showing {masterCurrentPage + 1} - 20 of {masterResultSize}");
            //Initializing the releases tab
            releasesTab.Header = String.Format($"{releasesTab.Header} {querryProcessor.NumReleases}");
            releaseResultSize  = querryProcessor.NumReleases;
            List <Release> releaseOutput = querryProcessor.releaseRead(0);

            for (int i = 0; i < releaseOutput.Count; i++)
            {
                ReleaseListView currentView = new ReleaseListView(releaseOutput[i], querryProcessor.DiscogsDatabase);
                releasesPanel.Children.Add(currentView);
            }
            releaseResultSize      = querryProcessor.NumReleases;
            releaseCurrentPage     = 0;
            releasePanelStats.Text = String.Format($"Showing {releaseCurrentPage + 1} - 20 of {releaseResultSize}");
        }
Ejemplo n.º 4
0
        private void EmptyDataPage_Loaded(object sender, RoutedEventArgs e)
        {
            Contacts = Contact.GetContacts(0);
            MasterListView.DataContext = this;
            MasterListView.Refresh     = async() =>
            {
                await Task.Delay(TimeSpan.FromSeconds(3));

                Contact.GetContacts(50).ToList().ForEach(o => Contacts.Add(o));
                MasterListView.SetRefresh(false);
            };
        }
Ejemplo n.º 5
0
        private void LoadMorePage_Loaded(object sender, RoutedEventArgs e)
        {
            Contacts = Contact.GetContacts(30);
            MasterListView.DataContext = this;
            MasterListView.LoadMore    = async() =>
            {
                if (_currentPageNum < MAX_PAGE)
                {
                    await Task.Delay(2000);

                    _currentPageNum++;
                    Contact.GetContacts(30).ToList().ForEach(o => Contacts.Add(o));
                }
                MasterListView.FinishLoadingMore();
            };
        }
        private void LoadMorePage_Loaded(object sender, RoutedEventArgs e)
        {
            _allContacts = Contact.GetContactsGrouped(100);
            UpdateContactsForPage();
            MasterListView.LoadMore = async() =>
            {
                if (_currentPageNum < MAX_PAGE)
                {
                    await Task.Delay(2000);

                    _currentPageNum++;
                    UpdateContactsForPage();
                }
                MasterListView.FinishLoadingMore();
            };
        }
        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;
            }
        }
Ejemplo n.º 8
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;
        }
        /// <summary>
        /// Logic for navigating backwards.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void previousButton_Click(object sender, RoutedEventArgs e)
        {
            if (artistsTab.IsSelected)
            {
                if (artistCurrentPage != 0)
                {
                    artistCurrentPage--;
                    List <Artist> output = querryProcessor.artistQuery((int)artistCurrentPage, currentartistQuerry, Builders <BsonDocument> .Filter.Empty);
                    artistPanel.Children.Clear();
                    artistResultSize = querryProcessor.artistQuery(currentartistQuerry, Builders <BsonDocument> .Filter.Empty);
                    for (int i = 0; i < output.Count; i++)
                    {
                        ArtistListView currentView = new ArtistListView(output[i], querryProcessor.DiscogsDatabase);
                        artistPanel.Children.Add(currentView);
                    }
                    if (artistResultSize < 20)
                    {
                        artistPanelStats.Text = String.Format($"Showing {artistCurrentPage * 20 + 1} - {artistResultSize} of {artistResultSize}");
                    }
                    else
                    {
                        artistPanelStats.Text = String.Format($"Showing {artistCurrentPage * 20 + 1} - {artistCurrentPage * 20 + 20} of {artistResultSize}");
                    }
                }
            }

            if (labelsTab.IsSelected)
            {
                if (labelCurrentPage != 0)
                {
                    labelCurrentPage--;
                    List <Label> output = querryProcessor.labelQuery((int)labelCurrentPage, currentlabelQuerry, Builders <BsonDocument> .Filter.Empty);
                    labelsPanel.Children.Clear();
                    labelResultSize = querryProcessor.labelQuery(currentlabelQuerry, Builders <BsonDocument> .Filter.Empty);
                    for (int i = 0; i < output.Count; i++)
                    {
                        LabelListView currentView = new LabelListView(output[i], querryProcessor.DiscogsDatabase);
                        labelsPanel.Children.Add(currentView);
                    }
                    if (labelResultSize < 20)
                    {
                        labelPanelStats.Text = String.Format($"Showing {labelCurrentPage * 20 + 1} - {labelResultSize} of {labelResultSize}");
                    }
                    else
                    {
                        labelPanelStats.Text = String.Format($"Showing {labelCurrentPage * 20 + 1} - {labelCurrentPage * 20 + 20} of {labelResultSize}");
                    }
                }
            }

            if (mastersTab.IsSelected)
            {
                if (masterCurrentPage != 0)
                {
                    masterCurrentPage--;
                    List <Master> output = querryProcessor.masterQuery((int)masterCurrentPage, currentmasterQuerry, Builders <BsonDocument> .Filter.Empty);
                    mastersPanel.Children.Clear();
                    masterResultSize = querryProcessor.masterQuery(currentmasterQuerry, Builders <BsonDocument> .Filter.Empty);
                    for (int i = 0; i < output.Count; i++)
                    {
                        MasterListView currentView = new MasterListView(output[i], querryProcessor.DiscogsDatabase);
                        mastersPanel.Children.Add(currentView);
                    }
                    if (masterResultSize < 20)
                    {
                        masterPanelStats.Text = String.Format($"Showing {masterCurrentPage * 20 + 1} - {masterResultSize} of {masterResultSize}");
                    }
                    else
                    {
                        masterPanelStats.Text = String.Format($"Showing {masterCurrentPage * 20 + 1} - {masterCurrentPage * 20 + 20} of {masterResultSize}");
                    }
                }
            }

            if (releasesTab.IsSelected)
            {
                if (releaseCurrentPage != 0)
                {
                    releaseCurrentPage--;
                    List <Release> output = querryProcessor.releaseQuery((int)releaseCurrentPage, currentreleaseQuerry, Builders <BsonDocument> .Filter.Empty);
                    releasesPanel.Children.Clear();
                    releaseResultSize = querryProcessor.releaseQuery(currentreleaseQuerry, Builders <BsonDocument> .Filter.Empty);
                    for (int i = 0; i < output.Count; i++)
                    {
                        ReleaseListView currentView = new ReleaseListView(output[i], querryProcessor.DiscogsDatabase);
                        releasesPanel.Children.Add(currentView);
                    }
                    if (releaseResultSize < 20)
                    {
                        releasePanelStats.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseResultSize} of {releaseResultSize}");
                    }
                    else
                    {
                        releasePanelStats.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseCurrentPage * 20 + 20} of {releaseResultSize}");
                    }
                }
            }
        }
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            string temp = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text;
            string text = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text.Remove(temp.Length - 2, 2);

            if (text == null)
            {
                return;
            }
            if (artistsTab.IsSelected)
            {
                artistPanel.Children.RemoveRange(0, artistPanel.Children.Count);
                string artistName = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text;
                currentartistQuerry = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text.Remove(artistName.Length - 2, 2);
                List <Artist> output = querryProcessor.artistQuery(0, currentartistQuerry, Builders <BsonDocument> .Filter.Empty);
                artistPanel.Children.Clear();
                artistResultSize  = querryProcessor.artistQuery(currentartistQuerry, Builders <BsonDocument> .Filter.Empty);
                artistCurrentPage = 0;
                for (int i = 0; i < output.Count; i++)
                {
                    ArtistListView currentView = new ArtistListView(output[i], querryProcessor.DiscogsDatabase);
                    artistPanel.Children.Add(currentView);
                }
                if (artistResultSize < 20)
                {
                    artistPanelStats.Text = String.Format($"Showing {artistCurrentPage + 1} - {artistResultSize} of {artistResultSize}");
                }
                else
                {
                    artistPanelStats.Text = String.Format($"Showing {artistCurrentPage + 1} - 20 of {artistResultSize}");
                }
            }

            if (labelsTab.IsSelected)
            {
                labelsPanel.Children.RemoveRange(0, labelsPanel.Children.Count);
                string labelName = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text;
                currentlabelQuerry = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text.Remove(labelName.Length - 2, 2);
                List <Label> output = querryProcessor.labelQuery(0, currentlabelQuerry, Builders <BsonDocument> .Filter.Empty);
                labelsPanel.Children.Clear();
                labelResultSize  = querryProcessor.labelQuery(currentlabelQuerry, Builders <BsonDocument> .Filter.Empty);
                labelCurrentPage = 0;
                for (int i = 0; i < output.Count; i++)
                {
                    LabelListView currentView = new LabelListView(output[i], querryProcessor.DiscogsDatabase);
                    labelsPanel.Children.Add(currentView);
                }
                if (labelResultSize < 20)
                {
                    labelPanelStats.Text = String.Format($"Showing {labelCurrentPage + 1} - {labelResultSize} of {labelResultSize}");
                }
                else
                {
                    labelPanelStats.Text = String.Format($"Showing {labelCurrentPage + 1} - 20 of {labelResultSize}");
                }
            }

            if (mastersTab.IsSelected)
            {
                mastersPanel.Children.RemoveRange(0, mastersPanel.Children.Count);
                string masterName = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text;
                currentmasterQuerry = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text.Remove(masterName.Length - 2, 2);
                List <Master> output = querryProcessor.masterQuery(0, currentmasterQuerry, Builders <BsonDocument> .Filter.Empty);
                mastersPanel.Children.Clear();
                masterResultSize  = querryProcessor.masterQuery(currentmasterQuerry, Builders <BsonDocument> .Filter.Empty);
                masterCurrentPage = 0;
                for (int i = 0; i < output.Count; i++)
                {
                    MasterListView currentView = new MasterListView(output[i], querryProcessor.DiscogsDatabase);
                    mastersPanel.Children.Add(currentView);
                }
                if (masterResultSize < 20)
                {
                    masterPanelStats.Text = String.Format($"Showing {masterCurrentPage + 1} - {masterResultSize} of {masterResultSize}");
                }
                else
                {
                    masterPanelStats.Text = String.Format($"Showing {masterCurrentPage + 1} - 20 of {masterResultSize}");
                }
            }

            if (releasesTab.IsSelected)
            {
                releasesPanel.Children.RemoveRange(0, releasesPanel.Children.Count);
                string releaseName = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text;
                currentreleaseQuerry = new TextRange(NameSearch.Document.ContentStart, NameSearch.Document.ContentEnd).Text.Remove(releaseName.Length - 2, 2);
                List <Release> output = querryProcessor.releaseQuery(0, currentreleaseQuerry, Builders <BsonDocument> .Filter.Empty);
                releasesPanel.Children.Clear();
                releaseResultSize  = querryProcessor.releaseQuery(currentreleaseQuerry, Builders <BsonDocument> .Filter.Empty);
                releaseCurrentPage = 0;
                for (int i = 0; i < output.Count; i++)
                {
                    ReleaseListView currentView = new ReleaseListView(output[i], querryProcessor.DiscogsDatabase);
                    releasesPanel.Children.Add(currentView);
                }
                if (releaseResultSize < 20)
                {
                    releasePanelStats.Text = String.Format($"Showing {releaseCurrentPage + 1} - {releaseResultSize} of {releaseResultSize}");
                }
                else
                {
                    releasePanelStats.Text = String.Format($"Showing {releaseCurrentPage + 1} - 20 of {releaseResultSize}");
                }
            }
        }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="control"></param>
 /// <param name="sortDelegate"></param>
 public Sorter(MasterListView control, Func <TListModel, ColumnHeader, IComparable, IComparable> sortDelegate) : base(control.ListView, showNativeSortIndicators: true)
 {
     _GetSortValue = sortDelegate;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="control"></param>
 /// <param name="getModelList"></param>
 public MasterListToListBinder(TModel model, MasterListView control, Expression <Func <TModel, IList <TListModel> > > getModelList)
     : base(model, control)
 {
     _GetModelListExpression = getModelList;
 }
Ejemplo n.º 14
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;
                }
            }
        }
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
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;
        }