예제 #1
0
        public ActionResult Edit(JenisBarang mdat)
        {
            // Get Data By ID
            JenisBarang myData = entities.JenisBarangs.Where(x => x.ID.Equals(mdat.ID)).FirstOrDefault();

            if (ModelState.IsValid)
            {
                // Change Data
                myData.Nama             = mdat.Nama;
                myData.Keterangan       = mdat.Keterangan;
                myData.LastModifiedTime = DateTime.Now;
                myData.ModifiedBy       = this.Session["NamaUser"].ToString();
                entities.SaveChanges();

                // Session Username & Role
                ViewBag.NamaUser = this.Session["NamaUser"];
                ViewBag.Role     = this.Session["Role"];
                return(RedirectToAction("Index"));
            }
            else
            {
                // Session Username & Role
                ViewBag.NamaUser = this.Session["NamaUser"];
                ViewBag.Role     = this.Session["Role"];
                return(View("Edit"));
            }
        }
예제 #2
0
        public ActionResult Edit(int ID)
        {
            // Get Data By ID
            JenisBarang myData = entities.JenisBarangs.Where(x => x.ID.Equals(ID)).FirstOrDefault();

            // Session Username & Role
            ViewBag.NamaUser = this.Session["NamaUser"];
            ViewBag.Role     = this.Session["Role"];
            return(View(myData));
        }
예제 #3
0
        public ActionResult Details(int ID)
        {
            // Session Username & Role
            ViewBag.NamaUser = this.Session["NamaUser"];
            ViewBag.Role     = this.Session["Role"];

            JenisBarang lists = entities.JenisBarangs.Where(x => x.ID == ID).FirstOrDefault();

            if (lists == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(lists));
        }
예제 #4
0
        public ActionResult Delete(int ID)
        {
            // Get Data By ID
            JenisBarang data = entities.JenisBarangs.Where(x => x.ID == ID).FirstOrDefault();

            // Changes Status to Inactive
            data.RowStatus = 1;
            entities.SaveChanges();

            // Session Username & Role
            ViewBag.NamaUser = this.Session["NamaUser"];
            ViewBag.Role     = this.Session["Role"];
            return(RedirectToAction("Index"));
        }
예제 #5
0
        public ActionResult Create(JenisBarang mdat)
        {
            if (ModelState.IsValid)
            {
                // Change Attributes
                mdat.CreatedTime = DateTime.Now;
                mdat.RowStatus   = 0;
                mdat.CreatedBy   = this.Session["NamaUser"].ToString();
                entities.JenisBarangs.Add(mdat);
                entities.SaveChanges();

                // Session Username & Role
                ViewBag.NamaUser = this.Session["NamaUser"];
                ViewBag.Role     = this.Session["Role"];
                return(RedirectToAction("Index"));
            }
            else
            {
                // Session Username & Role
                ViewBag.NamaUser = this.Session["NamaUser"];
                ViewBag.Role     = this.Session["Role"];
                return(View("Create"));
            }
        }
        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);
            }
        }