I want to make booking service that need date service..i using access and ole db conn..
Condition that i want in date service.
Only 2 no boking in one day
----------------------------
+ Date. + No booking +
----------------------------
+ 29/08/2017 + AN29081701 +
+ 29/08/2017 + AN29081702 +
+ 30/08/2017 + AN30081701 +
+ 01/09/2017 + AN01091701 +
----------------------------
Db : database
I want use automatic n manual to select date service..
In automatic : find top date on db which one only have one no boking (30/08/2017) So will be create AN30081702
in manual : using datepicker , first cek date on date picker compare with date service on db
If find date then cek again available 2 no boking or not if available msgbox("full"). Not create example for (01/09/2017)
AN01091702..
How to make correct n simple code like my condition that i want..
Help me i'm stuck here..thanks
Code:Call koneksi() Dim tambah As Long Dim tgl = Format(Date.Now, "ddMMyy") sql = "select * from booking order by no_booking desc" cmd = New OleDbCommand(sql, conn) dr = cmd.ExecuteReader dr.Read() If Not dr.HasRows Then Tbnobooking.Text = "AN" + tgl + "01" ElseIf dr.HasRows Then If Microsoft.VisualBasic.Mid(dr.GetString(0), 3, 6) <> tgl Then Tbnobooking.Text = "AN" + tgl + "01" ElseIf Microsoft.VisualBasic.Right(dr.GetString(0), 2) >= 02 Then Dim st = Microsoft.VisualBasic.Mid(dr.GetString(0), 3, 6) Dim dt As Date = Date.ParseExact(st, "ddMMyy", System.Globalization.DateTimeFormatInfo.InvariantInfo) Dim dtl As DateTime = dt Dim latestdate = Format(dtl, "ddMMyy") Dim dtb As DateTime = dtl.AddDays(1) Dim nextdate = Format(dtb, "ddMMyy") Tbnobooking.Text = "AN" + nextdate + "01" Else Dim st = Microsoft.VisualBasic.Mid(dr.GetString(0), 3, 6) Dim dt As Date = Date.ParseExact(st, "ddMMyy", System.Globalization.DateTimeFormatInfo.InvariantInfo) Dim dtl As DateTime = dt Dim latestdate = Format(dtl, "ddMMyy") tambah = Microsoft.VisualBasic.Right(dr.GetString(0), 2) + 1 Tbnobooking.Text = "AN" + latestdate + Microsoft.VisualBasic.Right("00" & tambah, 2) End If End If 'Date service Dim sst = Microsoft.VisualBasic.Mid((dafnoantrean.Text), 3, 6) Dim sdt As Date = Date.ParseExact(sst, "ddMMyy", System.Globalization.DateTimeFormatInfo.InvariantInfo) Dim tgls As DateTime = sdt Tbdateservice.Text = Format(tgls, "dd/MM/yyyy")




Reply With Quote
