private void button2_Click(object sender, EventArgs e) // confitm button { try { DataClasses1DataContext dbCon = new DataClasses1DataContext(); customer cr = new customer(); cr.name = nameTxt.Text; cr.password = Convert.ToInt32(passwordTxt.Text); cr.phone = phoneTxt.Text; cr.Address = addressTxt.Text; cr.date = Convert.ToDateTime(dateTimePickerTxt.Text); cr.roomNumber = Convert.ToInt32(roomIdTxt.Text); RoomTB rm = dbCon.RoomTBs.SingleOrDefault(x => x.roomNumber == Convert.ToInt32(roomIdTxt.Text)); if (rm != null) { balance = Convert.ToDouble(rm.price); // traking room price if (MessageBox.Show("Are you want to confirm Room with price : " + balance + " ?", "BookingConfirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { dbCon.customers.InsertOnSubmit(cr); dbCon.SubmitChanges(); this.Hide(); Form10 f10 = new Form10(); f10.Show(); transection tn = new transection(); // transection entry tn.customerId = cr.customerId; tn.balance = balance; dbCon.transections.InsertOnSubmit(tn); dbCon.SubmitChanges(); record rd = new record(); // record entry rd.customerId = cr.customerId; rd.roomId = Convert.ToInt32(cr.roomNumber); rd.date = cr.date; cId = cr.customerId; // traking customerId dbCon.records.InsertOnSubmit(rd); dbCon.SubmitChanges(); // MessageBox.Show("Data added to record"); } } else { MessageBox.Show("There is no room in this content"); } } catch (Exception ex) { MessageBox.Show("Data aren't insert correctly", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
partial void Updaterecord(record instance);
partial void Deleterecord(record instance);
partial void Insertrecord(record instance);