Beispiel #1
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();
        }
Beispiel #2
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();
        }