private void BTN_iniciar_Click(object sender, RoutedEventArgs e) { Empleado_Negocio empN = new Empleado_Negocio(); Compartido_Negocio compartido = new Compartido_Negocio(); var item = empN.LoginUsuario(txt_usuario.Text, compartido.Encriptar(txt_contraseña.Password.ToString())); //regEnt = reg.LoginUsuario(usu, passw); if (item.Rows.Count > 0) { foreach (DataRow resp in item.Rows) { Application.Current.Properties["NombreUsuario"] = resp["p_nombre_empleado"].ToString() + " " + resp["p_apellido_empleado"].ToString(); Application.Current.Properties["Perfil"] = resp["id_cargo"].ToString(); } this.Hide(); MenuPrincipal ventana = new MenuPrincipal(); ventana.ShowDialog(); } else { txt_contraseña.Password = ""; txt_usuario.Text = ""; MessageBox.Show("Usuario o Contraseña invalida"); } }
private void btn_Eliminar_E_Click(object sender, RoutedEventArgs e) { Empleado_Negocio empN = new Empleado_Negocio(); if (Txt_Rut_Empleado.Text != "") { bool retorno = false; string msj = "Esta seguro de eliminar este empleado"; string titulo = "ELIMINAR EMPLEADO"; var resp = MessageBox.Show(msj, titulo, MessageBoxButton.YesNo); if (resp == MessageBoxResult.Yes) { retorno = empN.EliminarEmp(int.Parse(Txt_id_E.Text)); if (retorno) { MessageBox.Show("Empleado Eliminado"); limpiarEmp(); } else { MessageBox.Show("El empleado no pudo ser eliminado"); } } } else { MessageBox.Show("Debe ingresar RUT para eliminar un empleado"); } }
private void btn_Buscar_E_Click(object sender, RoutedEventArgs e) { Empleado_Negocio empN = new Empleado_Negocio(); DataTable resp = new DataTable(); Compartido_Negocio comp = new Compartido_Negocio(); if (Txt_Rut_Empleado.Text != "") { try { resp = empN.ListarEmpleado(Txt_Rut_Empleado.Text); if (resp.Rows.Count > 0) { foreach (DataRow item in resp.Rows) { Txt_id_E.Text = item["ID_EMPLEADO"].ToString(); Txt_Dv_Empleado.Text = item["DV_EMPLEADO"].ToString(); Txt_P_Nombre_E.Text = item["p_nombre_empleado"].ToString(); Txt_S_Nombre_E.Text = item["s_nombre_empleado"].ToString(); Txt_P_Apellido_E.Text = item["p_apellido_empleado"].ToString(); Txt_S_Apellido_E.Text = item["s_apellido_empleado"].ToString(); Txt_Direccion_E.Text = item["direccion_empleado"].ToString(); Txt_numeracion_E.Text = item["numeracion_empleado"].ToString(); Txt_Fono_E.Text = item["fono_empleado"].ToString(); Txt_Depto_E.Text = item["depto_empleado"].ToString(); Txt_Correo_E.Text = item["correo_empleado"].ToString(); Txt_NombreU_E.Text = item["nombre_usu_empleado"].ToString(); Txt_Contrasena_E.Password = comp.DecrytedString(item["contrasena_empleado"].ToString()); Cmb_comuna_E.SelectedValue = item["id_comuna"].ToString(); Cmb_cargo_E.SelectedValue = item["id_cargo"].ToString(); cmb_id_taller_E.SelectedValue = item["id_taller"].ToString(); } } else { MessageBox.Show("Rut invalido"); //limpiarEmp(); } } catch (Exception ex) { MessageBox.Show("Busqueda no arrojó resultados"); throw ex; } } else { MessageBox.Show("Debe ingresar un Rut para la busqueda"); } }
private void LlenarComboEmpleado() { try { Usuario DatosAux = new Usuario { Conexion = Comun.Conexion, IncluirSelect = true }; Empleado_Negocio PN = new Empleado_Negocio(); this.cmbEmpleados.DataSource = PN.LlenarComboEmpleado(DatosAux); this.cmbEmpleados.DisplayMember = "Nombre"; this.cmbEmpleados.ValueMember = "IDEmpleado"; } catch (Exception ex) { throw ex; } }
private void btn_Agregar_E_Click(object sender, RoutedEventArgs e) { bool resp = false; Empleado_Negocio empN = new Empleado_Negocio(); if (Txt_Rut_Empleado.Text == "" || Txt_Dv_Empleado.Text == "" || Txt_P_Nombre_E.Text == "" || Txt_S_Nombre_E.Text == "" || Txt_P_Apellido_E.Text == "" || Txt_S_Apellido_E.Text == "" || Txt_Direccion_E.Text == "" || Txt_numeracion_E.Text == "" || Txt_Fono_E.Text == "" || Txt_Correo_E.Text == "" || Txt_NombreU_E.Text == "" || Txt_Contrasena_E.Password == "" || Cmb_comuna_E.Text == "" || Cmb_cargo_E.Text == "") { if (Txt_Rut_Empleado.Text == "" && Txt_Dv_Empleado.Text == "" && Txt_P_Nombre_E.Text == "" && Txt_S_Nombre_E.Text == "" && Txt_P_Apellido_E.Text == "" && Txt_S_Apellido_E.Text == "" && Txt_Direccion_E.Text == "" && Txt_numeracion_E.Text == "" && Txt_Fono_E.Text == "" && Txt_Correo_E.Text == "" && Txt_NombreU_E.Text == "" && Txt_Contrasena_E.Password == "" && Cmb_comuna_E.Text == "" && Cmb_cargo_E.Text == "") { MessageBox.Show("Debe completar todos los campos"); } else { if (Txt_Rut_Empleado.Text == "" && !resp) { MessageBox.Show("Debe ingresar Rut del empleado"); resp = true; } if (Txt_Dv_Empleado.Text == "" && !resp) { MessageBox.Show("Debe ingresar dígito verificador "); resp = true; } if (Txt_P_Nombre_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar primer nombre "); resp = true; } if (Txt_S_Nombre_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar segundo nombre"); resp = true; } if (Txt_P_Apellido_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar apellido paterno"); resp = true; } if (Txt_S_Apellido_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar apellido materno "); resp = true; } if (Txt_Direccion_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar dirección"); resp = true; } if (Txt_numeracion_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar numeración de domicilio "); resp = true; } if (Txt_Fono_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar número de teléfono"); resp = true; } if (Txt_Correo_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar correo"); resp = true; } if (Txt_NombreU_E.Text == "" && !resp) { MessageBox.Show("Debe ingresar nombre de usuario"); resp = true; } if (Txt_Contrasena_E.Password == "" && !resp) { MessageBox.Show("Debe ingresar una contraseña"); resp = true; } if (Cmb_comuna_E.Text == "" && !resp) { MessageBox.Show("Debe selecionar comuna "); resp = true; } if (Cmb_cargo_E.Text == "" && !resp) { MessageBox.Show("Debe seleccionar cargo del empleado"); resp = true; } } } else { bool resultado = false; try { resultado = empN.crearEmpleado(Txt_id_E.Text, Txt_Rut_Empleado.Text, Txt_Dv_Empleado.Text, Txt_P_Nombre_E.Text, Txt_S_Nombre_E.Text, Txt_P_Apellido_E.Text, Txt_S_Apellido_E.Text, Txt_Direccion_E.Text, Txt_numeracion_E.Text, Txt_Depto_E.Text, Txt_Fono_E.Text, Txt_Correo_E.Text, Txt_NombreU_E.Text, Txt_Contrasena_E.Password, Cmb_comuna_E.SelectedValue.ToString(), cmb_id_taller_E.SelectedValue.ToString(), Cmb_cargo_E.SelectedValue.ToString()); if (resultado) { if (Txt_id_E.Text != "") { MessageBox.Show("Empleado Modificado"); } else { MessageBox.Show("Empleado Registrado"); limpiarEmp(); } } else { MessageBox.Show("Empleado no pudo ser creado"); } } catch (Exception) { MessageBox.Show("Empleado no pudo ser creado"); throw; } } }