Exemplo n.º 1
0
 private void Main_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         SQLQuery sqlq = new SQLQuery();
         sqlq.SetLogOut(Global.username);
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
        private void PopulateUserList()
        {
            lbUser.Items.Clear();
            SQLQuery      sqlq     = new SQLQuery();
            List <string> Userlist = sqlq.GetLoggedInUserList();

            foreach (string item in Userlist)
            {
                lbUser.Items.Add(item);
            }
        }
Exemplo n.º 3
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            if (txtboxMessage.Text.Trim() == "")
            {
                return;
            }

            SQLQuery sqlq = new SQLQuery();

            sqlq.EnterMessage(txtboxMessage.Text.Trim());
            txtboxMessage.Text = "";
            PopulateRecentMessages((int)(lvMessages.Items[lvMessages.Items.Count - 1].Tag));
            lvMessages.Items[lvMessages.Items.Count - 1].EnsureVisible();
            lastreadMessage = lvMessages.Items.Count - 1;
        }
Exemplo n.º 4
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            PopulateUserList();
            try
            {
                PopulateRecentMessages((int)(lvMessages.Items[lvMessages.Items.Count - 1].Tag));
                if (ApplicationIsActivated() && lastreadMessage != -1)
                {
                    if (lvMessages.Items[lvMessages.Items.Count - 1].Bounds.IntersectsWith(lvMessages.ClientRectangle))
                    {
                        lvMessages.Items[lastreadMessage].EnsureVisible();
                        lastreadMessage = lvMessages.Items.Count - 1;
                    }
                    if (lvMessages.Items[0].Bounds.IntersectsWith(lvMessages.ClientRectangle))
                    {
                        SQLQuery sqlq = new SQLQuery();
                        Global.MessageList.Clear();
                        Global.MessageList.AddRange(sqlq.GetPastMessages((int)lvMessages.Items[0].Tag));

                        foreach (Global.MessageObject value in Global.MessageList)
                        {
                            ListViewItem item = new ListViewItem();
                            item.Tag  = value.MessageID;
                            item.Text = "[" + value.datetime.ToString() + "]";
                            item.Name = "Time";
                            ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(item, "Message");
                            subItem.Name = "Message";
                            subItem.Text = "[" + value.user + "] : " + value.Message;
                            item.SubItems.Add(subItem);
                            lvMessages.Items.Insert(0, item);
                            lastreadMessage++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
        private void Main_Load(object sender, EventArgs e)
        {
            if (!File.Exists("SQLConnectionString.txt"))
            {
                DatabaseInfo getconnStr = new DatabaseInfo();
                getconnStr.ShowDialog();
            }
            else
            {
                Global.connectionStr = File.ReadAllText("SQLConnectionString.txt");
            }

            if (Global.connectionStr == "")
            {
                this.Close();
            }

            Login login = new Login();

            login.ShowDialog();
            if (Global.username == "")
            {
                this.Close();
            }

            timer1.Enabled = true;
            SQLQuery sqlq = new SQLQuery();

            sqlq.SetLogIn(Global.username);
            Global.MessageList = new List <Global.MessageObject>();
            PopulateUserList();
            PopulateRecentMessages();


            this.AcceptButton = btnSend;

            lvMessages.Items[lvMessages.Items.Count - 1].EnsureVisible();
            lastreadMessage = lvMessages.Items.Count - 1;
        }
Exemplo n.º 6
0
        private void BtnCreateNew_Click(object sender, EventArgs e)
        {
            if (txtboxPass.Text.Trim() == "" || txtboxUser.Text.Trim() == "")
            {
                MessageBox.Show("Please enter Username and Password");
                return;
            }

            SQLQuery sqlFunction = new SQLQuery();

            try
            {
                sqlFunction.CreateLogin(txtboxUser.Text, txtboxPass.Text);
                Global.username = txtboxUser.Text;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }