using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace DataDisplay
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class BookForm : System.Windows.Forms.Form
{
private System.Data.OleDb.OleDbConnection conBooks;
private System.Data.OleDb.OleDbDataAdapter daBooks;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
private DataDisplay.dsBooks dsBooks1;
private System.Windows.Forms.DataGrid booksDataGrid;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public BookForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.conBooks = new System.Data.OleDb.OleDbConnection();
this.daBooks = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
this.dsBooks1 = new DataDisplay.dsBooks();
this.booksDataGrid = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dsBooks1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.booksDataGrid)).BeginInit();
this.SuspendLayout();
//
// conBooks
//
this.conBooks.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\360\Programs_managedVCSharp\DataDisplay\bin\Debug\RnrBooks.mdb;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
//
// daBooks
//
this.daBooks.DeleteCommand = this.oleDbDeleteCommand1;
this.daBooks.InsertCommand = this.oleDbInsertCommand1;
this.daBooks.SelectCommand = this.oleDbSelectCommand1;
this.daBooks.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Books", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ISBN", "ISBN"),
new System.Data.Common.DataColumnMapping("Title", "Title"),
new System.Data.Common.DataColumnMapping("Author", "Author")})});
this.daBooks.UpdateCommand = this.oleDbUpdateCommand1;
//
// oleDbDeleteCommand1
//
this.oleDbDeleteCommand1.CommandText = "DELETE FROM Books WHERE (ISBN = ?) AND (Author = ? OR ? IS NULL AND Author IS NUL" +
"L) AND (Title = ? OR ? IS NULL AND Title IS NULL)";
this.oleDbDeleteCommand1.Connection = this.conBooks;
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ISBN", System.Data.OleDb.OleDbType.VarWChar, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Author", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Author", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Author1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Author", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Title", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Title", System.Data.DataRowVersion.Original, null));
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Title1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Title", System.Data.DataRowVersion.Original, null));
//
// oleDbInsertCommand1
//
this.oleDbInsertCommand1.CommandText = "INSERT INTO Books(ISBN, Title, Author) VALUES (?, ?, ?)";
this.oleDbInsertCommand1.Connection = this.conBooks;
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ISBN", System.Data.OleDb.OleDbType.VarWChar, 13, "ISBN"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Title", System.Data.OleDb.OleDbType.VarWChar, 50, "Title"));
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Author", System.Data.OleDb.OleDbType.VarWChar, 30, "Author"));
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT ISBN, Title, Author FROM Books";
this.oleDbSelectCommand1.Connection = this.conBooks;
//
// oleDbUpdateCommand1
//
this.oleDbUpdateCommand1.CommandText = "UPDATE Books SET ISBN = ?, Title = ?, Author = ? WHERE (ISBN = ?) AND (Author = ?" +
" OR ? IS NULL AND Author IS NULL) AND (Title = ? OR ? IS NULL AND Title IS NULL)" +
"";
this.oleDbUpdateCommand1.Connection = this.conBooks;
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ISBN", System.Data.OleDb.OleDbType.VarWChar, 13, "ISBN"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Title", System.Data.OleDb.OleDbType.VarWChar, 50, "Title"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Author", System.Data.OleDb.OleDbType.VarWChar, 30, "Author"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ISBN", System.Data.OleDb.OleDbType.VarWChar, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Author", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Author", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Author1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Author", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Title", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Title", System.Data.DataRowVersion.Original, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_Title1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Title", System.Data.DataRowVersion.Original, null));
//
// dsBooks1
//
this.dsBooks1.DataSetName = "dsBooks";
this.dsBooks1.Locale = new System.Globalization.CultureInfo("en-US");
this.dsBooks1.Namespace = "http://www.tempuri.org/dsBooks.xsd";
//
// booksDataGrid
//
this.booksDataGrid.DataMember = "";
this.booksDataGrid.DataSource = this.dsBooks1.Books;
this.booksDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.booksDataGrid.Location = new System.Drawing.Point(48, 24);
this.booksDataGrid.Name = "booksDataGrid";
this.booksDataGrid.Size = new System.Drawing.Size(456, 272);
this.booksDataGrid.TabIndex = 0;
this.booksDataGrid.Navigate += new System.Windows.Forms.NavigateEventHandler(this.booksDataGrid_Navigate);
//
// BookForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(576, 325);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.booksDataGrid});
this.Name = "BookForm";
this.Text = "Book Data";
this.Load += new System.EventHandler(this.BookForm_Load);
((System.ComponentModel.ISupportInitialize)(this.dsBooks1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.booksDataGrid)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new BookForm());
}
private void booksDataGrid_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
private void BookForm_Load(object sender, System.EventArgs e)
{
daBooks.Fill(dsBooks1);
}
}
}