Example #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var uid = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);

            Console.WriteLine(e.ColumnIndex);
            if (e.ColumnIndex == 8)
            {
                var editForm = new EditUserForm(db, uid);
                editForm.ShowDialog();
            }
            else if (e.ColumnIndex == 9)
            {
                var uname = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                var ok    = MessageBox.Show("确定删除" + uname + "?", "确认删除", MessageBoxButtons.OKCancel);
                if (ok == DialogResult.OK)
                {
                    var deletesql = "DELETE FROM user WHERE u_id=" + uid.ToString() + ";";
                    try
                    {
                        db.Execute(deletesql);
                        MessageBox.Show("删除成功,刷新看到结果", "删除成功");
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                        MessageBox.Show("删除失败,有可能是数据库出错", "删除失败");
                    }
                }
            }
        }
Example #2
0
        private void 个人信息更改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var changeForm = new EditUserForm(db, loginUser.u_id, 1);

            changeForm.ShowDialog();
        }