密码权限编辑.cs

来自「湖南岳阳电力部门 电力管理系统 .net C#开发的」· CS 代码 · 共 175 行

CS
175
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 计量
{
    public partial class 密码权限编辑 : Form
    {
        int type = 2;
        int temp = 0;
        string a = "", b = "";
        public 密码权限编辑()
        {
            InitializeComponent();
        }

        private void 密码权限编辑_Load(object sender, EventArgs e)
        { 
            // TODO: 这行代码将数据加载到表“sqldatabase_DataDataSet.用户表”中。您可以根据需要移动或移除它。
            this.用户表TableAdapter.FillBy(this.sqldatabase_DataDataSet.用户表,type);
            this.textBox1.ReadOnly = true;
            this.textBox2.ReadOnly = true;
            this.button4.Enabled = false;
            this.button5.Enabled = false;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            type = 1;
            this.用户表TableAdapter.FillBy(this.sqldatabase_DataDataSet.用户表, type);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            type = 2;
            this.用户表TableAdapter.FillBy(this.sqldatabase_DataDataSet.用户表, type);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.temp = 1;
            this.button1.Enabled = false;
            this.button2.Enabled = false;
            this.button3.Enabled = false;
            this.button4.Enabled = true;
            this.button5.Enabled = true;
            this.comboBox1.Enabled = false;
            this.textBox1.ReadOnly = false;
            this.textBox2.ReadOnly = false;  
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.temp = 2;

            this.button1.Enabled = false;
            this.button2.Enabled = false;
            this.button3.Enabled = false;
            this.button4.Enabled = true;
            this.button5.Enabled = true;
            this.radioButton1.Enabled = false;
            this.radioButton2.Enabled = false;
            
            this.radioButton1.Enabled = false;
            this.radioButton2.Enabled = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.temp = 3;

            this.button1.Enabled = false;
            this.button2.Enabled = false;
            this.button3.Enabled = false;
            this.button4.Enabled = true;
            this.button5.Enabled = true;

            this.comboBox1.Enabled = false;

            this.textBox1.ReadOnly = false;
            this.textBox2.ReadOnly = false;

            a = this.textBox1.Text.Trim();
            b = this.textBox2.Text.Trim();

            this.radioButton1.Enabled = false;
            this.radioButton2.Enabled = false;

        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (temp == 1)
            {
                try
                {
                    int ii=this.用户表TableAdapter.Insert(this.textBox1.Text.Trim(), this.textBox2.Text.Trim(), type);
                    if (ii == 0) MessageBox.Show("增加失败"); 
                    else MessageBox.Show("增加成功");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("增加失败:"+exc.Message);
                }
            }
            else if (temp == 2)
            {
                try
                { 
                   int ii=this.用户表TableAdapter.Delete(this.textBox1.Text.Trim(),this.textBox2.Text.Trim(),type);
                   if (ii == 0) MessageBox.Show("删除失败");
                   else MessageBox.Show("删除成功");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("删除失败:"+exc.Message);
                }
            }
            else if (temp == 3)
            {
                try
                {
                    int ii = this.用户表TableAdapter.Update(this.textBox1.Text.Trim(), this.textBox2.Text.Trim(), type,a,b,type);
                    if (ii == 0) MessageBox.Show("修改失败");
                    else MessageBox.Show("修改成功");
                }
                catch (Exception exc)
                {
                    MessageBox.Show("修改失败:" + exc.Message);
                }
            }
            else
            {
                MessageBox.Show("错误操作");
            }
            this.button1.Enabled = true;
            this.button2.Enabled = true;
            this.button3.Enabled = true;

            this.button4.Enabled = false;
            this.button5.Enabled = false;

            this.textBox1.ReadOnly = true;
            this.textBox2.ReadOnly = true;
            temp = 0;
            this.radioButton1.Enabled = true;
            this.radioButton2.Enabled = true;
            this.comboBox1.Enabled = true;
            this.用户表TableAdapter.FillBy(this.sqldatabase_DataDataSet.用户表, type);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = true;
            this.button2.Enabled = true;
            this.button3.Enabled = true;

            this.button4.Enabled = false;
            this.button5.Enabled = false;

            this.textBox1.ReadOnly = true;
            this.textBox2.ReadOnly = true;
            this.comboBox1.Enabled = true;

            this.用户表TableAdapter.FillBy(this.sqldatabase_DataDataSet.用户表, type);
            temp = 0;
            this.radioButton1.Enabled = true;
            this.radioButton2.Enabled = true;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?