Ejemplo n.º 1
0
        private void ChangeBtn2_Click(object sender, EventArgs e)
        {
            if (listView2.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择一行");
                return;
            }

            Intent.State = "CHANGE";
            DriverEdit de = new DriverEdit();
            Driver     d  = new Driver();

            d.SetValue(
                listView2.SelectedItems[0].SubItems[0].Text,
                listView2.SelectedItems[0].SubItems[1].Text,
                listView2.SelectedItems[0].SubItems[2].Text,
                listView2.SelectedItems[0].SubItems[3].Text,
                listView2.SelectedItems[0].SubItems[4].Text,
                listView2.SelectedItems[0].SubItems[5].Text
                );
            de.d          = d;
            Intent.OLD_ID = d.DNo;

            if (de.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " UPDATE [Driver]" +
                      " SET" +
                      "   [DNo]='" + de.d.DNo + "'," +
                      "   [DName]='" + de.d.DName + "'," +
                      "   [Gender]='" + de.d.Gender + "'," +
                      "   [Age]=" + de.d.Age + "," +
                      "   [Phone]='" + de.d.Phone + "'," +
                      "   [Password]='" + de.d.Password + "'" +
                      " WHERE [DNo]='" + Intent.OLD_ID + "'";
                db.SetBySQL(sql);

                UpdateListView();
            }
        }
Ejemplo n.º 2
0
        /* Tab2所有功能 */
        private void AddBtn2_Click(object sender, EventArgs e)
        {
            Intent.State = "ADD";
            DriverEdit de = new DriverEdit();

            if (de.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " INSERT INTO [Driver]" +
                      " VALUES" +
                      " (" +
                      "   '" + de.d.DNo + "'," +
                      "   '" + de.d.DName + "'," +
                      "   '" + de.d.Gender + "'," +
                      "   " + de.d.Age + "," +
                      "   '" + de.d.Phone + "'," +
                      "   '" + de.d.Password + "'" +
                      " )";
                db.SetBySQL(sql);

                UpdateListView();
            }
        }