Exemplo n.º 1
0
        private void PopulateData()
        {
            var Data = AutoMapper.Mapper.Map <List <MasterPetugasDto> >(_pekerjaServices.GetAll());

            _data = CollectionViewSource.GetDefaultView(Data);

            _data.Filter = new Predicate <object>(FilterCandidates);

            Dgv_Home.ItemsSource = _data;
        }
        private void PopulateComboboxPetugas()
        {
            _itemRepo = new ItemServices();
            var Data = AutoMapper.Mapper.Map <List <MasterPetugasDto> >(_pekerjaRepo.GetAll().Where(x => x.STATUS == Status.Aktif));

            _dataPetugas = CollectionViewSource.GetDefaultView(Data);

            var TransportCompositeCollection = new CompositeCollection();

            TransportCompositeCollection.Add(new ComboBoxItem()
            {
                Content = "Please Select"
            });
            TransportCompositeCollection.Add(new CollectionContainer()
            {
                Collection = _dataPetugas
            });

            NamaPetugas.ItemsSource   = TransportCompositeCollection;
            NamaPetugas.SelectedIndex = 0;
        }
        private void Btn_Simpan_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _pekerjaService = new PekerjaServices();
                if (string.IsNullOrEmpty(NamaPetugas.Text))
                {
                    MessageBox.Show("Nama Petugas tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }
                ;

                var Dto = new MasterPetugasDto();
                Dto.NAMA_PETUGAS = NamaPetugas.Text;
                Dto.HANDPHONE    = Handphone.Text;
                Dto.FIRST_NAME   = FirstName.Text;
                Dto.ALAMAT       = Alamat.Text;
                Dto.LAST_NAME    = LastName.Text;
                Dto.ID           = int.Parse(IdPetugas.Text);
                Dto.STATUS       = (Status)StatusPetugas.SelectedItem;

                var GetDataExisting = _pekerjaService.GetAll().Where(x => !string.IsNullOrEmpty(x.NAMA_PETUGAS) && x.NAMA_PETUGAS.ToUpper() == Dto.NAMA_PETUGAS.ToUpper()).FirstOrDefault();
                if (GetDataExisting != null && GetDataExisting.ID != Dto.ID)
                {
                    MessageBox.Show("Nama Petugas sudah ada", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return;
                }

                _pekerjaService.Save(Dto);
                MessageBox.Show("Update Data Sukses", "Sukses", MessageBoxButton.OK, MessageBoxImage.Information);
                CloseWin();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Update Data Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }