Public Class impressoraspredefenidas Public maquinas As String Private Sub impressoraspredefenidas_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'UcctieDataSet.impressoras' table. You can move, or remove it, as needed. If Form1.frm = False Then maquinas = Form1.Label30.Text Else maquinas = Detalhes_da_Maquina.Label6.Text End If Me.ImpressorasTableAdapter.impressora(Me.UcctieDataSet.impressoras, maquinas) Label2.Text = "Impressoras Associadas a Maquina " + maquinas If Me.UcctieDataSet.impressoras.Rows.Count > 0 Then Me.CheckedListBox1.DataSource = Me.UcctieDataSet.impressoras Me.CheckedListBox1.DisplayMember = "Impressora" Me.CheckedListBox1.ValueMember = "impressora" Else Me.CheckedListBox1.Items.Add("Sem Impressoras Associadas a Maquina " + maquinas) End If ComboBox1.SelectedIndex = 0 End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.Close() End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Me.ImpressorasTableAdapter.impressora(Me.UcctieDataSet.impressoras, maquinas) Dim cnt As Integer cnt = Me.UcctieDataSet.impressoras.Count If cnt <= 0 Then MsgBox("Não existem impressoras associadas a esta Maquina") Me.Close() End If If CheckedListBox1.CheckedItems.Count = 1 Then MsgBox("Não existem Impressoras selecionadas para remoção") End If Dim sb As New System.Text.StringBuilder For Each item In CheckedListBox1.CheckedItems sb.Append(item) sb.Append(" ") Next MessageBox.Show(sb.ToString()) 'the code is not complete, because of the problem above End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim texto As String texto = TextBox1.Text + ComboBox1.Text If texto = "" Then MsgBox("Por favor introduza marca/modelo da impressora e tipo de ligação") Else Try UcctieDataSet.impressoras.NewimpressorasRow() Me.ImpressorasTableAdapter.Insert(texto, maquinas) Me.UcctieDataSet.impressoras.AcceptChanges() Me.ImpressorasTableAdapter.Update(Me.UcctieDataSet.impressoras) MsgBox("Impressora da Maquina " + maquinas + " adicionada com êxito") Me.Close() Catch ex As Exception MsgBox("Erro ao associar a impressora a maquina " + maquinas + ", por favor Corrija", MsgBoxStyle.Critical) End Try End If End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub CheckedListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CheckedListBox1.SelectedIndexChanged End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)