Exemplo n.º 1
0
        public ActionResult Add(DataTruck model)
        {
            if (ModelState.IsValid)
            {
                if (RepoDataTruck.IsExist(model.VehicleNo))
                {
                    ModelState.AddModelError("VehicleNo", "Vehicle No sudah terdaftar.");
                    return(View("Form", model));
                }
                Context.DataTruck dbitem = new Context.DataTruck();
                model.SetDb(dbitem);
                //generate code
                dbitem.urutan  = RepoDataTruck.getUrutan() + 1;
                dbitem.NoTruck = RepoDataTruck.generateCode(dbitem.urutan);

                RepoDataTruck.save(dbitem, UserPrincipal.id);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
Exemplo n.º 2
0
        public ActionResult Add(DataBox model)
        {
            if (ModelState.IsValid)
            {
                if (RepoDataBox.IsBoxExist(model.IdDataTruck.Value))
                {
                    ModelState.AddModelError("IdDataTruck", "Truck sudah tepasang box, harap ganti dengan truck yang lain");
                    return(View("Form", model));
                }
                Context.DataBox dbitem = new Context.DataBox();
                model.SetDb(dbitem);
                //generate code
                dbitem.Urutan = RepoDataBox.getUrutan() + 1;
                dbitem.NoBox  = RepoDataBox.generateCode(dbitem.Urutan);

                Context.DataBoxHistory dbitemHistory = new Context.DataBoxHistory();
                model.SetDbHistory(dbitemHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname);
                dbitemHistory.Vehicle     = RepoDataTruck.FindByPK(model.IdDataTruck.Value).VehicleNo;
                dbitemHistory.NoBox       = dbitem.NoBox;
                dbitemHistory.strKategori = model.IdKategori.HasValue ? RepoLookup.FindByPK(model.IdKategori.Value).Nama : "";
                dbitemHistory.strType     = model.IdType.HasValue ? RepoLookup.FindByPK(model.IdType.Value).Nama : "";
                dbitem.DataBoxHistory.Add(dbitemHistory);
                Context.DataTruckBoxHistory dbtruckHistory = new Context.DataTruckBoxHistory();
                model.SetDbTruckHistory(dbtruckHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname);
                RepoDataBox.save(dbitem, UserPrincipal.id, dbitemHistory, dbtruckHistory);

                Context.DataTruck dbtruck = RepoDataTruck.FindByPK(model.IdDataTruck.Value);
                dbtruckHistory.Vehicle     = dbtruck.VehicleNo;
                dbtruckHistory.NoBox       = dbitem.NoBox;
                dbtruckHistory.strKategori = model.IdKategori.HasValue ? RepoLookup.FindByPK(model.IdKategori.Value).Nama : "";
                dbtruckHistory.strType     = model.IdType.HasValue ? RepoLookup.FindByPK(model.IdType.Value).Nama : "";
                dbtruck.DataTruckBoxHistory.Add(dbtruckHistory);
                RepoDataTruck.save(dbtruck, UserPrincipal.id);


                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
        public ActionResult Add(DataPendingin model)
        {
            if (ModelState.IsValid)
            {
                if (RepoPendingin.IsBoxExist(model.IdDataTruk.Value))
                {
                    ModelState.AddModelError("IdDataTruk", "Truck sudah tepasang pendingin, harap ganti dengan truck yang lain");
                    return(View("Form", model));
                }
                Context.DataPendingin dbitem = new Context.DataPendingin();
                model.setDb(dbitem);

                //generate code
                dbitem.Urutan      = RepoPendingin.getUrutan() + 1;
                dbitem.NoPendingin = RepoPendingin.generateCode(dbitem.Urutan);

                Context.DataPendinginHistory dbitemhistory = new Context.DataPendinginHistory();
                model.setDbHistory(dbitemhistory, UserPrincipal.firstname + ' ' + UserPrincipal.lastname);
                dbitemhistory.NoPendingin       = dbitem.NoPendingin;
                dbitemhistory.strDataTruk       = RepoDataTruck.FindByPK(dbitem.IdDataTruk).VehicleNo;
                dbitemhistory.strJenisPendingin = dbitem.IdJenisPendingin.HasValue ? RepoLookup.FindByPK(dbitem.IdJenisPendingin).Nama : "";
                dbitem.ListHistoryPendingin.Add(dbitemhistory);
                Context.DataTruckPendinginHistory dbtruckhistory = new Context.DataTruckPendinginHistory();
                model.setDbTruckHistory(dbtruckhistory, UserPrincipal.firstname + ' ' + UserPrincipal.lastname);
                RepoPendingin.save(dbitem, UserPrincipal.id, dbitemhistory, dbtruckhistory);

                Context.DataTruck dbtruck = RepoDataTruck.FindByPK(model.IdDataTruk.Value);
                dbtruckhistory.NoPendingin       = dbitem.NoPendingin;
                dbtruckhistory.strDataTruk       = RepoDataTruck.FindByPK(dbitem.IdDataTruk).VehicleNo;
                dbtruckhistory.strJenisPendingin = dbitem.IdJenisPendingin.HasValue ? RepoLookup.FindByPK(dbitem.IdJenisPendingin).Nama : "";
                dbtruck.DataTruckPendinginHistory.Add(dbtruckhistory);
                RepoDataTruck.save(dbtruck, UserPrincipal.id);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
Exemplo n.º 4
0
        public ActionResult Add(DataGPS model)
        {
            if (ModelState.IsValid)
            {
                if (RepoDataGps.IsBoxExist(model.IdDataTruck.Value))
                {
                    ModelState.AddModelError("IdDataTruck", "Truck sudah tepasang gps, harap ganti dengan truck yang lain");
                    return(View("Form", model));
                }
                Context.DataGPS dbitem = new Context.DataGPS();
                model.SetDb(dbitem);
                //generate code
                dbitem.urutan = RepoDataGps.getUrutan() + 1;
                dbitem.NoGPS  = RepoDataGps.generateCode(dbitem.urutan);

                Context.DataGPSHistory dbitemHistory = new Context.DataGPSHistory();
                model.SetDbHistory(dbitemHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname);
                dbitemHistory.Vehicle   = RepoDataTruck.FindByPK(dbitem.IdDataTruck.Value).VehicleNo;
                dbitemHistory.NoGPS     = dbitem.NoGPS;
                dbitemHistory.strVendor = dbitem.IdVendor.HasValue ? RepoVendorGPS.FindByPK(dbitem.IdVendor.Value).Nama : "";
                dbitem.DataGPSHistory.Add(dbitemHistory);
                Context.DataTruckGPSHistory dbtruckHistory = new Context.DataTruckGPSHistory();
                model.SetDbTruckHistory(dbtruckHistory, UserPrincipal.firstname + " " + UserPrincipal.lastname);
                RepoDataGps.save(dbitem, UserPrincipal.id, dbitemHistory);

                Context.DataTruck dbtruck = RepoDataTruck.FindByPK(model.IdDataTruck.Value);
                dbtruckHistory.Vehicle   = dbtruck.VehicleNo;
                dbtruckHistory.NoGPS     = dbitem.NoGPS;
                dbtruckHistory.strVendor = dbitem.IdVendor.HasValue ? RepoVendorGPS.FindByPK(dbitem.IdVendor.Value).Nama : "";
                dbtruck.DataTruckGPSHistory.Add(dbtruckHistory);
                RepoDataTruck.save(dbtruck, UserPrincipal.id);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }