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")); }
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"); } }
private void LoginBtn_Click(object sender, EventArgs e) { BusReservationEntities db = new BusReservationEntities(); if (usertext.Text != string.Empty && passtext.Text != string.Empty) { var user = db.AdminLogins.Where(a => a.username.Equals(usertext.Text)).FirstOrDefault(); //var custUser = db.Customer_login.Where(a => a.Username.Equals(usertext.Text)).SingleOrDefault(); if (user != null) { if (user.password.Equals(passtext.Text)) { new AdminMenu().Show(); this.Close(); } else { MessageBox.Show("Wrong password"); } } else { MessageBox.Show("Wrong username"); } } else { MessageBox.Show("Please fill all form"); } }
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"); }
public CustomerDetail(int?Id) { InitializeComponent(); if (Id != null) { addbtn.Visible = false; db = new BusReservationEntities(); Customer customers = db.Customers.Where(a => a.Id == Id).FirstOrDefault(); id = customers.Id; nametxt.Text = customers.Name; fnametxt.Text = customers.FatherName; emailtext.Text = customers.Email; birthdate.Value = (DateTime)customers.DateOfBirth; phonetxt.Text = customers.PhoneNo; addresstext.Text = customers.Address; } else { updatebtn.Visible = false; } }
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()); }
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()); }
public CustomerTicketReservation(Login user, BusInfo busUser) { this.user = user; this.busUser = busUser; this.selectedSeats = SelectSeat.selectedSeats; db = new BusReservationEntities(); InitializeComponent(); usernameLb.Text = user.username.ToUpper(); try{ busId.Text = this.busUser.BusNo.ToString(); }catch (Exception) { } var item = db.Customers.Where(a => a.Id == this.user.custId).FirstOrDefault(); CustomerId.Text = item.Id.ToString(); try { customerNameTxt.Text = item.Name; fatherNameTxt.Text = item.FatherName; dateTimePicker1.Text = item.DateOfBirth.ToString(); emailTxt.Text = item.Email; phoneNumTxt.Text = item.PhoneNo; addressTxt.Text = item.Address; } catch (Exception e) { MessageBox.Show(e.GetBaseException().ToString()); } selectSeatLb.Text = SelectSeat.seats; BindSource(); BindDestination(); }
private void LoginBtn_Click(object sender, EventArgs e) { BusReservationEntities db = new BusReservationEntities(); if (usertext.Text != "User Name" && passtext.Text != "Password") { var user = db.Logins.Where(a => a.username.Equals(usertext.Text)).FirstOrDefault(); //var custUser = db.Customer_login.Where(a => a.Username.Equals(usertext.Text)).SingleOrDefault(); if (user != null) { if (user.password.Equals(passtext.Text)) { //MessageBox.Show("you are login"); if (remmechk.Checked) { Properties.Settings.Default.UserName = usertext.Text; Properties.Settings.Default.Password = passtext.Text; Properties.Settings.Default.Save(); } new CustomerMenu(user).Show(); this.Hide(); } else { MessageBox.Show("Wrong password"); } } else { MessageBox.Show("Wrong username"); } } else { MessageBox.Show("Please fill all form"); } }
public DBAccess() { db = new BusReservationEntities(); }