Пример #1
0
        private void btnRegUser_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var IdEmployee = cboEmployees.SelectedIndex + 1;
                var IdRoles    = cboRoleAcc.SelectedIndex + 1;
                var IdStatus   = cboStatusAcc.SelectedIndex + 1;
                var newUser    = new Login_FT
                {
                    Login_name        = txtUser.Text,
                    Login_pass        = txtPass.Password,
                    Roles             = IdRoles,
                    IsActive          = IdStatus,
                    Registration_date = DateTime.Now.Date,
                    Id_employee       = IdEmployee,
                    Question          = txtQuest.Text,
                    Answer            = txtAmwser.Password
                };
                LoginBL.GetInstance().RegisterUserLogin(newUser);
                MessageBoxRM.Show("Empleado Registrado correctamente!", "Registrado!", MessageBoxButtonRM.OK, MessageBoxIconRM.Information);

                txtUser.Clear();
                txtPass.Clear();
                txtPass2.Clear();
                txtQuest.Clear();
                txtAmwser.Clear();
                cboEmployees.SelectedIndex = -1;
                cboRoleAcc.SelectedIndex   = -1;
                cboStatusAcc.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBoxRM.Show(ex.InnerException.Message, "Ha ocurrido un error :(", MessageBoxButtonRM.OK, MessageBoxIconRM.Error);
            }
        }
Пример #2
0
 public void RegisterUserLogin(Login_FT objuser)
 {
     using (var en = new DB_SystemFoodTrucksEntities())
     {
         en.Login_FT.Add(objuser);
         en.SaveChanges();
     }
 }
Пример #3
0
        public Login_FT GetLoginsDetail(Login_FT login_FT)
        {
            using (var en = new DB_SystemFoodTrucksEntities())
            {
                var query = en.Login_FT.FirstOrDefault(x => x.Id == login_FT.Id);

                return(query);
            }
        }
Пример #4
0
 public void UpdateUser(Login_FT login_)
 {
     using (var en = new DB_SystemFoodTrucksEntities())
     {
         var userLogin_bd = en.Login_FT.FirstOrDefault(x => x.Id == login_.Id);
         en.Entry(userLogin_bd).State = EntityState.Modified;
         en.Entry(userLogin_bd).CurrentValues.SetValues(login_);
         en.SaveChanges();
     }
 }
Пример #5
0
        public bool chackIsActive(Login_FT login_FT)
        {
            bool isActive = false;

            using (var en = new DB_SystemFoodTrucksEntities())
            {
                var query = en.Login_FT.FirstOrDefault(x => x.Login_name == login_FT.Login_name);
                if (query.IsActive == 1)
                {
                    isActive = true;
                }
                return(isActive);
            }
        }
Пример #6
0
        private void btnUpdateUser_Click(object sender, RoutedEventArgs e)
        {
            var editUser = new Login_FT
            {
                Id          = cboUser.SelectedIndex + 1,
                Login_name  = txtUserUpdate.Text,
                Login_pass  = txtPassUpdate.Password,
                Question    = txtQuestUpdate.Text,
                Answer      = txtAmwserUpdate.Password,
                IsActive    = cboStatusAccUpdate.SelectedIndex + 1,
                Roles       = cboRolesUpdate.SelectedIndex + 1,
                Id_employee = idEmployeeUpdate
            };

            try
            {
                if (txtPassUpdate.Password == txtPass2Update.Password)
                {
                    LoginBL.GetInstance().UpdateUser(editUser);
                    cboUser.SelectedIndex            = -1;
                    cboStatusAccUpdate.SelectedIndex = -1;
                    cboRolesUpdate.SelectedIndex     = -1;
                    txtUserUpdate.Clear();
                    txtPassUpdate.Clear();
                    txtPass2Update.Clear();
                    txtQuestUpdate.Clear();
                    txtAmwserUpdate.Clear();
                    MessageBoxRM.Show("Usuario actualizado correctamente!", "Actualizacion Usuario", MessageBoxButtonRM.OK, MessageBoxIconRM.Information);
                }
                else
                {
                    ToolTip toolTip = new ToolTip();
                    toolTip.PlacementTarget = txtPass2Update;
                    txtPass2Update.ToolTip  = toolTip;
                    toolTip.Content         = "La contraseña no coinciden";
                    ToolTipService.SetShowDuration(txtPass2Update, 4000);
                    ToolTipService.SetPlacement(txtPass2Update, System.Windows.Controls.Primitives.PlacementMode.Bottom);
                    txtPass2Update.BorderBrush     = Brushes.Red;
                    txtPass2Update.BorderThickness = new Thickness(1, 1, 1, 1);
                    bdrValidation.Visibility       = Visibility.Visible;
                    validationIcon = bdrValidationIcon.Pass;
                    timer.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBoxRM.Show(ex.InnerException.Message, "Erro al actualizar usuario", MessageBoxButtonRM.OK, MessageBoxIconRM.Error);
            }
        }
Пример #7
0
        public bool checkPassword(Login_FT loginPss)
        {
            bool passCorrect = false;

            using (var en = new DB_SystemFoodTrucksEntities())
            {
                var pss   = new getPass();
                var query = en.Login_FT.FirstOrDefault(x => x.Login_name == loginPss.Login_name);
                if (loginPss.Login_pass == query.Login_pass)
                {
                    IdUser      = query.Id;
                    passCorrect = true;
                }
                return(passCorrect);
            }
        }
Пример #8
0
 private void cboUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cboUser.SelectedIndex > -1)
     {
         txtUserUpdate.Text = cboUser.SelectedValue.ToString();
         int idUser    = cboUser.SelectedIndex + 1;
         var userLogin = new Login_FT
         {
             Id = idUser
         };
         Login_FT login_FTs = LoginBL.GetInstance().GetLoginsDetail(userLogin);
         txtPassUpdate.Password           = login_FTs.Login_pass;
         txtPass2Update.Password          = login_FTs.Login_pass;
         cboStatusAccUpdate.SelectedIndex = login_FTs.IsActive - 1;
         cboRolesUpdate.SelectedIndex     = login_FTs.Roles - 1;
         txtQuestUpdate.Text      = login_FTs.Question;
         txtAmwserUpdate.Password = login_FTs.Answer;
         idEmployeeUpdate         = login_FTs.Id_employee;
     }
 }
Пример #9
0
        public bool checkUsername(Login_FT userName)
        {
            bool userExist = false;

            using (var en = new DB_SystemFoodTrucksEntities())
            {
                var query = en.Login_FT.FirstOrDefault(x => x.Login_name == userName.Login_name);
                if (query != null)
                {
                    if (userName.Login_name == query.Login_name)
                    {
                        userExist = true;
                    }
                    else
                    {
                        userExist = false;
                    }
                }
                return(userExist);
            }
        }
Пример #10
0
        public void RunLogin()
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                bool userExist, passCorrect, checkIsActive;
                string user = txtUser.Text;
                string pass = txtPass.Password;


                var queryUserN = new Login_FT
                {
                    Login_name = user,
                    Login_pass = pass
                };

                userExist = LoginBL.GetInstance().checkUsername(queryUserN);

                if (userExist == false)
                {
                    //this.Dispatcher.BeginInvoke(new Action(() =>
                    //{
                    lblWarning.Content    = "Este usuario no existe";
                    lblWarning.Visibility = Visibility.Visible;
                    pgrBar.Visibility     = Visibility.Hidden;
                    //}));
                }
                else
                {
                    //this.Dispatcher.BeginInvoke(new Action(() =>
                    //{
                    lblWarning.Visibility = Visibility.Hidden;
                    //}));

                    passCorrect = LoginBL.GetInstance().checkPassword(queryUserN);
                    var pss     = new LoginBL.getPass();
                    if (passCorrect == false)
                    {
                        //this.Dispatcher.BeginInvoke(new Action(() =>
                        //{
                        lblWarning.Content    = "Este usuario no existe";
                        lblWarning.Visibility = Visibility.Visible;
                        pgrBar.Visibility     = Visibility.Hidden;
                        //}));
                    }
                    else
                    {
                        checkIsActive = LoginBL.GetInstance().chackIsActive(queryUserN);
                        //this.Dispatcher.BeginInvoke(new Action(() =>
                        //{
                        lblWarning.Visibility = Visibility.Hidden;
                        //}));
                        if (ChkSale.IsChecked == true)
                        {
                            if (checkIsActive)
                            {
                                Sales show = new Sales();
                                show.Show();
                                this.Close();
                            }
                            else
                            {
                                MessageBoxRM.Show("Este usuario esta deshabilitado.\nPongase en contacto con el administrador para mas informacion", "Usuario Deshabilitado", MessageBoxButtonRM.OK, MessageBoxIconRM.Warning);
                                //this.Dispatcher.BeginInvoke(new Action(() =>
                                //{
                                pgrBar.Visibility = Visibility.Hidden;
                                //}));
                            }
                        }
                        else if (ChkAdmin.IsChecked == true)
                        {
                            if (checkIsActive)
                            {
                                wAdmin_area show = new wAdmin_area();
                                show.IdUser      = LoginBL.GetInstance().IdUser;
                                show.Show();
                                this.Close();
                            }
                            else
                            {
                                MessageBoxRM.Show("Este usuario esta deshabilitado.\nPongase en contacto con el administrador para mas informacion", "Usuario Deshabilitado", MessageBoxButtonRM.OK, MessageBoxIconRM.Warning);
                                //this.Dispatcher.BeginInvoke(new Action(() =>
                                //{
                                pgrBar.Visibility = Visibility.Hidden;
                                //}));
                            }
                        }
                    }
                }
            }));
        }