public IActionResult Payment(int ID)
        {
            Record record = RecordDataMapper.FindByID(ID);

            ViewBag.record = record;

            return(View());
        }
示例#2
0
        public void LoadData()
        {
            List <Record> list = RecordDataMapper.FindAllByID(ID);

            if (list != null)
            {
                BindingList <Record> bindingList = new BindingList <Record>(list);
                dataGrid.AutoGenerateColumns = false;
                dataGrid.DataSource          = bindingList;
            }
        }
示例#3
0
        private void buttonPaymentConfirm_Click(object sender, EventArgs e)
        {
            int cardNumber;
            int csv;

            try
            {
                cardNumber = Convert.ToInt32(boxPaymentCardNumber.Text);
            }
            catch
            {
                errorProvider.SetError(boxPaymentCardNumber, "Wrong format of Card Number");
                return;
            }

            try
            {
                csv = Convert.ToInt32(boxPaymentCSV.Text);
            }
            catch
            {
                errorProvider.SetError(boxPaymentCSV, "Wrong format of CSV");
                return;
            }


            //pseudo validace karty...
            Random rnd   = new Random();
            int    value = rnd.Next(10);

            if (value < 4)
            {
                //uspesna platba - pridat PaidDate do Record
                record.SetPaidDate(DateTime.Now);
                RecordDataMapper.Update(record);

                MessageBox.Show("Platba probehla v poradku", "Potvrzeni", MessageBoxButtons.OK);

                this.Owner.Refresh();
                this.Close();
            }
            else
            {
                //neuspesna platba
                MessageBox.Show("Platba se nezdarila", "Chyba", MessageBoxButtons.OK);
                return;
            }
        }
        public IActionResult DriverInterface()
        {
            if (HttpContext.Session.GetString("userType") != "driver")
            {
                return(RedirectToAction("Error"));
            }

            int loggedUser = Int32.Parse(HttpContext.Session.GetString("user"));

            List <Record> recordsList = RecordDataMapper.FindAllByID(loggedUser);

            ViewBag.recordsList = recordsList;


            return(View());
        }
        public IActionResult Pay(int ID, int number, int CSV)
        {
            Record record = RecordDataMapper.FindByID(ID);

            //pseudo validace karty...
            Random rnd   = new Random();
            int    value = rnd.Next(10);

            if (value < 5)
            {
                //uspesna platba - pridat PaidDate do Record
                record.PaidDate = DateTime.Now;
                RecordDataMapper.Update(record);

                return(RedirectToAction("DriverInterface", "Home"));
            }
            else
            {
                //neuspesna platba
                ModelState.AddModelError("Ammount", "Platba se nezdarila");
            }

            return(RedirectToAction("Payment", "Home", new { ID = record.ID }));
        }
示例#6
0
        private void buttonRecordConfirm_Click(object sender, EventArgs e)
        {
            string category = comboRecordCategory.Text;
            int    expireDays;
            int    ammount;
            int    points;

            try
            {
                expireDays = Convert.ToInt32(boxRecordExpire.Text);
                errorProvider.Clear();
            }
            catch
            {
                errorProvider.SetError(boxRecordExpire, "Field must contains number");
                return;
            }

            try
            {
                ammount = Convert.ToInt32(boxRecordAmmount.Text);
                errorProvider.Clear();
            }
            catch
            {
                errorProvider.SetError(boxRecordAmmount, "Field must contains number");
                return;
            }

            try
            {
                points = Convert.ToInt32(boxRecordPoints.Text);
                errorProvider.Clear();
            }
            catch
            {
                errorProvider.SetError(boxRecordPoints, "Field must contains number");
                return;
            }


            //vytvorit novy zaznam
            Record record = new Record();

            record.Ammount     = ammount;
            record.PointsTaken = points;
            record.DateOfEntry = DateTime.Now;
            record.ExpireDate  = record.DateOfEntry.AddDays(expireDays);

            if (checkBoxPaid.Checked)
            {
                record.PaidDate = DateTime.Now;
            }
            else
            {
                record.PaidDate = null;
            }
            record.driverID   = driverID;
            record.employeeID = manager.login;
            record.fineTypeID = (int)comboRecordCategory.SelectedValue;


            RecordDataMapper.Save(record);


            if (record.PointsTaken > 0)
            {
                //odebrat body ridici
                Driver driver = DriverDataMapper.FindByID(record.driverID);
                driver.SubtractPoints(record.PointsTaken);
                DriverDataMapper.Update(driver);


                if (driver.PointsLessThenZero())
                {
                    string message = "Body ridice <= 0. Odebrat RP";
                    MessageBox.Show(message, "Upozornění", MessageBoxButtons.OK);
                }
            }

            this.Owner.Refresh();
            this.Close();
        }
        public IActionResult AutomatickeVytvoreni(string SPZ, int speed, bool isInCity)
        {
            Vehicle vehicle = VehicleDataMapper.FindBySPZ(SPZ);

            if (vehicle == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Driver driver = DriverDataMapper.FindByID(vehicle.driverID);

            Record record = new Record();

            record.Ammount     = 0;
            record.DateOfEntry = DateTime.Now;
            record.PaidDate    = null;
            record.ExpireDate  = record.DateOfEntry.AddDays(30);
            record.driverID    = driver.ID;
            record.PointsTaken = 0;
            record.employeeID  = 1;
            record.fineTypeID  = 6;


            if (speed < 10 && isInCity == true)
            {
                record.Ammount     = 500;
                record.PointsTaken = 0;
            }
            else if (speed >= 10 && speed < 30 && isInCity == true)
            {
                record.Ammount     = 2000;
                record.PointsTaken = 1;
            }
            else if (speed >= 30 && isInCity == true)
            {
                record.Ammount     = 5000;
                record.PointsTaken = 3;
            }
            else if (speed < 10 && isInCity == false)
            {
                record.Ammount     = 500;
                record.PointsTaken = 0;
            }
            else if (speed >= 10 && speed < 30 && isInCity == false)
            {
                record.Ammount     = 2000;
                record.PointsTaken = 2;
            }
            else if (speed >= 30 && isInCity == false)
            {
                record.Ammount     = 5000;
                record.PointsTaken = 4;
            }


            RecordDataMapper.Save(record);

            driver.RemainingPoints -= record.PointsTaken;
            if (driver.RemainingPoints <= 0)
            {
                driver.State        = false;
                ViewBag.driverState = false;
            }

            DriverDataMapper.Update(driver);

            return(RedirectToAction("Login", "Home"));
        }