public void AfterFullConfirm(int IDUser_Meal, int IDActor) { var temp = db.tblUser_Meal.FirstOrDefault(it => it.ID == IDUser_Meal); var meal = db.tblMeals.FirstOrDefault(it => it.ID == temp.IDMeal); var usm = db.tblUser_Meal.Where(it => it.IDMeal == meal.ID); //int num = db.tblUser_Meal.Count(it => it.IDMeal == meal.ID); meal.Status = true; db.SaveChanges(); foreach (var it in usm) { tblHistory htr = new tblHistory(); htr.IDUser = it.IDUser; htr.IDAction = 2; htr.Money = meal.Totalmoney / usm.Count(); htr.Datetime = (DateTime)meal.Datetime; htr.IDActor = IDActor; db.tblHistories.Add(htr); var us = db.tblUsers.FirstOrDefault(i => i.ID == it.IDUser); us.Money -= htr.Money; } db.SaveChanges(); }
public ActionResult PaymentConfirm(int a) { var actor = (tblUser)Session["User"]; var pm = db.tblPayments.FirstOrDefault(it => it.ID == a); if (actor.ID != pm.IDActor && actor.ID != pm.IDUser) { pm.Status = true; tblConfirm cf = new tblConfirm(); cf.IDPayment = a; cf.IDResponsible = actor.ID; db.tblConfirms.Add(cf); db.SaveChanges(); var uspay = db.tblUsers.FirstOrDefault(it => it.ID == pm.IDUser); uspay.Money += pm.Money; tblHistory htr = new tblHistory(); htr.IDUser = pm.IDUser; htr.IDAction = 1; htr.IDActor = actor.ID; htr.Money = pm.Money; htr.Datetime = DateTime.Now; db.tblHistories.Add(htr); db.SaveChanges(); } return(Content("Successed!")); }
public tblHistory CheckKC(string keycode) { tblHistory result = null; DataClasses1DataContext db = new DataClasses1DataContext(); var check = (from table in db.tblHistories where table.keyCode == keycode select table).Single(); if (check != null) { result = check; } return(result); }
public void InsrtHistory(tblEmployee emp, long ActionId, string FormName, string oldAction, string newAction, string Remark) { history = new tblHistory(); history.Emp_Id = emp.Employee_Id; history.EmployeeName = emp.Employee_Name; history.ActionRowId = ActionId; history.FromName = FormName; history.Old_Action = oldAction; history.New_Action = newAction; history.Remark = Remark; history.EntryDatetime = DateTime.Now; history.Department_Id = emp.Employee_Department; dbSche.tblHistories.Add(history); dbSche.SaveChanges(); }
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 JsonResult SaveTranslation(History trView) { string email = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; TranslatorDBEntities db = new TranslatorDBEntities(); var user = db.tblCustomers.Where(a => a.Email == email).FirstOrDefault(); tblHistory newData = new tblHistory(); newData.UserID = user.id; var jsonString = trView.ToString(); newData.SourceLanguage = trView.SourceLanguage; newData.SourceText = trView.SourceText; newData.DestinationLanguage = trView.DestinationLanguage; newData.DestinationText = trView.DestinationText; db.tblHistories.Add(newData); db.SaveChanges(); return(Json(JsonRequestBehavior.AllowGet)); }
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"); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (txtKeyCode.Text == "" || txtKeyCode.Text == null) { MessageBox.Show("please input keycode"); } else { KeyCodeCheck check = new KeyCodeCheck(); tblHistory result = check.CheckKC(txtKeyCode.Text); if (result != null) { shareHis = result; MessageBox.Show("Right key code, please take picture!"); checkKeyCode = true; btnTakePicture.Enabled = true; txtKeyCode.ReadOnly = true; } else { MessageBox.Show("wrong keycode"); } } }