public addFeedback(Accomodation currentAccomondation, Customer currentCust) { // TODO: Complete member initialization InitializeComponent(); CurrentFacility = null; CurrentAccomondation = currentAccomondation; rtb_feedback.Text = CurrentAccomondation.Feedback; CurrentCustomer = currentCust; Db = new Database(); }
public Details(Customer c, Accomodation a, DateTime start, DateTime end, string roomID) { InitializeComponent(); CurrentCustomer = c; CurrentAccomodation = a; StartD = start; EndD = end; RoomID = roomID; Database = new Database(); populateDetails(); }
public Bookings(Customer c, Accomodation a, int book_id, int acc_id, int room_id, int room_number, string start_date, string end_date) { C = c; A = a; Book_id = book_id; Acc_id = acc_id; Room_id = room_id; Room_number = room_number; Start_date = start_date; End_date = end_date; }
public Bookings(Customer c, string name, int book_id, int acc_id, int room_id, int room_number, string start_date, string end_date) { Db = new Database(); C = c; A = Db.searchAccomodation(""+acc_id); Name = name; Book_id = book_id; Acc_id = acc_id; Room_id = room_id; Room_number = room_number; Start_date = start_date; End_date = end_date; }
public void closeCustomerAccount(Customer c) { try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); string myInsertQuery = "INSERT INTO closedaccounts (title, firstname, surname, birthday, street, postcode, city, country," + " cardholder_name, creditcard_number, expdate_month, expdate_year )"; myInsertQuery += " VALUES('" + c.Title + "','" + c.Firstname + "','" + c.Surname + "','" + c.Birthday + "','" + c.Street + "','" + c.Postcode + "','" + c.City + "','" + c.Country + "','" + c.CardholderName + "','" + c.Cardnumber + "','" + c.Expiremonth + "','" + c.Expireyear + "')"; command.CommandText = myInsertQuery; command.ExecuteNonQuery(); connection.Close(); SQLiteConnection connection2 = new SQLiteConnection("Data Source=tourismus.db"); connection2.Open(); SQLiteCommand command2 = new SQLiteCommand(connection2); string myInsertQuery2 = "DELETE FROM customer where cust_id="+c.Custi_id; command2.CommandText = myInsertQuery2; command2.ExecuteNonQuery(); connection2.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log(c.Custi_id, 3); } catch (Exception et) { Console.WriteLine(et.ToString()); } }
public accomodationInfo(Customer c, Accomodation a) { InitializeComponent(); CurrentCustomer = c; CurrentAccomondation = a; CurrentFacility = null; db = new Database(); try { CurrentAccomondation = db.searchAccomodation(CurrentAccomondation.ID); } catch (Exception e) { Console.WriteLine(e.ToString()); } showAccommodationData(); }
public bookingDetails(Accomodation a, Customer c) { InitializeComponent(); startDateRoom = new List<DateTime>(); endDateRoom = new List<DateTime>(); roomId = new List<int>(); rooms = new Dictionary<int, int>(); CurrentCustomer = c; CurrentAccomodation = a; accommodation_id = a.ID; user_id = c.Custi_id; Database = new Database(); dgv_bookings.ColumnCount = 2; dgv_bookings.Columns[0].Name = "Room ID"; dgv_bookings.Columns[1].Name = "Room Number"; dgv_bookings.Columns[0].Width = dgv_bookings.Width / 2 - 22; dgv_bookings.Columns[1].Width = dgv_bookings.Width / 2 - 21; l_hotelName_bd.Text = Database.getHotelNameDb(accommodation_id); dbDateCheck(); }
public CustomerValidation(Customer c) { InitializeComponent(); C = c; b_cancel.DialogResult = DialogResult.Cancel; }
public void updateFacFeedback(Facility f, Customer c) { try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); string myEditQuery = "UPDATE facility SET feedback='" + f.Feedback + "' WHERE fac_id=" + f.ID; command.CommandText = myEditQuery; command.ExecuteNonQuery(); connection.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information + // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility + // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log(c.Custi_id, 9); } catch (Exception et) { Console.WriteLine(et.ToString()); } }
public Facility selectFacility(string fac_id, Customer c) { Facility ftemp = null; try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand cmd = new SQLiteCommand("select * from facility where fac_id="+fac_id, connection); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) while (reader.Read()) { ftemp = new Facility(System.Convert.ToString(reader.GetInt32(reader.GetOrdinal("fac_id"))), reader.GetString(reader.GetOrdinal("type")), reader.GetString(reader.GetOrdinal("name")), reader.GetString(reader.GetOrdinal("adress_city")), reader.GetString(reader.GetOrdinal("adress_country")), reader.GetString(reader.GetOrdinal("adress_postcode")), reader.GetString(reader.GetOrdinal("adress_street")), reader.GetString(reader.GetOrdinal("adress_number")), reader.GetString(reader.GetOrdinal("information")), reader.GetString(reader.GetOrdinal("feedback")), reader.GetString(reader.GetOrdinal("picture_url"))); } connection.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information + // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log(c.Custi_id, 5); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return ftemp; }
public void insertCustomer(Customer c) { try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); string myInsertQuery = "INSERT INTO customer (title, firstname, surname, birthday, street, postcode, city, country," + " cardholder_name, creditcard_number, expdate_month, expdate_year )"; myInsertQuery += " VALUES('" + c.Title + "','" + c.Firstname + "','" + c.Surname + "','" + c.Birthday + "','" + c.Street + "','" + c.Postcode + "','" + c.City + "','" + c.Country + "','" + c.CardholderName + "','" + c.Cardnumber + "','" + c.Expiremonth + "','" + c.Expireyear + "')"; command.CommandText = myInsertQuery; command.ExecuteNonQuery(); connection.Close(); //get the id for the log SQLiteConnection connection2 = new SQLiteConnection("Data Source=tourismus.db"); connection2.Open(); int cust_id = 0; SQLiteCommand cmd = new SQLiteCommand("SELECT cust_id from customer where firstname = '" + c.Firstname + "' and surname = '"+ c.Surname + "' and birthday = '" + c.Birthday + "'", connection2); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { cust_id = reader.GetInt32(reader.GetOrdinal("cust_id")); } } connection2.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log(cust_id, 1); } catch (Exception et) { Console.WriteLine(et.ToString()); } }
public List<Customer> getCustomersBySurename(string sur) { List<Customer> customerList = new List<Customer>(); try{ SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand cmd = new SQLiteCommand("select * from customer where surname = '"+sur+"'", connection); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { //title, firstname, surname, birthday, street, postcode, city, country, cardholder_name, creditcard_number, expdate_month, expdate_year String title = reader.GetString(reader.GetOrdinal("title")); String surname = reader.GetString(reader.GetOrdinal("surname")); String firstname = reader.GetString(reader.GetOrdinal("firstname")); String birthday = reader.GetString(reader.GetOrdinal("birthday")); String street = reader.GetString(reader.GetOrdinal("street")); String postcode = reader.GetString(reader.GetOrdinal("postcode")); String city = reader.GetString(reader.GetOrdinal("city")); String country = reader.GetString(reader.GetOrdinal("country")); String cardholder = reader.GetString(reader.GetOrdinal("cardholder_name")); int creditcardnumber = reader.GetInt32(reader.GetOrdinal("creditcard_number"));//issue String expdatemonth = reader.GetString(reader.GetOrdinal("expdate_month")); String expdateyear = reader.GetString(reader.GetOrdinal("expdate_year")); Customer c = new Customer(title, surname, firstname, birthday, street, postcode, city, country, cardholder, "" + creditcardnumber, expdatemonth, expdateyear); c.Custi_id = reader.GetInt32(reader.GetOrdinal("cust_id")); customerList.Add(c); } } connection.Close(); } catch(Exception e){ System.Console.WriteLine(e.ToString()); } return customerList; }
public List<Bookings> getBookings(Customer cust) { List<Bookings> bookingList = new List<Bookings>(); try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand cmd = new SQLiteCommand("select * from bookings natural join accommodations where cust_id = " + cust.Custi_id, connection); SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { String acc_name = reader.GetString(reader.GetOrdinal("acc_name")); int book_id = reader.GetInt32(reader.GetOrdinal("book_id")); int acc_id = reader.GetInt32(reader.GetOrdinal("acc_id")); int room_id = reader.GetInt32(reader.GetOrdinal("room_id")); int room_number = reader.GetInt32(reader.GetOrdinal("room_number")); String start_date = reader.GetString(reader.GetOrdinal("start_date")); String end_date = reader.GetString(reader.GetOrdinal("end_date")); Bookings b = new Bookings(cust,acc_name, book_id, acc_id, room_id, room_number, start_date, end_date); bookingList.Add(b); } } connection.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return bookingList; }
public void editCustomer(Customer c, int cust_id) { try { SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); string myEditQuery = "UPDATE customer SET title='" + c.Title + "', firstname='" + c.Firstname + "', surname='" + c.Surname + "', birthday='" + c.Birthday + "', street='" + c.Street + "', postcode='" + c.Postcode + "', city='" + c.City + "', country='" + c.Country + "',"+ "cardholder_name='" + c.CardholderName + "', creditcard_number='" + c.Cardnumber + "', expdate_month='" + c.Expiremonth + "', expdate_year='" + c.Expireyear + "' WHERE cust_id="+cust_id; command.CommandText = myEditQuery; command.ExecuteNonQuery(); connection.Close(); // 1 = Account created + // 2 = Account updated + // 3 = Account deleted + // 4 = Aquired accommodation information // 5 = Aquired facility information // 6 = Booked an accommodation + // 7 = Deleted a booking + // 8 = Gave feedback about accommodation // 9 = Gave feedback about facility // 10 = Start of session // 11 = End of session //log(string custname, int custId, int action) logger.log( cust_id, 2); } catch (Exception et) { Console.WriteLine(et.ToString()); } }
public AddCustomer(Customer c) { Customer = c; Cust_id = c.Custi_id; InitializeComponent(); Db = new Database(); l_formtitle.Text = "Edit customer"; b_closeAccount.Show(); cb_title.Text = c.Title; tb_firstname.Text = c.Firstname; tb_surname.Text = c.Surname; cb_byear.Text = c.Birthday.Split('-')[0]; cb_bmonth.Text = c.Birthday.Split('-')[1]; cb_bday.Text = c.Birthday.Split('-')[2]; switch (c.Birthday.Split('-')[1]) { case "01": cb_bmonth.Text = "Janurary"; break; case "02": cb_bmonth.Text = "Februray"; break; case "03": cb_bmonth.Text = "March"; break; case "04": cb_bmonth.Text = "April"; break; case "05": cb_bmonth.Text = "May"; break; case "06": cb_bmonth.Text = "June"; break; case "07": cb_bmonth.Text = "July"; break; case "08": cb_bmonth.Text = "August"; break; case "09": cb_bmonth.Text = "September"; break; case "10": cb_bmonth.Text = "October"; break; case "11": cb_bmonth.Text = "November"; break; case "12": cb_bmonth.Text = "December"; break; default: cb_bmonth.Text = "0"; break; } tb_street.Text = c.Street; tb_postcode.Text = c.Postcode; tb_city.Text = c.City; cb_country.Text = c.Country; tb_cardholder.Text = c.CardholderName; tb_creditnum.Text = c.Cardnumber; cb_expiremonth.Text = c.Expiremonth; cb_expireyear.Text = c.Expireyear; }
private void b_saveCustomer_Click(object sender, EventArgs e) { //switch case wegen monat if (cb_title.Text != "" && tb_firstname.Text != "" && tb_surname.Text != "" && cb_byear.Text != "" && cb_bmonth.Text != "" && cb_bday.Text != "" && tb_street.Text != "" && tb_postcode.Text != "" && tb_city.Text != "" && cb_country.Text != "" && tb_cardholder.Text != "" && tb_creditnum.Text != "" && cb_expiremonth.Text != "" && cb_expireyear.Text != "") { switch (cb_bmonth.Text) { case "Janurary": Bmonth = "01"; break; case "Februray": Bmonth = "02"; break; case "March": Bmonth = "03"; break; case "April": Bmonth = "04"; break; case "May": Bmonth = "05"; break; case "June": Bmonth = "06"; break; case "July": Bmonth = "07"; break; case "August": Bmonth = "08"; break; case "September": Bmonth = "09"; break; case "October": Bmonth = "10"; break; case "November": Bmonth = "11"; break; case "December": Bmonth = "12"; break; default: Bmonth = "0"; break; } //create customer Customer = new Customer(cb_title.Text, tb_surname.Text, tb_firstname.Text, cb_byear.Text + "-" + Bmonth + "-" + cb_bday.Text, tb_street.Text, tb_postcode.Text, tb_city.Text, cb_country.Text, tb_cardholder.Text, tb_creditnum.Text, cb_expiremonth.Text, cb_expireyear.Text);//title,surname,firstname,birthday,street,postcode,city,country,cardholder,cardnumber,expire); // call method in db if (Cust_id == -1) Db.insertCustomer(Customer); else Db.editCustomer(Customer, Cust_id); } this.Close(); }