private void BtnDesactivar_Click(object sender, EventArgs e) { try { //Instancia de Web service con credenciales NT ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient(); auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient auxServiceCargosUsuarios = new ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient(); auxServiceCargosUsuarios.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargosUsuarios.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa); if (MessageBox.Show("¿Esta Seguro de Desactivar Usuario " + _primer_nombre + " " + _primer_apellido + " Para la Empresa " + auxEmpresa.Nombre + "?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service auxServiceCargosUsuarios.ActualizarCargosUsuarioSinEntidad_Escritorio(_rut_usuario, Convert.ToInt32(_id_cargo), 0); btnActivar.Visible = false; btnDesactivar.Visible = false; //Vaciar variables _rut_usuario = null; _primer_nombre = string.Empty; _segundo_nombre = string.Empty; _primer_apellido = string.Empty; _segundo_apellido = string.Empty; _direccion = string.Empty; _telefono_fijo = string.Empty; _telefono_movil = string.Empty; _estado = string.Empty; _id_comuna = string.Empty; _rut_empresa = string.Empty; _id_cargo = string.Empty; pbSeleccion.Visible = false; //limpiar GridView dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); //Metodo Carga de GridView cargarDataGridViewPpal(); MessageBox.Show("Usuario Desactivado Para Empresa " + auxEmpresa.Nombre + " .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //continua CON LA VISTA ACTUAL } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnDesactivar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { if (_rut_usuario == null || _rut_empresa == null || _id_cargo == null) { if (_rut_usuario == null) { MessageBox.Show("Debe Seleccionar Usuario antes de Guardar.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (_rut_empresa == null) { MessageBox.Show("Debe Seleccionar Empresa antes de Guardar.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (_id_cargo == null) { MessageBox.Show("Debe Seleccionar Cargo antes de Guardar.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient auxServiceCargosUsuarios = new ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient(); auxServiceCargosUsuarios.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargosUsuarios.ClientCredentials.UserName.Password = Cuenta.Clave_iis; if (MessageBox.Show("Confirmar La Creacion del Nuevo Usuario Multiempresa", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service auxServiceCargosUsuarios.InsertarCargosUsuarioSinEntidad_Escritorio(_rut_usuario, Convert.ToInt32(_id_cargo), 1); //Metodo Carga de GridView this.DialogResult = DialogResult.OK; this.Close(); } else { //se devuelve al Cuadro de datos } ; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnGuardar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { ServiceProcess_Validadores.Process_ValidadoresSoapClient auxServiceValidadores = new ServiceProcess_Validadores.Process_ValidadoresSoapClient(); auxServiceValidadores.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceValidadores.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient auxServiceCargosUsuarios = new ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient(); auxServiceCargosUsuarios.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargosUsuarios.ClientCredentials.UserName.Password = Cuenta.Clave_iis; //Validacion espacio en blanco y seleccion de combobox if (txtRutUsuario.Text.Trim().Equals("") || txtPrimerNombre.Text.Trim().Equals("") || txtSegundoNombre.Text.Trim().Equals("") || txtPrimerApellido.Text.Equals("") || txtSegundoApellido.Text.Equals("") || txtDireccion.Text.Equals("") || txtTelefonoFijo.Text.Equals("") || txtTelefonoMovil.Text.Equals("") || txtCargo.Text.Equals("") || Convert.ToInt32(cbRegion.SelectedIndex) == 0 || Convert.ToInt32(cbProvincia.SelectedIndex) == 0 || Convert.ToInt32(cbComuna.SelectedIndex) == 0 || Convert.ToInt32(cbEmpresa.SelectedIndex) == 0) { if (txtRutUsuario.Text.Trim().Equals(""))//Mensaje Para Rut Vacio { MessageBox.Show("El campo Rut No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtPrimerNombre.Text.Trim().Equals(""))//Mensaje Para Primer Nombre Vacio { MessageBox.Show("El campo Primer Nombre No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtSegundoNombre.Text.Trim().Equals(""))//Mensaje Para Segundo Nombre Vacio { MessageBox.Show("El campo Segundo Nombre No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtPrimerApellido.Text.Equals(""))//Mensaje Para Primer Apellido Vacio { MessageBox.Show("El campo Primer Apellido No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtSegundoApellido.Text.Equals(""))//Mensaje Para Segundo Apellido Vacio { MessageBox.Show("El campo Segundo Apellido No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtDireccion.Text.Equals(""))//Mensaje Para Direccion Vacio { MessageBox.Show("El campo Direccion No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtTelefonoFijo.Text.Equals(""))//Mensaje Para Telefono fijo Vacio { MessageBox.Show("El campo Telefono Fijo No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtTelefonoMovil.Text.Equals(""))//Mensaje Para Telefono Movil Vacio { MessageBox.Show("El campo Telefono Movil No puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtCargo.Text.Equals(""))//Mensaje Para cargo Vacio { MessageBox.Show("Debe seleccionar un Cargo para el usuario.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Convert.ToInt32(cbRegion.SelectedIndex) == 0)//Mensaje Para Combo region Sin seleccionar { MessageBox.Show("Debe seleccionar una Region .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Convert.ToInt32(cbProvincia.SelectedIndex) == 0)//Mensaje Para Combo provincia Sin seleccionar { MessageBox.Show("Debe seleccionar una Provincia .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Convert.ToInt32(cbComuna.SelectedIndex) == 0)//Mensaje Para Combo Comuna Sin seleccionar { MessageBox.Show("Debe seleccionar una Comuna .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Convert.ToInt32(cbEmpresa.SelectedIndex) == 0)//Mensaje Para Combo Empresa Sin seleccionar { MessageBox.Show("Debe seleccionar una Empresa .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { //Validar longitud de caracteres if (txtRutUsuario.Text.Trim().Length < 10 || txtRutUsuario.Text.Trim().Length > 12 || txtPrimerNombre.Text.Trim().Length < 2 || txtPrimerNombre.Text.Trim().Length > 70 || txtSegundoNombre.Text.Trim().Length < 2 || txtSegundoNombre.Text.Trim().Length > 70 || txtPrimerApellido.Text.Trim().Length < 2 || txtPrimerApellido.Text.Trim().Length > 70 || txtSegundoApellido.Text.Trim().Length < 2 || txtSegundoApellido.Text.Trim().Length > 70 || txtDireccion.Text.Trim().Length < 5 || txtDireccion.Text.Trim().Length > 70 || txtTelefonoFijo.Text.Trim().Length < 9 || txtTelefonoFijo.Text.Trim().Length > 12 || txtTelefonoMovil.Text.Trim().Length < 8 || txtTelefonoMovil.Text.Trim().Length > 12) { if (txtRutUsuario.Text.Trim().Length < 10 || txtRutUsuario.Text.Trim().Length > 12)//Mensaje longitud fuera de rango rut usuario { MessageBox.Show("El Rut, debe tener un minimo de 10 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtPrimerNombre.Text.Trim().Length < 2 || txtPrimerNombre.Text.Trim().Length > 70)//Mensaje longitud fuera de rango primer nombre { MessageBox.Show("El Primer Nombre, debe tener un minimo de 2 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtSegundoNombre.Text.Trim().Length < 2 || txtSegundoNombre.Text.Trim().Length > 70)//Mensaje longitud fuera de rango segundo nombre { MessageBox.Show("El Segundo Nombre, debe tener un minimo de 2 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtPrimerApellido.Text.Trim().Length < 2 || txtPrimerApellido.Text.Trim().Length > 70)//Mensaje longitud fuera de rango primer apellido { MessageBox.Show("El Primer Apellido, debe tener un minimo de 2 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtSegundoApellido.Text.Trim().Length < 2 || txtSegundoApellido.Text.Trim().Length > 70)//Mensaje longitud fuera de rango segundo apellido { MessageBox.Show("El Segundo Apellido, debe tener un minimo de 2 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtDireccion.Text.Trim().Length < 5 || txtDireccion.Text.Trim().Length > 70)//Mensaje longitud fuera de rango direccion { MessageBox.Show("La Direccion, debe tener un minimo de 5 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtTelefonoFijo.Text.Trim().Length < 9 || txtTelefonoFijo.Text.Trim().Length > 12) //Mensaje longitud fuera de rango telefono fijo { MessageBox.Show("El Telefono Fijo, debe tener un minimo de 9 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtTelefonoMovil.Text.Trim().Length < 8 || txtTelefonoMovil.Text.Trim().Length > 12) //Mensaje longitud fuera de rango telefono movil { MessageBox.Show("El Telefono Movil, debe tener un minimo de 8 Caracteres.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { //Validacion de formato de correo, validacion numero de telefono, validacion rut correcto if (!auxServiceValidadores.numeroValidacionService(txtTelefonoFijo.Text) || !auxServiceValidadores.numeroValidacionService(txtTelefonoMovil.Text) || !auxServiceValidadores.rutValidacionService(txtRutUsuario.Text)) { if (!auxServiceValidadores.numeroValidacionService(txtTelefonoFijo.Text))//Mensaje de ingreso de caracteres en telefono fijo { MessageBox.Show("El Telefono Fijo debe contener solo Numeros.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!auxServiceValidadores.numeroValidacionService(txtTelefonoMovil.Text))//Mensaje de ingreso de caracteres en telefono movil { MessageBox.Show("El Telefono Movil debe contener solo Numeros.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!auxServiceValidadores.rutValidacionService(txtRutUsuario.Text))//Mensaje de rut no valido { MessageBox.Show("Rut Ingresado No Valido.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { DataSet ds = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(txtRutUsuario.Text.ToUpper(), cbEmpresa.SelectedValue.ToString().ToUpper()); //Validacion si existe Usuario if (ds.Tables.Count == 0) { //confirmacion de crear nuevo usuario if (MessageBox.Show("Confirmar La Creacion del Usuario.", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service tabla usuario auxServiceUsuario.InsertarUsuarioSinEntidad_Escritorio(txtRutUsuario.Text.ToUpper(), txtPrimerNombre.Text.ToUpper(), txtSegundoNombre.Text.ToUpper(), txtPrimerApellido.Text.ToUpper(), txtSegundoApellido.Text.ToUpper(), txtDireccion.Text.ToUpper(), Convert.ToInt32(txtTelefonoFijo.Text.ToUpper()), Convert.ToInt32(txtTelefonoMovil.Text.ToString()), Convert.ToInt32(cbComuna.SelectedValue.ToString())); //Insertar datos via web service tabla cargo_usuario auxServiceCargosUsuarios.InsertarCargosUsuarioSinEntidad_Escritorio(txtRutUsuario.Text, Convert.ToInt32(_id_cargo), 1); this.DialogResult = DialogResult.OK; this.Close(); } else { //se devuelve al Cuadro de datos MessageBox.Show("Se cancelo la creacion del Usuario.", "CREACION DE USUARIO", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { string nombreEmpresa = Convert.ToString(cbEmpresa.GetItemText(cbEmpresa.SelectedItem)); MessageBox.Show("El Usuario Ya existe En la Empresa " + nombreEmpresa + ".", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } } catch (Exception ex) { MessageBox.Show("Error en metodo BtnGuardar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "Mensaje de sistema"); } }