private void Borrar() { try { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "1200304"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { if (MessageBox.Show("Esta seguro de Borrar este Registro", "Atencion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { App_Code.Sistema.Sistema_Usuarios oRegistro = new App_Code.Sistema.Sistema_Usuarios(int.Parse(this.lblFicha.Text)); oRegistro.FechaBaja = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy")); oRegistro.Estatus = "Bloqueado"; oRegistro.Actualizar(); this.Nuevo(); MessageBox.Show(oRegistro.Msg + ", El usuario a sido bloqueado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } }
private void Guardar() { App_Code.Sistema.Sistema_Usuarios oRegistro = new App_Code.Sistema.Sistema_Usuarios(int.Parse(this.lblFicha.Text)); oRegistro.EmpresaId = panterasoftware.Formularios.frmPrincipal.id_empresa; oRegistro.GrupoId = int.Parse(this.cmbGrupos.SelectedValue.ToString()); oRegistro.Apellido = this.txtApellidos.Text.ToString().ToUpper(); oRegistro.Nombre = this.txtNombres.Text.ToString().ToUpper(); oRegistro.Clave = this.txtClave.Text.ToString(); oRegistro.Usuario = this.txtUsuario.Text.ToString(); oRegistro.Estatus = this.cmbEstatus.SelectedItem.ToString(); oRegistro.FechaAlta = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy")); try { if (!Validar()) { if (oRegistro.Err) { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "1200302"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { oRegistro.Insertar(); } } else { oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "1200303"); if (oFuncion.Err) { MessageBox.Show("Disculpe Usted No Tiene Acceso a Esta Accion", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else { oRegistro.Actualizar(); } } MessageBox.Show(oRegistro.Msg, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.Consulta(); this.Presentar(oRegistro.Id); } } catch (Exception) { } }
private bool Validar() { if (this.txtUsuario.Text.Length == 0 || this.txtNombres.Text.Length == 0) { this.txtNombres.BackColor = Color.Red; this.txtUsuario.BackColor = Color.Red; MessageBox.Show("Disculpe verifique los campos en rojo", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } if (this.txtClave.Text != this.txtRepClave.Text) { MessageBox.Show("Disculpe las contraseñas no coinciden", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } if (this.lblFicha.Text == "0") { DataTable oTabla = new App_Code.Sistema.Sistema_Usuarios().Buscar( 1, "id", "(usuario = '" + this.txtUsuario.Text + "')", ""); if (oTabla.Rows.Count > 0) { this.txtUsuario.BackColor = Color.Red; MessageBox.Show("Disculpe ya el usuario existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } } else { DataTable oTabla = new App_Code.Sistema.Sistema_Usuarios().Buscar( 1, "id", "(usuario = '" + this.txtUsuario.Text + "') AND (id <> '" + this.lblFicha.Text + "')", ""); if (oTabla.Rows.Count > 0) { this.txtUsuario.BackColor = Color.Red; MessageBox.Show("Disculpe ya el usuario existe", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(true); } } return(false); }
private void btnIngresar_Click(object sender, EventArgs e) { if (!Validar()) { DataTable oTabla = new App_Code.Sistema.Sistema_Usuarios().Buscar( 1, "id,nombre,apellido,grupo_id,empresa_id,estatus", "(usuario = '" + this.txtUsuario.Text + "') AND (clave = '" + this.txtClave.Text + "')", ""); if (oTabla.Rows.Count > 0) { if ((oTabla.Rows[0]["estatus"].ToString()) == "Bloqueado") { MessageBox.Show("Disculpe usuario bloqueado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { App_Code.Sistema.Sistema_Grupos oGrupo = new App_Code.Sistema.Sistema_Grupos(int.Parse(oTabla.Rows[0]["grupo_id"].ToString())); frmPrincipal.id_usuario = int.Parse(oTabla.Rows[0]["id"].ToString()); frmPrincipal.usuario = oTabla.Rows[0]["apellido"].ToString().ToUpper() + " " + oTabla.Rows[0]["nombre"].ToString().ToUpper(); frmPrincipal.id_grupo_usuario = int.Parse(oTabla.Rows[0]["grupo_id"].ToString()); if (oGrupo.Nombre == "Administrador" || oGrupo.Nombre == "Desarrollo") { panterasoftware.Configuracion.frmSelEmpresa oEmpresa = new panterasoftware.Configuracion.frmSelEmpresa(); oEmpresa.Show(); this.Hide(); } else { App_Code.Sistema.Sistema_Empresas oEmpresa = new App_Code.Sistema.Sistema_Empresas(int.Parse(oTabla.Rows[0]["empresa_id"].ToString())); frmPrincipal oPrincipal = new frmPrincipal(); frmPrincipal.id_empresa = oEmpresa.Id; frmPrincipal.codigo = oEmpresa.Codigo; oPrincipal.Show(); this.Hide(); } } } else { MessageBox.Show("Disculpe usuario o contraseña incorrecta", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void Presentar(int id) { App_Code.Sistema.Sistema_Usuarios oRegistro = new App_Code.Sistema.Sistema_Usuarios(id); App_Code.Sistema.Sistema_Grupos oGrupo = new App_Code.Sistema.Sistema_Grupos(oRegistro.GrupoId); this.lblFicha.Text = oRegistro.Id.ToString("0"); this.txtApellidos.Text = oRegistro.Apellido; this.txtNombres.Text = oRegistro.Nombre; this.txtClave.Text = oRegistro.Clave; this.txtRepClave.Text = oRegistro.Clave; this.txtUsuario.Text = oRegistro.Usuario; this.cmbEstatus.Text = oRegistro.Estatus; this.BuscarAsignados(); this.txtUsuario.BackColor = Color.White; this.txtNombres.BackColor = Color.White; this.cmbGrupos.Text = oGrupo.Nombre; oFuncion.Leer(panterasoftware.Formularios.frmPrincipal.id_grupo_usuario, "1200304"); if (!oFuncion.Err) { this.btnEliminar.Enabled = true; } }