//Metodo Carga GridView Usuario Empresa private void cargarDataGridViewEmpresa() { try { 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_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient(); auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresas = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); //CAPTURAR DATASET DataSet dsU = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(_rut_usuario, auxEmpresa.Rut_empresa); if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0)) { //no carga nada al gridview por que ya es usuario de la empresa } else { //cargar array con datos de fila ListaEmpresas[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresas[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresas[_fila, 0], ListaEmpresas[_fila, 1]); _fila++; } } } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewUsuario, 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"); } }
private void TxtFiltrarEmpresa_KeyUp(object sender, KeyEventArgs e) { try { dgvEmpresas.Rows.Clear(); dgvEmpresas.Refresh(); //instansear web service con seguridad 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_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerEmpresaConClaveSinEntidad_Escritorio(txtFiltrarEmpresa.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresas = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); //CAPTURAR DATASET DataSet dsU = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(_rut_usuario, auxEmpresa.Rut_empresa); if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0)) { //no carga nada al gridview por que ya es usuario de la empresa } else { //cargar array con datos de fila ListaEmpresas[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresas[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresas[_fila, 0], ListaEmpresas[_fila, 1]); _fila++; } } lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); pbSeleccion1.Visible = true; pbSeleccion2.Visible = false; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = false; dgvCargo.Rows.Clear(); dgvCargo.Refresh(); _rut_empresa = null; _id_cargo = null; } else { lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); pbSeleccion1.Visible = true; pbSeleccion2.Visible = false; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = false; dgvCargo.Rows.Clear(); dgvCargo.Refresh(); _rut_empresa = null; _id_cargo = null; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrarEmpresa_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }