📄 winform.pas.~7~
字号:
Self.DataColumn6.DataType := TypeOf(System.Decimal);
//
// DataColumn7
//
Self.DataColumn7.ColumnName := 'UnitsInStock';
Self.DataColumn7.DataType := TypeOf(SmallInt);
//
// DataColumn8
//
Self.DataColumn8.ColumnName := 'UnitsOnOrder';
Self.DataColumn8.DataType := TypeOf(SmallInt);
//
// DataColumn9
//
Self.DataColumn9.ColumnName := 'ReorderLevel';
Self.DataColumn9.DataType := TypeOf(SmallInt);
//
// DataColumn10
//
Self.DataColumn10.AllowDBNull := False;
Self.DataColumn10.ColumnName := 'Discontinued';
Self.DataColumn10.DataType := TypeOf(Boolean);
//
// DataTable2
//
Self.DataTable2.Columns.AddRange(TArrayOfSystem_Data_DataColumn.Create(Self.DataColumn11,
Self.DataColumn12, Self.DataColumn13, Self.DataColumn14));
Self.DataTable2.Constraints.AddRange(TArrayOfSystem_Data_Constraint.Create(System.Data.UniqueConstraint.Create('C' +
'onstraint1', TArrayOfString.Create('CategoryID'), True)));
Self.DataTable2.PrimaryKey := TArrayOfSystem_Data_DataColumn.Create(Self.DataColumn11);
Self.DataTable2.TableName := 'Categories';
//
// DataColumn11
//
Self.DataColumn11.AllowDBNull := False;
Self.DataColumn11.ColumnName := 'CategoryID';
Self.DataColumn11.DataType := TypeOf(Integer);
//
// DataColumn12
//
Self.DataColumn12.AllowDBNull := False;
Self.DataColumn12.ColumnName := 'CategoryName';
Self.DataColumn12.MaxLength := 15;
//
// DataColumn13
//
Self.DataColumn13.ColumnName := 'Description';
Self.DataColumn13.DataType := TypeOf(TArrayOfWideChar);
//
// DataColumn14
//
Self.DataColumn14.ColumnName := 'Picture';
Self.DataColumn14.DataType := TypeOf(TArrayOfByte);
//
// bdpDeleteCommand1
//
Self.bdpDeleteCommand1.CommandOptions := nil;
Self.bdpDeleteCommand1.CommandText := 'DELETE FROM dbo.Categories WHERE Ca' +
'tegoryID = ? AND CategoryName = ?';
Self.bdpDeleteCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpDeleteCommand1.Connection := Self.BdpConnection1;
Self.bdpDeleteCommand1.ParameterCount := (SmallInt(2));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryIDOriginal', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'CategoryID', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryNameOriginal', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
15, System.Data.ParameterDirection.Input, False, (Byte(15)), (Byte(0)),
15, 'CategoryName', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand1.SchemaName := nil;
Self.bdpDeleteCommand1.Transaction := nil;
Self.bdpDeleteCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpInsertCommand1
//
Self.bdpInsertCommand1.CommandOptions := nil;
Self.bdpInsertCommand1.CommandText := 'INSERT INTO dbo.Categories (Categor' +
'yID, CategoryName, Description, Picture ) VALUES ( ?, ?, ?, ?)';
Self.bdpInsertCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpInsertCommand1.Connection := Self.BdpConnection1;
Self.bdpInsertCommand1.ParameterCount := (SmallInt(4));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryID', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'CategoryID', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryName', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
15, System.Data.ParameterDirection.Input, False, (Byte(15)), (Byte(0)),
15, 'CategoryName', System.Data.DataRowVersion.Current, nil));
Self.bdpInsertCommand1.SchemaName := nil;
Self.bdpInsertCommand1.Transaction := nil;
Self.bdpInsertCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpSelectCommand1
//
Self.bdpSelectCommand1.CommandOptions := nil;
Self.bdpSelectCommand1.CommandText := 'SELECT * FROM dbo.Categories';
Self.bdpSelectCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpSelectCommand1.Connection := Self.BdpConnection1;
Self.bdpSelectCommand1.ParameterCount := (SmallInt(0));
Self.bdpSelectCommand1.SchemaName := nil;
Self.bdpSelectCommand1.Transaction := nil;
Self.bdpSelectCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpUpdateCommand1
//
Self.bdpUpdateCommand1.CommandOptions := nil;
Self.bdpUpdateCommand1.CommandText := 'UPDATE dbo.Categories SET CategoryI' +
'D = ?, CategoryName = ?, Description = ?, Picture = ? WHERE CategoryID = ' +
'? AND CategoryName = ?';
Self.bdpUpdateCommand1.CommandType := System.Data.CommandType.Text;
Self.bdpUpdateCommand1.Connection := Self.BdpConnection1;
Self.bdpUpdateCommand1.ParameterCount := (SmallInt(6));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryID', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'CategoryID', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryName', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
15, System.Data.ParameterDirection.Input, False, (Byte(15)), (Byte(0)),
15, 'CategoryName', System.Data.DataRowVersion.Current, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryIDOriginal', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'CategoryID', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryNameOriginal', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
15, System.Data.ParameterDirection.Input, False, (Byte(15)), (Byte(0)),
15, 'CategoryName', System.Data.DataRowVersion.Original, nil));
Self.bdpUpdateCommand1.SchemaName := nil;
Self.bdpUpdateCommand1.Transaction := nil;
Self.bdpUpdateCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// ProductAdapter
//
Self.ProductAdapter.Active := True;
Self.ProductAdapter.DataSet := Self.dataSet1;
Self.ProductAdapter.DataTable := Self.DataTable1;
Self.ProductAdapter.DeleteCommand := Self.bdpDeleteCommand2;
Self.ProductAdapter.InsertCommand := Self.bdpInsertCommand2;
Self.ProductAdapter.SelectCommand := Self.bdpSelectCommand2;
Self.ProductAdapter.StartRecord := 0;
Self.ProductAdapter.TableMappings.AddRange(TArrayOfSystem_Data_Common_DataTableMapping.Create(System.Data.Common.DataTableMapping.Create('T' +
'able', 'Products', TArrayOfSystem_Data_Common_DataColumnMapping.Create(System.Data.Common.DataColumnMapping.Create('P' +
'roductID', 'ProductID'), System.Data.Common.DataColumnMapping.Create('P' +
'roductName', 'ProductName'), System.Data.Common.DataColumnMapping.Create('S' +
'upplierID', 'SupplierID'), System.Data.Common.DataColumnMapping.Create('C' +
'ategoryID', 'CategoryID'), System.Data.Common.DataColumnMapping.Create('Q' +
'uantityPerUnit', 'QuantityPerUnit'), System.Data.Common.DataColumnMapping.Create('U' +
'nitPrice', 'UnitPrice'), System.Data.Common.DataColumnMapping.Create('U' +
'nitsInStock', 'UnitsInStock'), System.Data.Common.DataColumnMapping.Create('U' +
'nitsOnOrder', 'UnitsOnOrder'), System.Data.Common.DataColumnMapping.Create('R' +
'eorderLevel', 'ReorderLevel'), System.Data.Common.DataColumnMapping.Create('D' +
'iscontinued', 'Discontinued')))));
Self.ProductAdapter.UpdateCommand := Self.bdpUpdateCommand2;
//
// bdpDeleteCommand2
//
Self.bdpDeleteCommand2.CommandOptions := nil;
Self.bdpDeleteCommand2.CommandText := 'DELETE FROM dbo.Products WHERE Prod' +
'uctID = ? AND ProductName = ? AND SupplierID = ? AND CategoryID = ? AND Q' +
'uantityPerUnit = ? AND UnitPrice = ? AND UnitsInStock = ? AND UnitsOnOrde' +
'r = ? AND ReorderLevel = ? AND Discontinued = ?';
Self.bdpDeleteCommand2.CommandType := System.Data.CommandType.Text;
Self.bdpDeleteCommand2.Connection := Self.BdpConnection1;
Self.bdpDeleteCommand2.ParameterCount := (SmallInt(10));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('P' +
'roductIDOriginal', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'ProductID', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('P' +
'roductNameOriginal', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
40, System.Data.ParameterDirection.Input, False, (Byte(40)), (Byte(0)),
40, 'ProductName', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('S' +
'upplierIDOriginal', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'SupplierID', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('C' +
'ategoryIDOriginal', Borland.Data.Common.BdpType.Int32, Borland.Data.Common.BdpType.Unknown,
4, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'CategoryID', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('Q' +
'uantityPerUnitOriginal', Borland.Data.Common.BdpType.&String, Borland.Data.Common.BdpType.Unknown,
20, System.Data.ParameterDirection.Input, False, (Byte(20)), (Byte(0)),
20, 'QuantityPerUnit', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('U' +
'nitPriceOriginal', Borland.Data.Common.BdpType.Decimal, Borland.Data.Common.BdpType.Unknown,
8, System.Data.ParameterDirection.Input, False, (Byte(19)), (Byte(0)),
19, 'UnitPrice', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('U' +
'nitsInStockOriginal', Borland.Data.Common.BdpType.Int16, Borland.Data.Common.BdpType.Unknown,
2, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'UnitsInStock', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('U' +
'nitsOnOrderOriginal', Borland.Data.Common.BdpType.Int16, Borland.Data.Common.BdpType.Unknown,
2, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'UnitsOnOrder', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('R' +
'eorderLevelOriginal', Borland.Data.Common.BdpType.Int16, Borland.Data.Common.BdpType.Unknown,
2, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'ReorderLevel', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.Parameters.Add(Borland.Data.Common.BdpParameter.Create('D' +
'iscontinuedOriginal', Borland.Data.Common.BdpType.Boolean, Borland.Data.Common.BdpType.Unknown,
2, System.Data.ParameterDirection.Input, False, (Byte(0)), (Byte(0)),
0, 'Discontinued', System.Data.DataRowVersion.Original, nil));
Self.bdpDeleteCommand2.SchemaName := nil;
Self.bdpDeleteCommand2.Transaction := nil;
Self.bdpDeleteCommand2.UpdatedRowSource := System.Data.UpdateRowSource.None;
//
// bdpInsertCommand2
//
Self.bdpInsertCommand2.CommandOptions := nil;
Self.bdpInsertCommand2.CommandText := 'INSERT INTO dbo.Products (ProductID' +
', ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsI' +
'nStock, UnitsOnOrder, ReorderLevel, Discontinued ) VALUES ( ?, ?, ?, ?, ?' +
', ?, ?, ?, ?, ?)';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -