Exemple #1
0
        private bool FilterCandidates(object obj)
        {
            TRNBongkarMuatDto c = (TRNBongkarMuatDto)obj;

            return(filters.Values
                   .Aggregate(true,
                              (prevValue, predicate) => prevValue && predicate(c)));
        }
Exemple #2
0
        public void Save(TRNBongkarMuatDto item)
        {
            trn_bongkar_muat model;

            if (item == null)
            {
                throw new Exception("Invalid Data Entry");
            }
            try
            {
                if (item.ID > 0)
                {
                    //update
                    model = _trnBongkarMuatRepo.Get(c => c.ID == item.ID).FirstOrDefault();

                    if (model == null)
                    {
                        throw new Exception("Data Not Found");
                    }

                    var oriDto = Mapper.Map <TRNBongkarMuatDto>(model);
                }
                var dbTrnBongkarMuat = Mapper.Map <trn_bongkar_muat>(item);

                model = Mapper.Map <trn_bongkar_muat>(item);
                var modelItem = model.trn_bongkat_muat_details_pekerja.ToList();

                try
                {
                    model.master_item      = null;
                    model.master_supplier  = null;
                    model.master_transport = null;
                    model.trn_bongkat_muat_details_pekerja = null;
                    _trnBongkarMuatRepo.InsertOrUpdate(model);

                    DeleteTrnBongkarMuatDetails(item.ID);
                    foreach (var TrnBongkarMuatDetailsItem in modelItem)
                    {
                        TrnBongkarMuatDetailsItem.ID_TRN_BONGKAR_MUAT = model.ID;
                        _trnBongkarMuatDetailsPekerjaRepo.InsertOrUpdate(TrnBongkarMuatDetailsItem);
                    }
                    Uow.SaveChanges();
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        private void Btn_Simpan_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Kegiatan.SelectedItem.GetType() != typeof(ActionType))
                {
                    MessageBox.Show("Kegiatan harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Kegiatan.Focus();
                    return;
                }

                if (JenisBarang.SelectedItem.GetType() != typeof(ItemType))
                {
                    MessageBox.Show("Jenis Barang harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    JenisBarang.Focus();
                    return;
                }

                if (NamaBarang.SelectedItem.GetType() != typeof(MasterItemDto))
                {
                    MessageBox.Show("Nama Barang harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    NamaBarang.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(Kwantum.Text))
                {
                    MessageBox.Show("Kwantum (KG) tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Kwantum.Focus();
                    return;
                }

                if (ListPekerja.Items.Count == 0)
                {
                    MessageBox.Show("Pekerja tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    NamaPetugas.Focus();
                    return;
                }

                if (NoPolisi.SelectedItem.GetType() != typeof(MasterTransportDto))
                {
                    MessageBox.Show("No Polisi harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    NoPolisi.Focus();
                    return;
                }

                if (NamaPengirim.SelectedItem.GetType() != typeof(MasterSupplierDto))
                {
                    MessageBox.Show("Pengirim harus dipilih", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    NamaPengirim.Focus();
                    return;
                }

                if (Berangkat.Value == new TimeSpan(0, 0, 0))
                {
                    MessageBox.Show("Waktu berangkat harus lebih dari jam 00:00:00", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Berangkat.Focus();
                    return;
                }

                if (Sampai.Value == new TimeSpan(0, 0, 0))
                {
                    MessageBox.Show("Waktu sampai harus lebih dari jam 00:00:00", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Sampai.Focus();
                    return;
                }

                if (Sampai.Value <= Berangkat.Value)
                {
                    MessageBox.Show("Waktu sampai harus lebih dari waktu Berangkat", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    Sampai.Focus();
                    return;
                }

                var Dto = new TRNBongkarMuatDto();

                var Barang    = (MasterItemDto)NamaBarang.SelectedItem;
                var Transport = (MasterTransportDto)NoPolisi.SelectedItem;
                var Pengirim  = (MasterSupplierDto)NamaPengirim.SelectedItem;

                Dto.TANGGAL_KIRIM   = DateTime.Parse(TglKirim.Text);
                Dto.BERANGKAT       = new DateTime(Dto.TANGGAL_KIRIM.Year, Dto.TANGGAL_KIRIM.Month, Dto.TANGGAL_KIRIM.Day, Berangkat.Value.Hours, Berangkat.Value.Minutes, Berangkat.Value.Seconds);
                Dto.SAMPAI          = new DateTime(Dto.TANGGAL_KIRIM.Year, Dto.TANGGAL_KIRIM.Month, Dto.TANGGAL_KIRIM.Day, Sampai.Value.Hours, Sampai.Value.Minutes, Sampai.Value.Seconds);
                Dto.HARGA           = Barang.HARGA;
                Dto.HARGA_KONTAINER = Barang.ONGKOS_CONTAINER;
                Dto.ID_BARANG       = Barang.ID;
                Dto.ID_PENGIRIM     = Pengirim.ID;
                Dto.JENIS_BARANG    = (ItemType)JenisBarang.SelectedItem;
                Dto.JUMLAH_PEKERJA  = ListPekerja.Items.Count;
                Dto.KEGIATAN        = (ActionType)Kegiatan.SelectedItem;
                Dto.KWANTUM         = decimal.Parse(Kwantum.Text);

                var LamaWaktu = Dto.SAMPAI.Add(Dto.BERANGKAT.TimeOfDay);
                Dto.LAMA_WAKTU = new DateTime(Dto.TANGGAL_KIRIM.Year, Dto.TANGGAL_KIRIM.Month, Dto.TANGGAL_KIRIM.Day, LamaWaktu.Hour, LamaWaktu.Minute, LamaWaktu.Second);

                Dto.NAMA_BARANG = Barang.NAMA_BARANG;
                Dto.NOPOL       = Transport.NO_POLISI;
                Dto.PENGIRIM    = Pengirim.NAMA_SUPPLIER;
                Dto.TOTAL_HARGA = Dto.KWANTUM * Dto.HARGA;
                Dto.ONGKOS      = Dto.TOTAL_HARGA / ((decimal)ListPekerja.Items.Count);
                Dto.ID_NOPOL    = Transport.ID;

                //not mandatory
                if (!string.IsNullOrEmpty(UangMakan.Text))
                {
                    Dto.UANG_MAKAN = decimal.Parse(UangMakan.Text);
                }

                if (!string.IsNullOrEmpty(MuatContainer.Text))
                {
                    Dto.MUAT_KONTAINER  = decimal.Parse(MuatContainer.Text);
                    Dto.TOTAL_KONTAINER = Dto.MUAT_KONTAINER * Barang.ONGKOS_CONTAINER;
                }
                var ListPetugas = ListPekerja.Items.Cast <MasterPetugasDto>()
                                  .Select(item => item)
                                  .ToList();

                Dto.trn_bongkat_muat_details_pekerja = AutoMapper.Mapper.Map <List <TRNBongkarMuatDetailsPekerjaDto> >(ListPetugas.ToList());
                _trnServices.Save(Dto);

                MessageBox.Show("Save Data Sukses", "Sukses", MessageBoxButton.OK, MessageBoxImage.Information);
                CloseWin();
            }
            catch (Exception exp)
            {
                var a = exp.Message;
                MessageBox.Show("Save Data Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }