public void CreateHistory(string carname) { tblCarDAO dao = new tblCarDAO(); tblCar car = dao.getCarByName(carname); if (dao.Getposition(car.carID) != null) { DataClasses1DataContext db = new DataClasses1DataContext(); var carpark = (from table in db.tblCarParks where table.position == dao.Getposition(car.carID) select table).SingleOrDefault(); if (carpark.timeIn == null) { carpark.timeIn = DateTime.Now; } db.SubmitChanges(); tblHistory his = new tblHistory(); his.carID = car.carID; his.position = dao.Getposition(car.carID); his.timeIn = DateTime.Now; his.userID = car.userID; Random rd = new Random(); his.keyCode = rd.Next(1000, 9999).ToString(); db.tblHistories.InsertOnSubmit(his); db.SubmitChanges(); var caru = (from table in db.tblCars where table.carName == carname select table).Single(); caru.status = "activated"; db.SubmitChanges(); string phone = (from table in db.tblUsers where table.userID == car.userID select table.phoneNumber).Single(); SMSSender sms = new SMSSender(); bool checksended = sms.sendSMS(phone, his.keyCode); if (checksended == true) { System.Windows.Forms.MessageBox.Show("your keycode is already sended!!!"); } } else { System.Windows.Forms.MessageBox.Show("you have no place in plan"); } }
public void CreateHistory(string carname) { cameraCheck camc = new cameraCheck(); tblCar car = camc.getCarByName(carname); if (camc.Getposition(car.carID) != 0) { DataClasses1DataContext db = new DataClasses1DataContext(); tblHistory his = new tblHistory(); his.carID = car.carID; his.position = camc.Getposition(car.carID).ToString(); his.timeIn = DateTime.Now; his.userID = car.userID; Random rd = new Random(); his.keyCode = rd.Next(1000, 9999).ToString(); db.tblHistories.InsertOnSubmit(his); db.SubmitChanges(); string phone = (from table in db.tblUsers where table.userID == car.userID select table.phoneNumber).Single(); SMSSender sms = new SMSSender(); bool checksended = sms.sendSMS(phone, his.keyCode); if (checksended == true) { System.Windows.Forms.MessageBox.Show("your keycode is already sended!!!"); } } else { System.Windows.Forms.MessageBox.Show("you have no place in plan"); } }