private void btnRegister_Click(object sender, EventArgs e)
        {
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;
            string password2 = txtPassword2.Text;

            Int32.TryParse(txtStaffId.Text, out var staffId);

            //validate all the registration inputs
            bool allInputsValid = ValidateInputs(username, password, password2, staffId);

            if (allInputsValid)
            {
                //if all inputs are validated, send the registration data to the database and add our new account
                var ad      = new AccountsData();
                var account = new AccountBase(username, password, staffId);
                ad.AddAccount(account);

                Dispose();
                Login.Show();

                //user message to let them know their registration was successful
                var message = new UserMessage();
                message.Show("Your account has been successfully created!");
            }
        }
Пример #2
0
 public ActionResult AccountsEdit()
 {
     if (!string.IsNullOrEmpty(Session["username"] as string))
     {
         if (Session["roleid"].ToString() == "1" || Session["roleid"].ToString() == "3")
         {
             try
             {
                 AccountsData    ad       = new AccountsData();
                 List <Accounts> accounts = ad.GetAccountsData();
                 return(View(accounts));
             }
             catch (Exception ex)
             {
                 return(View("Error", ex));
             }
         }
         else
         {
             return(View("Accessdenied"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            var ad      = new AccountsData();
            var sd      = new StaffData();
            var message = new UserMessage();

            bool allInputsValid = ValidateInputs(username, password);        //check all users inputs are valid
            var  accountInfo    = ad.GetAccountPassword(username, password); //get account password from database
            bool passwordMatch  = accountInfo.Item1;                         //return if passwords matched between input and hashed stored password

            Int32.TryParse(accountInfo.Item2, out var staffId);              //get the staffs id that's trying to log in

            if (allInputsValid && passwordMatch)
            {
                //if everything's valid, get all that staffs information, store in a data structure
                var staff = sd.GetStaffInformation(staffId, username, password);
                //reset login data and hide login component
                SetupTextBoxes();
                Hide();
                //bring the logged in menu up, user is now logged in
                var menuInterface = new MenuInterface(staff, this);
                menuInterface.ShowDialog();
            }
            else if (allInputsValid)
            {
                message.Show("Your password does not match the password we have stored for your account.");
            }
        }
Пример #4
0
        //function that checks all controller validation methods and returns results for user message errors
        public bool ValidateInputs(string username, string password)
        {
            var ad                 = new AccountsData();
            var av                 = new AccountValidation();
            var message            = new UserMessage();
            var passwordValidation = av.ValidatePassword(password, password);

            bool uniqueUsername = ad.CheckForExistingUsername(username);
            bool validUsername  = av.ValidateUsername(username);
            bool validPassword  = passwordValidation.Item2;

            //username was invalid
            if (!validUsername)
            {
                message.Show("This is not a valid username, please ensure its at least 3 characters and only letters and numbers");
                return(false);
            }
            //username already exists
            if (uniqueUsername)
            {
                message.Show("This username does not exist, please ensure you're typing it in correctly.");
                return(false);
            }
            //the password input was not valid
            if (!validPassword)
            {
                message.Show("This is not a valid password, please ensure it is at least 6 characters long.");
                return(false);
            }

            return(true);
        }
Пример #5
0
        public string Print()
        {
            AccountsData    ad       = new AccountsData();
            List <Accounts> accounts = ad.GetAccountsData();

            return(new PageOrientations().RenderRazorViewToString(this, "Print", accounts));
        }
        public void ValidatePassword_PasswordLogIn_ReturnsTrue()
        {

            var ad = new AccountsData();
            var accountInfo = ad.GetAccountPassword("admin", "admin123");
            bool passwordMatch = accountInfo.Item1;
            Assert.IsTrue(passwordMatch);
        }
Пример #7
0
        private void AddAccount(bool isSameLevel = true)
        {
            string accountGroupID = AccountGroup_GridView.GetFocusedRow().CastTo <AccountGroup>().AccountGroupID;

            if (string.IsNullOrEmpty(accountGroupID))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000022);
                return;
            }

            Accounts selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>();
            string   parentID;
            byte     level;

            if (selected == null)
            {
                if (!isSameLevel)
                {
                    MessageBoxHelper.ShowErrorMessage("Chưa chọn TK cha.");
                    return;
                }
                else
                {
                    parentID = string.Empty;
                    level    = 1;
                }
            }
            else
            {
                if (isSameLevel)
                {
                    parentID = selected.ParentID;
                    level    = selected.AccountLevel;
                    if (string.IsNullOrEmpty(selected.ParentID))
                    {
                        // nothing
                    }
                    else
                    {
                        accountGroupID = selected.AccountGroupID;
                    }
                }
                else
                {
                    parentID       = selected.AccountID;
                    level          = (byte)(selected.AccountLevel + 1);
                    accountGroupID = selected.AccountGroupID;
                }
            }

            AccountsData.Add(new Accounts
            {
                AccountGroupID = accountGroupID,
                ParentID       = parentID,
                AccountLevel   = level,
                Status         = ModifyMode.Insert
            });
        }
        public async Task WriteAccountsDataAsync(AccountsData data)
        {
            Directory.CreateDirectory(_folderPath);

            using (FileStream fs = new FileStream(_FilePath, FileMode.OpenOrCreate))
                await JsonSerializer.SerializeAsync(fs, data);

            _accountsData = data;
        }
        public bool ValidateInputs(string username, string password, string password2, int staffId)
        {
            var ad                 = new AccountsData();
            var sd                 = new StaffData();
            var av                 = new AccountValidation();
            var message            = new UserMessage();
            var passwordValidation = av.ValidatePassword(password, password2);

            //username validation class methods
            bool uniqueUsername = ad.CheckForExistingUsername(username);
            bool validUsername  = av.ValidateUsername(username);
            //password validation class methods
            bool passwordsEqual = passwordValidation.Item1;
            bool validPassword  = passwordValidation.Item2;
            //staff id validation class methods
            bool validStaffId      = sd.CheckForValidStaffId(staffId);
            bool staffIdHasAccount = sd.CheckIfStaffIdHasAccount(staffId);

            //messages to show user if any of the validations fail
            //username validation messages
            if (!validUsername)
            {
                message.Show("This is not a valid username, please ensure its at least 3 characters and only letters and numbers");
                return(false);
            }
            if (!uniqueUsername)
            {
                message.Show("This username already exists, please choose a different one.");
                return(false);
            }
            //password validation messages
            if (!passwordsEqual)
            {
                message.Show("Your passwords do not match, please ensure you enter the same password both times.");
                return(false);
            }
            if (!validPassword)
            {
                message.Show("This is not a valid password, please ensure it is at least 6 characters long.");
                return(false);
            }
            //staff id validation messages
            if (!validStaffId)
            {
                message.Show("This staff Id is not valid, please ensure it was entered correctly.");
                return(false);
            }
            //staff id already has an account
            if (!staffIdHasAccount)
            {
                message.Show("This staff Id already has an account associated with it, please talk to an administrator.");
                return(false);
            }

            return(true);
        }
Пример #10
0
        public void AccountsData()
        {
            var accountsData = new AccountsData(_jToken);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(123, accountsData.Accounts.First().Id);
                Assert.AreEqual("*****@*****.**",
                                accountsData.Accounts.First().Email);
                Assert.AreEqual("dnsimple-personal",
                                accountsData.Accounts.First().PlanIdentifier);
            });
        }
Пример #11
0
        private void Account_TreeList_ValidateNode(object sender, ValidateNodeEventArgs e)
        {
            Account_TreeList.ClearColumnErrors();

            Accounts       selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>();
            TreeList       view     = sender as TreeList;
            TreeListColumn column;

            if (selected == null)
            {
                return;
            }

            string accountID = selected.AccountID;

            if (string.IsNullOrWhiteSpace(accountID))
            {
                e.Valid = false;
                //Set errors with specific descriptions for the columns
                column = view.Columns[nameof(selected.AccountID)];
                view.SetColumnError(column, BSMessage.BSM000013);
            }

            // Kiểm tra tồn tại trong grid
            if (AccountsData.ToList().Count(o => o.AccountID == accountID) > 1)
            {
                e.Valid = false;
                column  = view.Columns[nameof(selected.AccountID)];
                view.SetColumnError(column, BSMessage.BSM000015);
            }

            if (string.IsNullOrEmpty(selected.AccountName))
            {
                e.Valid = false;
                column  = view.Columns[nameof(selected.AccountName)];
                view.SetColumnError(column, BSMessage.BSM000011);
            }

            if (string.IsNullOrEmpty(selected.AccountGroupID))
            {
                e.Valid = false;
                column  = view.Columns[nameof(selected.AccountGroupID)];
                view.SetColumnError(column, BSMessage.BSM000016);
            }

            if (selected.Status != ModifyMode.Insert)
            {
                selected.Status = ModifyMode.Update;
            }
        }
Пример #12
0
        private void Accounts_Add_Button_Click(object sender, EventArgs e)
        {
            string AccountGroupID = AccountGroup_GridView.GetFocusedRow().CastTo <AccountGroup>().AccountGroupID;

            if (string.IsNullOrEmpty(AccountGroupID))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000009);
                return;
            }

            AccountsData.Add(new Accounts
            {
                AccountGroupID = AccountGroupID,
                Status         = ModifyMode.Insert
            });
        }
Пример #13
0
 public ActionResult AccountsEdit(FormCollection form)
 {
     if (!string.IsNullOrEmpty(Session["username"] as string))
     {
         try
         {
             List <Accounts> accounts = new List <Accounts>();
             for (int i = 1; i <= 12; i++)
             {
                 Accounts account = new Accounts();
                 if (i <= 10)
                 {
                     account.Tenant = form["tenant" + i];
                 }
                 else
                 {
                     account.Tenant = "test";
                 }
                 account.BalanceOverdue    = form["BalanceOverDue" + i];
                 account.NetBalance        = form["netBalance" + i];
                 account.Provision         = form["provision" + i];
                 account.ReceivableBalance = form["ReceivableBalance" + i];
                 account.ThirtyDays        = form["thirtydays" + i];
                 account.SixtyDays         = form["sixtydays" + i];
                 account.NintyDays         = form["nintydays" + i];
                 account.NintyPlusDays     = form["nintyplusdays" + i];
                 account.Comment           = form["comment" + i];
                 account.Action            = form["action" + i];
                 accounts.Add(account);
             }
             AccountsData ad = new AccountsData();
             ad.UpdateAccounts(accounts);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             return(View("Error", ex));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #14
0
 public void GetValue(List <XElement> l)
 {
     if (l != null && l.Count > 0)
     {
         foreach (XElement x in l)
         {
             AccountsData ad = new AccountsData();
             ad.Sno       = x.Attribute("Sno").Value;
             ad.Name      = x.Attribute("Name").Value;
             ad.TaxClass  = x.Attribute("TaxClass").Value;
             ad.Code      = x.Attribute("Code").Value;
             ad.Desc      = x.Attribute("Descr").Value;
             ad.TaxRate   = decimal.Parse(x.Attribute("TaxRate").Value);
             ad.Narration = x.Attribute("Narration").Value;
             adata.Add(ad);
         }
     }
     dgAccountsReport.ItemsSource = adata;
 }
Пример #15
0
 // GET: Accounts
 public ActionResult Index()
 {
     if (!string.IsNullOrEmpty(Session["username"] as string))
     {
         try
         {
             AccountsData    ad       = new AccountsData();
             List <Accounts> accounts = ad.GetAccountsData();
             return(View(accounts));
         }
         catch (Exception ex)
         {
             return(View("Error", ex));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Пример #16
0
 private void BtnDeleteAccounts_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are You Sure Delete Accounts ?", "Delete Accounts", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             System.Data.DataTable dt = new System.Data.DataTable();
             dt.Columns.Add("Username");
             dt.Columns.Add("Password");
             dt.Columns.Add("Validator");
             AccountsList.DataSource = dt;
             AccountsData.Clear();
             TxtCount.Text             = "0";
             this.FlatAlertBox.Visible = false;
             this.FlatAlertBox.kind    = FlatAlertBox._Kind.Success;
             this.FlatAlertBox.Visible = true;
             this.FlatAlertBox.Text    = $"Delete Success.";
             SaveAccounts();
         }
     }
     catch (Exception)
     {
     }
 }
Пример #17
0
        public void BodyGet()
        {
            adata = new ObservableCollection <AccountsData>();
            List <XElement> l   = _viewmodel.GridValidation();
            List <XElement> lst = l.Where(x => x.Attribute("Sno").Value.Equals(_viewmodel.ad.Sno)).ToList();

            if (lst != null && lst.Count != 0)
            {
                foreach (XElement x in lst)
                {
                    AccountsData ad = new AccountsData();
                    //ad.Sno = x.Attribute("Sno").Value;  removed the control from design
                    ad.TaxClass  = x.Attribute("TaxClass").Value;
                    ad.TaxRate   = decimal.Parse(x.Attribute("TaxRate").Value);
                    ad.Narration = x.Attribute("Narration").Value;
                    adata.Add(ad);
                }
            }
            else
            {
                Clear();
            }
            dgBody.ItemsSource = adata;
        }
 public void ValidateUsername_UsernameUnique_ReturnsTrue()
 {
     var ad = new AccountsData();
     bool uniqueUsername = ad.CheckForExistingUsername("69c5c5b711");
     Assert.IsTrue(uniqueUsername);
 }
 public void ValidateUsername_UsernameNotUnique_ReturnsFalse()
 {
     var ad = new AccountsData();
     bool uniqueUsername = ad.CheckForExistingUsername("admin");
     Assert.IsFalse(uniqueUsername);
 }
Пример #20
0
        private Task OnReceive(string message)
        {
            var         jObject    = JObject.Parse(message);
            string      stream     = jObject.Value <string>("stream");
            IStreamData streamData = null;

            if (stream == websocket.stream.Topic.ToTopic(ETopic.Orders))
            {
                streamData = new OrdersData {
                    Orders = JsonConvert.DeserializeObject <Payload <List <Order> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Accounts))
            {
                streamData = new AccountsData {
                    Accounts = JsonConvert.DeserializeObject <Payload <List <Account> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Transfers))
            {
                streamData = JsonConvert.DeserializeObject <Payload <TransfersData> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Trades))
            {
                streamData = new TradesData {
                    Trades = JsonConvert.DeserializeObject <Payload <List <Trade> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MarketDiff))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MarketDiff> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MarketDepth))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MarketDepth> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.KLine))
            {
                streamData = JsonConvert.DeserializeObject <Payload <KLine> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Ticker))
            {
                streamData = JsonConvert.DeserializeObject <Payload <Ticker> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.AllTickers))
            {
                streamData = new AllTickersData {
                    AllTickers = JsonConvert.DeserializeObject <Payload <List <Ticker> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.MiniTicker))
            {
                streamData = JsonConvert.DeserializeObject <Payload <MiniTicker> >(message).Data;
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.AllMiniTickers))
            {
                streamData = new AllMiniTickersData {
                    AllMiniTickers = JsonConvert.DeserializeObject <Payload <List <MiniTicker> > >(message).Data
                };
            }
            else if (stream == websocket.stream.Topic.ToTopic(ETopic.Blockheight))
            {
                streamData = JsonConvert.DeserializeObject <Payload <Blockheight> >(message).Data;
            }
            else
            {
                throw new WebSocketException($"Unhandled topic stream: {stream}");
            }
            StreamData(this, streamData);
            return(Task.CompletedTask);
        }