ts.analista
Member
Talk guys, good morning.
I'm not getting personal list data from a survey of DataGrid for my Registration form. Remembering that I'm doing a CRUD in my application. See codes
Event Code of DataGridView CellDoubleClick
I'm not getting personal list data from a survey of DataGrid for my Registration form. Remembering that I'm doing a CRUD in my application. See codes
VB.NET:
//CODE Class DALCustomers
'
''' <summary>
''' Obtained by searching the registry ID
''' </summary>
''' <param name="CustomerID"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function GetCustomers(ByVal CustomerID As Integer) As DataRow
_dlinha = Nothing
Try
_sqlcon = New SqlClient.SqlConnection(_conStr)
_sqlcon.Open()
_sqlcom = New SqlClient.SqlCommand()
With _sqlcom
.Connection = _sqlcon
.CommandType = CommandType.Text
.CommandText = "SELECT CustomerID, CustomerNome, CustomerAddress, CustomerPhone, CustomerEmail FROM Customers "
.Parameters.Add("@CustomerID", SqlDbType.Int).Value = PessoaID
End With
_sqldap = New SqlClient.SqlDataAdapter(_sqlcom)
_dset = New DataSet()
_sqldap.Fill(_dset)
If _dset.Tables(0).Rows.Count > 0 Then
_dline = _dset.Tables(0).Rows(0)
Else
_dline = Nothing
End If
_sqlcom.Parameters.Clear()
Catch ex As Exception
_dline = Nothing
Throw ex
Finally
releasesobjects()
End Try
Return _dline
End Function
//Code Class BLL Customers
Public Function GetCustomers(ByVal CustomersID As String) As DataRow
_dline = Nothing
Try
_obj = New DALCustomers()
_dlinha = _obj.GetCustomers(CustomersID)
Catch ex As Exception
Throw ex
Finally
_obj = Nothing
End Try
Return _dline
End Function
Event Code of DataGridView CellDoubleClick
VB.NET:
Private Sub DataGridView1_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim CustomersID As Integer = 0
Try
_objs = New BLLCustomers()
_dline = _objs.GetCustomer(DataGridView1.Rows(e.RowIndex).Cells(0).Value)
Dim frm As New FromCustomers()
frm.ShowDialog()
FrmCustomers.txtCustomerID.Text = _dline("CustomerID").ToString()
FrmCustomers.CustomerNome.Text = _dline("CustomerNome").ToString()
FrmCustomers.CustomerAddress.Text = _dline("CustomerAddress").ToString()
FrmCustomers.CustomerPhone.Text = _dline("CustomerPhone").ToString()
Catch ex As Exception
MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
_dline = Nothing
_objs = Nothing
End Try
End Sub