public void showData()
        {
            var Artwork = Artworkbll.Search(pageIndex, pageSize, sortBy, sortOrder, keyword);

            dgArtwork.ItemsSource = Artwork.Items;
            pageCount             = Artwork.PageCount;
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <string> errors = new List <string>();

            if (string.IsNullOrEmpty(txtTitle.Text))
            {
                errors.Add("Title is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtContent.Text))
            {
                errors.Add("Content is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtMedium.Text))
            {
                errors.Add("Medium is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtYear.Text))
            {
                errors.Add("Year is required.");
            }
            ;
            if (errors.Count > 0)
            {
                foreach (var error in errors)
                {
                    txtError.Text = txtError.Text + error + "\n";
                }

                return;
            }


            var op = Artworkbll.Add(new Artwork()
            {
                ArtistID = Guid.NewGuid(),
                Title    = txtTitle.Text,
                Content  = txtContent.Text,
                Year     = txtYear.Text,
                Medium   = txtMedium.Text,
            });

            if (op.Code != "200")
            {
                MessageBox.Show("Error : " + op.Message);
            }

            else
            {
                MessageBox.Show("Artwork is successfully added to table");
            }

            myParentWindow.showData();
            this.Close();
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <string> errors = new List <string>();

            if (string.IsNullOrEmpty(txtTitle.Text))
            {
                errors.Add("Title is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtContent.Text))
            {
                errors.Add("Content is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtMedium.Text))
            {
                errors.Add("Medium is required.");
            }
            ;

            if (string.IsNullOrEmpty(txtYear.Text))
            {
                errors.Add("Year is required.");
            }
            ;


            if (errors.Count > 0)
            {
                foreach (var error in errors)
                {
                    txtError.Text = txtError.Text + error + "\n";
                }

                return;
            }

            var op = Artworkbll.Update(new Artwork()
            {
                ArtistID = artworkDTO.ArtistID,
                Title    = txtTitle.Text,
                Content  = txtContent.Text,
                Year     = txtYear.Text,
                Medium   = txtMedium.Text,
            });


            if (op.Code != "200")
            {
                MessageBox.Show("Error : " + op.Message);
            }
            else
            {
                MessageBox.Show("User is successfully updated");
            }

            this.Close();
        }
        private void btnDeactivate_Click(object sender, RoutedEventArgs e)
        {
            ArtworkDTO artworkDTO = ((FrameworkElement)sender).DataContext as ArtworkDTO;

            if (MessageBox.Show("Are you sure you want to deactivate " + artworkDTO.Title + " " + artworkDTO.Content + "?",
                                "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                var op = Artworkbll.Deactivate(artworkDTO.ArtistID);

                if (op.Code != "200")
                {
                    MessageBox.Show("Error : " + op.Message);
                }
                else
                {
                    MessageBox.Show("Artwork is successfully deactivated from table");
                    showData();
                }
            }
            ;
        }