Академический Документы
Профессиональный Документы
Культура Документы
EventArgs) Handles Me.Activated frmActivo = Me End Sub Public Function Guardar() As Integer Try If conectar() = True Then Dim sql As String = "select cc from empleado where cc='" & cc.Te xt & "';" comando = New MySqlCommand(sql, conexion) comando.ExecuteNonQuery() leer = comando.ExecuteReader If leer.Read Then MsgBox("El empleado con la cedula " & cc.Text & " ya se encu entra registrado.", MsgBoxStyle.Information) cc.Clear() cc.Focus() Exit Function End If conexion.Close() End If If Guarda = 1 Then If conectar() = True And cc.Text <> "" Then Dim sql As String = "insert into empleado(cc,nombre,direccio n,telefono,cargo,sueldo,f_nacimiento,f_contrato,sexo,contrasea) values('" & txtcc .Text & "','" & txtnom.Text & "','" & txtdir.Text & "','" & txttel.Text & "','" & txtcargo.Text & "','" & txtsueldo.Text & "','" & nac.Text & "','" & con.Text & "','" & txtsex.Text & "','" & txtcontra.Text & "');" comando = New MySqlCommand(sql, conexion) comando.ExecuteNonQuery() conexion.Close() MessageBox.Show("Datos almcenados en la base de datos", "Sis tema", MessageBoxButtons.OK, MessageBoxIcon.Information) Else MsgBox("No ha Ingresado Todos los datos", MsgBoxStyle.Critic al) MsgBox(cc.Text, MsgBoxStyle.Critical) End If End If Catch ex As Exception MessageBox.Show(ex.Message, "Sistema", MessageBoxButtons.OK, Message BoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceN otification) conexion.Close() End Try End Function Private Sub RegistroEmpleado_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 'esta variable controla que no se abra mas de una ventana en el contened or esta declarada globalmente ventana = False Guarda = 0 End Sub
Private Sub RegistroEmpleado_Load(ByVal sender As Object, ByVal e As System. EventArgs) Handles Me.Load sex.DropDownStyle = ComboBoxStyle.DropDownList cargo.DropDownStyle = ComboBoxStyle.DropDownList Label11.Text = sesion dtp() Guarda = 1 cargo.ResetText() cargo.Items.Add("Administrador") cargo.Items.Add("Vendedor") cargo.DropDownStyle = ComboBoxStyle.DropDownList sex.ResetText() sex.Items.Add("M") sex.Items.Add("F") sex.DropDownStyle = ComboBoxStyle.DropDownList End Sub Private Sub solo_numeros(ByVal sender As Object, ByVal e As System.Windows.F orms.KeyPressEventArgs) Handles tel.KeyPress, cc.KeyPress, sueldo.KeyPress If (Not Char.IsNumber(e.KeyChar) And e.KeyChar <> Microsoft.VisualBasic. ChrW(8)) Then e.Handled = True End If End Sub Private Sub solo_letras(ByVal sender As Object, ByVal e As System.Windows.Fo rms.KeyPressEventArgs) Handles nom.KeyPress If (Char.IsNumber(e.KeyChar) And e.KeyChar <> Microsoft.VisualBasic.ChrW (8)) Then e.Handled = True End If End Sub Sub dtp() con.Format = DateTimePickerFormat.Custom con.CustomFormat = "yyyy-mm-dd" nac.Format = DateTimePickerFormat.Custom nac.CustomFormat = "yyyy-mm-dd" End Sub End Class