Exemple #1
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            Intent.State = "ADD";
            ProductEdit pe = new ProductEdit();

            if (pe.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " INSERT INTO [Products]" +
                      " VALUES" +
                      " (" +
                      "   '" + pe.p.ProductID + "'," +
                      "   '" + pe.p.ProductName + "'," +
                      "   '" + pe.p.SupplierName + "'" +
                      " )";
                db.SetBySQL(sql);
            }

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

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

            Product p = new Product();

            p.SetValue(
                listView1.SelectedItems[0].SubItems[0].Text,
                listView1.SelectedItems[0].SubItems[1].Text,
                listView1.SelectedItems[0].SubItems[2].Text
                );
            Intent.OLD_ID = p.ProductID;
            ProductEdit pe = new ProductEdit();

            pe.p = p;

            if (pe.ShowDialog() == DialogResult.OK)
            {
                sql = @"" +
                      " UPDATE [Products]" +
                      " SET " +
                      "   [ProductID]='" + pe.p.ProductID + "'," +
                      "   [ProductName]='" + pe.p.ProductName + "'," +
                      "   [SupplierName]='" + pe.p.SupplierName + "'" +
                      " WHERE [ProductID]='" + Intent.OLD_ID + "'";
                db.SetBySQL(sql);
            }

            UpdateListView();
        }