Ejemplo n.º 1
0
        //private void LoadContacts()
        //{
        //    SqlConnection con = new SqlConnection(constring);
        //    try
        //    {
        //        con.Open();
        //        string query = "SELECT name FROM Users";
        //        SqlCommand cmd = new SqlCommand(query, con);
        //        cmd.ExecuteNonQuery();

        //        SqlDataAdapter sda = new SqlDataAdapter(cmd);
        //        DataTable dt = new DataTable("Users");
        //        sda.Fill(dt);
        //        ContactsGrid.ItemsSource = dt.DefaultView;
        //        sda.Update(dt);

        //    }
        //    catch(Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //}

        private void getContacts()
        {
            using (SqlConnection con = new SqlConnection(constring))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT username, name FROM Users"))
                {
                    cmd.Connection = con;
                    cmd.Connection.Open();
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        sda.SelectCommand = cmd;
                        DataTable dt = new DataTable();
                        sda.Fill(dt);
                        List <UserItems> uilist = new List <UserItems>();

                        foreach (DataRow dr in dt.Rows)
                        {
                            UserItems ui = new UserItems();
                            ui.name = dr["name"].ToString();
                            ui.user = dr["username"].ToString();
                            uilist.Add(ui);
                        }
                        myContacts.ItemsSource = uilist;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //public DataTable Grouping(string username)
        //{
        //    using (SqlConnection con = new SqlConnection(constring))
        //    {
        //        using (SqlCommand cmd = new SqlCommand("SELECT GroupName FROM UsersGroups WHERE username ="******"SELECT GroupName FROM UsersGroups WHERE username = @user"))
                {
                    cmd.Parameters.AddWithValue("@user", username);
                    cmd.Connection = con;
                    cmd.Connection.Open();
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        sda.SelectCommand = cmd;
                        DataTable dt = new DataTable();
                        sda.Fill(dt);
                        List <UserItems> uilist = new List <UserItems>();

                        foreach (DataRow dr in dt.Rows)
                        {
                            UserItems ui = new UserItems();
                            ui.group = dr["GroupName"].ToString();
                            uilist.Add(ui);
                        }
                        myGroups.ItemsSource = uilist;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void ListViewItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UserItems ui        = myGroups.SelectedItem as UserItems;
            string    groupname = ui.group;
            //if (item != null && item.IsSelected)
            //{
            indivGroup ig = new indivGroup(groupname);

            ig.Show();
            //    group = item.ToString();
            //}
        }
Ejemplo n.º 4
0
        private void getGroupMem(string username, string group)
        {
            string       xml = ms.retrieveGroupMem(group);
            StringReader xr  = new StringReader(xml);
            DataTable    dt  = new DataTable();

            dt.ReadXml(xr);
            List <UserItems> uilist = new List <UserItems>();

            foreach (DataRow dr in dt.Rows)
            {
                UserItems ui = new UserItems();
                ui.user = dr["username"].ToString();
                uilist.Add(ui);
            }
            groupMembers.ItemsSource = uilist;

            //using (SqlConnection con = new SqlConnection(constring))
            //{
            //    using (SqlCommand cmd = new SqlCommand("SELECT username FROM UsersGroups WHERE GroupName = @group"))
            //    {
            //        //cmd.Parameters.AddWithValue("@username", username);
            //        cmd.Parameters.AddWithValue("@group", group);
            //        cmd.Connection = con;
            //        cmd.Connection.Open();
            //        using (SqlDataAdapter sda = new SqlDataAdapter())
            //        {
            //            sda.SelectCommand = cmd;
            //            DataTable dt = new DataTable();
            //            sda.Fill(dt);
            //            List<UserItems> uilist = new List<UserItems>();

            //            foreach (DataRow dr in dt.Rows)
            //            {
            //                UserItems ui = new UserItems();
            //                ui.user = dr["username"].ToString();
            //                uilist.Add(ui);
            //            }
            //            groupMembers.ItemsSource = uilist;
            //        }
            //    }

            //}
        }