private void Create()
        {
            newEntity = new InvestorEntity();
            newEntity.UserId = Convert.ToInt32(ddlUser.SelectedValue);
            newEntity.Notes = txtNotes.Text;
            newEntity.Amount = Convert.ToDecimal(txtAmount.Text);

            newService.Save(ActionType.Create, newEntity);

            Response.Redirect("ManageInvestors.aspx");
        }
        private InvestorEntity SetData(DataRow oRow)
        {
            try
            {
                InvestorEntity ent = new InvestorEntity();
                ent.ID = Convert.ToInt32(oRow["id"]);
                ent.UserId = Convert.ToInt32(oRow["user_id"]);
                ent.Amount = Convert.ToDecimal(oRow["amount"]);
                ent.Notes = oRow["notes"].ToString();
                ent.Status = Convert.ToInt32(oRow["status"]);

                return ent;

            }
            catch (Exception ex) { throw ex; }
        }
        public void Save(ActionType type, InvestorEntity ent)
        {
            try
            {

                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    int ret = 0;
                    int typ = (int)type;
                    string sql = "SaveInvestment";
                    string[] asParams;
                    DbType[] atParamTypes;
                    object[] aoValues;

                    asParams = new string[] {   "@actiontype",
                                                "@id",
                                                "@userid",
                                                "@amount",
                                                "@notes",
                                                "@createdby",
                                                "@createddate",
                                                "@updatedby",
                                                "@updateddate"};

                    atParamTypes = new DbType[] {
                                                    DbType.Int16,
                                                    DbType.Int32,
                                                    DbType.Int32,
                                                    DbType.Decimal,
                                                    DbType.String,
                                                    DbType.String,
                                                    DbType.DateTime,
                                                    DbType.String,
                                                    DbType.DateTime };

                    aoValues = new object[] {
                                                typ,
                                                ent.ID,
                                                ent.UserId,
                                                ent.Amount,
                                                ent.Notes,
                                                appUsr.UserName,
                                                DateTime.Now,
                                                appUsr.UserName,
                                                DateTime.Now
                                            };

                    db.ExecuteCommandNonQuery(sql, asParams, atParamTypes, aoValues, out ret, CommandTypeEnum.StoredProcedure);

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public InvestorEntity GetOne(int userId)
        {
            try
            {

                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string sql;
                    int ret = 0;
                    DataTable oTable = new DataTable();
                    sql = "GetInvestment";
                    db.ExecuteCommandReader(sql,
                        new string[] { "@id" },
                        new DbType[] { DbType.Int32 },
                        new object[] { userId },
                        out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    InvestorEntity user = new InvestorEntity();
                    if (oTable.Rows.Count > 0)
                    {
                        DataRow oRow = oTable.Rows[0];
                        user = SetData(oRow);

                    }

                    return user;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Update()
        {
            newEntity = new InvestorEntity();
            newEntity.ID = id;
            newEntity.Notes = txtNotes.Text;
            newEntity.Amount = Convert.ToDecimal(txtAmount.Text);

            newService.Save(ActionType.Update, newEntity);

            Response.Redirect("ManageInvestors.aspx");
        }
        private void PopulateFields(int id)
        {
            newEntity = new InvestorEntity();
            newEntity = newService.GetOne(id);

            UserEntity usrEnt = new UserEntity();
            UserService usrSrv = new UserService();
            usrEnt = usrSrv.GetOne(newEntity.UserId);

            txtAmount.Text = newEntity.Amount.ToString();
            txtNotes.Text = newEntity.Notes;
            ddlUser.SelectedValue = newEntity.UserId.ToString();
        }