示例#1
0
        private void ChangeBtn_Click(object sender, EventArgs e)
        {
            Intent.State = "CHANGE";

            if (listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择一行");
                return;
            }

            Employee emp = new Employee();

            emp.SetValue(
                listView1.SelectedItems[0].SubItems[0].Text,
                listView1.SelectedItems[0].SubItems[1].Text,
                listView1.SelectedItems[0].SubItems[2].Text
                );

            EmployeeEdit ee = new EmployeeEdit();

            ee.emp = emp;
            if (ee.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " UPDATE [Employee]" +
                      " SET" +
                      "   [EmpNo]='" + emp.EmpNo + "'," +
                      "   [EmpName]='" + emp.EmpName + "'," +
                      "   [Location]='" + emp.Location + "'";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }
示例#2
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            Intent.State = "ADD";

            EmployeeEdit ee = new EmployeeEdit();

            if (ee.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " INSERT INTO [Employee]" +
                      " VALUES" +
                      " (" +
                      " '" + ee.emp.EmpNo + "'," +
                      " '" + ee.emp.EmpName + "'," +
                      " '" + ee.emp.Location + "'" +
                      " )";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }