private void btnModificar_Click(object sender, EventArgs e) { if (dgvPerfiles.SelectedRows.Count > 0) { if (dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[0].Value.ToString().CompareTo("1") != 0) { numAccion = clsComun.MODIFICAR; numIdPerfil = Int32.Parse(dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[0].Value.ToString()); limpiarFormulario(); clsPerfil objPerfil = new clsPerfil(); objPerfil.IdPerfil = numIdPerfil; objPerfil = ctrPerfil.seleccionarPerfil(objPerfil); mostrarInformacion(objPerfil, numAccion); txtNombreDetalle.Focus(); } else { MessageBox.Show("Este perfil no se puede modificar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Debe seleccionar un perfil", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public static bool eliminarPerfil(clsPerfil objPerfil) { List <SqlParameter> lstParametrosSQL = new List <SqlParameter>(); SqlParameter sqlParametro; lstParametrosSQL = crearLista(objPerfil); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@Accion"; sqlParametro.Value = 2; sqlParametro.Direction = ParameterDirection.Input; lstParametrosSQL.Add(sqlParametro); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@IdGenerado"; sqlParametro.Value = 0; sqlParametro.Direction = ParameterDirection.Output; lstParametrosSQL.Add(sqlParametro); int numResultado = clsGestorBD.ejecutarStoredProcedureInt("up_ManPerfil", lstParametrosSQL); if (numResultado != 0) { return(true); } else { return(false); } }
clsPerfil GetPerfil() { clsPerfil ob = new clsPerfil(); ob.Descripcion = txtDescripcion.Text; ob.IdPErfil = Convert.ToInt32((txtCodigo.Text == "") ? "0" : txtCodigo.Text); ob.IdEstado = (chkActivo.Checked == true) ? 1 : 2; return(ob); }
public static ResultadoTransaccion ObtenerPerfilesUsuarios(int idUsuario) { ResultadoTransaccion res = new ResultadoTransaccion(); var listPerfiles = new List <clsPerfil>(); try { //Abrir Conexion conn = BaseDatos.NuevaConexion(); objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_C_USUARIO_PERFILES"); objParams[0].Value = idUsuario; SqlCommand command = new SqlCommand("SP_C_USUARIO_PERFILES", conn); command.Parameters.AddRange(objParams); command.CommandType = CommandType.StoredProcedure; dreader = command.ExecuteReader(); while (dreader.Read()) { var perfil = new clsPerfil(); perfil.Id = Convert.ToInt64(dreader["id_perfil"]); perfil.Nombre = dreader["nombre_perfil"].ToString(); perfil.Prioridad = Convert.ToInt32(dreader["prioridad"]); if (!String.IsNullOrEmpty(dreader["id_panel"].ToString())) { perfil.PanelDeControl.Id = Convert.ToInt32(dreader["id_panel"]); perfil.PanelDeControl.Nombre = dreader["nombre_panel"].ToString(); perfil.PanelDeControl.XmlFile = dreader["xml_file"].ToString(); } else { perfil.PanelDeControl = null; } listPerfiles.Add(perfil); } res.Estado = Entidades.Enums.Enums.EstadoTransaccion.Aceptada; res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.ObjetoTransaccion = listPerfiles; } catch (Exception ex) { res.Estado = Entidades.Enums.Enums.EstadoTransaccion.Rechazada; res.Descripcion = ex.Message; Base.Log.Log.EscribirLog(ex.Message); } finally { if (dreader != null) { dreader.Close(); } if (conn != null) { conn.Close(); } } return(res); }
private void llenarComboPerfil(List<clsPerfil> lstPerfiles) { clsPerfil objPerfil = new clsPerfil(); objPerfil.StrNombre = "SELECCIONAR"; cboPerfil.Items.Add(objPerfil); for (int i = 0; i < lstPerfiles.Count; i++) { cboPerfil.Items.Add(lstPerfiles[i]); } }
public frmPerfil() { InitializeComponent(); clsPerfil objPerfil = new clsPerfil(); objPerfil.TipoEmpleado = "TODOS"; objPerfil.Estado = "TODOS"; dtPerfiles = ctrPerfil.seleccionarPerfilesCriterios(objPerfil); cargarGrilla(); }
private void btnEliminar_Click(object sender, EventArgs e) { if (dgvPerfiles.SelectedRows.Count > 0) { if (dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[0].Value.ToString().CompareTo("1") != 0) { if (MessageBox.Show("¿Está seguro que desea eliminar este perfil?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { numAccion = clsComun.ELIMINAR; numIdPerfil = Int32.Parse(dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[0].Value.ToString()); clsPerfil objPerfil = new clsPerfil(); objPerfil.IdPerfil = numIdPerfil; if (ctrPerfil.eliminarPerfil(objPerfil)) { dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[3].Value = "INACTIVO"; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[1].Style.ForeColor = Color.White; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[1].Style.BackColor = Color.Red; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[2].Style.ForeColor = Color.White; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[2].Style.BackColor = Color.Red; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[3].Style.ForeColor = Color.White; dgvPerfiles.Rows[dgvPerfiles.CurrentRow.Index].Cells[3].Style.BackColor = Color.Red; btnActivar.Visible = true; btnEliminar.Visible = false; MessageBox.Show("El perfil se eliminó exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (MessageBox.Show("Ocurrió un error mientras se intentaba eliminar el perfil", "Mensaje", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) != DialogResult.Cancel) { btnEliminar_Click(sender, e); } } } } else { MessageBox.Show("Este perfil no se puede eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Debe seleccionar un perfil", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void chargeData() { clsPerfil perfil = new clsPerfil(); perfil pf = new perfil(); pf = perfil.returnPerfil(); this.lblNombre.Text = string.Format("{0} {1}", pf.nombre.Split(' ')[0], pf.nombre.Split(' ')[1]); this.lblApellido.Text = string.Format("{0} {1}", pf.nombre.Split(' ')[2], pf.nombre.Split(' ')[3]); this.lblDireccion.Text = pf.direccion; this.lblEdad.Text = string.Format("{0} años", pf.edad); this.lblTelefono.Text = pf.telefono; this.lblEmail.Text = pf.email; }
private void buscarCriterios(object sender, EventArgs e) { try { clsPerfil objPerfil = new clsPerfil(); objPerfil.Nombre = txtNombreBuscar.Text; objPerfil.TipoEmpleado = cboTipoEmpleadoBuscar.SelectedItem.ToString(); objPerfil.Estado = cboEstadoBuscar.SelectedItem.ToString(); dtPerfiles = ctrPerfil.seleccionarPerfilesCriterios(objPerfil); cargarGrilla(); } catch { } }
private void mostrarInformacion(clsPerfil objPerfil, int numAccion) { if (numAccion != clsComun.INSERTAR) { txtNombreDetalle.Text = objPerfil.Nombre; cboTipoEmpleadoDetalle.Text = objPerfil.TipoEmpleado; string[] strMenus = objPerfil.ListaMenus.Split(','); foreach (string menu in strMenus) { lbxAccesosPermitidos.Items.Add(menu); } } if (numAccion == clsComun.VER) { txtNombreDetalle.Solo_Lectura = SistemaCentroSalud.Controles.cuTextBox.SoloLectura.verdadero; cboTipoEmpleadoDetalle.Enabled = false; //lbxAccesosPermitidos.Enabled = false; btnTodoDerecha.Visible = false; btnDerecha.Visible = false; btnIzquierda.Visible = false; btnTodoIzquierda.Visible = false; btnCancelar.Visible = false; btnGuardar.Text = "Volver"; } else { txtNombreDetalle.Solo_Lectura = SistemaCentroSalud.Controles.cuTextBox.SoloLectura.falso; cboTipoEmpleadoDetalle.Enabled = true; //lbxAccesosPermitidos.Enabled = true; btnTodoDerecha.Visible = true; btnDerecha.Visible = true; btnIzquierda.Visible = true; btnTodoIzquierda.Visible = true; btnCancelar.Visible = true; btnGuardar.Text = "Guardar"; } clsComun.redimensionarTabControl(tbcPerfil, 569, 318); clsComun.redimensionarVentana(this, 574, 345); clsComun.tabSiguiente(tbcPerfil, tbpBuscar, tbpDetalle); }
private static List <SqlParameter> crearLista(clsPerfil objPerfil) { List <SqlParameter> lstParametrosSQL = new List <SqlParameter>(); SqlParameter sqlParametro; foreach (PropertyInfo pi in objPerfil.GetType().GetProperties()) { if (pi.CanRead) { sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@" + pi.Name; sqlParametro.Value = pi.GetValue(objPerfil, null); sqlParametro.Direction = ParameterDirection.Input; lstParametrosSQL.Add(sqlParametro); } } return(lstParametrosSQL); }
private void cargarComboPerfil() { clsPerfil objPerfil = new clsPerfil(); objPerfil.TipoEmpleado = "TÉCNICO"; DataTable dt = ctrPerfil.seleccionarPerfilesCriterios(objPerfil); objPerfil.Nombre = "SELECCIONAR"; cboPerfil.Items.Add(objPerfil); for (int i = 0; i < dt.Rows.Count; i++) { objPerfil = new clsPerfil(); objPerfil.IdPerfil = Int32.Parse(dt.Rows[i]["IdPerfil"].ToString()); objPerfil.Nombre = dt.Rows[i]["Nombre"].ToString(); cboPerfil.Items.Add(objPerfil); } }
public static DataTable seleccionarPerfilesCriterios(clsPerfil objPerfil) { List <SqlParameter> lstParametrosSQL = new List <SqlParameter>(); SqlParameter sqlParametro; lstParametrosSQL = crearLista(objPerfil); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@Accion"; sqlParametro.Value = 6; sqlParametro.Direction = ParameterDirection.Input; lstParametrosSQL.Add(sqlParametro); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@IdGenerado"; sqlParametro.Value = 0; sqlParametro.Direction = ParameterDirection.Output; lstParametrosSQL.Add(sqlParametro); return(clsGestorBD.ejecutarStoredProcedureDataTable("up_ManPerfil", lstParametrosSQL)); }
public List <clsPerfil> ConsultarTodos() { try { List <clsPerfil> listaPerfil = new List <clsPerfil>(); TECAv8Entities ent = new TECAv8Entities(); var query = from a in ent.Perfil select a; foreach (var item in query) { clsPerfil p = new clsPerfil(); p.IdPErfil = item.IdPerfil; p.Descripcion = item.Descripcion; p.IdEstado = Convert.ToInt32(item.IdEstado); listaPerfil.Add(p); } return(listaPerfil); } catch (Exception ex) { Console.WriteLine("Error" + ex); return(null); } }
public static clsPerfil seleccionarPerfil(clsPerfil objPerfil) { List <SqlParameter> lstParametrosSQL = new List <SqlParameter>(); SqlParameter sqlParametro; lstParametrosSQL = crearLista(objPerfil); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@Accion"; sqlParametro.Value = 4; sqlParametro.Direction = ParameterDirection.Input; lstParametrosSQL.Add(sqlParametro); sqlParametro = new SqlParameter(); sqlParametro.ParameterName = "@IdGenerado"; sqlParametro.Value = 0; sqlParametro.Direction = ParameterDirection.Output; lstParametrosSQL.Add(sqlParametro); DataSet dsResultado = clsGestorBD.ejecutarStoredProcedureDataSet("up_ManPerfil", lstParametrosSQL); objPerfil.Nombre = dsResultado.Tables[0].Rows[0]["Nombre"].ToString(); objPerfil.TipoEmpleado = dsResultado.Tables[0].Rows[0]["TipoEmpleado"].ToString(); string strListaMenus = dsResultado.Tables[1].Rows[0]["Menu"].ToString(); for (int i = 1; i < dsResultado.Tables[1].Rows.Count; i++) { strListaMenus = strListaMenus + "," + dsResultado.Tables[1].Rows[i]["Menu"].ToString(); } objPerfil.ListaMenus = strListaMenus; return(objPerfil); }
public Boolean Guardar(clsPerfil Info, ref int IdPerfil) { try { using (TECAv8Entities Context = new TECAv8Entities()) { var contact = Perfil.CreatePerfil(0); var address = new Perfil(); address.IdEstado = Info.IdEstado; address.Descripcion = Info.Descripcion; address.IdPerfil = IdPerfil = GetId(); contact = address; Context.Perfil.AddObject(contact); Context.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static List <clsPerfil> up_SelPerfilEnfermera() { List <clsPerfil> lstPerfiles = new List <clsPerfil>(); DataTable dtPerfiles = clsGestorBD.up_SelPerfil(0, "", "ENFERMERA", "ACTIVO", clsGestorBD.SELECTCUSTOM); for (int i = 0; i < dtPerfiles.Rows.Count; i++) { string strId = dtPerfiles.Rows[i][0].ToString(); string strNombre = dtPerfiles.Rows[i][1].ToString(); string strTipoPersonal = dtPerfiles.Rows[i][2].ToString(); string strEstado = dtPerfiles.Rows[i][3].ToString(); clsPerfil objPerfil = new clsPerfil(); objPerfil.NumIdPerfil = Int32.Parse(strId); objPerfil.StrNombre = strNombre; objPerfil.StrTipoPersonal = strTipoPersonal; objPerfil.StrEstado = strEstado; lstPerfiles.Add(objPerfil); } return(lstPerfiles); }
private void gridView1_DoubleClick(object sender, EventArgs e) { Info = (clsPerfil)gridView1.GetFocusedRow(); this.Close(); }
private void HabilitarFuncionalidades() { string[] l = null; if (System.Configuration.ConfigurationSettings.AppSettings.Get("SupervisorDocumental") != null) { l = System.Configuration.ConfigurationSettings.AppSettings.Get("SupervisorDocumental").Split(','); } if (l != null) { var super = l.Select(s => Convert.ToInt64(s)).ToList(); if (super.Contains(Base.Usuario.UsuarioConectado.Usuario.Id)) { var c = new clsUsuarioCargo(15, "SupervisorDocumental"); Base.Usuario.UsuarioConectado.Usuario.Cargos.Add(c); var p = new clsPerfil(); p.Id = 15; p.Nombre = "SupervisorDocumental"; p.PanelDeControl = new ClsPanelDeControl(); p.PanelDeControl.Id = 1; p.PanelDeControl.Nombre = "panel Papperless"; p.PanelDeControl.XmlFile = "panel1.xml"; Base.Usuario.UsuarioConectado.Usuario.Perfiles.Add(p); } } DeshabilitarFuncionalidads(); foreach (var clsPerfil in Base.Usuario.UsuarioConectado.Usuario.Perfiles) { if (clsPerfil.Id == (int)Enums.UsuariosCargo.Supervisor_Documental) { MenuPaperlessAsignacion.Visible = true; MenuPaperlessAsignar.Visible = true; NavPaperlessInformes.Visible = NavPaperlessInformes2.Visible = true; } if (clsPerfil.Id == (int)Enums.UsuariosCargo.Encargado_Documental_1ra_Etapa) { MenuPaperlessUsuario1.Visible = true; MenuPaperlessUsuario1.Caption = "Primera Etapa - Mis Asignaciones"; } if (clsPerfil.Id == (int)Enums.UsuariosCargo.Encargado_Documental_2da_Etapa) { MenuPaperlessUsuario2.Visible = true; MenuPaperlessUsuario2.Caption = "Segunda Etapa - Mis Asignaciones"; } if (clsPerfil.Id != (int)Enums.UsuariosCargo.Customer_Service && clsPerfil.Id != (int)Enums.UsuariosCargo.Vendedor) { MenuPaperlessGestion.Visible = true; } if (clsPerfil.Id != (int)Enums.UsuariosCargo.Customer_Service && clsPerfil.Id != (int)Enums.UsuariosCargo.Vendedor) { MenuPaperlessGestion.Visible = true; } if (clsPerfil.Nombre.Equals(Enums.UsuariosCargo.AdministradorDatosMaestros.ToString())) { menuAdministracion.Visible = true; } if (clsPerfil.Id == (int)Enums.UsuariosCargo.Vendedor) { MenuCotizaciones.Visible = true; } if (clsPerfil.Id32 == (Int32)Enums.UsuariosCargo.Customer_Service || clsPerfil.Id32 == (Int32)Enums.UsuariosCargo.Vendedor || clsPerfil.Id32 == (Int32)Enums.UsuariosCargo.Supervisor_Procesos || clsPerfil.Id32 == (Int32)Enums.UsuariosCargo.Gerente_General || clsPerfil.Id32 == (Int32)Enums.UsuariosCargo.Gerente_Administración_y_Finanzas) { MenuGestionCotizaciones.Visible = true; } //TSC PREALERTA if (clsPerfil.Id == (int)Enums.UsuariosCargo.Supervisor_Documental) { MenuPaperlessPreAlerta.Visible = true; } if (clsPerfil.Id == (int)Enums.UsuariosCargo.Encargado_Documental_1ra_Etapa) { MenuPaperlessPreAlerta.Visible = true; } //FIN TSC PREALERTA } }
private void btnGuardar_Click(object sender, EventArgs e) { if (numAccion == clsComun.VER) { clsComun.redimensionarTabControl(tbcPerfil, 459, 318); clsComun.redimensionarVentana(this, 463, 345); clsComun.tabAnterior(tbcPerfil, tbpBuscar, tbpDetalle); limpiarFormulario(); txtNombreBuscar.Focus(); } else { if (validarFormulario()) { clsPerfil objPerfil = new clsPerfil(); objPerfil.IdPerfil = numIdPerfil; objPerfil.Nombre = txtNombreDetalle.Text; objPerfil.TipoEmpleado = cboTipoEmpleadoDetalle.SelectedItem.ToString(); string strListaMenus = strListaMenus = lbxAccesosPermitidos.Items[0].ToString(); for (int i = 1; i < lbxAccesosPermitidos.Items.Count; i++) { strListaMenus += "," + lbxAccesosPermitidos.Items[i].ToString(); } objPerfil.ListaMenus = strListaMenus; if (numAccion == clsComun.INSERTAR) { if (ctrPerfil.registrarPerfil(objPerfil)) { if (MessageBox.Show("El perfil se registró exitosamente\n¿Desea seguir registrando perfiles?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { limpiarFormulario(); txtNombreDetalle.Focus(); } else { clsComun.redimensionarTabControl(tbcPerfil, 459, 318); clsComun.redimensionarVentana(this, 463, 345); clsComun.tabAnterior(tbcPerfil, tbpBuscar, tbpDetalle); limpiarFormulario(); txtNombreBuscar.Focus(); dtPerfiles = ctrPerfil.seleccionarPerfiles(objPerfil); cargarGrilla(); } } else { if (MessageBox.Show("Ocurrió un error mientras se intentaba registrar el perfil", "Mensaje", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) != DialogResult.Cancel) { btnGuardar_Click(sender, e); } } } else if (numAccion == clsComun.MODIFICAR) { if (ctrPerfil.modificarPerfil(objPerfil)) { MessageBox.Show("El perfil se modificó exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); clsComun.redimensionarTabControl(tbcPerfil, 459, 318); clsComun.redimensionarVentana(this, 463, 345); clsComun.tabAnterior(tbcPerfil, tbpBuscar, tbpDetalle); limpiarFormulario(); txtNombreBuscar.Focus(); dtPerfiles = ctrPerfil.seleccionarPerfiles(objPerfil); cargarGrilla(); } else { if (MessageBox.Show("Ocurrió un error mientras se intentaba modificar el perfil", "Mensaje", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) != DialogResult.Cancel) { btnGuardar_Click(sender, e); } } } } } }