i have a little problem and actually i can't get out from his.. I have a column called 'Periodicidade' that gives me how many times must a thing get done.
What i want to do is a validation that it will count how many times exists one of them, and if one of them have the radiobutton fill, it will force the user to fill the others of the same type of periocidade, but in the moment he is counting the total gridview rows, and not the type of same periodicidade. My current code is:
Dim todos_items_periocidade_vazios As Boolean = True
Dim todos_items_periocidade_preenchidos As Boolean = False
Dim periocidade_validada As Boolean = False
'quantas linhas tem a grid
Dim n_linha_grid As Integer = GridView_Manutencao.Rows.Count
Dim periocidade_linha As String
Dim contador_preenchido As Integer = 0
Dim contador_linhas As Integer = 0
'para cada linha verificar
For Each row2 As GridViewRow In GridView_Manutencao.Rows
'percorrer tabela e validar a periocidade da linha encontrada
periocidade_linha = (CType(row2.FindControl("Label_Periodicidade"), Label).Text)
For Each row As GridViewRow In GridView_Manutencao.Rows
If ((CType(row.FindControl("Label_Periodicidade"), Label).Text) = periocidade_linha) Then
contador_linhas = contador_linhas + 1
periocidade_validada = True
If periocidade_validada = True Then
'testar se está vazio ou preenchido
If (CType(row.FindControl("RBList"), RadioButtonList).SelectedValue = "") Then
'percorrer a tabela e verificar se todos os itens estão vazios ou não
For Each row1 As GridViewRow In GridView_Manutencao.Rows
If ((CType(row1.FindControl("Label_Periodicidade"), Label).Text) = periocidade_linha) Then
If (CType(row1.FindControl("RBList"), RadioButtonList).SelectedValue = "") Then
todos_items_periocidade_vazios = True
Else
todos_items_periocidade_vazios = False
End If
End If
Next
Else
For Each row1 As GridViewRow In GridView_Manutencao.Rows
If ((CType(row1.FindControl("Label_Periodicidade"), Label).Text) = periocidade_linha) Then
If (CType(row1.FindControl("RBList"), RadioButtonList).SelectedValue <> "") Then
contador_preenchido = contador_preenchido + 1
todos_items_periocidade_preenchidos = True
Else
todos_items_periocidade_preenchidos = False
End If
End If
Next
End If
End If
End If
Next
valida_comentario()
If contador_preenchido = 0 Then
periocidade_validada = False
tudo_validado = False
ElseIf contador_preenchido < contador_linhas Then
periocidade_validada = False
tudo_validado = False
Else
If valida_comentario() = True Then
If ((todos_items_periocidade_vazios = True) And (todos_items_periocidade_preenchidos = True)) Then
periocidade_validada = True
tudo_validado = True
Lbl_Mensagem.Text = "Registo inserido com sucesso!"
ElseIf ((todos_items_periocidade_vazios = False) And (todos_items_periocidade_preenchidos = True)) Then
periocidade_validada = True
tudo_validado = True
Lbl_Mensagem.Text = "Registo inserido com sucesso!"
Else
periocidade_validada = False
tudo_validado = False
Lbl_Mensagem.Text = "Erro"
End If
Else
tudo_validado = False
periocidade_validada = False
Lbl_Mensagem.Text = "Erro"
End If
End If
Next
Return periocidade_validada
I got the answer, hope to be useful to all of you, thanks, here it goes:
Dim texto_periodicidade As String
Dim valor As String
Dim flag_validacao As Boolean = False
Dim contador_falso As Integer
contador_falso = 0
For Each linha As GridViewRow In GridView_Manutencao.Rows
texto_periodicidade = CType(linha.FindControl("Label_Periodicidade"), Label).Text
valor = CType(linha.FindControl("RBList"), RadioButtonList).SelectedValue
For Each row As GridViewRow In GridView_Manutencao.Rows
If (texto_periodicidade = CType(row.FindControl("Label_Periodicidade"), Label).Text) Then
If (valor = CType(row.FindControl("RBList"), RadioButtonList).SelectedValue) Then
flag_validacao = True
Else
contador_falso = contador_falso + 1
flag_validacao = False
End If
End If
Next row
Next linha
If contador_falso > 0 Then
Lbl_Mensagem.Text = "Complete os restantes valores da periocidade!"
contador_falso = 0
Return False
Else
If valida_comentario() = True Then
contador_falso = 0
Return True
End If
End If
Related
For the first time when I run my window application it will successfully run, but when I change the database column and binding then it gives me an error that specific data column is not there in database; also I am make null chart datasource but it gives an error. Please help.
Dim ctrArr As Integer
Dim serCnt As Integer
Dim series1 As New Series
Dim seriesFound As Boolean = False
For serCnt = 0 To ctrChart.Series.Count - 1
ctrChart.Series(0).ArgumentDataMember = ""
ctrChart.Series(0).ValueDataMembers(0) = ""
ctrChart.Series(0).Visible = False
Next
For ctrArr = 0 To gStrYAxisParamArray.Length - 1 'deptname'
For serCnt = 0 To ctrChart.Series.Count - 1
If UCase(Trim(gStrYAxisParamArray(ctrArr))) = UCase(ctrChart.Series(serCnt).Name.ToString) Then
ctrChart.Series(serCnt).ArgumentDataMember = ""
ctrChart.Series(serCnt).ValueDataMembers(0) = ""
ctrChart.Series(serCnt).Visible = True
ctrChart.Series(serCnt).ArgumentDataMember = gxAxis
ctrChart.Series(serCnt).ValueDataMembers.Item(0) = Trim(gStrYAxisParamArray(ctrArr))
seriesFound = True
Exit For
End If
Next
If seriesFound = False Then
series1 = New Series(Trim(gStrYAxisParamArray(ctrArr)).ToString, ViewType.Bar)
'ctrChart.Series.AddRange(New Series() {series1, series2})
ctrChart.Series.Add(series1)
series1.ArgumentDataMember = ""
series1.ValueDataMembers(0) = ""
series1.Visible = True
series1.ArgumentDataMember = gxAxis
series1.Label.Border.Visible = False
series1.ValueDataMembers(0) = Trim(gStrYAxisParamArray(ctrArr))
series1.LegendText = Trim(gStrYAxisParamArray(ctrArr).ToString)
End If
seriesFound = False
Next
cmbSeries.Items.Clear()
For ctrArr = 0 To ChrtStockDept.Series.Count - 1
With cmbSeries.Items
cmbSeries.Items.Add(ChrtStockDept.Series(ctrArr).Name.ToString)
End With
Next
I have a Datagridview connected to a dataset.The problem is that occasionally,when the data is refreshed,it is not displayed in the DGV.The code is:
Private Sub DisplayInDGV()
Dim SQLSet As String
Dim DASet As New OleDb.OleDbDataAdapter
Dim DSSet As New DataSet
SQLSet = "Select * From SetDisplayTable"
DASet = New OleDb.OleDbDataAdapter(SQLSet, Con)
DSSet.Clear()
DASet.Fill(DSSet, "DSSetHere")
With DGVSetView
.Refresh()
.AutoGenerateColumns = False
.DataSource = Nothing
.DataSource = DSSet.Tables(0)
.Update()
DGVSetView.Columns(i).DataPropertyName = DSSet.Tables(0).Columns(i).ToString
.Columns(0).DataPropertyName = DSSet.Tables(0).Columns(0).ToString
.Columns(2).DataPropertyName = DSSet.Tables(0).Columns(1).ToString
.Columns(3).DataPropertyName = DSSet.Tables(0).Columns(2).ToString
.Columns(4).DataPropertyName = DSSet.Tables(0).Columns(3).ToString
.Columns(5).DataPropertyName = DSSet.Tables(0).Columns(4).ToString
.Columns(6).DataPropertyName = DSSet.Tables(0).Columns(5).ToString
.Columns(7).DataPropertyName = DSSet.Tables(0).Columns(6).ToString
.Columns(8).DataPropertyName = DSSet.Tables(0).Columns(7).ToString
.Columns(9).DataPropertyName = DSSet.Tables(0).Columns(8).ToString
.Columns(10).DataPropertyName = DSSet.Tables(0).Columns(9).ToString
.Columns(11).DataPropertyName = DSSet.Tables(0).Columns(10).ToString 'Item Unique Code for Hot Edit
.Columns(14).DataPropertyName = DSSet.Tables(0).Columns(12).ToString
End With
'Updating Totals/::
For ItemRow As Integer = 0 To DGVSetView.Rows.Count - 1
If DGVSetView.Rows(ItemRow).Cells(14).Value = True Then
DGVSetView.Rows(ItemRow).Cells(12).Value = DGVSetView.Rows(ItemRow).Cells(10).Value
ElseIf DGVSetView.Rows(ItemRow).Cells(14).Value = False Then
DGVSetView.Rows(ItemRow).Cells(13).Value = DGVSetView.Rows(ItemRow).Cells(10).Value
End If
Next
'Updating School and general totals in DGV//:
Dim SchoolTotal, GeneralTotal As Decimal
For ColumnTotal As Integer = 0 To DGVSetView.Rows.Count - 1
SchoolTotal += DGVSetView.Rows(ColumnTotal).Cells(12).Value
GeneralTotal += DGVSetView.Rows(ColumnTotal).Cells(13).Value
Next
txtSchoolAmtFinal.Text = SchoolTotal
txtGeneralAmtFinal.Text = GeneralTotal
DGVSetView.Update()
'Get gross total of the DGV amount column//:
If DGVSetView.RowCount <> 0 Then
Dim GrossAmt As Decimal = 0
For Index As Integer = 0 To DGVSetView.RowCount - 1
' GrossAmt += Convert.ToDecimal(DataGridView1.Rows(Index).Cells(11).Value)
If Str(DGVSetView.Rows(Index).Cells(10).Value) = "Null" Or (DGVSetView.Rows(Index).Cells(10).Value) <= 0 Then
MsgBox("Item Number " & (DGVSetView.Rows(Index).Cells(10).Value) & " is either blank or 0", MsgBoxStyle.Exclamation, "Item Error")
Else
GrossAmt += Convert.ToDecimal(DGVSetView.Rows(Index).Cells(10).Value)
End If
Next
txtInsertGrossAmt.Text = GrossAmt ' - Val(DGVSetView.Text)
Call SetNetAmount()
End If
'Generate Serial//:
Dim X As Integer
Do While X < DGVSetView.Rows.Count
DGVSetView.Item(0, X).Value = X + 1
X = X + 1
Loop
'Disbaling editing in all columns except pending//:
With DGVSetView
.Columns(0).ReadOnly = True
.Columns(2).ReadOnly = True
.Columns(3).ReadOnly = True
.Columns(4).ReadOnly = True
.Columns(5).ReadOnly = True
.Columns(6).ReadOnly = True
.Columns(7).ReadOnly = True
.Columns(8).ReadOnly = True
.Columns(9).ReadOnly = True
.Columns(10).ReadOnly = True
End With
txtTotalItems.Text = DGVSetView.Rows.Count
For Each r As DataGridViewRow In DGVSetView.Rows
r.Cells(1).Value = True
Next r
End Sub
The problem is that occasionally,the DGV will not show any rows and displays a blank frame.At such instances.if I check in DGV.Rows.count
the result is 0 despite there being underlying data in the table.
Note that this happens randomly.At other times the DGV refreshed properly and also displays data correctly.
Also note that this DGV resides within a TabControl.
Further,when the DGV fails to display the data,the totals which I have calculated in the above sub procedure return zero value.As such the problem appears to lie somewhere in the rows not being inserted in the DGV.
Thank you.
Khalid.
//Edit;Code Updated:
#jmcilhinney I have updated my code as follows.However,the earlier problem of the DGV going blank occasionally persists.Also the update process has slowed down slightly.It seems I may be making a mistake in the location of placing the Suspend and ResumeBinding statements:
Private Sub SetPreview()
Dim SQLSet As String
Dim DASet As New OleDb.OleDbDataAdapter
Dim DSSet As New DataSet
SQLSet = "Select * From SetDisplayTable"
Dim DTDGV As New DataTable
Dim DGVBindingSource As New BindingSource
DASet = New OleDb.OleDbDataAdapter(SQLSet, Con)
DASet.Fill(DTDGV)
DGVBindingSource.DataSource = DTDGV
DGVBindingSource.ResumeBinding()
With DGVSetView
.AutoGenerateColumns = False
.DataSource = DGVBindingSource
.Columns(0).DataPropertyName = DTDGV.Columns(0).ToString
.Columns(2).DataPropertyName = DTDGV.Columns(1).ToString
.Columns(3).DataPropertyName = DTDGV.Columns(2).ToString
.Columns(4).DataPropertyName = DTDGV.Columns(3).ToString
.Columns(5).DataPropertyName = DTDGV.Columns(4).ToString
.Columns(6).DataPropertyName = DTDGV.Columns(5).ToString
.Columns(7).DataPropertyName = DTDGV.Columns(6).ToString
.Columns(8).DataPropertyName = DTDGV.Columns(7).ToString
.Columns(9).DataPropertyName = DTDGV.Columns(8).ToString
.Columns(10).DataPropertyName = DTDGV.Columns(9).ToString
.Columns(11).DataPropertyName = DTDGV.Columns(10).ToString 'Item Unique Code for Hot Edit
.Columns(14).DataPropertyName = DTDGV.Columns(12).ToString
End With
DGVBindingSource.SuspendBinding()
'Updating Totals/::
For ItemRow As Integer = 0 To DGVSetView.Rows.Count - 1
If DGVSetView.Rows(ItemRow).Cells(14).Value = True Then
DGVSetView.Rows(ItemRow).Cells(12).Value = DGVSetView.Rows(ItemRow).Cells(10).Value
ElseIf DGVSetView.Rows(ItemRow).Cells(14).Value = False Then
DGVSetView.Rows(ItemRow).Cells(13).Value = DGVSetView.Rows(ItemRow).Cells(10).Value
End If
Next
'Updating School and general totals in DGV//:
Dim SchoolTotal, GeneralTotal As Decimal
For ColumnTotal As Integer = 0 To DGVSetView.Rows.Count - 1
SchoolTotal += DGVSetView.Rows(ColumnTotal).Cells(12).Value
GeneralTotal += DGVSetView.Rows(ColumnTotal).Cells(13).Value
Next
txtSchoolAmtFinal.Text = SchoolTotal
txtGeneralAmtFinal.Text = GeneralTotal
DGVSetView.Update()
'Get gross total of the DGV amount column//:
If DGVSetView.RowCount <> 0 Then
Dim GrossAmt As Decimal = 0
For Index As Integer = 0 To DGVSetView.RowCount - 1
' GrossAmt += Convert.ToDecimal(DataGridView1.Rows(Index).Cells(11).Value)
If Str(DGVSetView.Rows(Index).Cells(10).Value) = "Null" Or (DGVSetView.Rows(Index).Cells(10).Value) <= 0 Then
MsgBox("Item Number " & (DGVSetView.Rows(Index).Cells(10).Value) & " is either blank or 0", MsgBoxStyle.Exclamation, "Item Error")
Else
GrossAmt += Convert.ToDecimal(DGVSetView.Rows(Index).Cells(10).Value)
End If
Next
txtInsertGrossAmt.Text = GrossAmt ' - Val(DGVSetView.Text)
Call SetNetAmount()
End If
'Disabling editing in all columns except pending//:
With DGVSetView
.Columns(0).ReadOnly = True
.Columns(2).ReadOnly = True
.Columns(3).ReadOnly = True
.Columns(4).ReadOnly = True
.Columns(5).ReadOnly = True
.Columns(6).ReadOnly = True
.Columns(7).ReadOnly = True
.Columns(8).ReadOnly = True
.Columns(9).ReadOnly = True
.Columns(10).ReadOnly = True
End With
txtTotalItems.Text = DGVSetView.Rows.Count
For Each r As DataGridViewRow In DGVSetView.Rows
r.Cells(1).Value = True
Next r
End Sub
Private Sub tunjukrekod()
Dim cn As MySqlConnection = New MySqlConnection()
cn.ConnectionString = ("server=localhost; userid=root; password=; database=payrollsystemdb;")
cn.Open()
cmd.Connection = cn
Try
If TextBoxEmployeeID.Text <> "" Then
dt.Clear()
cmd = New MySqlCommand("select * from employeedetail where EmployeeID='" & TextBoxEmployeeID.Text & "'", cn)
da = New MySqlDataAdapter(cmd)
da.Fill(dt)
TextBoxEmployeeID.Text = dt.Rows(0).Item(0)
TextBoxEmployeeName.Text = dt.Rows(0).Item(1)
TextBoxChineseName.Text = dt.Rows(0).Item(2)
If dt.Rows(0).Item(3) = "Active" Then
RadioButtonActiveStatus.Checked = True
ElseIf dt.Rows(0).Item(3) = "Inactive" Then
RadioButtonInactiveStatus.Checked = True
End If
TextBoxbranchID.Text = dt.Rows(0).Item(4)
TextBoxAccessLevel.Text = dt.Rows(0).Item(5)
RichTextBoxAddress.Text = dt.Rows(0).Item(6)
TextBoxTel1.Text = dt.Rows(0).Item(7)
TextBoxTel2.Text = dt.Rows(0).Item(8)
TextBoxMobile.Text = dt.Rows(0).Item(9)
TextBoxEmail.Text = dt.Rows(0).Item(10)
TextBoxICNew.Text = dt.Rows(0).Item(11)
TextBoxICOld.Text = dt.Rows(0).Item(12)
TextBoxPassport.Text = dt.Rows(0).Item(13)
DateTimePickerpassportexpire.Value = dt.Rows(0).Item(14)
TextBoxPermit.Text = dt.Rows(0).Item(15)
DateTimePickerpermitexpire.Value = dt.Rows(0).Item(16)
DateTimePickerBirthDate.Value = dt.Rows(0).Item(17)
TextBoxreligionPD.Text = dt.Rows(0).Item(18)
TextBoxAge.Text = dt.Rows(0).Item(19)
TextBoxracePD.Text = dt.Rows(0).Item(20)
TextBoxcitizenshipPD.Text = dt.Rows(0).Item(21)
TextBoxsexPD.Text = dt.Rows(0).Item(22)
TextBoxmaritalPD.Text = dt.Rows(0).Item(23)
If dt.Rows(0).Item(24) = "yes" Then
RadioButtonyesC.Checked = True
ElseIf dt.Rows(0).Item(24) = "No" Then
RadioButtonnoC.Checked = True
End If
If dt.Rows(0).Item(25) = "yes" Then
RadioButtonYesEOT.Checked = True
ElseIf dt.Rows(0).Item(25) = "No" Then
RadioButtonnoEOT.Checked = True
End If
TextBoxNameSpouse.Text = dt.Rows(0).Item(26)
TextBoxICNewSpouse.Text = dt.Rows(0).Item(27)
TextBoxICOldSpouse.Text = dt.Rows(0).Item(28)
RichTextBoxAddressSpouse.Text = dt.Rows(0).Item(29)
TextBoxIncomeSpouse.Text = dt.Rows(0).Item(30)
TextBoxBranchSpouse.Text = dt.Rows(0).Item(31)
If dt.Rows(0).Item(32) = "yes" Then
RadioButtonyesworking.Checked = True
ElseIf dt.Rows(0).Item(32) = "No" Then
RadioButtonNoworking.Checked = True
End If
TextBoxChildrenSpouse.Text = dt.Rows(0).Item(33)
If dt.Rows(0).Item(34) = "Auto" Then
RadioButtonAutoAuMaSpouse.Checked = True
ElseIf dt.Rows(0).Item(34) = "Manual" Then
RadioButtonManualAuMaSpouse.Checked = True
End If
TextBoxpositionED.Text = dt.Rows(0).Item(35)
TextBoxdepartmentED.Text = dt.Rows(0).Item(36)
TextBoxdivisionED.Text = dt.Rows(0).Item(37)
TextBoxsectionED.Text = dt.Rows(0).Item(38)
TextBoxlocationED.Text = dt.Rows(0).Item(39)
TextBoxgradeED.Text = dt.Rows(0).Item(40)
TextBoxcategoryED.Text = dt.Rows(0).Item(41)
TextBoxworkgroupED.Text = dt.Rows(0).Item(42)
TextBoxformularateED.Text = dt.Rows(0).Item(43)
DateTimePickerjoindateED.Value = dt.Rows(0).Item(44)
DateTimePickerconfirmdateED.Value = dt.Rows(0).Item(45)
DateTimePickerresigneddateED.Value = dt.Rows(0).Item(46)
TextBoxacbankED.Text = dt.Rows(0).Item(47)
If dt.Rows(0).Item(48) = "IC New" Then
RadioButtonICNewACBank.Checked = True
ElseIf dt.Rows(0).Item(48) = "IC Old" Then
RadioButtonICOldACBank.Checked = True
ElseIf dt.Rows(0).Item(48) = "Passport No" Then
RadioButtonPassportNoACBank.Checked = True
ElseIf dt.Rows(0).Item(48) = "Permit No" Then
RadioButtonPermitNoACBank.Checked = True
End If
TextBoxACNoED.Text = dt.Rows(0).Item(49)
TextBoxHRDFundED.Text = dt.Rows(0).Item(50)
If dt.Rows(0).Item(51) = "IC New" Then
RadioButtonICNewHRDFund.Checked = True
ElseIf dt.Rows(0).Item(51) = "IC Old" Then
RadioButtonICOldHRDFund.Checked = True
ElseIf dt.Rows(0).Item(51) = "Passport No" Then
RadioButtonPassportNoHRDFund.Checked = True
ElseIf dt.Rows(0).Item(51) = "Permit No" Then
RadioButtonPermitNoHRDFund.Checked = True
End If
TextBoxProbationED.Text = dt.Rows(0).Item(52)
TextBoxSalaryED.Text = dt.Rows(0).Item(53)
TextBoxNoticeResignED.Text = dt.Rows(0).Item(54)
TextBoxEmployerNamePE.Text = dt.Rows(0).Item(55)
RichTextBoxAddressPE.Text = dt.Rows(0).Item(56)
TextBoxTelNo1PE.Text = dt.Rows(0).Item(57)
TextBoxTelNo2PE.Text = dt.Rows(0).Item(58)
TextBoxFaxPE.Text = dt.Rows(0).Item(59)
TextBoxPICPE.Text = dt.Rows(0).Item(60)
TextBoxPositionPE.Text = dt.Rows(0).Item(61)
DateTimePickerdatejoinPE.Value = dt.Rows(0).Item(62)
TextBoxSalaryPE.Text = dt.Rows(0).Item(63)
DateTimePickerdateresignPE.Value = dt.Rows(0).Item(64)
TextBoxReasonPE.Text = dt.Rows(0).Item(65)
TextBoxEPFNoGD.Text = dt.Rows(0).Item(66)
If dt.Rows(0).Item(67) = "IC New" Then
RadioButtonICNewICTypeEPFGD.Checked = True
ElseIf dt.Rows(0).Item(67) = "IC Old" Then
RadioButtonICOldICTypeEPFGD.Checked = True
ElseIf dt.Rows(0).Item(67) = "Passport No" Then
RadioButtonPassportNoICTypeEPFGD.Checked = True
ElseIf dt.Rows(0).Item(67) = "Permit No" Then
RadioButtonPermitNoICTypeEPFGD.Checked = True
End If
TextBoxInitialGD.Text = dt.Rows(0).Item(68)
TextBoxNKGD.Text = dt.Rows(0).Item(69)
TextBoxepftableGD.Text = dt.Rows(0).Item(70)
TextBoxkwspGD.Text = dt.Rows(0).Item(71)
TextBoxIncomeTaxGD.Text = dt.Rows(0).Item(72)
If dt.Rows(0).Item(73) = "IC New" Then
RadioButtonICNewICTypeIncomeGD.Checked = True
ElseIf dt.Rows(0).Item(73) = "IC Old" Then
RadioButtonICOldICTypeIncomeGD.Checked = True
ElseIf dt.Rows(0).Item(73) = "Passport No" Then
RadioButtonPassportNoICTypeIncomeGD.Checked = True
ElseIf dt.Rows(0).Item(73) = "Permit No" Then
RadioButtonPermitNoICTypeIncomeGD.Checked = True
End If
TextBoxbranchincomeGD.Text = dt.Rows(0).Item(74)
TextBoxpcbcodeGD.Text = dt.Rows(0).Item(75)
TextBoxincometaxdeptGD.Text = dt.Rows(0).Item(76)
TextBoxSocsoNoGD.Text = dt.Rows(0).Item(77)
If dt.Rows(0).Item(78) = "IC New" Then
RadioButtonICNewICTypeSocsoGD.Checked = True
ElseIf dt.Rows(0).Item(78) = "IC Old" Then
RadioButtonICOldICTypeSocsoGD.Checked = True
ElseIf dt.Rows(0).Item(78) = "Passport No" Then
RadioButtonPassportNoICTypeSocsoGD.Checked = True
ElseIf dt.Rows(0).Item(78) = "Permit No" Then
RadioButtonPermitNoICTypeSocsoGD.Checked = True
End If
TextBoxBranchSocsoGD.Text = dt.Rows(0).Item(79)
TextBoxSocsoOfficeGD.Text = dt.Rows(0).Item(80)
TextBoxsocsotypeGD.Text = dt.Rows(0).Item(81)
TextBoxboardofsocsoGD.Text = dt.Rows(0).Item(82)
TextBoxTHAccGD.Text = dt.Rows(0).Item(83)
If dt.Rows(0).Item(84) = "IC New" Then
RadioButtonICNewICTypeTHGD.Checked = True
ElseIf dt.Rows(0).Item(84) = "IC Old" Then
RadioButtonICOldICTypeTHGD.Checked = True
ElseIf dt.Rows(0).Item(84) = "Passport No" Then
RadioButtonPassportNoICTypeTHGD.Checked = True
ElseIf dt.Rows(0).Item(84) = "Permit No" Then
RadioButtonPermitNoICTypeTHGD.Checked = True
End If
TextBoxthcGD.Text = dt.Rows(0).Item(85)
'Dim ms As New MemoryStream(changephoto(CInt(khaiEDForm2.DataGridViewfind.SelectedCells(0).Value)))
'PictureBox1.Image = Image.FromStream(ms)
cmd = New MySqlCommand("select * from salarydetail", cn)
da.SelectCommand = cmd
da.Fill(dtsalary)
End If
Catch ex As Exception
'TextBoxEmployeeName.Focus()
End Try
End Sub
'Function changephoto(ByVal photo As Integer) As Byte()
' Dim cn As MySqlConnection = New MySqlConnection()
' cn.ConnectionString = ("server=localhost; userid=root; password=; database=payrollsystemdb;")
' cn.Open()
' '.CommandText = System.Data.CommandType.Text
' With cmd
' .Connection = cn
' .CommandText = "SELECT Imageblob FROM employeedetail WHERE EmployeeID=" & khaiEDForm2.DataGridViewfind.SelectedRows(0).Cells(0).Value
' End With
' Dim myphoto() As Byte = CType(cmd.ExecuteScalar(), Byte())
' cn.Close()
' Return myphoto
'End Function
Private Sub TextBoxEmployeeID_LostFocus(sender As Object, e As EventArgs) Handles TextBoxEmployeeID.LostFocus
If TextBoxEmployeeID.Text = "" Then
TextBoxEmployeeID.Select()
Else
tunjukrekod()
tunjukdgv()
End If
addrow()
End Sub
How I Can Rewrite the code? because the code cam retrive picture only when from form2 to form1.
I used visual studio express 2014, MySQL Database using PHPMYADMIN, MySQLConnection.
ok . i got the solution ! finally !
dr = cmd.ExecuteReader()
If (dr.HasRows) Then
While (dr.Read())
With Me
'fetch image from database
Dim imgBytes() As Byte = dr("Imageblob") 'image field
Dim image As Bitmap = New Bitmap(New System.IO.MemoryStream(imgBytes)) 'convert binary to image
.PictureBox1.Image = image 'show picture to picture box
End With
End While
Else
MsgBox("No records Found!")
End If
I am trying to add a property called NumDBsToDisplay that gives the option of selecting between 0 and 3 databases to be displayed on my custom control. I can't get the property to show up in the designer, am I missing something here?
Here's the code:
Public Property NumDBsToDisplay(ByVal i As Integer) As Integer
Get
Dim count As Integer = 0
If cboPridb.Visible = True Then
count += 1
End If
If cboSecdb.Visible = True Then
count += 1
End If
If cboTridb.Visible = True Then
count += 1
End If
Return count
End Get
Set(ByVal value As Integer)
If value = 0 Then
cboPridb.Visible = False
cboSecdb.Visible = False
cboTridb.Visible = False
ElseIf value = 1 Then
lblPridB.Text = "Primary Database"
cboPridb.Visible = True
cboSecdb.Visible = False
cboTridb.Visible = False
ElseIf value = 2 Then
lblPridB.Text = "Primary Database"
lblSecDB.Text = "Secondary Database"
cboPridb.Visible = True
cboSecdb.Visible = True
cboTridb.Visible = False
Else
lblPridB.Text = "Primary Database"
lblSecDB.Width = 131
lblSecDB.Text = "Secondary Database"
lblTriDB.Text = "Tertiary Database"
cboPridb.Visible = True
cboSecdb.Visible = True
cboTridb.Visible = True
End If
End Set
End Property
Thank you for the help.
I need your help. I would like to understand why when running ScriptManager.RegisterClientScriptBlock the controls of my page disappear and reappear only after confirmation of Ok?
Protected Sub ddlDeckFittingCategory_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddlDeckFittingCategory.SelectedIndexChanged
If txbNumberofColumns.Text = "" Or Me.txbShellDiameter.Text = "" Then
ScriptManager.RegisterClientScriptBlock(Me.Page, Page.GetType, "alert", "alert('Informe o valor do Diâmetro do Casco (m)!');", True)
ddlDeckFittingCategory.SelectedValue = -1
Else
If Request("TipoTela") = 1 Then
If ddlDeckFittingCategory.SelectedValue = "Typical" Then
objFinttings_temp.IncluirFittingsTempTQIFLTTipico(Session("cod_usuario_usu"))
'objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(CType(txbNumberofColumns.Text, Double))
objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(txbNumberofColumns.Text)
tbFittingsFonte.Visible = True
tbFittingsFonte.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
Dim dvConsultarCodFonteEmFittingsTempPorUsuario As DataView = objFinttings_temp.ConsultarCodFonteEmFittingsTempPorUsuario(Session("cod_usuario_usu"))
Session("cod_fonte_fon") = dvConsultarCodFonteEmFittingsTempPorUsuario.Table.Rows(0)("cod_fonte_fon")
Session("ddlDeckFittingCategory") = ddlDeckFittingCategory.SelectedValue
Else
objFinttings_temp.IncluirFittingsTQIFLTDetalhado(0)
tbFittings.Visible = True
tbFittings.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
End If
GrvFittingsFonte.DataBind()
Else
If ddlDeckFittingCategory.SelectedValue = "Typical" Then
objFinttings_temp.IncluirFittingsTempTQIFLTTipico(Session("cod_usuario_usu"))
'objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(CType(txbNumberofColumns.Text, Double))
objFinttings_temp.AtualizaFittingsTempColumnWell_24_in_Diam(txbNumberofColumns.Text)
tbFittingsFonte.Visible = True
tbFittingsFonte.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
Else
objFinttings_temp.IncluirFittingsTQIFLTDetalhado(Session("cod_fonte_fon"))
tbFittings.Visible = True
tbFittings.HeaderText = ""
TcPrincipal.ActiveTabIndex = 6
End If
GrvFittingsFonte.DataBind()
If ddlSelfSupportingRoof.SelectedValue = 1 Or ddlSelfSupportingRoof.SelectedValue = "-1" Then
txbNumberofColumns.Enabled = False
rvNumColuna.Visible = False
ddlEffectiveColumnDiameter.Enabled = False
rvDiametroEfetivoColuna.Visible = False
Else
txbNumberofColumns.Enabled = True
rvNumColuna.Visible = True
ddlEffectiveColumnDiameter.Enabled = True
rvDiametroEfetivoColuna.Visible = True
End If
End If
End If
End Sub
enter code here
use Page.ClientScript.RegisterStartupScript()
it will run after the page loads.