Esempio n. 1
0
 public void SetAccountName(List <string> accounttypes)
 {
     foreach (string type in accounttypes)
     {
         Account = (Account_Type)Enum.Parse(typeof(Account_Type), type);
     }
 }
Esempio n. 2
0
        public void EditAccount(Account_Type a)
        {
            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "EditAccountType";
                        var    cmd   = new MySqlCommand(query, connect)
                        {
                            CommandType = CommandType.StoredProcedure
                        };

                        cmd.Parameters.AddWithValue("AccountTypeID", a.ID);
                        cmd.Parameters.AddWithValue("AccountName", a.Name);
                        cmd.Parameters.AddWithValue("PBenifit", a.Benefit);
                        cmd.Parameters.AddWithValue("PCost", a.Cost);

                        cmd.ExecuteNonQuery();

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
        }
Esempio n. 3
0
        public Edit(Account account)
        {
            InitializeComponent();
            this.account         = account;
            cbType.FlatStyle     = FlatStyle.Flat;
            cbType.DataSource    = Account_TypeController.getController().getTypeTable();
            cbType.DisplayMember = "Name";
            cbType.ValueMember   = "ID";
            var info = Account_InfoController.getController().findOneWithType(account.Username);

            if (info != null)
            {
                account_Info     = info.Item1;
                account_Type     = info.Item2;
                tbFirstName.Text = account_Info.First_Name;
                tbLastName.Text  = account_Info.Last_Name;
                tbPhone.Text     = account_Info.Phone;
                rtbAddress.Text  = account_Info.Address;
                rtbNote.Text     = account_Info.Note;
                dtpBd.Value      = account_Info.Birthday;
            }
            else
            {
                tbFirstName.Text = "";
                tbLastName.Text  = "";
                tbPhone.Text     = "";
                rtbAddress.Text  = "";
                rtbNote.Text     = "";
            }
            tbDisplay.Text       = account.Display_Name;
            cbType.SelectedValue = account.Type;
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            String type = textBox1.Text;

            if (type.Trim() == "")
            {
                MessageBox.Show("Không được để trống");
            }
            if (Types.Exists(x => x.Name == type.ToUpper()))
            {
                MessageBox.Show("Đã tồn tại");
            }
            else
            {
                Account_Type at = new Account_Type();
                at.Name = type.ToUpper();
                if (!Account_TypeController.getController().Save(at))
                {
                    MessageBox.Show("Lỗi ");
                }
                else
                {
                    UpdateData();
                }
            }
        }
Esempio n. 5
0
 public User(string username, Account_Type account, string sirname, string Lastname, string steamID, string lolusername, string email)
 {
     this.Username    = username;
     this.Account     = account;
     this.SirName     = sirname;
     this.Lastname    = Lastname;
     this.SteamID     = steamID;
     this.LOLUsername = lolusername;
     this.Email       = email;
 }
Esempio n. 6
0
            public override string ToString()
            {
                StringBuilder MT_Account = new StringBuilder();

                MT_Account.AppendFormat("id = {0}", id)
                .AppendFormat(" | client_id = {0}", client_id)
                .AppendFormat(" | Login ={0}", Login)
                .AppendFormat(" | created_date = {0}", created_date)
                .AppendFormat(" | ftd_date = {0}", ftd_date)
                .AppendFormat(" | deposit_amount = {0}", deposit_amount)
                .AppendFormat(" | withdrawal_amount = {0}", withdrawal_amount)
                .AppendFormat(" | investor_pass = {0}", investor_pass)
                .AppendFormat(" | master_pass = {0}", master_pass)
                .AppendFormat(" | Group = {0}", Group.ToString())
                .AppendFormat(" | Account_Type = {0}", Account_Type.ToString());
                return(MT_Account.ToString());
            }
Esempio n. 7
0
        /* ExecuteSelect function for Account_type  */
        /// <summary>
        /// Retrieves data from Account_Type table and saves in a List.
        /// </summary>
        public List <Account_Type> ExecuteReader_Account_Type(string query, List <MySqlParameter> parameters)
        {
            conn = new MySqlConnection(connectionString);
            comm = new MySqlCommand(query, conn);

            if (parameters.Count() > 0)
            {
                foreach (MySqlParameter p in parameters)
                {
                    comm.Parameters.AddWithValue(p.ParameterName, p.Value);
                }
            }

            List <Account_Type> result = new List <Account_Type>();

            try
            {
                using (MySqlDataReader reader = comm.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Account_Type newEntry = new Account_Type();
                        newEntry.idAccount_Type   = AccountDAO.GetAccountById(reader.GetInt32("idAccount_Type"));
                        newEntry.nameAccount_Type = reader.GetString("nameAccount_Type");
                        result.Add(newEntry);
                    }
                }
            }
            catch (Exception Ex)
            {
                throw new Exception("An error ocurred.Description: " + Ex.Message);
            }
            finally
            {
                conn.Close();
            }

            if (result.Count() > 0)
            {
                return(result);
            }
            return(null);
        }
Esempio n. 8
0
        public List <Account_Type> ListAccounts()
        {
            var accountList = new List <Account_Type>();

            using (connect = new MySqlConnection(_connectionString))
            {
                try
                {
                    string query = "ListAccountType";
                    var    cmd   = new MySqlCommand(query, connect)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    connect.Open();

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        var accountType = new Account_Type();
                        accountType.ID      = int.Parse(reader["Account_Type_ID"].ToString());
                        accountType.Name    = reader["Account_Name"].ToString();
                        accountType.Benefit = reader["Benefit"].ToString();
                        accountType.Cost    = decimal.Parse(reader["Cost"].ToString());



                        accountList.Add(accountType);
                    }

                    connect.Close();
                }
                catch (InvalidOperationException ioException)
                {
                    connect.Close();
                }

                return(accountList);
            }
        }
Esempio n. 9
0
        // Creates an account
        public int create(int accountTypeID, int bankID, int customerID, int contactID)
        {
            // Establishes model
            AccountModel accountModel = new AccountModel();

            // Holds the new account
            Account      newAccount  = new Account();
            Account_Type accountType = new Account_Type();
            Bank         newBank     = new Bank();

            // Stored details for the account
            newAccount.CustomerID    = customerID;
            newAccount.ContactID     = contactID;
            newAccount.AccountTypeID = accountTypeID;
            newAccount.BankID        = bankID;

            // Creates the account
            int accountID = accountModel.CreateAccount(newAccount);

            // Returns accountID
            return(accountID);
        }
Esempio n. 10
0
        public int CreateAccountType(Account_Type a)
        {
            int ret = 0;

            using (connect = new MySqlConnection(_connectionString))
            {
                connect.Open();
                using (MySqlTransaction transaction = connect.BeginTransaction())
                {
                    try
                    {
                        string query = "NewAccountType";
                        var    cmd   = new MySqlCommand(query, connect)
                        {
                            CommandType = CommandType.StoredProcedure
                        };

                        cmd.Parameters.AddWithValue("AccountName", a.Name);
                        cmd.Parameters.AddWithValue("PBenifit", a.Benefit);
                        cmd.Parameters.AddWithValue("PCost", a.Cost);

                        ret = int.Parse(cmd.ExecuteScalar().ToString());

                        transaction.Commit();

                        connect.Close();
                    }
                    catch (InvalidOperationException ioException)
                    {
                        transaction.Rollback();
                        connect.Close();
                    }
                }
            }
            return(ret);
        }
Esempio n. 11
0
        // The main method to get a user account.
        public Account_Type SearchAccountType(int ID)
        {
            var accountT = new Account_Type();

            using (connect = new MySqlConnection(_connectionString))
            {
                try
                {
                    string query = "GetAccountType";
                    var    cmd   = new MySqlCommand(query, connect)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    cmd.Parameters.AddWithValue("AccountTypeID", ID);
                    connect.Open();

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        accountT.ID      = int.Parse(reader["Account_Type_ID "].ToString());
                        accountT.Name    = reader["Account_Name"].ToString();
                        accountT.Benefit = reader["Benefit"].ToString();
                        accountT.Cost    = decimal.Parse(reader["Cost "].ToString());
                    }

                    connect.Close();
                }
                catch (InvalidOperationException ioException)
                {
                    connect.Close();
                }

                return(accountT);
            }
        }
        public Tuple <Account_Info, Account_Type> findOneWithType(String id)
        {
            String query = String.Format(
                @"select  ai.ID as InfoID, ai.First_Name, ai.Last_Name, ai.Birthday, ai.""Address"", ai.Phone, ai.Note, ai.""Image"", 
""at"".ID as 'TypeID', ""at"".""Name"" as 'TypeName'
from dbo.Account a, dbo.Account_Info ai, dbo.Account_Type ""at""
where a.Info = ai.ID and a.""Type"" = ""at"".ID and a.Username = N'{0}'", id);
            var data = DataProvider.getController().ExecuteQuery(query);

            if (data.Rows.Count > 0)
            {
                var          data_row     = data.Rows[0];
                Account_Info account_Info = new Account_Info();
                Account_Type account_Type = new Account_Type();
                account_Info.ID         = (int)data_row.ItemArray[0];
                account_Info.First_Name = data_row.ItemArray[1].ToString();
                account_Info.Last_Name  = data_row.ItemArray[2].ToString();
                account_Info.Birthday   = (DateTime)data_row.ItemArray[3];
                account_Info.Address    = data_row.ItemArray[4].ToString();
                account_Info.Phone      = data_row.ItemArray[5].ToString();
                account_Info.Note       = data_row.ItemArray[6].ToString();
                Bitmap bmp;
                Console.WriteLine(data_row.ItemArray[7].GetType());
                var check = data_row.ItemArray[7].ToString();
                if (check != "")
                {
                    account_Info.Image = HelperUtils.ObjToImg(data_row.ItemArray[7]);
                }

                account_Type.ID = int.Parse(data_row.ItemArray[8].ToString());

                account_Type.Name = data_row.ItemArray[9].ToString();
                return(new Tuple <Account_Info, Account_Type>(account_Info, account_Type));
            }
            return(null);
        }
Esempio n. 13
0
 // Gets a list of accounts by the values speicifed in the account_type object.
 public List <Account> SearchAccounts(Account_Type at)
 {
     throw new NotImplementedException();
 }
Esempio n. 14
0
 public Account_Type SearchAccountType(Account_Type a)
 {
     return(SearchAccountType(a.ID));
 }
 public bool Save(Account_Type at)
 {
     return(Service.save(at));
 }
Esempio n. 16
0
 // Changes the customer specifed by the customer object account type to the Account_Type object.
 public void ChangeAccountType(Customer c, Account_Type type)
 {
     throw new NotImplementedException();
 }