private void GetMembers()
 {
     using (MembershipContext db = new MembershipContext())
     {
         try
         {
             var Members = (from allMembers in db.Members select allMembers);
             MemberGridView.DataSource = Members.ToList();
             MemberGridView.DataBind();
         }
         catch
         {
         }
     }
 }
Exemplo n.º 2
0
    private void Bind(int pageIndex)
    {
        try
        {
            using (RockyingDataClassesDataContext db = new RockyingDataClassesDataContext(Utility.ConnectionString))
            {
                string query = "SELECT ID, Email, Createdate, Newsletter, UserType, MemberName, Status, Password " +
                               " FROM Member AS M WHERE UserType <> 1 ";

                if (MemberTypeDropDown.SelectedValue != "")
                {
                    query = string.Format("{0} AND(UserType = {1})", query, MemberTypeDropDown.SelectedValue);
                }

                if (StatusDropDown.SelectedValue != "")
                {
                    query = string.Format("{0} AND(Status = {1})", query, StatusDropDown.SelectedValue);
                }

                if (SubscribeList.SelectedValue != "")
                {
                    query = string.Format("{0} AND(Newsletter = {1})", query, SubscribeList.SelectedValue);
                }

                query = string.Format("{0} ORDER BY CreateDate desc ", query);

                MemberGridView.DataSource = db.ExecuteQuery <Member>(query, new object[] { }).ToList <Member>();
                MemberGridView.PageIndex  = pageIndex;
                MemberGridView.DataBind();
            }
        }
        catch (Exception ex)
        {
            Trace.Write("Unable to fetch member records.");
            Trace.Write(ex.Message);
            Trace.Write(ex.StackTrace);
        }
    }
Exemplo n.º 3
0
        private void ShowData()
        {
            try
            {
                var data = new Anggota_KMB();
                MemberGridView.DataSource = data.RetrievingData();

                MemberGridView.Refresh();
                if (MemberGridView.Columns.Count > 0)
                {
                    MemberGridView.Columns[0].Visible       = false;
                    MemberGridView.Columns[1].AutoSizeMode  = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    MemberGridView.Columns[2].AutoSizeMode  = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    MemberGridView.Columns[3].AutoSizeMode  = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[4].AutoSizeMode  = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[5].AutoSizeMode  = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[6].AutoSizeMode  = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    MemberGridView.Columns[7].AutoSizeMode  = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    MemberGridView.Columns[8].Visible       = false;
                    MemberGridView.Columns[9].AutoSizeMode  = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[10].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[11].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[12].Visible      = false;
                    MemberGridView.Columns[13].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[14].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[15].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[16].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[17].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    MemberGridView.Columns[18].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
                MemberGridView.ClearSelection();
            }
            catch (Exception er)
            {
                Console.WriteLine("ERROR : Anggota_KMB.RetrivingData" + er.Message);
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Gets the default connection string/path to our database from the web.config file
            string dbstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            // Creates a connection to our database
            SqlConnection con = new SqlConnection(dbstring);

            // query
            string sqlStr = "SELECT UserName as 'Member', RoleName as 'Role' FROM aspnet_usersinroles uir, aspnet_roles r, aspnet_users u WHERE uir.userid = u.userid and uir.roleid = r.roleid";

            // Open the database connection
            con.Open();

            // Create an executable SQL command containing our SQL statement and the database connection
            SqlCommand sqlCmd = new SqlCommand(sqlStr, con);


            // Fill in the parameters in our prepared SQL statement
            sqlCmd.Parameters.AddWithValue("@username", User.Identity.Name);

            // Adapt the data from the SQL query in order to populate the GridView
            SqlDataAdapter adapter   = new SqlDataAdapter(sqlCmd);
            DataTable      datatable = new DataTable();

            adapter.Fill(datatable);

            // Add a new column to the DataTable to add the buttons to allow the administrator to modify a user
            datatable.Columns.Add(new DataColumn("Edit", typeof(string)));

            MemberGridView.DataSource = datatable;
            MemberGridView.DataBind();
            con.Close();

            AssignClassesToRow();
        }