public bool UpdateRecords(BorrowRecords br) { string tmp1 = Convert.ToString(br.BorrowDate); string[] bdate1 = tmp1.Split(' '); string bdate = bdate1[0]; string tme2 = Convert.ToString(br.DueDate); string[] ddate1 = tme2.Split(' '); string ddate = ddate1[0]; string query = "UPDATE Records SET BookID1='" + br.BookID1 + "',BookID2='" + br.BookID2 + "',BookID3= '" + br.BookID3 + "', BorrowDate= '" + bdate + "',DueDate = '" + ddate + "' WHERE StudentID ='" + br.StudentID + "' "; //myCommand = new SqlCommand(); // myCommand.Parameters.Add(new SqlParameter("@book.Image",book.Image)); try { dcc.ConnectWithDB(); int n = dcc.ExecuteSQL(query); dcc.CloseConnection(); return(true); } catch (Exception exp) { return(false); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,MovieId,PickUpDate,DueDate,ApplicationUser")] BorrowRecords borrowRecords) { if (id != borrowRecords.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(borrowRecords); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BorrowRecordsExists(borrowRecords.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details))); } return(View(borrowRecords)); }
public async Task <IActionResult> Create([FromRoute] int id, [FromForm] string title, [FromForm] string posterPath) { var borrowRecords = new BorrowRecords { MovieId = id, Title = title, PosterPath = posterPath }; var user = await _userManager.GetUserAsync(User); borrowRecords.ApplicationUserId = user.Id; _context.Add(borrowRecords); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details))); }
private void cellClick(object sender, DataGridViewCellEventArgs e) { brecords = new BorrowRecords(); brecords.StudentID = RecordsTableDG.Rows[e.RowIndex].Cells[2].Value.ToString(); studentid = brecords.StudentID; //stID = student.Id; brecords.BookID1 = RecordsTableDG.Rows[e.RowIndex].Cells[3].Value.ToString(); brecords.BookID2 = RecordsTableDG.Rows[e.RowIndex].Cells[4].Value.ToString(); brecords.BookID3 = RecordsTableDG.Rows[e.RowIndex].Cells[5].Value.ToString(); brecords.BorrowDate = RecordsTableDG.Rows[e.RowIndex].Cells[0].Value.ToString(); brecords.DueDate = RecordsTableDG.Rows[e.RowIndex].Cells[1].Value.ToString(); // MessageBox.Show("you are selected"); viewDetailsBTN.Visible = true; }
public List <BorrowRecords> GetAllRecords() { List <BorrowRecords> listOfRecords = new List <BorrowRecords>(); string query = "SELECT * from Records"; dcc.ConnectWithDB(); SqlDataReader sdr = dcc.GetData(query); while (sdr.Read()) { BorrowRecords r = new BorrowRecords(); //book.Image = sdr["Image"].; // pictureBox1.Image = new Bitmap(ms) r.StudentID = sdr["StudentID"].ToString(); r.BookID1 = sdr["BookID1"].ToString(); r.BookID2 = sdr["BookID2"].ToString(); r.BookID3 = sdr["BookID3"].ToString(); r.BorrowDate = sdr["BorrowDate"].ToString(); r.DueDate = sdr["DueDate"].ToString(); // r.BorrowDate = Convert.ToDateTime(bdate); // r.BorrowDate = Convert.ToDateTime(sdr["BorrowDate"].ToString()); // DateTime.ParseExact(iString, "yyyy-MM-dd //r.BorrowDate = DateTime.ParseExact(bdate,"MM-dd-yyyy",null); //r.DueDate = Convert.ToDateTime(sdr["DueDate"].ToSt ring()); listOfRecords.Add(r); } dcc.CloseConnection(); return(listOfRecords); }
private void Borrow_Click(object sender, EventArgs e) { // DataGridViewRow dRow = borrowListDG.Rows[0]; if (borrowListDG.Rows.Count == 0) { MessageBox.Show("Select a book"); } else { studentRepo = new StudentRepo(); book = new Book(); //book.Image = Convert.ToByte[] (BookTable.Rows[e.RowIndex].Cells[0].Value.ToString()); //book.Image = new MemoryStream((byte[])BookTable.Rows[e.RowIndex].Cells[0].Value); book.BookId = booksDG.Rows[indexRow].Cells[1].Value.ToString(); book.Copies = Convert.ToInt32(booksDG.Rows[indexRow].Cells[2].Value.ToString()); book.Title = booksDG.Rows[indexRow].Cells[3].Value.ToString(); book.Author = booksDG.Rows[indexRow].Cells[4].Value.ToString(); book.Classification = booksDG.Rows[indexRow].Cells[5].Value.ToString(); book.Publisher = booksDG.Rows[indexRow].Cells[6].Value.ToString(); book.Subtitle = booksDG.Rows[indexRow].Cells[7].Value.ToString(); book.Copyright = booksDG.Rows[indexRow].Cells[8].Value.ToString(); book.Place = booksDG.Rows[indexRow].Cells[9].Value.ToString(); book.PublishDate = booksDG.Rows[indexRow].Cells[10].Value.ToString(); if (Convert.ToInt32(student_Borrowed.Text) == 3) { MessageBox.Show("Already 3 Books has been Taken"); } else { BorrowRecords b = new BorrowRecords(); b.BookID1 = null; b.BookID2 = null; b.BookID3 = null; // b.BookID1 = borrowListDG.Rows[0].Cells[0].Value.ToString(); //b.BookID2 = borrowListDG.Rows[1].Cells[0].Value.ToString(); // b.BookID3 = borrowListDG.Rows[2].Cells[0].Value.ToString(); b.StudentID = studentSearchTB.Text; b.BorrowDate = borrowedDate.Text; b.DueDate = dueDate.Text; if (borrowListDG.Rows[0] == null) { b.BookID1 = null; } else { b.BookID1 = borrowListDG.Rows[0].Cells[0].Value.ToString(); } if (borrowListDG.Rows[1].Displayed == false) { b.BookID2 = null; } else { MessageBox.Show("2 not null"); b.BookID2 = borrowListDG.Rows[1].Cells[0].Value.ToString(); } if (borrowListDG.Rows[2].Displayed == false) { b.BookID3 = null; } else { b.BookID3 = borrowListDG.Rows[2].Cells[0].Value.ToString(); } /*string a = Convert.ToString(borrowedDate.Value.Date); * string[] s = a.Split(' '); * MessageBox.Show(s[0]); * * MessageBox.Show(b.BorrowDate+"");*/ bool borrowResult = bookRepo.UpdateBook(book.BookId, book.Copies); bool borrowResult1 = bookRepo.UpdateRecords(b); bool borrowResult2 = studentRepo.UpdateStudentBorrow(studentSearchTB.Text, Convert.ToInt32(TotalCopiesLB.Text)); if (borrowResult && borrowResult1 && borrowResult2) { MessageBox.Show("Borrowed Succesfully"); } else { MessageBox.Show("Cannot Borrow"); } } } }