Beispiel #1
0
        /* ###################### 要求三 ###################### */
        private void AddBtn_Click(object sender, EventArgs e)
        {
            Intent.STATE = "ADD";

            StudentEdit se = new StudentEdit();

            if (se.ShowDialog() == DialogResult.OK)
            {
                Student s = se.s;

                sql = @"" +
                      " INSERT INTO [Student]" +
                      " VALUES" +
                      " ('" + s.SNo + "', '" + s.SName + "','" + s.Date + "', '" + s.classNo + "')";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }
Beispiel #2
0
        private void ChangeBtn_Click(object sender, EventArgs e)
        {
            Intent.STATE = "CHANGE";

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

            Student s = new Student();

            s.SetValue(
                listView3.SelectedItems[0].SubItems[0].Text,
                listView3.SelectedItems[0].SubItems[1].Text,
                listView3.SelectedItems[0].SubItems[2].Text,
                listView3.SelectedItems[0].SubItems[3].Text
                );

            StudentEdit se = new StudentEdit();

            se.s          = s;
            Intent.OLD_ID = s.SNo;
            if (se.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " UPDATE [Student]" +
                      " SET" +
                      "   [Sno]='" + s.SNo + "'," +
                      "   [SName]='" + s.SName + "'," +
                      "   [Date]='" + s.Date + "'," +
                      "   [classNo]='" + s.classNo + "'" +
                      " WHERE [Sno]='" + Intent.OLD_ID.ToString() + "'";
                db.SetBySQL(sql);
            }
            UpdateListView();
        }