Пример #1
0
        private void bgLoadSession_DoWork(object sender, DoWorkEventArgs e)
        {
            tecnicos objLong = (tecnicos)e.Argument;

            userObj  = daoPer.LoginUser(objLong);
            e.Result = userObj;
        }
Пример #2
0
        private void BtnIniciar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.txtNombreUser.Text.Length > 0)
                {
                    if (this.txtPassUser.Password.Length > 0)
                    {
                        this.PBarLogin.Visibility = System.Windows.Visibility.Visible;
                        EnabledComponents(false);
                        tecnicos login = new tecnicos()
                        {
                            usuario  = txtNombreUser.Text.ToString().Trim(),
                            password = txtPassUser.Password.ToString().Trim()
                        };

                        //Comienza el worker
                        bwLogin.RunWorkerAsync(login);
                    }
                    else
                    {
                        MessageBox.Show("Escriba Password", "Login");
                        this.txtPassUser.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error en inicio de sesión: " + ex.Message);
            }
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.txtUser.Text.Length > 0)
         {
             if (this.txtPass.Text.Length > 0)
             {
                 splash.Show();
                 enabledComponents(false);
                 tecnicos login = new tecnicos()
                 {
                     usuario  = txtUser.Text.ToString().Trim(),
                     password = txtPass.Text.ToString().Trim()
                 };
                 //Comienza el worker
                 bgLoadSession.RunWorkerAsync(login);
             }
             else
             {
                 MessageBox.Show("Escriba Password", "Login");
                 this.txtPass.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en inicio de sesión: " + ex.Message);
     }
 }
Пример #4
0
        public tecnicos GetUser(int id)
        {
            tecnicos uslog = new tecnicos();

            try
            {
                using (var context = new MttoAppEntities())
                {
                    // Query for all
                    var als = from b in context.tecnicos
                              where b.Id == id
                              select b;

                    var item = als.FirstOrDefault();
                    if (item != null)
                    {
                        uslog.Id       = item.Id;
                        uslog.Nombre   = item.Nombre;
                        uslog.usuario  = item.usuario;
                        uslog.password = item.password;
                        uslog.activo   = item.activo;
                        uslog.id_rol   = item.id_rol;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Excepción al consultar usuario usuario: " + e,
                                "Atención", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(uslog);
        }
Пример #5
0
        private void LoginWork(object sender, DoWorkEventArgs e)
        {
            tecnicos objLong = (tecnicos)e.Argument;
            int      pilar   = 0;

            if (Global.Modulo == 1)
            {
                pilar = 101;
            }
            if (Global.Modulo == 2)
            {
                pilar = 102;
            }

            userObj  = daoPer.LoginUser(objLong, pilar);
            e.Result = userObj;
        }
Пример #6
0
        private void LoginComplete(object sender, RunWorkerCompletedEventArgs e)
        {
            tecnicos usCompl = (tecnicos)e.Result;

            if (usCompl.Id > 0)
            {
                Global.UserLoged = usCompl;


                switch (Global.Modulo)
                {
                case 1:
                    Vistas.SubMenu menu = new Vistas.SubMenu();
                    menu.Show();
                    menu.BringToFront();
                    break;

                case 2:
                    Vistas.FormSop sop = new Vistas.FormSop();
                    sop.Show();
                    sop.BringToFront();
                    break;

                default:
                    break;
                }


                this.FormsWindow.Close();
                GC.Collect();
            }
            else
            {
                MessageBox.Show(
                    "Error al iniciar sesión, usuario no reconocido!",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
            }

            EnabledComponents(true);
            this.PBarLogin.Visibility = System.Windows.Visibility.Hidden;
        }
Пример #7
0
        public int EditTecnico(tecnicos tec)
        {
            tecnicos tece;

            int regs = 0;

            try
            {
                //1. Get row from DB
                using (var context = new MttoAppEntities())
                {
                    tece = context.tecnicos.Where(s => s.Id == tec.Id).FirstOrDefault();
                }

                //2. change data in disconnected mode (out of ctx scope)
                if (tece != null)
                {
                    tece.usuario  = tec.usuario;
                    tece.password = tec.password;
                    tece.id_rol   = tec.id_rol;
                    tece.activo   = tec.activo;
                }

                //save modified entity using new Context
                using (var context = new MttoAppEntities())
                {
                    //3. Mark entity as modified
                    context.Entry(tece).State = System.Data.Entity.EntityState.Modified;

                    //4. call SaveChanges
                    regs = context.SaveChanges();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Excepción al editar técnico: " + e.ToString(), "Atención", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(regs);
        }
Пример #8
0
        public tecnicos LoginUser(tecnicos u, int pilar)
        {
            tecnicos uslog = new tecnicos();

            try
            {
                using (var context = new MttoAppEntities())
                {
                    string passMD5 = SomeHelpers.CalculateMD5Hash(u.password);

                    // Query for all
                    var als = from b in context.tecnicos
                              where b.usuario.Equals(u.usuario) &&
                              b.password.Equals(passMD5) &&
                              b.tipo_usuario == pilar
                              select b;

                    var item = als.FirstOrDefault();

                    if (item != null)
                    {
                        uslog.Id       = item.Id;
                        uslog.Nombre   = item.Nombre;
                        uslog.usuario  = item.usuario;
                        uslog.password = item.password;
                        uslog.activo   = item.activo;
                        uslog.id_rol   = item.id_rol;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Excepción al iniciar sesión con usuario: " + e,
                                "Atención", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(uslog);
        }