Exemplo n.º 1
0
        private void Btn_DeleteUser_Click(object sender, RoutedEventArgs e)
        {
            var resultMsg = MessageBox.Show("Selected user will delete.\n\nAre you sure?", "Delete User", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (resultMsg == MessageBoxResult.Yes)
            {
                var result = db.DeleteUser((long)cb_users.SelectedValue);
                switch (result)
                {
                case 1:
                    notifyCall = new NotificationPanelCall("Delete User", "Successfully deleted", StatusColor.Success, 3);
                    UnloadAllFields();
                    cb_users.SelectedIndex = -1;
                    LoadUsers();
                    cb_users.IsEnabled     = true;
                    wp_editPanel.IsEnabled = false;
                    break;

                case 0:
                    notifyCall = new NotificationPanelCall("Error", "User not found", StatusColor.Error, 3);
                    CustomAnimations.ShakeAnimation(this);
                    break;

                case -1:
                    notifyCall = new NotificationPanelCall("Error", "Something went wrong", StatusColor.Error, 3);
                    CustomAnimations.ShakeAnimation(this);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void baseView_Loaded(object sender, RoutedEventArgs e)
        {
            var billsCordination    = GetRectangle(heading_Bills, baseView);
            var foodCordination     = GetRectangle(heading_FoodBills, baseView);
            var creditCordination   = GetRectangle(heading_creditCards, baseView);
            var expectedCordination = GetRectangle(heading_expectedBills, baseView);

            _animations = new CustomAnimations(billsCordination, expectedCordination, creditCordination, foodCordination);
        }
Exemplo n.º 3
0
        private void Btn_signIn(object sender, RoutedEventArgs e)
        {
            userRecord = new User();
            db         = new core.DB();

            #region user data transfer to MainWindow

            mainWindow = (IUserInfoTransfer)Application.Current.MainWindow;
            if (txt_uName.Text != "" && txt_uPass.Password != "")
            {
                if (db.SignIn(txt_uName.Text, txt_uPass.Password, out userRecord))
                {
                    mainWindow.Transfer(userRecord);
                    notifyCall = new NotificationPanelCall("Login", "Successfully logged in", StatusColor.Success, 3);
                    RemoveThis();
                }
                else
                {
                    lbl_WarningMessage.Visibility = Visibility.Hidden;

                    CustomAnimations.ShakeAnimation(this);
                    if (MainWindow.dataContextMainWindow.UserInfo.Authorization != 0)
                    {
                        mainWindow.Transfer(new User()
                        {
                            User_ID = 0, UserName = "******", Authorization = 0, SuperUser = false
                        });                                                                                                   // Default Data Transfer
                        notifyCall = new NotificationPanelCall("Invalid User", "Username or password is wrong. (+) Current session closed", StatusColor.Warning, 3);
                    }
                    else
                    {
                        notifyCall = new NotificationPanelCall("Invalid User", "Username or password is wrong", StatusColor.Error, 3);
                    }

                    txt_uPass.Password = "";
                    txt_uPass.Focus();
                }
            }
            else
            {
                lbl_WarningMessage.Content    = "fields should not be null";
                lbl_WarningMessage.Visibility = Visibility.Visible;
            }
            #endregion
        }
Exemplo n.º 4
0
        private void Btn_SaveMyProfil_Click(object sender, RoutedEventArgs e)
        {
            lbl_WarningMessage.Content    = "fields should not be empty";
            lbl_WarningMessage.Visibility = CheckEmpty() ? Visibility.Visible : Visibility.Hidden;

            if (!CheckEmpty())
            {
                var currentPass = txt_CurrentUPass_new.Password;
                if (CurrentUser.UserPassword != currentPass)
                {
                    lbl_WarningMessage.Content    = "current password is faulty";
                    lbl_WarningMessage.Visibility = Visibility.Visible;
                    txt_CurrentUPass_new.Password = "";
                    txt_CurrentUPass_new.Focus();
                }
                else
                {
                    if (PassDontMatch())
                    {
                        lbl_WarningMessage.Content    = "passwords do not match";
                        lbl_WarningMessage.Visibility = txt_uPass_new.Password != txt_RuPass_new.Password ? Visibility.Visible : Visibility.Hidden;
                        CustomAnimations.ShakeAnimation(this);
                        txt_RuPass_new.Password = "";
                        txt_RuPass_new.Focus();
                    }
                    else
                    {
                        User user = new User
                        {
                            User_ID       = CurrentUser.User_ID,
                            UserName      = txt_uName_new.Text,
                            UserPassword  = (txt_uPass_new.Password != "") ? txt_uPass_new.Password : CurrentUser.UserPassword,
                            SuperUser     = false,
                            Enable        = true,
                            Authorization = CurrentUser.Authorization,
                            Email         = txt_eMail_new.Text,
                            Name          = txt_name_new.Text,
                            SecondName    = txt_secondName_new.Text,
                            Surname       = txt_surname_new.Text,
                            Title         = txt_title_new.Text,
                            Position      = txt_position_new.Text,
                            PhotoAddress  = "",
                            CardID        = txt_cardID_new.Text,
                            DateTime      = CurrentUser.DateTime
                        };

                        using (db = new DB("UsersDB", ""))
                        {
                            var result = db.UpdateUser(ref user, CurrentUser.User_ID);
                            switch (result)
                            {
                            case 1:
                                notifyCall = new NotificationPanelCall("Update User", "Successfully updated", StatusColor.Success, 3);
                                RemoveThis();
                                txt_CurrentUPass_new.Password = "";
                                // UnloadAllFields();
                                break;

                            case 0:
                                notifyCall = new NotificationPanelCall("Error", "Something went wrong", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                break;

                            case -1:
                                notifyCall = new NotificationPanelCall("Error", "User is not found", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                txt_uName_new.Text = "";
                                txt_uName_new.Focus();
                                break;

                            case -2:
                                notifyCall = new NotificationPanelCall("Error", "Same User already exist", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                txt_uName_new.Text = "";
                                txt_uName_new.Focus();
                                break;

                            default:
                                CustomAnimations.ShakeAnimation(this);
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                CustomAnimations.ShakeAnimation(this);
                txt_CurrentUPass_new.Focus();
            }
        }
Exemplo n.º 5
0
        private void Btn_SaveUser_Click(object sender, RoutedEventArgs e)
        {
            lbl_WarningMessage.Content    = "fields should not be empty";
            lbl_WarningMessage.Visibility = CheckEmpty() ? Visibility.Visible : Visibility.Hidden;

            if (!CheckEmpty())
            {
                var currentPass = core.CryptorEngine.Encrypt(txt_CurrentUPass_new.Password, true);
                if (CurrentUser.UserPassword != currentPass)
                {
                    lbl_WarningMessage.Content    = "your password is faulty";
                    lbl_WarningMessage.Visibility = Visibility.Visible;
                    txt_CurrentUPass_new.Password = "";
                    txt_CurrentUPass_new.Focus();
                }
                else
                {
                    if (PassDontMatch())
                    {
                        lbl_WarningMessage.Content    = "passwords do not match";
                        lbl_WarningMessage.Visibility = txt_uPass_new.Password != txt_RuPass_new.Password ? Visibility.Visible : Visibility.Hidden;
                        CustomAnimations.ShakeAnimation(this);
                        txt_RuPass_new.Password = "";
                        txt_RuPass_new.Focus();
                    }
                    else
                    {
                        User user = new User
                        {
                            User_ID       = SelectedUser.User_ID,
                            UserName      = txt_uName_new.Text,
                            UserPassword  = txt_uPass_new.Password,
                            SuperUser     = false,
                            Enable        = true,
                            Authorization = (short)cb_auth_new.SelectedValue,
                            Email         = txt_eMail_new.Text,
                            Name          = txt_name_new.Text,
                            SecondName    = txt_secondName_new.Text,
                            Surname       = txt_surname_new.Text,
                            Title         = txt_title_new.Text,
                            Position      = txt_position_new.Text,
                            PhotoAddress  = "",
                            CardID        = txt_cardID_new.Text,
                            DateTime      = DateTime.Now
                        };

                        using (db = new core.DB())
                        {
                            var result = (int)db.UpdateUser(user);
                            switch (result)
                            {
                            case 1:
                                notifyCall = new NotificationPanelCall("Update User", "Successfully updated", StatusColor.Success, 3);
                                RemoveThis();
                                txt_CurrentUPass_new.Password = "";
                                Btn_CancelUpdate_Click(sender, e);
                                LoadUsers();
                                break;

                            case 0:
                                notifyCall = new NotificationPanelCall("Error", "Something went wrong", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                break;

                            case -1:
                                notifyCall = new NotificationPanelCall("Error", "User is not found", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                txt_uName_new.Text = "";
                                txt_uName_new.Focus();
                                break;

                            case -2:
                                notifyCall = new NotificationPanelCall("Error", "Same User already exist", StatusColor.Error, 3);
                                CustomAnimations.ShakeAnimation(this);
                                txt_uName_new.Text = "";
                                txt_uName_new.Focus();
                                break;

                            default:
                                CustomAnimations.ShakeAnimation(this);
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                CustomAnimations.ShakeAnimation(this);
            }
        }
Exemplo n.º 6
0
        private void Btn_CreateUser_Click(object sender, RoutedEventArgs e)
        {
            lbl_WarningMessage.Content    = "fields should not be empty";
            lbl_WarningMessage.Visibility = CheckEmpty() ? Visibility.Visible : Visibility.Hidden;

            if (!CheckEmpty())
            {
                if (txt_uPass_new.Password != txt_RuPass_new.Password)
                {
                    lbl_WarningMessage.Content    = "passwords do not match";
                    lbl_WarningMessage.Visibility = txt_uPass_new.Password != txt_RuPass_new.Password ? Visibility.Visible : Visibility.Hidden;
                    CustomAnimations.ShakeAnimation(this);
                }
                else
                {
                    User user = new User
                    {
                        UserName      = txt_uName_new.Text,
                        UserPassword  = txt_uPass_new.Password,
                        SuperUser     = false,
                        Enable        = true,
                        Authorization = (short)cb_auth_new.SelectedValue,
                        Email         = txt_eMail_new.Text,
                        Name          = txt_name_new.Text,
                        SecondName    = txt_secondName_new.Text,
                        Surname       = txt_surname_new.Text,
                        Title         = txt_title_new.Text,
                        Position      = txt_position_new.Text,
                        PhotoAddress  = "",
                        CardID        = txt_cardID_new.Text,
                        DateTime      = DateTime.Now
                    };

                    using (db = new core.DB())
                    {
                        var result = db.AddUser(user);
                        switch (result)
                        {
                        case 1:
                            notifyCall = new NotificationPanelCall("Create User", "Successfully created", StatusColor.Success, 3);
                            RemoveThis();
                            UnloadAllFields();
                            break;

                        case 0:
                            notifyCall = new NotificationPanelCall("Error", "Something went wrong", StatusColor.Error, 3);
                            CustomAnimations.ShakeAnimation(this);
                            break;

                        case -1:
                            notifyCall = new NotificationPanelCall("Error", "Same User already exist", StatusColor.Error, 3);
                            CustomAnimations.ShakeAnimation(this);
                            txt_uName_new.Text = "";
                            txt_uName_new.Focus();
                            break;

                        default:
                            CustomAnimations.ShakeAnimation(this);
                            break;
                        }
                    }
                }
            }
            else
            {
                CustomAnimations.ShakeAnimation(this);
            }
        }