Example #1
0
        public ActionResult Create(Vehicle vehicle)
        {
            try
            {
                sqlconn.Open();

                var r = VehicleLogic.Create(sqlconn, vehicle, vehicle.VehicleTypeId.Value, vehicle.VehicleBrandId.Value, 4, 1);

                if (r == -1)
                {
                    sqlconn.Close();
                    TempData["SuccessMessage"] = "VIN už v DB existuje.";
                    return(View());
                }

                sqlconn.Close();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                sqlconn.Close();
                TempData["SuccessMessage"] = "Chyba při ukládání vozidla do DB.";
                return(View());
            }
        }
Example #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Inspection im = new Inspection()
                {
                    Id                = -1,
                    Vehicle           = VehicleLogic.FindById(_sqlConn, Convert.ToInt32(cbVehicle.SelectedValue)),
                    InspectionDate    = inspectionDatePicker.SelectedDate.Value,
                    ValidTo           = validToPicker.SelectedDate.Value,
                    InspectionStation = InspectionStationLogic.FindById(_sqlConn, Convert.ToInt32(cbStation.SelectedValue)),
                    ProtocolNumber    = tbProtocolNr.Text,
                    Tachometer        = Convert.ToInt32(tbTachometer.Text),
                    Price             = Convert.ToInt32(tbPrice.Text),
                    Defects           = tbDefects.Text
                };

                bool result = InspectionLogic.Insert(_sqlConn, im, out var error);
                if (!result)
                {
                    MessageBox.Show(error, "Stop", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show($"Prohlídka byla uložena.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Vyplněné údaje jsou chybné:\n{ex.Message}",
                                "Stop", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
 // Use this for initialization
 void Start()
 {
     collider = GetComponent<WheelCollider>();
     owner = GetComponentInParent<VehicleLogic>();
     foreach (Transform t in transform)
         wheel = t;  //happens only once
 }
Example #4
0
        // GET: Vehicles/Details/5
        public ActionResult Details(int id)
        {
            sqlconn.Open();
            Vehicle vehicle = VehicleLogic.FindById(sqlconn, id);

            sqlconn.Close();
            return(View(vehicle));
        }
Example #5
0
        // GET: Vehicles
        public ActionResult Index()
        {
            sqlconn.Open();
            List <Vehicle> vehicles = VehicleLogic.FindAll(sqlconn);

            sqlconn.Close();

            return(View(vehicles));
        }
Example #6
0
 // Use this for initialization
 void Start()
 {
     wheelCollider = GetComponent <WheelCollider>();
     owner         = GetComponentInParent <VehicleLogic>();
     foreach (Transform t in transform)
     {
         wheel = t;  //happens only once
     }
 }
Example #7
0
        public void Refresh()
        {
            List <Vehicle> vehicles = VehicleLogic.FindAll(_sqlConn);

            cbVehicle.ItemsSource       = vehicles;
            cbVehicle.DisplayMemberPath = "Title";
            cbVehicle.SelectedValuePath = "Id";

            List <InspectionStation> stations = InspectionStationLogic.FindAll(_sqlConn);

            cbStation.ItemsSource       = stations;
            cbStation.DisplayMemberPath = "Company";
            cbStation.SelectedValuePath = "Id";
        }
Example #8
0
        // GET: Vehicles/Delete/5
        public ActionResult Delete(int id)
        {
            sqlconn.Open();
            var vehicle = VehicleLogic.Delete(sqlconn, 1, id);

            sqlconn.Close();

            if (!vehicle)
            {
                return(View(@"<script language='javascript'>alert('Nemáte oprávnění smazat vozidlo.');</script>"));
            }

            return(RedirectToAction(nameof(Index)));
        }
Example #9
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var mb = MessageBox.Show($"Přejete si opravdu smazat vozdilo?",
                                     "Smazání vozidla", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (mb == MessageBoxResult.No)
            {
                return;
            }

            VehicleLogic.Delete(_sqlConn, 2, _vehicle.Id);

            _parent.Refresh();
            Close();
        }
Example #10
0
        // GET: Stats
        public ActionResult Index()
        {
            sqlconn.Open();
            long vehiclesCount    = VehicleLogic.CountVehiclesByAdminId(sqlconn, 1);
            long driversCount     = VehicleLogic.CountDriversByAdminId(sqlconn, 1);
            long inspectionsCount = InspectionLogic.EndingInspectionsCount(sqlconn, 1, 30);

            sqlconn.Close();


            ViewData["Vehicles"]    = vehiclesCount;
            ViewData["Drivers"]     = driversCount;
            ViewData["Inspections"] = inspectionsCount;

            return(View());
        }
Example #11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var typeId  = cbType.SelectedValue;
            var brandId = cbBrand.SelectedValue;

            Vehicle vm = new Vehicle()
            {
                Id    = -1, LicensePlate = tbLicensePlate.Text, Price = Convert.ToDecimal(tbPrice.Text), PurchasedOn = Convert.ToDateTime(datePicker.Text),
                Title = tbTitle.Text, VehicleBrand = null, VehicleType = null, Vin = tbVin.Text, Vintage = Convert.ToInt16(tbVintage.Text)
            };

            var result = VehicleLogic.Create(_sqlConn, vm, Convert.ToInt32(typeId), Convert.ToInt32(brandId), 4, 1);

            if (result == -1)
            {
                MessageBox.Show($"VIN již v DB existuje.", "Stop", MessageBoxButton.OK, MessageBoxImage.Stop);
            }

            else if (result == 0)
            {
                MessageBox.Show($"Vozidlo bylo uloženo.", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
                Refresh();
            }
        }
Example #12
0
        public ActionResult Delete(int id, Vehicle vehicle)
        {
            try
            {
                sqlconn.Open();
                List <Inspection> inspections = InspectionLogic.FindAllByVehicleId(sqlconn, id);
                sqlconn.Close();

                if (inspections.Count > 0)
                {
                    return(View("<script>alert('Nemůžete smazat vozidlo, které obsahuje prohlídky.');</script>"));
                }

                sqlconn.Open();
                VehicleLogic.Delete(sqlconn, 1, vehicle.Id);
                sqlconn.Close();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(vehicle));
            }
        }
Example #13
0
        static void Main(string[] args)
        {
            LanguageLogic         languageLogic         = new LanguageLogic();
            UserLogic             userLogic             = new UserLogic();
            UserFleetLogic        userFleetLogic        = new UserFleetLogic();
            FleetLogic            fleetLogic            = new FleetLogic();
            VehicleLogic          vehicleLogic          = new VehicleLogic();
            DriverLogic           driverLogic           = new DriverLogic();
            ConfigTagLogic        configTagLogic        = new ConfigTagLogic();
            ConfigTagLanguageCrud configTagLanguageCrud = new ConfigTagLanguageCrud();
            FunctionsLogic        functionsLogic        = new FunctionsLogic();
            ConfigUserLoginLogic  configUserLoginLogic  = new ConfigUserLoginLogic();
            Mail             mail             = new Mail();
            UserRestoreLogic userRestoreLogic = new UserRestoreLogic();
            CarFleetSecurity secCarFleet      = CarFleetSecurity.GetContext;

            //List<LanguageEntity> listLanguage = languageLogic.SelectAll();
            //LanguageEntity languageEntity = languageLogic.GetById(1);
            //UserEntity userEntity = userLogic.Login("ManuelM");
            //List<UserFleetEntity> listuserFleet = userFleetLogic.SelectByUserId(userEntity.Id);
            //List<FleetEntity> listFleet = fleetLogic.GetByCompanyId(userEntity.Id_company);
            //List<VehicleEntity> listVehicle = vehicleLogic.GetByCompanyId(userEntity.Id_company);
            //List<VehicleEntity> listVehicle2 = vehicleLogic.GetByFleetId(listFleet.FirstOrDefault().Id);
            //List<DriverEntity> listDriver = driverLogic.GetByCompanyId(userEntity.Id_company);
            //ConfigTagEntity configTagEntity=new ConfigTagEntity();
            //configTagEntity.Tag_key = "lblUser";
            //configTagEntity.Page_name = "Login";
            //configTagLogic.Insert(configTagEntity);
            //int totalDriver = functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.DRIVER);
            //int totalFleet= functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.FLEET);
            //int totalVehicle = functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.VEHICLE);
            //string token=configUserLoginLogic.Insert(4188, "", 1800);

            string pass        = CarFleetSecurityCipher.Encrypt("ManuelM");
            string passDecrypt = CarFleetSecurityCipher.Decrypt(pass);

            string        email       = "ManuelM";
            List <string> addressList = new List <string>();

            addressList.Add("*****@*****.**");

            string     errorMessage;
            UserEntity userEntity = userLogic.SelectByLoginName(email);

            if (userEntity != null)
            {
                Random random         = new Random();
                string code           = random.Next(10000, 99999).ToString();
                int    timeExpiration = secCarFleet.GetNumberConfig(CarFleetSecurity.APP_CONFIG_RESTORE_PASSWORD_TIME_EXPIRE);
                if (userRestoreLogic.Insert(userEntity.Id, code, timeExpiration))
                {
                    Mail carFleetMail = new Mail();
                    var  sendMail     = carFleetMail.RestorePassword("*****@*****.**", code, out errorMessage);
                }
                if (userRestoreLogic.IsValidCode(email, code, out errorMessage))
                {
                    string newPassword = "******";
                    var    updatePass  = userLogic.UpdatePassword(email, newPassword);
                }
            }


            var f = 234;
        }
Example #14
0
        public void Refresh()
        {
            var vehicles = VehicleLogic.FindAll(_sqlConn);

            DgVehicles.ItemsSource = vehicles;
        }
 public HttpResponseMessage PutVehicles(Vehicle vehicle)
 {
     return(VehicleLogic.PutVehicles(Request, vehicle));
 }
 public HttpResponseMessage DeleteVehicles(int id)
 {
     return(VehicleLogic.DeleteVehicles(Request, id));
 }
 public HttpResponseMessage GetVehicles(int?id = null, string make = null, string model = null)
 {
     return(VehicleLogic.GetVehicles(Request, id));
 }