clase donador
DESCRIPTION
vb.net programacion orientada a objetosTRANSCRIPT
![Page 1: Clase Donador](https://reader035.vdocuments.site/reader035/viewer/2022072008/55cf8f9c550346703b9dfdb5/html5/thumbnails/1.jpg)
Clase donador Public Sub AgregarDonador() Using cn As SqlConnection = CreateConnection() Dim cmd As New SqlCommand Try With cmd .Connection = cn .CommandType = CommandType.StoredProcedure .CommandText = "sp_AgregarDonador" .Parameters.Add("@RazonSocial", SqlDbType.VarChar).Value = Me.RazonSocial .Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Me.Nombre .Parameters.Add("@Apellido", SqlDbType.VarChar).Value = Me.Apellido .Parameters.Add("@Calle", SqlDbType.VarChar).Value = Me.Calle .Parameters.Add("@Nro", SqlDbType.Int).Value = Me.Nro .Parameters.Add("@BarrioID", SqlDbType.Int).Value = Me.BarrioID .Parameters.Add("@Telefono", SqlDbType.VarChar).Value = Me.Telefono .Parameters.Add("@EMail", SqlDbType.VarChar).Value = Me.Email cn.Open() .ExecuteNonQuery() End With Catch ex As Exception MsgBox(ex.Message.ToString()) Finally cn.Close() End Try
End Using End Sub
![Page 2: Clase Donador](https://reader035.vdocuments.site/reader035/viewer/2022072008/55cf8f9c550346703b9dfdb5/html5/thumbnails/2.jpg)
Botón guardar:
Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click If txtRznSocial.Text = "" Or txtNombre.Text = "" Or txtApellido.Text = "" _ Or txtCalle.Text = "" Or txtNro.Text = "" Or txtTelDonador.Text = "" _ Or txtMail.Text = "" Or cboBarrio.SelectedIndex = -1 Then MessageBoxEx.Show("Debe completar los datos del Donador", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub Else Dim oDonador As New Donador oDonador.RazonSocial = txtRznSocial.Text oDonador.Nombre = txtNombre.Text oDonador.Apellido = txtApellido.Text oDonador.Calle = txtCalle.Text oDonador.Nro = txtNro.Text oDonador.BarrioID = cboBarrio.SelectedValue oDonador.Telefono = txtTelDonador.Text oDonador.Email = txtMail.Text Try oDonador.AgregarDonador() MessageBoxEx.Show("Donador agregado correctamente!", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information) Formularios.LimpiarCajas(GroupBox2) cboBarrio.SelectedIndex = -1 GroupBox2.Enabled = False GroupBox4.Enabled = False Catch ex As Exception MessageBoxEx.Show(ex.Message.ToString()) End Try
End If End Sub