コード例 #1
0
        /* Tab1 */
        private void AddBtn_Click(object sender, EventArgs e)
        {
            Intent.State = "ADD";
            TeacherEdit te = new TeacherEdit();

            if (te.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " INSERT INTO [TEACHERS]" +
                      " VALUES" +
                      " (" +
                      "   '" + te.t.TNo + "'," +
                      "   '" + te.t.TName + "'," +
                      "   '" + te.t.Gender + "'" +
                      " )";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }
コード例 #2
0
        private void ChangeBtn_Click(object sender, EventArgs e)
        {
            Intent.State = "CHANGE";

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

            TeacherEdit te = new TeacherEdit();

            Teacher t = new Teacher();

            t.SetValue(
                listView1.SelectedItems[0].SubItems[0].Text,
                listView1.SelectedItems[0].SubItems[1].Text,
                listView1.SelectedItems[0].SubItems[2].Text
                );
            te.t          = t;
            Intent.OLD_ID = t.TNo;

            if (te.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " UPDATE [TEACHERS]" +
                      " SET" +
                      "   [TNo]='" + t.TNo + "'," +
                      "   [TName]='" + t.TName + "'," +
                      "   [Gender]='" + t.Gender + "'" +
                      " WHERE [TNo]='" + Intent.OLD_ID + "'";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }