vb.net - Visual basic 2010, database – how to fill specific field -


i'm creating database connection in visual basic. when user click on "borrow book" transfer chosen data table used lent books. works alright, need last thing. in database in lent table have attribute "end date of lent" , want fill everytime when user borrow book date today + 1 month (for instance, if 19/04/2016, end date 19/05/2016). created method "borrowtime" this, don't know should type , how can value of inserted row "row". , sorry horrible of code , form...

public class frm_userview     dim bookssource new bindingsource     dim borrowsource new bindingsource      dim booksview new dataview     dim borrowview new dataview      dim ds new dataset      dim borrow byte       private sub frm_userview_load(sender system.object, e system.eventargs) handles mybase.load         tmr_timer.start()         me.loanerbookstableadapter.fill(me.gmitlibrarydataset1.loanerbooks)         me.bookstableadapter.fill(me.gmitlibrarydataset.books)          bookssource = dgd_userbookview.datasource         booksview = ctype(bookssource.list, dataview)          ds = booksview.dataviewmanager.dataset.clone          borrowsource.datasource = ds         borrowsource.datamember = "books"          borrowview = ctype(borrowsource.list, dataview)         dgd_user_borrow_view.datasource = borrowsource        end sub      private sub btn_borrow_click(sender system.object, e system.eventargs) handles btn_borrowbook.click         borrow = 1         movebooks(dgd_userbookview, borrowview, borrow)          dgd_user_borrow_view.sort(dgd_user_borrow_view.columns(0), system.componentmodel.listsortdirection.ascending)          borrowsource.movelast()         borrowsource.movelast()     end sub     private sub movebooks(byref source datagridview, byref target dataview, byref borrow byte)         = 0 source.selectedrows.count - 1             dim numberofrow integer             dim row datarowview             row = target.addnew()             dim col int16 = 0             each cell datagridviewcell in source.selectedrows(i).cells                 row.item(col) = cell.value                 if borrow = 1                     numberofrow = 0                     borrowtime(numberofrow, dgd_user_borrow_view)                 end if                 col = col + 1             next         next          dim count int16 = source.selectedrows.count          = 0 count - 1             source.rows.removeat(source.selectedrows(0).index)         next     end sub     private sub borrowtime(byref row integer, byref dgd_table datagridview)         'code adding date     end sub      private sub btn_returnbook_click(sender system.object, e system.eventargs) handles btn_returnbook.click         borrow = 0         movebooks(dgd_user_borrow_view, booksview, borrow)          dgd_userbookview.sort(dgd_userbookview.columns(0), system.componentmodel.listsortdirection.ascending)          bookssource.movelast()         bookssource.movelast()     end sub      private sub btn_userlogout_click(sender system.object, e system.eventargs) handles btn_userlogout.click         frm_login.show()         me.hide()     end sub      private sub timer1_tick(sender system.object, e system.eventargs) handles tmr_timer.tick         dim countbooks integer         dim countlent integer         countbooks = bookssource.count         countlent = borrowsource.count          lbl_bookcounter.text = "there " + countbooks.tostring + " books"         lbl_borrowcounter.text = "you have lent " + countlent.tostring + " books"     end sub end class 

i need put code here:

 private sub borrowtime(byref row integer, byref dgd_table datagridview)        'code adding date  end sub 

my form

enter image description here

public class frm_userview dim bookssource new bindingsource dim borrowsource new bindingsource

dim booksview new dataview dim borrowview new dataview  dim ds new dataset  dim borrow byte   private sub frm_userview_load(sender system.object, e system.eventargs) handles mybase.load     tmr_timer.start()     me.loanerbookstableadapter.fill(me.gmitlibrarydataset1.loanerbooks)     me.bookstableadapter.fill(me.gmitlibrarydataset.books)      bookssource = dgd_userbookview.datasource     booksview = ctype(bookssource.list, dataview)      ds = booksview.dataviewmanager.dataset.clone      borrowsource.datasource = ds     borrowsource.datamember = "books"      borrowview = ctype(borrowsource.list, dataview)     dgd_user_borrow_view.datasource = borrowsource    end sub  private sub btn_borrow_click(sender system.object, e system.eventargs) handles btn_borrowbook.click     borrow = 1     movebooks(dgd_userbookview, borrowview, borrow)      dgd_user_borrow_view.sort(dgd_user_borrow_view.columns(0), system.componentmodel.listsortdirection.ascending)      borrowsource.movelast()     borrowsource.movelast() end sub private sub movebooks(byref source datagridview, byref target dataview, byref borrow byte)     = 0 source.selectedrows.count - 1         dim numberofrow integer         dim row datarowview         row = target.addnew()         dim col int16 = 0         each cell datagridviewcell in source.selectedrows(i).cells             row.item(col) = cell.value             if borrow = 1                 numberofrow = 0                 borrowtime(numberofrow, dgd_user_borrow_view)             end if             col = col + 1         next     next      dim count int16 = source.selectedrows.count      = 0 count - 1         source.rows.removeat(source.selectedrows(0).index)     next end sub private sub borrowtime(byref row integer, byref dgd_table datagridview)     'code adding date end sub  private sub btn_returnbook_click(sender system.object, e system.eventargs) handles btn_returnbook.click     borrow = 0     movebooks(dgd_user_borrow_view, booksview, borrow)      dgd_userbookview.sort(dgd_userbookview.columns(0), system.componentmodel.listsortdirection.ascending)      bookssource.movelast()     bookssource.movelast() end sub  private sub btn_userlogout_click(sender system.object, e system.eventargs) handles btn_userlogout.click     frm_login.show()     me.hide() end sub  private sub timer1_tick(sender system.object, e system.eventargs) handles tmr_timer.tick     dim countbooks integer     dim countlent integer     countbooks = bookssource.count     countlent = borrowsource.count      lbl_bookcounter.text = "there " + countbooks.tostring + " books"     lbl_borrowcounter.text = "you have lent " + countlent.tostring + " books" end sub 

end class


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -