Пример #1
0
        private void bT709ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 bt709Formu = new Form3();

            bt709Formu.ShowDialog();
        }
Пример #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            Form3 f = new Form3();

            f.ShowDialog();
        }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            errorTime = errorTime - 1;
            string username = txtName.Text.Trim(); //取出账号
            string pw       = txtPwd.Text.Trim();  //取出密码
            string str      = "Server=(local)\\mysql;DataBase=TestData; Integrated Security=True";

            if (radioButton1.Checked == true)
            {
                try
                {
                    SqlConnection con = new SqlConnection(str);                                                         //实例化链接
                    con.Open();                                                                                         //开启连接
                    string         s1  = "select * from Suser where name='" + username + "' and password='******'"; //编写SQL命令
                    SqlCommand     cmd = new SqlCommand(s1, con);
                    SqlDataAdapter ada = new SqlDataAdapter(cmd);
                    ada.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    int     n  = ada.Fill(ds); //查询结果填充数据集
                                               //ada.Fill(ds, "user");//将结果放入数据适配器,返回元素个数
                    if (n != 0)
                    {
                        num = int.Parse(ds.Tables[0].Rows[0]["num"].ToString());
                        this.Hide();
                        Form3 form3 = new Form3();
                        form3.ShowDialog();
                        // MessageBox.Show("欢迎使用!");             //登录成功
                    }
                    else
                    if (errorTime < 3)
                    {
                        MessageBox.Show("用户名或密码有错。请重新输入!还有" + errorTime.ToString() + "次机会");
                        txtName.Text = "";   //清空账号
                        txtPwd.Text  = "";   //清空密码?
                        txtName.Focus();     //光标设置在账号上
                    }
                    else
                    {
                        MessageBox.Show("你输入的用户名或密码已达三次? 将退出程序");
                        this.Close();
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
            if (radioButton2.Checked == true)
            {
                try
                {
                    SqlConnection con = new SqlConnection(str);                                                                   //实例化链接
                    con.Open();                                                                                                   //开启连接
                    string         s1  = "select num,password from Tuser where num='" + username + "' and password='******'"; //编写SQL命令
                    SqlCommand     cmd = new SqlCommand(s1, con);
                    SqlDataAdapter ada = new SqlDataAdapter(cmd);
                    ada.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    ada.Fill(ds);                  //查询结果填充数据集
                    int n = ada.Fill(ds, "Tuser"); //将结果放入数据适配器,返回元素个数
                    if (n != 0)
                    {
                        this.Visible = false;
                        Form4 form4 = new Form4();
                        form4.ShowDialog();
                        // MessageBox.Show("欢迎使用!");             //登录成功
                        this.Hide();
                        this.Visible = true;
                    }
                    else
                    if (errorTime < 3)
                    {
                        MessageBox.Show("用户名或密码有错。请重新输入!还有" + errorTime.ToString() + "次机会");
                        txtName.Text = "";   //清空账号
                        txtPwd.Text  = "";   //清空密码?
                        txtName.Focus();     //光标设置在账号上
                    }
                    else
                    {
                        MessageBox.Show("你输入的用户名或密码已达三次? 将退出程序");
                        this.Close();
                    }
                    con.Close();
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
Пример #4
0
 private void поискToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Act = "поиск";
     form3.ShowDialog();
 }
Пример #5
0
        private void ContextMenuStrip3_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            TreeNode      CurSelectedNode = treeView1.SelectedNode;
            ToolStripItem Item1           = e.ClickedItem;
            var           plc             = pmg.FindPLCByName(CurSelectedNode.Name);


            if (Item1.Equals(this.contextMenuStrip3.Items[3]))
            {
                Form3 AddvarDlg = new Form3(this);

                if (AddvarDlg.ShowDialog() == DialogResult.OK)
                {
                    MessageBox.Show("新增PLC变量成功");
                }
                else
                {
                    MessageBox.Show("取消增加PLC变量");
                }
                AddvarDlg.Close();
            }
            if (Item1.Equals(this.contextMenuStrip3.Items[1]))
            {
                try
                {
                    plc.Open();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                    //throw;
                }
                if (plc.IsConnected)
                {
                    plc.CycleTimer.Enabled = true;
                    plc.Node.BackColor     = Color.Blue;
                }
                else
                {
                    MessageBox.Show(string.Format($"{0} is not connected yet", plc.name));
                }


                return;
            }
            if (Item1.Equals(this.contextMenuStrip3.Items[2]))
            {
                if (plc.IsConnected)
                {
                    plc.CycleTimer.Enabled = false;
                    plc.Close();
                    plc.Node.BackColor = Color.Black;
                    MessageBox.Show("PLC has been closed!");
                }
                else
                {
                    MessageBox.Show(string.Format($"{0} is not connected yet", plc.name));
                }
            }
            if (Item1.Equals(this.contextMenuStrip3.Items[0]))
            {
                if (plc.IsConnected)
                {
                    MessageBox.Show("请断开当前PLC!");
                    return;
                }
                else
                {
                    CurSelectedNode.Nodes.Remove(plc.Node);
                    Pmg.del(plc);
                    MessageBox.Show(string.Format($"PLC{0}已被删除", plc.name));
                    plc = null;
                    return;
                }
            }
        }
Пример #6
0
        private void button4_Click_2(object sender, EventArgs e)
        {
            Form form = new Form3(whitelist);

            form.ShowDialog(this);
        }
Пример #7
0
        private void Button2_Click(object sender, EventArgs e)
        {
            var form3 = new Form3();

            form3.ShowDialog();
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form3 Ayuda = new Form3();

            Ayuda.ShowDialog();
        }