Centar za edukaciju-BiH



#1 20.12.2018 14:31
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:hidden field - visible false
Hteo bih da sakrijem polje ali da mi taj podatak sačuva u db.

prim. kada se logujem, iz baze dobijem id. Kada je polje visible true sve je ok međutim kada promenim na false jer ne želim da se vidi taj podatak imam problem. Ne upisuje id u tabeli.

Kako da rešim taj problem?
Isto i kada želim da upiÅ¡em IP adresu. Ne želim da se prikaže eli želim da je sačuvam u tabeli.
↑  ↓

#2 20.12.2018 18:46
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: hidden field - visible false
Napravi Public variabla u neki modul i tako neces imati problema sa unos podatke

eve vaka e kaj mene
PreuzmiIzvorni kôd (vbnet):
  1.  Public ID_Korisnik As Integer               ' Aktiven korisnik
  2.         Public ID_Magacin As Integer                ' Aktiven Magacin
  3.         Public ID_Kasa As Integer                   ' Se koristi samo ako ima i kasa
↑  ↓

#3 21.12.2018 09:33
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: hidden field - visible false
Uradio sam tako ali i dalje mi traži podatak ID_Korisnik. Cannot insert the value NULL into column...
Polje ID_Korisnik je obavezno. Kako da prosledim taj podatak u insert?
↑  ↓

#4 21.12.2018 10:09
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,642


Predmet:Re: hidden field - visible false
Nije mi bas jasno o cemu se radi, pa bi bilo dobro da okais primjer.
Mislim da nije uzrok visible.
Upis u bazu mozes napraviti putem sql-a i nemoras imati polja ako imas podatke u Public variablama.
Naj bolje je da zakacis primjer.
Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#5 21.12.2018 10:19
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: hidden field - visible false
evo koda
problem mi je sa poljem txt.KCID koje želim da bude visible false

Public Class PodaciSaRelacije

Private Sub T_KONTROLA_DFBindingNavigatorSaveItem_Click(sender
As Object, e As EventArgs) Handles T_KONTROLA_DFBindingNavigatorSaveItem.Click
Try
Me.Validate()
Me.T_KONTROLA_DFBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.KontrolaPodataka_DataSet)
Me.T_KONTROLA_CFTableAdapter.Update(Me.KontrolaPodataka_DataSet)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub

Private Sub PodaciSaRelacije_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Me.T_VOZACITableAdapter.Fill(Me.KontrolaPodataka_DataSet.T_VOZACI)
Me.T_KONTROLA_CFTableAdapter.Fill(Me.KontrolaPodataka_DataSet.T_KONTROLA_CF)
Me.T_KCTableAdapter.Fill(Me.KontrolaPodataka_DataSet.T_KC)
Me.T_KONTROLA_DFTableAdapter.Fill(Me.KontrolaPodataka_DataSet.T_KONTROLA_DF)

KeyPreview = True

Dim myCulture As System.Globalization.CultureInfo = Globalization.CultureInfo.CurrentCulture

Dim dayName As String = myCulture.DateTimeFormat.GetDayName(DateTime.Parse(KNT_DF_DATUMTextBox.Text).DayOfWeek)
TXT_Dan.Text = dayName

txt_Ime.Text = Login.Ime
txt_KCID.Text = KC_ID

Dim strHostName As String
Dim strIPAddress As String

strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()

txt_CompName.Text = strHostName
txt_IP.Text = strIPAddress

End Sub

Private Sub CustomDataGridView1_CellDoubleClick_1(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellDoubleClick
If CustomDataGridView1.Columns(e.ColumnIndex).HeaderText = "KNT_CF_VOZAC_ID" Then
Vozaci.Show()
ElseIf CustomDataGridView1.Columns(e.ColumnIndex).HeaderText = "KNT_DRUGI_VZC_ID" Then
Vozaci.Show()
ElseIf CustomDataGridView1.Columns(e.ColumnIndex).HeaderText = "KNT_CF_RELACIJE_ID" Then
Relacije.Show()
ElseIf CustomDataGridView1.Columns(e.ColumnIndex).HeaderText = "KNT_VOZILO_ID" Then
Vozila.Show()
End If
End Sub

Private Sub PodaciSaRelacije_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Enter Then
e.Handled = True
e.SuppressKeyPress = True
SendKeys.Send("{TAB}")
End If
End Sub

Private Sub CustomDataGridView1_CellEndEdit(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellEndEdit
Dim Vozac, Relacija, Vozilo As New KontrolaPodataka_DataSetTableAdapters.T_KONTROLA_CFTableAdapter
Dim KCID = Login.KC_ID

If e.ColumnIndex = 0 Then

For i As Integer = 0 To Me.CustomDataGridView1.RowCount - 1
For j As Integer = i + 1 To Me.CustomDataGridView1.RowCount - 1
If CustomDataGridView1.Rows(i).Cells(0).Value = CustomDataGridView1.Rows(j).Cells(0).Value Then
MessageBox.Show("dupli unos " & CustomDataGridView1.Rows(i).Cells(0).Value)
SendKeys.Send("{left}")
SendKeys.Send("{left}")

End If
Next

Next

If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then

If Not IsNothing(Vozac.VozacImePrezime(CInt(Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)), KCID)) Then

CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = Vozac.VozacImePrezime(CInt(Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)), KCID)

CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 4).Value = "Redovna posada"

Else

If Not String.IsNullOrEmpty(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Then
If Not String.IsNullOrEmpty(Trim(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString())) Then

MessageBox.Show("PogreÅ¡an ID vozača ili vozač ne pripada odabranom KC")
SendKeys.Send("{left}")
SendKeys.Send("{left}")

End If
End If

End If

End If
End If

'If e.ColumnIndex = 2 Then
'
'
' 'On Error Resume Next
' If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then
'
'
' CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = Vozac.VozacImePrezime(CInt(Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)), KCID)
'
' CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 2).Value = "Dupla posada"
'
' End If
'
'End If
'
'
'
'' On Error Resume Next
'If e.ColumnIndex = 5 Then
'
' If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then
'
' CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = Relacija.RelacijaNaziv(CInt(Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)))
'
' End If
'
'End If
'
'If e.ColumnIndex = 7 Then
'
' If Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) > 0 Then
'
' CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = Vozilo.VoziloRegistracija(CInt(Val(CustomDataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)))
'
' End If
'
'End If

End Sub

Private Function CleanInputNumber(ByVal str As String) As String
Return System.Text.RegularExpressions.Regex.Replace(str, "91", "1")
End Function

Private Sub KNT_DF_DATUMTextBox_Leave(sender As Object, e As EventArgs) Handles KNT_DF_DATUMTextBox.Leave

Dim myCulture As System.Globalization.CultureInfo = Globalization.CultureInfo.CurrentCulture
Dim dayOfWeek As DayOfWeek = DateTime.Parse(KNT_DF_DATUMTextBox.Text).DayOfWeek
Dim dayName As String = myCulture.DateTimeFormat.GetDayName(dayOfWeek)
TXT_Dan.Text = dayName
txt_KCID.Text = Login.KC_ID
End Sub

Private Sub KNT_DF_IDTextBox_TextChanged(sender As Object, e As EventArgs) Handles KNT_DF_IDTextBox.TextChanged
Dim myCulture As System.Globalization.CultureInfo = Globalization.CultureInfo.CurrentCulture
Dim dayOfWeek As DayOfWeek = DateTime.Parse(KNT_DF_DATUMTextBox.Text).DayOfWeek
Dim dayName As String = myCulture.DateTimeFormat.GetDayName(dayOfWeek)
TXT_Dan.Text = dayName
End Sub

Private Sub CustomDataGridView1_CellLeave(sender As Object, e As DataGridViewCellEventArgs) Handles CustomDataGridView1.CellLeave

End Sub

Private Sub CustomDataGridView1_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles CustomDataGridView1.CellValidating
'If CustomDataGridView1.CurrentRow.Cells("KNT_CF_VOZAC_ID").IsInEditMode Then
'
' Dim c As Control = CustomDataGridView1.EditingControl
'
' Select Case CustomDataGridView1.Columns(e.ColumnIndex).Name
'
' Case "KNT_CF_VOZAC_ID"
' c.Text = CleanInputNumber(c.Text)
'
' 'Case "yColumn"
' ' c.Text = CleanInputAlphabet(c.Text)
'
' End Select
'End If

'If CustomDataGridView1.Columns(e.ColumnIndex).DataPropertyName = "KNT_CF_VOZAC_ID" AndAlso e.FormattedValue.ToString() <> CustomDataGridView1(e.ColumnIndex, e.RowIndex).Value.ToString() Then
'
' Dim dt As DataTable = CType(CustomDataGridView1.DataSource, DataTable)
'
' Dim rows As DataRow() = dt.Select("KNT_CF_VOZAC_ID = " & e.FormattedValue)
'
' If rows.Length > 0 Then
'
' MessageBox.Show("This value is already used.")
'
' e.Cancel = True
'
' End If
'
'End If

'If e.Column.Name = "KNT_CF_VOZAC_ID" AndAlso e.Row.Cells("Column1").Value = "Age" AndAlso IsNumeric() = False Then
' 'we will prevent the user from leaving the cell unless s/he entered numeric value for this cell
' e.Cancel = True
'End If

End Sub

End Class
↑  ↓

#6 21.12.2018 10:20
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: hidden field - visible false
Mislim, ja sam sakrio polje kcid iza datuma ali mislim da ima neko "lepše" rešenje.
↑  ↓

#7 21.12.2018 10:57
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: hidden field - visible false
Vec sam ti odgovori napravi modul i u modulu stavi public variabla i to je resejne tvog problema
↑  ↓

#8 21.12.2018 12:31
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: hidden field - visible false
negde grešim Disappointed

***login forma***
Private Sub btn_PrijaviSe_Click(sender As Object, e As EventArgs) Handles btn_PrijaviSe.Click
If con.State = ConnectionState.Open Then con.Close()

con.Open()

If txt_KorisnickoIme.Text = "" Then
MsgBox("Unesite korisničko ime..", MsgBoxStyle.Critical)

ElseIf txt_Lozinka.Text = "" Then
MsgBox("Unesite lozinku..", MsgBoxStyle.Critical)

Else
Dim query As String
query = "select * from T_Users where KorisnickoIme= '" + txt_KorisnickoIme.Text + "' and Password= '" + txt_Lozinka.Text + "'"
cmd = New SqlCommand(query, con)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
Dim a As Integer
a = ds.Tables(0).Rows.Count
If a = 0 Then
MsgBox("NeuspeÅ¡no prijavljivanje! PogreÅ¡no korisničko ime i/ili lozinka. PokuÅ¡ajte ponovo.", MsgBoxStyle.Critical)
Else
Module1.KC_ID = ds.Tables(0).Rows(0).Item(14)
KorisnikID = ds.Tables(0).Rows(0).Item(0)
PodaciSaRelacije.Show()
Me.Hide()

End If
End If
End Sub
***

***Modul***

Module Module1
Public KC_ID As Integer

End Module

***forma za upis posle datuma***

Private Sub KNT_DF_DATUMTextBox_Leave(sender As Object, e As EventArgs) Handles KNT_DF_DATUMTextBox.Leave

Me.txt_KCID.Text = Module1.KC_ID

End Sub
↑  ↓

#9 21.12.2018 12:33
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: hidden field - visible false
polje txt_KCID - visible - false

kada promenim da je true onda radi ok
Ovaj post je ureden 1 puta. Posljednja izmjena 21.12.2018 12:34 od strane xl_kid. ↑  ↓

#10 21.12.2018 18:14
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: hidden field - visible false
Samo ova ti tereba bez module
KC_ID = ds.Tables(0).Rows(0).Item(14)
Msgbox KC_ID ' Da vidis jeli radi \
↑  ↓

Stranice (3):1,2,3


Sva vremena su GMT +01:00. Trenutno vrijeme: 1: 33 am.