Esempio n. 1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            userDB    = userAdapter.GetData();
            sessionDB = sessionAdapter.GetData();
            if (comboBox1.SelectedIndex == 0)
            {
                var query = from u in userDB
                            where u.OnlineStatus == true
                            join s in sessionDB on u.UserID equals s.UserID into countSes
                            from ses in countSes
                            where ses.StartSession == countSes.Max(r => r.StartSession)
                            select new { UserID = u.UserID, UserName = u.UserName, Password = u.UserPassword, SessionsCount = countSes.Count(), LastEnter = ses.StartSession };


                dataGridViewUsers.DataSource = query.ToList();
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                var query = from u in userDB
                            where u.OnlineStatus == false
                            join s in sessionDB on u.UserID equals s.UserID into countSes
                            from ses in countSes
                            where ses.StartSession == countSes.Max(r => r.StartSession)
                            select new { UserID = u.UserID, UserName = u.UserName, Password = u.UserPassword, SessionsCount = countSes.Count(), LastEnter = ses.StartSession };


                dataGridViewUsers.DataSource = query.ToList();
            }
        }
Esempio n. 2
0
        public Form1()
        {
            InitializeComponent();
            //comboBox1.SelectedIndex = 0;

            chatAdapter    = new MyChatTableAdapters.ChatTableAdapter();
            userAdapter    = new MyChatTableAdapters.UsersTableAdapter();
            sessionAdapter = new MyChatTableAdapters.SessionsLogTableAdapter();

            userDB    = userAdapter.GetData();
            chatDB    = chatAdapter.GetData();
            sessionDB = sessionAdapter.GetData();
        }
Esempio n. 3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            var chatAdapter = new MyChatTableAdapters.ChatTableAdapter();
            var userAdapter = new MyChatTableAdapters.UsersTableAdapter();
            var userDB      = userAdapter.GetData();
            var chatDB      = chatAdapter.GetData();

            var dateStart = DateTime.Parse(dateTimePicker1.Text);
            var dateEnd   = DateTime.Parse(dateTimePicker2.Text);



            if (checkBoxDate.Checked && checkBoxName.Checked)
            {
                var query = from u in userDB
                            where u.UserName == textBox1.Text
                            join m in chatDB on u.UserID equals m.UserID
                            where m.MessageDate >= dateStart && m.MessageDate <= dateEnd
                            select new { UserID = u.UserID, UserName = u.UserName, MessageText = m.MessageText, MessageDate = m.MessageDate };

                dataGridViewChat.DataSource = query.ToList();
            }
            else if (checkBoxDate.Checked && !checkBoxName.Checked)
            {
                var query = from u in userDB
                            join m in chatDB on u.UserID equals m.UserID
                            where m.MessageDate >= dateStart && m.MessageDate <= dateEnd
                            select new { UserID = u.UserID, UserName = u.UserName, MessageText = m.MessageText, MessageDate = m.MessageDate };

                dataGridViewChat.DataSource = query.ToList();
            }
            else if (!checkBoxDate.Checked && checkBoxName.Checked)
            {
                var query = from u in userDB
                            where u.UserName == textBox1.Text
                            join m in chatDB on u.UserID equals m.UserID
                            select new { UserID = u.UserID, UserName = u.UserName, MessageText = m.MessageText, MessageDate = m.MessageDate };

                dataGridViewChat.DataSource = query.ToList();
            }
            this.Close();
        }