public int delete(int id) { borrow borrow = this.context.borrows.SingleOrDefault(a => a.sl == id); this.context.borrows.Remove(borrow); return(this.context.SaveChanges()); }
bool SaveDate() { if (borrowwrenchlist == null || borrowwrenchlist.Count <= 0) { MessageAlert.Alert("没有数据"); return(false); } try { foreach (BorrowWrench b in borrowwrenchlist) { borrow bw = new borrow() { WrenchID = b.wrenchid, borrowUser = b.userguid, borrowDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), borrowOperator = b.operatorguid, guid = Guid.NewGuid().ToString(), is_return = false }; Borrow.add(bw); } } catch { return(false); } return(true); }
ReturnWrench GetReturnWrench(BorrowWrench br) { ReturnWrench rw = new ReturnWrench(); List <borrow> bl = Borrow.SelectByWrench(br.wrenchguid, br.userguid, false); if (bl != null && bl.Count > 0) { borrow b = bl.FirstOrDefault(); wrench w = Wrench.selectByguid(b.WrenchID); users u = User.SelectByguid(b.borrowUser); users operatos = User.SelectByguid(b.borrowOperator); _returnwrench.Add(new ReturnWrench() { wrenchbarcode = w.wrenchBarCode, wrenchcode = w.wrenchCode, wrenchguid = w.guid, cardid = u.cardID, username = u.username, factory = w.factory, rang = w.rangeMin.ToString("f2") + "~" + w.rangeMin.ToString("f2"), borrowdate = b.borrowDate.Replace('T', ' '), operater = operatos.username, wrenchcommit = w.comment }); return(rw); } return(null); }
public bool Update(borrow borrowmodel) { string tablename = typeof(borrow).Name; string strsql = string.Format("WrenchID_id='{0}',borrowUser='******',borrowOperator='{2}',returnUser='******',returnOperator='{4}',borrowDate='{5}',returnDate='{6}',comment='{7}',is_return={8}", borrowmodel.WrenchID, borrowmodel.borrowUser, borrowmodel.borrowOperator, borrowmodel.returnUser, borrowmodel.returnOperator, borrowmodel.borrowDate, borrowmodel.returnDate, borrowmodel.comment, borrowmodel.is_return); string contation = string.Format("guid='{0}'", borrowmodel.guid); return(ServerHelp.updateByWhere(tablename, _webip, contation, strsql)); }
private void Button_Click_21(object sender, RoutedEventArgs e) { borrow b = new borrow() { borrowDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), borrowOperator = "222", borrowUser = "******", guid = Guid.NewGuid().ToString() }; MessageBox.Show(Borrow.addreturnid(b).ToString()); }
string addborrow() { borrow b = new borrow() { borrowUser = _user.guid, borrowOperator = _opertaor.guid, borrowDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), guid = Guid.NewGuid().ToString() }; return(Borrow.addreturnid(b)); }
public ActionResult Borrow(int id, string userid, string username, string sl, string bname, string bdate, string rdate) { /* if (!String.IsNullOrEmpty(userid) && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(sl) && !String.IsNullOrEmpty(bname) &&!String.IsNullOrEmpty(bdate) && !String.IsNullOrEmpty(rdate)) * {*/ if (!String.IsNullOrEmpty(userid) && !String.IsNullOrEmpty(username)) { book book = service.Get(id); int uid = Convert.ToInt32(userid); if (bservice.GetAll().Where(c => c.userid == uid).Count() < 3) { borrow b = new borrow(); b.userid = uid; b.username = username; b.serialno = sl; b.book_name = bname; b.borrow_date = bdate; b.return_date = rdate; book.amount = book.amount - 1; service.update(book); bservice.insert(b); ViewBag.msg = "Borrow book succesfully done...!!!"; return(View(b)); } else { borrow b = new borrow(); ViewBag.msg1 = "You can not borrow more then 3 book at a time...!!!"; return(View(b)); } } else { borrow b = new borrow(); ViewBag.error = "You must login first to borrow...!!!"; /* ViewBag.date = DateTime.Today.ToShortDateString(); * ViewBag.date7 = DateTime.Today.AddDays(7).ToShortDateString();*/ return(View(b)); } // } /* else * { * ViewBag.msg = "Not inserted..."; * return View(b); * }*/ }
/// <summary> /// 扳手归还 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_26(object sender, RoutedEventArgs e) { Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("guid", "f1e06654-dc4d-4d13-a549-837850b3a480"); IBorrow Borrow = new MySqlBorrow(); List <borrow> bl = Borrow.SelectByCondition(d); borrow b = bl.FirstOrDefault(); b.returnDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); b.returnOperator = "374b4fde-f46d-446a-aa62-331764bc5f57"; b.returnUser = "******"; MessageBox.Show(Borrow.Update(b).ToString()); }
/// <summary> /// 扳手借出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_25(object sender, RoutedEventArgs e) { IBorrow Borrow = new MySqlBorrow(); borrow b = new borrow() { WrenchID = "1", borrowDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), borrowOperator = "374b4fde-f46d-446a-aa62-331764bc5f57", borrowUser = "******", guid = Guid.NewGuid().ToString() }; MessageBox.Show(Borrow.add(b).ToString()); }
//Get book_return page public ActionResult book_return(int id) { borrow b = bservice.Getbysl(id); string a = Convert.ToDateTime(b.return_date).ToShortDateString(); DateTime dt = Convert.ToDateTime(a).Date; DateTime dt1 = DateTime.Today.Date; if (dt > dt1) { ViewBag.date = DateTime.Today.ToShortDateString(); ViewBag.fine = "0"; return(View(b)); } else { ViewBag.date = DateTime.Today.ToShortDateString(); double diff = dt1.Subtract(dt).TotalDays; ViewBag.fine = diff * 5; return(View(b)); } }
/// <summary> /// 只要找到 /// </summary> /// <returns></returns> bool Update() { try { foreach (BorrowWrench b in borrowwrenchlist) { //默认归还第一条 List <borrow> bl = Borrow.SelectByWrench(b.wrenchguid, false); if (bl != null && bl.Count > 0) { borrow bw = bl.FirstOrDefault(); bw.is_return = true; bw.returnDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); bw.returnOperator = SystData.userInfo.user.guid; bw.returnUser = borrowuser.user.guid; Borrow.Update(bw); } } } catch { return(false); } return(true); }
public int insert(borrow b) { this.context.borrows.Add(b); return(this.context.SaveChanges()); }
public bool Del(borrow borrowmodel) { string contion = string.Format("id='{0}'", borrowmodel.id); return(ServerHelp.deleteDataByWhere <borrow>(_webip, contion)); }
public int insert(borrow b) { return(this.data.insert(b)); }