private void button1_Click(object sender, EventArgs e)
 {
     if (ValidateChildren(ValidationConstraints.Enabled))
     {
         string uemail = email.Text;
         string upass  = password.Text;
         var    u      = db.Users.Where(x => x.Email == uemail).FirstOrDefault();
         if (u != null)
         {
             if (u.Password == upass)
             {
                 MessageBox.Show("You are successfully Logged In");
                 this.Hide();
                 Homepage home = new Homepage(uemail);
                 home.Show();
             }
             else
             {
                 MessageBox.Show("Incorrect password");
             }
         }
         else
         {
             MessageBox.Show("User not exists");
         }
     }
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                User user         = new User();
                var  radioButtons = gender.Controls.OfType <RadioButton>();
                foreach (RadioButton rb in radioButtons)
                {
                    if (rb.Checked)
                    {
                        user.Gender = rb.Text;
                    }
                }

                user.Firstname = fname.Text;
                user.Lastname  = lname.Text;
                user.Mobileno  = mobile.Text;
                user.Email     = email.Text;
                user.Password  = password.Text;
                //MessageBox.Show(user.Firstname + ',' + user.Lastname + ',' + user.Mobileno + ',' + user.Email + ',' + user.Password + ',' + user.Gender);

                db.Users.Add(user);
                db.SaveChanges();

                this.Hide();
                Homepage home = new Homepage(user.Email);
                home.Show();
            }
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                ParkingPlace PP = new ParkingPlace();
                PP.ParkingName = txtParkingName.Text;
                string str = txtAddress.Text;
                str = str.Replace("\n", String.Empty);
                str = str.Replace("\r", String.Empty);
                str = str.Replace("\t", String.Empty);
                //MessageBox.Show(str);
                PP.Address      = str;
                PP.TwoCapacity  = Int32.Parse(txtTwoCapacity.Text);
                PP.FourCapacity = Int32.Parse(txtFourCapacity.Text);
                PP.TwoRate      = Int32.Parse(txtTwoRate.Text);
                PP.FourRate     = Int32.Parse(txtFourRate.Text);
                //MessageBox.Show(PP.ParkingName + "," + PP.Address + "," + PP.TwoCapacity + "," + PP.FourCapacity + "," + PP.TwoRate + "," + PP.FourRate + ".");

                db.ParkingPlaces.Add(PP);
                db.SaveChanges();

                this.Hide();
                Homepage home = new Homepage(aEmail);
                home.Show();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var parking = db.ParkingPlaces.Where(x => x.ParkingName == parkName).FirstOrDefault();
            var user    = db.Users.Where(x => x.Email == Homepage.usr).FirstOrDefault();

            Vehicle v = new Vehicle();

            v.VehicleType        = vtype.Text;
            v.ModelName          = vname.Text;
            v.RegistrationNumber = vnumber.Text;
            v.User = user;
            db.Vehicles.Add(v);

            ParkingReservation parkingReservation = new ParkingReservation();

            if (vtype.Text == "2-Wheeler")
            {
                parkingReservation.Payment = parking.TwoRate;
                parkingReservation.Plot    = parking.TwoCapacity;
                parking.TwoCapacity        = parking.TwoCapacity - 1;
            }
            else
            {
                parkingReservation.Payment = parking.FourRate;
                parkingReservation.Plot    = parking.FourCapacity;
                parking.FourCapacity       = parking.FourCapacity - 1;
            }
            parkingReservation.TimeArrival   = atime.Value;
            parkingReservation.TimeDeparture = dtime.Value;
            parkingReservation.Vehicle       = v;
            parkingReservation.ParkingPlace  = parking;
            parkingReservation.User          = user;
            db.ParkingReservations.Add(parkingReservation);
            db.SaveChanges();

            MessageBox.Show("Your parking reservation is successfull!!\nParking Plot:" + parkingReservation.Plot + "\nAmount Payable:" + parkingReservation.Payment);
            this.Hide();
            Homepage home = new Homepage(Homepage.usr);

            home.Show();
        }