コード例 #1
0
        private void addbtn_Click(object sender, EventArgs e)
        {
            BusReservationEntities db = new BusReservationEntities();
            Customer customers        = new Customer
            {
                Name        = nametxt.Text,
                FatherName  = fnametxt.Text,
                DateOfBirth = birthdate.Value,
                Email       = emailtext.Text,
                PhoneNo     = phonetxt.Text,
                Address     = addresstext.Text
            };


            if (passText.Text == passConfText.Text)
            {
                db.Customers.Add(customers);
                db.SaveChanges();
                db.Logins.Add(new Login
                {
                    custId   = customers.Id,
                    username = nametxt.Text,
                    password = passText.Text
                });
                db.SaveChanges();
                MessageBox.Show("Customer is added");
                this.Hide();
            }
            else
            {
                MessageBox.Show("Password is not match with Confrim password");
            }
        }
コード例 #2
0
        public IHttpActionResult PutUserDetails(string id, UserDetail UserDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != UserDetail.UID.ToString())
            {
                return(BadRequest());
            }

            db.Entry(UserDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        private void BookBtn_Click(object sender, EventArgs e)
        {
            var bookData = db.TicketDetails.Where(a => a.custId == user.custId).FirstOrDefault();

            if (bookData == null)
            {
                try
                {
                    db.TicketDetails.Add(new TicketDetail
                    {
                        BusId        = busUser.id,
                        custId       = user.custId,
                        dateOfTicket = dateOfJurDt.Value,
                        seatNo       = SelectSeat.seats
                    });
                    db.SaveChanges();
                    this.bookedSeat(this.selectedSeats);
                    MessageBox.Show(SelectSeat.seats + " Seats are booked");
                    new TicketInfo(user).Show();
                }
                catch (Exception)
                {
                    MessageBox.Show("Please select seats First");
                }
            }
            else
            {
                MessageBox.Show("You Allredy Booked a seat");
            }
        }
コード例 #4
0
        public IHttpActionResult PutPassengerDetail(int id, PassengerDetail passengerDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != passengerDetail.PNR)
            {
                return(BadRequest());
            }

            db.Entry(passengerDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PassengerDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
        public IHttpActionResult PutTicket(int id, Ticket ticket)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ticket.TicketID)
            {
                return(BadRequest());
            }

            db.Entry(ticket).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TicketExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #6
0
        public IHttpActionResult PostUserDetail(UserDetail UserDetail, GuestUserDetail GuestUserDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.proc_UserRegistration(GuestUserDetail.FirstName, GuestUserDetail.Lastname, GuestUserDetail.EmailId, GuestUserDetail.PhoneNumber,
                                     UserDetail.Password, UserDetail.Gender, UserDetail.DOB, UserDetail.Address, UserDetail.State, UserDetail.City, UserDetail.Pincode);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = UserDetail.UID }, UserDetail));
        }
コード例 #7
0
        public IHttpActionResult PutJourneyRoute(int id, JourneyRoute journeyRoute)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != journeyRoute.RouteID)
            {
                return(BadRequest());
            }

            db.Entry(journeyRoute).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JourneyRouteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #8
0
        public IHttpActionResult Put(int id, UserDetail changepassword)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (id != changepassword.UID)
            //{
            //    return BadRequest();
            //}

            //db.Entry(changepassword).State = EntityState.Modified;
            using (var a = new BusReservationEntities())
            {
                var user = a.UserDetails.Where(m => m.UID == id).FirstOrDefault <UserDetail>();
                if (user != null)
                {
                    if (changepassword.Password != null)
                    {
                        user.Password = changepassword.Password;
                    }
                    a.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            return(Ok("updated password"));
        }
コード例 #9
0
 private void SaveBtn_Click(object sender, EventArgs e)
 {
     this.custUser.Email = emailTxt.Text;
     db.SaveChanges();
     MessageBox.Show("Changings has been saved");
     new CustomerMenu(user).Show();
     this.Hide();
 }
コード例 #10
0
        public IHttpActionResult PostGuestUserDetail(GuestUserDetail guestUserDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.proc_InsertGuestUserDetail(guestUserDetail.FirstName, guestUserDetail.Lastname, guestUserDetail.EmailId, guestUserDetail.PhoneNumber);
            //db.tblUsers.Add(tblUser);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = guestUserDetail.GID }, guestUserDetail));
        }
コード例 #11
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (ticket != null && seats != null)
     {
         db.TicketDetails.Remove(ticket);
         for (int i = 0; i < seats.Count(); i++)
         {
             db.SeatInfoes.Remove(seats[i]);
         }
         db.SaveChanges();
         MessageBox.Show("Ticket has been removed");
         this.Hide();
     }
 }
コード例 #12
0
        private void updatebtn_Click(object sender, EventArgs e)
        {
            db = new BusReservationEntities();
            Customer customers = db.Customers.Where(a => a.Id == id).FirstOrDefault();

            customers.Name        = nametxt.Text;
            customers.FatherName  = fnametxt.Text;
            customers.Email       = emailtext.Text;
            customers.DateOfBirth = birthdate.Value;
            customers.PhoneNo     = phonetxt.Text;
            customers.Address     = addresstext.Text;
            db.SaveChanges();
            MessageBox.Show("Record Updated");
        }
コード例 #13
0
        public IHttpActionResult PostRegistrationDetails(RegistrationDetails registrationDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.proc_Register(registrationDetails.FirstName, registrationDetails.Lastname, registrationDetails.EmailId, registrationDetails.PhoneNumber,
                             registrationDetails.Password, registrationDetails.Gender, registrationDetails.DOB, registrationDetails.Address, registrationDetails.State,
                             registrationDetails.City, registrationDetails.Pincode, registrationDetails.SecurityQuestion
                             );
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = registrationDetails.UID }, registrationDetails));
        }
コード例 #14
0
        public void DeleteFromBusInfo(int id)
        {
            var busDate = db.BusInfoes.Where(c => c.id == id).FirstOrDefault();

            if (busDate != null)
            {
                try
                {
                    db.BusInfoes.Remove(busDate);
                    db.SaveChanges();
                }
                catch (Exception) { }
            }
        }
コード例 #15
0
 public IHttpActionResult Put(int id, Ticket valuechange)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid model"));
     }
     using (var ue = new BusReservationEntities())
     {
         var existingdetails = ue.Tickets.Where(p => p.BookingUserID == id).FirstOrDefault <Ticket>();
         if (existingdetails != null)
         {
             existingdetails.TicketBookingStatus = 0;
             ue.SaveChanges();
         }
         else
         {
             return(NotFound());
         }
     }
     return(Ok());
 }
コード例 #16
0
        public object PostGuestUserDetail(GuestUserDetail guestUserDetail)
        {
            List <proc_GuestUserDetail_Result> list = new List <proc_GuestUserDetail_Result>();

            foreach (var item in db.proc_GuestUserDetail())
            {
                list.Add(item);
            }
            foreach (var item in list)
            {
                if (item.EmailId == guestUserDetail.EmailId)
                {
                    return("false");
                }
            }
            var guest = db.postGuestUserDetails(guestUserDetail.FirstName, guestUserDetail.Lastname, guestUserDetail.EmailId, guestUserDetail.PhoneNumber);

            //db.tblUsers.Add(tblUser);
            db.SaveChanges();
            return(guest);
        }
コード例 #17
0
 public IHttpActionResult PutUser(int id, EditUser valuechange)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Not a valid model"));
     }
     using (var ue = new BusReservationEntities())
     {
         var existingdetails = ue.UserDetails.Where(p => p.UID == id).FirstOrDefault <UserDetail>();
         if (existingdetails != null)
         {
             if (valuechange.PhoneNumber != null)
             {
                 existingdetails.PhoneNumber = valuechange.PhoneNumber;
             }
             if (valuechange.Address != null)
             {
                 existingdetails.Address = valuechange.Address;
             }
             if (valuechange.EmailId != null)
             {
                 existingdetails.GuestUserDetail.EmailId = valuechange.EmailId;
             }
             if (valuechange.Password != null)
             {
                 existingdetails.Password = valuechange.Password;
             }
             if (valuechange.Address == null)
             {
                 existingdetails.Address = existingdetails.Address;
             }
             ue.SaveChanges();
         }
         else
         {
             return(NotFound());
         }
     }
     return(Ok());
 }