Пример #1
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            string connect = "Server=127.0.0.1;port=3306;Database=phplogin;Uid = root;password = amber";
            MySqlConnection com = new MySqlConnection(connect);
            MySqlCommand Comanda = com.CreateCommand();
            Comanda.CommandText = "Select * from comments where user ='******' order by id ASC";
            com.Open();
            bool k = false;
            bool l = false;
            MySqlDataReader row = Comanda.ExecuteReader();
            while (row.Read())
            {
                sender = row["sender"].ToString();
                DateTime dat = Convert.ToDateTime(row["date"].ToString());
                if (DateTime.Compare(dat, data) > 0)
                {
                        foreach (Form OpenForm in Application.OpenForms)
                        {
                            if (OpenForm.Text == row["sender"].ToString())
                            {
                                l = true;
                                Form4 b = (Form4)OpenForm;
                                b.timer1.Enabled = true;
                                b.datatext = "aa";
                            }
                        }
                        if (l == false)
                        {

                            Form4 f3 = new Form4();
                            f3.conectare(a, row["sender"].ToString(), row["text"].ToString());
                            f3.Show();

                        }
                        k = true;

                }
            }
            com.Close();
            if (k == true)
            {
                data = DateTime.Now;

            }
        }
Пример #2
0
        private void panel_DClick(string user, string receiver)
        {
            bool l = false;
            foreach (Form OpenForm in Application.OpenForms)
            {
                if (OpenForm.Text == receiver)
                {
                    l = true;
                    Form4 b = (Form4)OpenForm;
                    b.Focus();
                }
            }
            if (l == false)
            {

                Form4 f2 = new Form4();
                f2.conectare(user, receiver , "");
                f2.datatext = "";
                f2.Show();

            }
        }