Example #1
0
        public List <ManageAccounts> GetAll()
        {
            List <ManageAccounts> Accounts = new List <ManageAccounts>();

            SqlCommand command = new SqlCommand("GetDetailAccounts", connection);

            command.CommandType = CommandType.StoredProcedure;

            using (SqlDataReader dataReader = command.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    var            currentRow = dataReader;
                    ManageAccounts accounts   = new ManageAccounts();
                    accounts.Id       = (int)currentRow["Id"];
                    accounts.Name     = currentRow["username"].ToString();
                    accounts.Password = currentRow["password"].ToString();
                    accounts.Role_id  = (int)currentRow["role_id"];

                    Accounts.Add(accounts);
                }
            }
            return
                (Accounts);
        }
Example #2
0
 public void TestInitialize() // executes once before each test run https://stackoverflow.com/questions/13943078/c-sharp-unit-test-with-common-code-repeated
 {
     _manage            = new ManageAccounts();
     _view              = new MockView();
     _customerPresenter = new CustomerPresenter(_view);
     _accountsPresenter = new AccountsPresenter(_view, _customerPresenter);
 }
        private void metroButton3_Click(object sender, EventArgs e)
        {
            panelEveryThingHolder.Controls.Clear();
            ManageAccounts a = new ManageAccounts();

            panelEveryThingHolder.Controls.Add(a);
        }
        public Admin()
        {
            InitializeComponent();
            panelEveryThingHolder.Controls.Clear();
            ManageAccounts a = new ManageAccounts();

            panelEveryThingHolder.Controls.Add(a);
        }
        public ActionResult Edit(ManageAccounts accounts, int id)
        {
            if (account.Update(accounts, id) >= 1)
            {
                ViewBag.Message = "Account Details Updated Successfully";
                ModelState.Clear();
                return(RedirectToAction("Index"));
            }


            return(View());
        }
Example #6
0
        public int Update(ManageAccounts accounts, int id)
        {
            SqlCommand cmd = new SqlCommand("UpdateAccounts", connection);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@1", accounts.Name);
            cmd.Parameters.AddWithValue("@2", accounts.Password);
            cmd.Parameters.AddWithValue("@3", accounts.Role_id);

            cmd.Parameters.AddWithValue("@Id", id);

            int i = cmd.ExecuteNonQuery();

            return(i);
        }
        public ActionResult Create(ManageAcountsViewModel accountView)
        {
            ManageAccounts accounts = new ManageAccounts()
            {
                Name     = accountView.Username,
                Password = accountView.Password,
                Role_id  = accountView.Role_id
            };

            account.Create(accounts);


            ViewBag.Message = "Account Details Added Successfully";
            ModelState.Clear();
            return(RedirectToAction("Index"));
        }
Example #8
0
        public int Create(ManageAccounts accounts)
        {
            SqlCommand cmd = new SqlCommand("CreateAccounts", connection);

            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                cmd.Parameters.AddWithValue("@1", accounts.Name);
                cmd.Parameters.AddWithValue("@2", accounts.Password);
                cmd.Parameters.AddWithValue("@3", accounts.Role_id);

                int i = cmd.ExecuteNonQuery();

                return(i);
            }
            finally
            {
                cmd.Dispose();
            }
        }
Example #9
0
        public ManageAccounts GetDetails(int id)
        {
            ManageAccounts accounts = new ManageAccounts();

            SqlCommand command = new SqlCommand("GetDetailAccounts", connection);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@Id", id);
            using (SqlDataReader dataReader = command.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    var currentRow = dataReader;
                    accounts.Id       = (int)currentRow["Id"];
                    accounts.Name     = currentRow["username"].ToString();
                    accounts.Password = currentRow["password"].ToString();
                    accounts.Role_id  = (int)currentRow["role_id"];
                }
                return(accounts);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MessageBoxButton btnC = MessageBoxButton.OK;

                ManageAccounts obj_Manage_Accounts = new ManageAccounts();
                string         singleUsername      = string.Empty;
                string         siglePassword       = string.Empty;
                string         singleproxy         = string.Empty;
                string         path = string.Empty;

                string proxyAddress  = string.Empty;
                string proxyPort     = string.Empty;
                string proxyUserName = string.Empty;
                string proxyPassword = string.Empty;

                singleUsername = txt_AddSingleAccount_Account.Text;
                siglePassword  = txt_AddSingleAccount_Password.Password;

                if (string.IsNullOrEmpty(singleUsername))
                {
                    ModernDialog.ShowMessage("Please Enter Account !", "Message Box ", btnC);

                    txt_AddSingleAccount_Account.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(siglePassword))
                {
                    ModernDialog.ShowMessage("Please Enter Password !", "Message Box ", btnC);

                    txt_AddSingleAccount_Password.Focus();
                    return;
                }

                try
                {
                    proxyAddress = txt_AddSingleAccount_ProxyAddress.Text;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }
                try
                {
                    proxyPort = txt_AddSingleAccount_ProxyPort.Text;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }

                try
                {
                    proxyUserName = txt_AddSingleAccount_ProxyUsername.Text;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }
                try
                {
                    proxyPassword = txt_AddSingleAccount_ProxyPassword.Password;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }

                Qm.AddAccountInDataBase(singleUsername, siglePassword, proxyAddress, proxyPort, proxyUserName, proxyPassword, path);

                obj_Manage_Accounts.LoadAccountsFromDataBase();

                Window parentWindow = (Window)this.Parent;
                parentWindow.Close();
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }