예제 #1
0
        public 配置用户信息()
        {
            InitializeComponent();
            u = new UserManege();
            DataTable table = new DataTable();

            table = u.getTable();
            dataGridView1.DataSource = table;
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //保存所有修改的项
            //1,已有的项。修改
            //2.增加的项,增加
            List <string> userName = new List <string>();
            List <string> passwd   = new List <string>();

            /*for (int i = 0; i < dataGridView1.RowCount; i++)
             * {
             *  userName.Add(dataGridView1[i, 0].Value as string);
             *  passwd.Add(dataGridView1[i, 1].Value as string);
             * }*/

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                userName.Add(dataGridView1.Rows[i].Cells[0].Value as string);
                passwd.Add(dataGridView1.Rows[i].Cells[1].Value as string);
            }

            u.deleTable();
            u.CreateTable(1);
            for (int i = 0; i < userName.Count; i++)
            {
                if (userName[i] == "" || passwd[i] == "")
                {
                    continue;
                }
                u.addUser(userName[i], passwd[i]);
            }


            DataTable table = new DataTable();

            table = u.getTable();
            dataGridView1.DataSource = table;
        }