//波形1显示按钮    点击
        private void WaveShow1Button_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Enabled == false && pictureBox1.Visible == false)
            {
                pictureBox1.Enabled = true;
                pictureBox1.Visible = true;
                hScrollBar1.Enabled = true;
            }
            if (dataGridView1.Enabled == true && dataGridView1.Visible == true)
            {
                dataGridView1.Visible = false;
                dataGridView1.Enabled = false;
            }
            if (listBox1.SelectedIndex < 0)
            {
                MessageBox.Show("请选择需显示的数据", "请选择数据", MessageBoxButtons.OK);
                return;
            }

            tablename1 = listBox1.SelectedItem.ToString();

            try
            {
                ds.Tables.Add(cm.GetTableValue(tablename1));
            }
            catch (Exception) { }

            SelectShowData(tablename1, ref pictureBox1, ref hScrollBar1, ref wave1_timegap_TrackBar);

            hScrollBar1.Value              = 0;
            hScrollBar1.Enabled            = true;
            wave1_timegap_TrackBar.Enabled = true;
        }
Example #2
0
        private void ChangePasswordButton_Click(object sender, EventArgs e)
        {
            if (ChangePasswordTextbox.Text == "")
            {
                MessageBox.Show("密码只能由字母、数字、点、下划线组成,且不能为空!");
            }
            ShowPasswordTextbox.Enabled = true;
            DataTable dt = new DataTable();
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            int    pkvalue = -1;
            string pkname  = dt.Columns[0].ColumnName;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    pkvalue = Convert.ToInt32(dt.Rows[i][0]);
                    break;
                }
            }
            cm.UpdataDatabass("account", ChangePasswordTextbox.Text, "Password", pkname, pkvalue);
            MessageBox.Show("密码修改成功!");
            ShowPasswordTextbox.Text = ChangePasswordTextbox.Text;
        }
Example #3
0
        private void ShowPasswordButton_Click(object sender, EventArgs e)
        {
            ShowPasswordTextbox.Enabled = true;
            DataTable dt = new DataTable();
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    ShowPasswordTextbox.Text = dt.Rows[i]["Password"].ToString();
                    break;
                }
            }
        }
Example #4
0
        private void ChangeAdminYesRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            int    pkvalue = -1;
            string pkname  = dt.Columns[0].ColumnName;

            if (dt.Rows[0]["Account"].ToString() == UserNameTextbox.Text)
            {
                MessageBox.Show("此默认账户不能被修改!");
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    pkvalue = Convert.ToInt32(dt.Rows[i][0]);
                    break;
                }
            }
            if (ChangeAdminYesRadioButton.Checked)
            {
                cm.UpdataDatabass("Account", "1", "Level", pkname, pkvalue);
            }
            else
            {
                cm.UpdataDatabass("Account", "0", "Level", pkname, pkvalue);
            }
            cm.IsUserAdmin();
            this.Refresh();
            #region 获取所有用户信息
            //获取所有用户信息
            UserListView.BeginUpdate();

            UserListView.View = View.Details;
            UserListView.Clear();
            UserListView.Columns.Add("用户名(双击选择用户)", 200, HorizontalAlignment.Right);
            UserListView.Columns.Add("管理员", 50, HorizontalAlignment.Center);
            UserListView.FullRowSelect = true;

            dt = cm.GetTableValue("Account");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string name;
                ulong  admin;
                name  = (string)dt.Rows[i]["Account"];
                admin = (ulong)dt.Rows[i]["Level"];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = name;
                if (admin == 1)
                {
                    lvi.SubItems.Add("是");
                }
                else
                {
                    lvi.SubItems.Add("否");
                }
                UserListView.Items.Add(lvi);
            }
            UserListView.EndUpdate();
            #endregion
        }
Example #5
0
        // 删除用户按钮   点击
        private void DeletUserButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = new DialogResult();

            dr = MessageBox.Show("确认删除用户 " + UserNameTextbox.Text + "?", "", MessageBoxButtons.YesNo);
            if (dr == DialogResult.No)
            {
                return;
            }
            DataTable dt = new DataTable("Account");
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");
            int    pkvalue = -1;
            string pkname  = dt.Columns[0].ColumnName;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (UserNameTextbox.Text == dt.Rows[i]["Account"].ToString())
                {
                    pkvalue = Convert.ToInt32(dt.Rows[i][0]);
                    break;
                }
            }
            cm.DeletRowfromDatabass("Account", pkname, pkvalue);
            MessageBox.Show("删除用户成功!");

            #region 获取所有用户信息
            //获取所有用户信息
            UserListView.BeginUpdate();

            UserListView.View = View.Details;
            UserListView.Clear();
            UserListView.Columns.Add("用户名(双击选择用户)", 200, HorizontalAlignment.Right);
            UserListView.Columns.Add("管理员", 50, HorizontalAlignment.Center);
            UserListView.FullRowSelect = true;

            dt = cm.GetTableValue("Account");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string name;
                ulong  admin;
                name  = (string)dt.Rows[i]["Account"];
                admin = (ulong)dt.Rows[i]["Level"];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = name;
                if (admin == 1)
                {
                    lvi.SubItems.Add("是");
                }
                else
                {
                    lvi.SubItems.Add("否");
                }
                UserListView.Items.Add(lvi);
            }
            UserListView.EndUpdate();
            #endregion
        }
Example #6
0
        // 添加用户按钮
        private void NewUserAddButton_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable("Account");
            CTMySql   cm = new CTMySql();

            cm.ConnectDatabass();
            dt = cm.GetTableValue("Account");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (NewUserNameTextbox.Text == (string)dt.Rows[i]["Account"])
                {
                    MessageBox.Show("用户已经存在,请更改用户名");
                    return;
                }
            }
            if (NewUserPasswordTextbox.Text == "")
            {
                MessageBox.Show("密码不能为空,请重试");
                return;
            }
            DialogResult dr = DialogResult.Yes;

            if (NewUserAdminYesRadioButton.Checked)
            {
                dr = MessageBox.Show("确定添加的新用户为管理员用户?", "", MessageBoxButtons.YesNo);
            }
            if (dr == DialogResult.No)
            {
                return;
            }
            int level = 0;

            if (NewUserAdminYesRadioButton.Checked)
            {
                level = 1;
            }
            if (NewUserAdminNoRadioButton.Checked)
            {
                level = 0;
            }
            string[] data = new string[3];
            data[0] = NewUserPasswordTextbox.Text;
            data[1] = NewUserNameTextbox.Text;
            data[2] = level.ToString();
            cm.AddRowtoDatabass(data, "Account");

            #region 获取所有用户信息
            //获取所有用户信息
            UserListView.BeginUpdate();

            UserListView.View = View.Details;
            UserListView.Clear();
            UserListView.Columns.Add("用户名(双击选择用户)", 200, HorizontalAlignment.Right);
            UserListView.Columns.Add("管理员", 50, HorizontalAlignment.Center);
            UserListView.FullRowSelect = true;

            dt = cm.GetTableValue("Account");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string name;
                ulong  admin;
                name  = (string)dt.Rows[i]["Account"];
                admin = (ulong)dt.Rows[i]["Level"];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = name;
                if (admin == 1)
                {
                    lvi.SubItems.Add("是");
                }
                else
                {
                    lvi.SubItems.Add("否");
                }
                UserListView.Items.Add(lvi);
            }
            UserListView.EndUpdate();
            #endregion

            MessageBox.Show("新用户添加成功!");
        }
Example #7
0
        void InitForm()
        {
            #region 初始锁定控件
            //初始锁定控件
            NewUserNameTextbox.Enabled         = false;
            NewUserPasswordTextbox.Enabled     = false;
            NewUserAdminNoRadioButton.Enabled  = false;
            NewUserAdminYesRadioButton.Enabled = false;

            NewUserAddButton.Enabled = false;

            UserNameTextbox.Enabled           = false;
            ChangeAdminNoRadioButton.Enabled  = false;
            ChangeAdminYesRadioButton.Enabled = false;
            DeletUserButton.Enabled           = false;
            ShowPasswordButton.Enabled        = false;
            ShowPasswordTextbox.Enabled       = false;
            ChangePasswordButton.Enabled      = false;
            ChangePasswordTextbox.Enabled     = false;
            #endregion

            #region 获取所有用户信息
            //获取所有用户信息
            UserListView.BeginUpdate();

            UserListView.View = View.Details;
            UserListView.Clear();
            UserListView.Columns.Add("用户名(双击选择用户)", 200, HorizontalAlignment.Right);
            UserListView.Columns.Add("管理员", 50, HorizontalAlignment.Center);
            UserListView.FullRowSelect = true;

            DataTable dt = new DataTable("Account");
            CTMySql   cm = new CTMySql();

            dt = cm.GetTableValue("Account");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string name;
                ulong  admin;
                name  = (string)dt.Rows[i]["Account"];
                admin = (ulong)dt.Rows[i]["Level"];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = name;
                if (admin == 1)
                {
                    lvi.SubItems.Add("是");
                }
                else
                {
                    lvi.SubItems.Add("否");
                }
                UserListView.Items.Add(lvi);
            }
            UserListView.EndUpdate();
            #endregion

            #region 检测管理员权限
            if (!CTMySql.isUserAdmin)
            {
                UserListView.Enabled  = false;
                NewUserButton.Enabled = false;
            }
            #endregion
        }