package App_VJSNet;
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import App_VJSNet.*;
/**
* Summary description for Book.
*/
public class
Book extends
System.Windows.Forms.Form
{
private
System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
private
App_VJSNet.Bookdset objBookdset;
private
System.Windows.Forms.RichTextBox richTextData;
private
System.Windows.Forms.Label label3;
private
System.Windows.Forms.TabControl tabControl1;
private
System.Windows.Forms.TabPage tabPage1;
private
System.Windows.Forms.Label lbinfo1;
private
System.Windows.Forms.ListView listView1;
private
System.Windows.Forms.Button btnview;
private
System.Windows.Forms.Button btnsearch;
private
System.Windows.Forms.TextBox TxtWord;
private
System.Windows.Forms.Label label8;
private
System.Windows.Forms.TabPage tabPage2;
private
System.Windows.Forms.ComboBox cmbverse;
private
System.Windows.Forms.ComboBox cmbchapter;
private
System.Windows.Forms.ComboBox cmbbook;
System.Windows.Forms.Label label9;
System.Windows.Forms.Label label10;
System.Windows.Forms.Label label11;
System.Windows.Forms.Label label12;
System.Windows.Forms.Label label13;
private
System.Windows.Forms.ComboBox cmbtitle;
private
System.Windows.Forms.PictureBox pictureBox2;
private
System.Windows.Forms.Label label2;
private
System.Windows.Forms.Label label1;
private
System.Windows.Forms.Button btnDone;
private
System.Windows.Forms.Button btnAbout;
private
System.Windows.Forms.PictureBox pictureBox1;
private
System.Windows.Forms.Label lblBook;
private
System.Windows.Forms.Label lblBookTitle;
private
System.Windows.Forms.Label lblChapter;
private
System.Windows.Forms.TextBox editBook;
private
System.Windows.Forms.TextBox editBookTitle;
private
System.Windows.Forms.TextBox editChapter;
private
System.Windows.Forms.Label lblVerse;
private
System.Windows.Forms.TextBox editTextData;
private
System.Windows.Forms.TextBox editVerse;
private
System.Windows.Forms.Button btnNavFirst;
private
System.Windows.Forms.Button btnNavPrev;
private
System.Windows.Forms.Label lblNavLocation;
private
System.Windows.Forms.Button btnNavNext;
private
System.Windows.Forms.Button btnLast;
private
System.Windows.Forms.ImageList imageList1;
private
System.Windows.Forms.ImageList imageList2;
private
System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
private
System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
private
System.Data.OleDb.OleDbConnection oleDbConnection1;
private
System.ComponentModel.IContainer components;
// Variables
MainForm fm =
new
MainForm();
int
View_Listview;
int
vrow;
// Select
command
System.Data.OleDb.OleDbCommand selectCMD ;
// Data adapter
System.Data.OleDb.OleDbDataAdapter bookDA =
new
System.Data.OleDb.OleDbDataAdapter();
// DataSet
System.Data.DataSet KJVDSet;
protected
void
Dispose(boolean
disposing) |
|
Windows
form Designer generated code |
private
void
Book_Load (Object sender, System.EventArgs e)
{
try
{
// Attempt to
load the dataset.
this.LoadDataSet();
// display the
2nd record of The 'BibleTable' table
this.get_BindingContext().get_Item(objBookdset,"BibleTable").set_Position(2);
// ListView
control, set the view to show details.
this.listView1.set_View(View.Details);
View_Listview = 1;
// ComboBox
controls, search by Address
selectCMD =
new
System.Data.OleDb.OleDbCommand("SELECT Book, BookTitle,
Chapter, Verse, TextData FROM BibleTable ORDER BY Book,
Chapter, Verse",
this.oleDbConnection1);
selectCMD.set_Connection( this.oleDbConnection1);
bookDA.set_SelectCommand(selectCMD);
KJVDSet=
new
System.Data.DataSet();
this.oleDbConnection1.Open();
bookDA.Fill(KJVDSet,"BibleTable");
this.oleDbConnection1.Close();
/**
1- Cmbbook stores the orders of all books.
2- Cmbbookrecno stores the orders of the KJV records
corresponding to the items of Cmbbook.
3- Cmbtitle stores the titles of books
4- Cmbtitlerecno stores the orders of the KJV records
corresponding to the items of Cmbtitle.
**/
for
(vrow = 2; vrow <=
KJVDSet.get_Tables().get_Item("BibleTable").get_Rows().get_Count()
- 1; vrow++)
{
if
((KJVDSet.get_Tables().get_Item("BibleTable").get_Rows().get_Item(vrow).get_Item("Chapter").ToString().equals("001"))
&& (KJVDSet.get_Tables().get_Item("BibleTable").get_Rows().get_Item(vrow).get_Item("Verse").ToString().equals("001")))
{
this.cmbtitle.get_Items().Add(KJVDSet.get_Tables().get_Item("BibleTable").get_Rows().get_Item(vrow).get_Item("BookTitle").ToString());
this.cmbbook.get_Items().Add(KJVDSet.get_Tables().get_Item("BibleTable").get_Rows().get_Item(vrow).get_Item("Book").ToString());
}
}
}
catch
(System.Exception eLoad)
{
// Add your
error handling code here.
// Display
error message, if any.
System.Windows.Forms.MessageBox.Show(eLoad.get_Message());
}
this.objBookdset_PositionChanged();
// Navigation
controls, enebled(False or True
NavigationFP( false);
NavigationNL( true);
this.cmbtitle.set_Text("Select");
this.cmbbook.set_Text("Select");
this.cmbchapter.set_Text("no
select");
this.cmbverse.set_Text("no
select");
// StatusBar
Panel N1 = Message
fm.Show();
fm.statusBarPanel1.set_Text("Ready... ");
fm.Refresh();
}
public
void
LoadDataSet ()
throws System.Exception
{
// Create a new
dataset to hold the records returned from the call to
FillDataSet.
// A temporary
dataset is used because filling the existing dataset
would
// require the
databindings to be rebound.
App_VJSNet.Bookdset objDataSetTemp;
objDataSetTemp =
new
App_VJSNet.Bookdset();
try
{
// Attempt to
fill the temporary dataset.
this.FillDataSet(objDataSetTemp);
}
catch
(System.Exception eFillDataSet)
{
// Add your
error handling code here.
throw
eFillDataSet;
}
try
{
// Empty the
old records from the dataset.
objBookdset.Clear();
// Merge the
records into the main dataset.
objBookdset.Merge(objDataSetTemp);
}
catch
(System.Exception eLoadMerge)
{
// Add your
error handling code here.
throw
eLoadMerge;
}
}
public
void
FillDataSet (App_VJSNet.Bookdset dataSet)
throws
System.Exception
{
// Turn off
constraint checking before the dataset is filled.
// This allows
the adapters to fill the dataset without concern
// for
dependencies between the tables.
dataSet.set_EnforceConstraints( false);
try
{
// Open the
connection.
this.oleDbConnection1.Open();
// Attempt to
fill the dataset through the OleDbDataAdapter1.
this.oleDbDataAdapter1.Fill(dataSet);
}
catch
(System.Exception fillException)
{
// Add your
error handling code here.
throw
fillException;
}
finally
{
// Turn
constraint checking back on.
dataSet.set_EnforceConstraints( true);
// Close the
connection whether or not the exception was thrown.
this.oleDbConnection1.Close();
}
}
private
void
NavigationFP(
boolean bval)
{
this.btnNavFirst.set_Enabled(bval);
this.btnNavPrev.set_Enabled(bval);
}
private
void
NavigationNL(
boolean bval)
{
this.btnNavNext.set_Enabled(bval);
this.btnLast.set_Enabled(bval);
}
private
void
objBookdset_PositionChanged ()
{
this.lblNavLocation.set_Text(((String.valueOf((this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Position()
+ 1)) + " of ")
+ String.valueOf( this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Count())));
// Navigation
controls enebled(True or False
if
(this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Position()
<= 2)
{
NavigationFP( false);
NavigationNL( true);
}
else
{
if
((this.get_BindingContext().get_Item(objBookdset,
"BibleTable").get_Position() +1) >= (this.get_BindingContext().get_Item(objBookdset,
"BibleTable").get_Count()))
{
NavigationFP( true);
NavigationNL( false);
}
else
{
NavigationFP( true);
NavigationNL( true);
}
}
}
private
void
btnNavFirst_Click (Object sender, System.EventArgs e)
{
this.get_BindingContext().get_Item(objBookdset,"BibleTable").set_Position(2);
this.objBookdset_PositionChanged();
}
private
void
btnNavPrev_Click (Object sender, System.EventArgs e)
{
if
(this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Position()
> 2)
{
this.get_BindingContext().get_Item(objBookdset,"BibleTable").set_Position((this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Position()
- 1));
this.objBookdset_PositionChanged();
}
}
private
void
btnNavNext_Click (Object sender, System.EventArgs e)
{
this.get_BindingContext().get_Item(objBookdset,"BibleTable").set_Position((this.get_BindingContext().get_Item(objBookdset,"BibleTable").get_Position()
+ 1));
this.objBookdset_PositionChanged();
}
private
void
btnLast_Click (Object sender, System.EventArgs e)
{
this.get_BindingContext().get_Item(objBookdset,"BibleTable").set_Position((this.objBookdset.get_Tables().get_Item("BibleTable").get_Rows().get_Count()
- 1));
this.objBookdset_PositionChanged();
}
private
void
btnAbout_Click (Object sender, System.EventArgs e)
{
About fabout =
new
About();
// StatusBar
Panel N1 = Message
fm.Show();
fm.statusBarPanel1.set_Text("About form, moment ... ");
fm.Refresh();
fabout.Show();
}
private
void
btnDone_Click (Object sender, System.EventArgs e)
{
this.Close();
} |