The Visual J# .Net Form - book_note.jsl, Text Codes
 
 
 

       
      Return



  The Form -  book_note.jsl ...

 
 

 The codes  corresponding ...
   
    
   The text Code is red color, the codes added manuel
 
 
package work_VJnet;

import System.Drawing.*;

import System.Collections.*;

import System.ComponentModel.*;

import System.Windows.Forms.*;

/**

* Summary description for book_note.

*/

public class book_note extends System.Windows.Forms.Form

{

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 System.Data.OleDb.OleDbCommand oleDbSelectCommand2;

private System.Data.OleDb.OleDbCommand oleDbInsertCommand2;

private System.Data.OleDb.OleDbCommand oleDbUpdateCommand2;

private System.Data.OleDb.OleDbCommand oleDbDeleteCommand2;

private System.Data.OleDb.OleDbConnection oleDbConnection1;

private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;

private work_VJnet.book_dset objbook_dset;

System.Windows.Forms.ToolBarButton ToolBarcancel;

System.Windows.Forms.ToolBarButton ToolBarsave;

System.Windows.Forms.ToolBarButton ToolBarmodify;

System.Data.OleDb.OleDbCommand oleDbCommand8;

System.Windows.Forms.ToolBarButton ToolBaradd;

System.Windows.Forms.Panel Panel91;

System.Windows.Forms.Panel Panel43;

System.Windows.Forms.OpenFileDialog OpenFileDialog1;

System.Windows.Forms.ToolBarButton ToolBarpreview;

System.Windows.Forms.ToolBarButton ToolBarnext;

System.Windows.Forms.ToolBarButton ToolBarlast;

System.Windows.Forms.ToolBarButton ToolBarfirst;

System.Data.OleDb.OleDbCommand oleDbCommand7;

System.Windows.Forms.Panel Panel2;

System.Windows.Forms.Panel Panel21;

System.Windows.Forms.Panel Panel22;

System.Windows.Forms.Label lboperation;

System.Windows.Forms.Label lblNavLocation;

System.Windows.Forms.Panel Panel42;

System.Windows.Forms.PictureBox Pic_line02;

System.Windows.Forms.ToolBarButton ToolBarclose;

System.Windows.Forms.ImageList ImageList1;

System.Windows.Forms.ToolBarButton ToolBarprint;

System.Windows.Forms.ToolBarButton ToolBarsearch;

private System.Data.OleDb.OleDbCommand oleDbCommand1;

private System.Data.OleDb.OleDbCommand oleDbCommand2;

private System.Data.OleDb.OleDbCommand oleDbCommand3;

System.Windows.Forms.Panel Panel3;

System.Windows.Forms.PictureBox Pic_book;

System.Windows.Forms.Panel Panel31;

System.Windows.Forms.Panel Panel312;

System.Windows.Forms.ToolBar ToolBar2;

System.Windows.Forms.Panel Panel311;

System.Windows.Forms.ToolBar ToolBar1;

System.Windows.Forms.Panel Panel32;

System.Windows.Forms.Panel Panel324;

System.Windows.Forms.ToolBar ToolBar6;

System.Windows.Forms.Panel Panel323;

System.Windows.Forms.ToolBar ToolBar5;

System.Windows.Forms.Panel Panel322;

System.Windows.Forms.ToolBar ToolBar4;

System.Windows.Forms.Panel Panel321;

System.Windows.Forms.ToolBar ToolBar3;

System.Windows.Forms.Panel Panel33;

System.Windows.Forms.Panel Panel333;

System.Windows.Forms.ToolBar ToolBar9;

System.Windows.Forms.Panel Panel332;

System.Windows.Forms.ToolBar ToolBar8;

System.Windows.Forms.Panel Panel331;

System.Windows.Forms.ToolBar ToolBar7;

System.Data.OleDb.OleDbCommand oleDbCommand4;

System.Data.OleDb.OleDbCommand oleDbCommand5;

System.Windows.Forms.Panel Panel1;

System.Windows.Forms.Panel Panel4;

System.Windows.Forms.Panel Panel_photo;

System.Windows.Forms.TextBox editphoto_photo;

System.Windows.Forms.PictureBox Pic_photo;

System.Windows.Forms.Button Btnphoto_new;

System.Windows.Forms.Button Btnphoto_del;

System.Windows.Forms.TextBox editoriginalfirst_name;

System.Windows.Forms.TextBox editbirth_y;

System.Windows.Forms.TextBox editbirth_m;

System.Windows.Forms.TextBox editbirth_d;

System.Windows.Forms.TextBox editbirth;

System.Windows.Forms.TextBox editcivil_status;

System.Windows.Forms.TextBox editfather_name;

System.Windows.Forms.TextBox editfirst_name;

System.Windows.Forms.TextBox editname;

System.Windows.Forms.TextBox editsex;

System.Windows.Forms.DateTimePicker DateTime_birth;

System.Windows.Forms.ComboBox cmbcivil_status;

System.Windows.Forms.ComboBox cmbfather_name;

System.Windows.Forms.ComboBox cmbfirst_name;

System.Windows.Forms.ComboBox cmbname;

System.Windows.Forms.ComboBox cmbsex;

System.Windows.Forms.Label lblfunction;

System.Windows.Forms.TextBox editfunction;

System.Windows.Forms.Label lblbirth;

System.Windows.Forms.Label lblcivil_status;

System.Windows.Forms.Label lblfather_name;

System.Windows.Forms.Label lblfirst_name;

System.Windows.Forms.Label lblname;

System.Windows.Forms.Label lblsex;

System.Windows.Forms.PictureBox PictureBox2;

System.Windows.Forms.ImageList ImageList00;

System.Data.OleDb.OleDbCommand oleDbCommand6;

System.Data.OleDb.OleDbCommand oleDbCommand9;

System.Windows.Forms.Panel Panel6;

System.Windows.Forms.Label lblalternativePhone;

System.Windows.Forms.Label lblemail;

System.Windows.Forms.Label lblfax;

System.Windows.Forms.TextBox editalternativePhone;

System.Windows.Forms.TextBox editemail;

System.Windows.Forms.TextBox editfax;

System.Windows.Forms.Label lblhomephone;

System.Windows.Forms.Label lblmobilephone;

System.Windows.Forms.Label lblweb;

System.Windows.Forms.Label lblworkphone;

System.Windows.Forms.TextBox edithomephone;

System.Windows.Forms.TextBox editmobilephone;

System.Windows.Forms.TextBox editweb;

System.Windows.Forms.TextBox editworkphone;

System.Windows.Forms.PictureBox PictureBox1;

private System.Data.OleDb.OleDbCommand oleDbCommand10;

System.Windows.Forms.Panel Panel41;

System.Windows.Forms.PictureBox Pic_line01;

System.Windows.Forms.Panel Panel7;

System.Windows.Forms.PictureBox PictureBox4;

System.Windows.Forms.Label ltoday;

System.Data.OleDb.OleDbCommand oleDbCommand11;

System.Data.OleDb.OleDbCommand oleDbCommand12;

System.Windows.Forms.Panel Panel5;

System.Windows.Forms.TextBox editcity;

System.Windows.Forms.TextBox editcountry;

System.Windows.Forms.ComboBox cmbcity;

System.Windows.Forms.ComboBox cmbcountry;

System.Windows.Forms.Label lblpost_office_box;

System.Windows.Forms.TextBox editpost_office_box;

System.Windows.Forms.Label lblcity;

System.Windows.Forms.Label lblcountry;

System.Windows.Forms.TabControl TabControl1;

System.Windows.Forms.TabPage TabPage1;

System.Windows.Forms.TextBox editaddress1;

System.Windows.Forms.TabPage TabPage2;

System.Windows.Forms.TextBox editaddress2;

System.Windows.Forms.PictureBox PictureBox3;

private System.ComponentModel.IContainer components;

//variable

//Select command

System.Data.OleDb.OleDbCommand vselect1;

//Dataadapter

System.Data.OleDb.OleDbDataAdapter vda1;

System.Data.DataSet vdset1;

boolean mbeditflag;

boolean mbaddflag;

public book_note()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

}

/**

* Clean up any resources being used.

*/

protected void Dispose(boolean disposing)

{

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

super.Dispose(disposing);

}


 
      Windows Form Designer generated code

public static class book_note_cl

{

public static String booknote_type;

public static int booknote_width;

public static int booknote_left;

public static int booknote_top;

}

private void book_note_Load (Object sender, System.EventArgs e)

{

//move

this.editphoto_photo.set_Top(-this.editphoto_photo.get_Height());

//resize

this.Panel21.set_Top((this.Panel2.get_Height() - this.Panel21.get_Height()) / 2);

this.Panel22.set_Left((this.Panel21.get_Width() - this.Panel22.get_Width()) / 2);

this.lblNavLocation.set_Width(this.Panel22.get_Left() - 16);

this.lblNavLocation.set_Left((this.Panel22.get_Left() - this.lblNavLocation.get_Width()) / 2);

this.lblNavLocation.set_Top(0);

this.lboperation.set_Width(this.lblNavLocation.get_Width());

this.lboperation.set_Left(this.Panel22.get_Left() + (this.Panel22.get_Left() - this.lblNavLocation.get_Width()) / 2);

this.lboperation.set_Top(this.lblNavLocation.get_Top());

this.Panel91.set_Top(this.Panel4.get_Top());

this.Panel41.set_Left(this.Panel91.get_Left());

this.Panel42.set_Left(this.Panel91.get_Left());

this.Panel91.set_Height(this.Panel4.get_Height() + this.Panel41.get_Height() + this.Panel5.get_Height() + this.Panel42.get_Height() + this.Panel6.get_Height());

this.Panel41.set_Top(this.Panel4.get_Top() + this.Panel4.get_Height());

this.Panel5.set_Top(this.Panel41.get_Top() + this.Panel41.get_Height());

this.Panel42.set_Top(this.Panel5.get_Top() + this.Panel5.get_Height());

this.Panel6.set_Top(this.Panel42.get_Top() + this.Panel42.get_Height());

this.Panel43.set_Top(this.Panel6.get_Top() + this.Panel6.get_Height());

this.Panel5.set_Left(this.Panel4.get_Left());

this.Panel6.set_Left(this.Panel4.get_Left());

this.Pic_line01.set_Width(this.Panel4.get_Width());

this.Pic_line01.set_Left(this.Panel91.get_Width());

this.Pic_line02.set_Width(this.Pic_line01.get_Width());

this.Pic_line02.set_Left(this.Pic_line01.get_Left());

this.Panel3.set_Height(this.Panel43.get_Top() - 8);

this.Panel3.set_Top(4);

this.Pic_book.set_Left((this.Panel3.get_Width() - this.Pic_book.get_Width()) / 2);

this.Pic_book.set_Top(this.Panel33.get_Top() + this.Panel33.get_Height() + (this.Panel3.get_Height() - (this.Panel33.get_Top() + this.Panel33.get_Height() + this.Pic_book.get_Height())) / 2);

book_note_cl.booknote_width = this.get_Width();

book_note_cl.booknote_left = this.get_Left();

book_note_cl.booknote_top = this.get_Top();

this.LoadDataSet();

book_note_cl.booknote_type = "";

mbeditflag = false;

mbaddflag = false;

sub_load("name");

sub_load("first");

sub_load("father");

sub_load("city");

sub_load("civil_status");

this.ltoday.set_Text(System.DateTime.get_Today().ToLongDateString());

NavFirst();

}

public void LoadDataSet ()

{

try

{

// Attempt to load the dataset.

this.LoadDataSet1();

}

catch (System.Exception eLoad)

{

// Display error message, if any.

System.Windows.Forms.MessageBox.Show(eLoad.get_Message());

}

}

public void LoadDataSet1 () 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.

work_VJnet.book_dset objDataSetTemp;

objDataSetTemp = new work_VJnet.book_dset();

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.

objbook_dset.Clear();

// Merge the records into the main dataset.

objbook_dset.Merge(objDataSetTemp);

}

catch (System.Exception eLoadMerge)

{

// Add your error handling code here.

throw eLoadMerge;

}

}

public void FillDataSet (work_VJnet.book_dset 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();

}

}

//add data to comboboxes

private void sub_load(String v_field)

{

int i;

if (v_field.Trim().Equals("name"))

{

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT DISTINCT Trim(name) AS vname FROM book WHERE (Trim(name) <> '') ORDER BY Trim(name)");

}

if (v_field.Trim().Equals("first"))

{

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT DISTINCT Trim(first_name) AS vfirst FROM book WHERE (Trim(first_name) <>'')ORDER BY Trim(first_name)");

}

if (v_field.Trim().Equals("father"))

{

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT DISTINCT Trim(father_name) AS vfather FROM book WHERE (Trim(father_name) <>'')ORDER BY Trim(father_name)");

}

if (v_field.Trim().Equals("city"))

{

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT DISTINCT Trim(city) AS vcity FROM book WHERE (Trim(city)<>'')ORDER BY Trim(city)");

}

if (v_field.Trim().Equals("civil_status"))

{

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT DISTINCT Trim(civil_status) AS vcivil FROM book WHERE (Trim(civil_status) <>'')ORDER BY Trim(civil_status)");

}

vda1 = new System.Data.OleDb.OleDbDataAdapter(vselect1);

vdset1 = new System.Data.DataSet();

vselect1.set_Connection(this.oleDbConnection1);

vdset1.set_EnforceConstraints(false);

try

{

this.oleDbConnection1.Open();

vda1.Fill(vdset1, "book");

}

catch (System.Exception fillException)

{

System.Windows.Forms.MessageBox.Show(fillException.get_Message());

}

vdset1.set_EnforceConstraints(true);

this.oleDbConnection1.Close();

if (vdset1.get_Tables().get_Item("book").get_Rows().get_Count() > 0)

{

for (i = 0 ; i <= (vdset1.get_Tables().get_Item("book").get_Rows().get_Count() - 1); i++)

{

if (v_field.Trim().Equals("name"))

{

this.cmbname.get_Items().Add(vdset1.get_Tables().get_Item("book").get_Rows().
get_Item(i).get_Item("vname").ToString().Trim());

}

if (v_field.Trim().Equals("first"))

{

this.cmbfirst_name.get_Items().Add(vdset1.get_Tables().get_Item("book").
get_Rows().get_Item(i).get_Item("vfirst").ToString().Trim());

}

if (v_field.Trim().Equals("father"))

{

this.cmbfather_name.get_Items().Add(vdset1.get_Tables().get_Item("book").
get_Rows().get_Item(i).get_Item("vfather").ToString().Trim());

}

if (v_field.Trim().Equals("city"))

{

this.cmbcity.get_Items().Add(vdset1.get_Tables().get_Item("book").get_Rows().
get_Item(i).get_Item("vcity").ToString().Trim());

}

if (v_field.Trim().Equals("civil_status"))

{

this.cmbcivil_status.get_Items().Add(vdset1.get_Tables().get_Item("book").get_Rows().
get_Item(i).get_Item("vcivil").ToString().Trim());

}

}

}

}

private void book_note_Closed (Object sender, System.EventArgs e)

{

if ((mbaddflag == true) || (mbeditflag == true))

{

this.close_response();

}

}

private void close_response()

{

System.Windows.Forms.DialogResult response;

String msg_inf;

msg_inf = "are you sure want to lose all changes, book note ...";

response = MessageBox.Show(msg_inf, work_VJnet.mainform.mainform_cl.Title, MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);

//Gets the result of the MessageBox display.

if (response == DialogResult.Yes)

{

mbaddflag = false;

mbeditflag = false;

this.Close();

}

}

private void ToolBar1_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar1.get_Buttons().IndexOf(e.get_Button()))

{

//first

case 0:

this.NavFirst();

break;

//preview

case 1:

this.NavPrev();

break;

//next

}

}

private void ToolBar2_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar2.get_Buttons().IndexOf(e.get_Button()))

{

//next

case 0:

this.NavNext();

break;

//last

case 1:

this.NavLast();

break;

}

}

private void ToolBar3_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar3.get_Buttons().IndexOf(e.get_Button()))

{

//add

case 0:

this.sub_add();

break;

}

}

private void ToolBar4_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar4.get_Buttons().IndexOf(e.get_Button()))

{

//modify

case 0:

this.sub_modify();

break;

}

}

private void ToolBar5_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar5.get_Buttons().IndexOf(e.get_Button()))

{

//save

case 0:

this.sub_Update();

break;

}

}

private void ToolBar6_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar6.get_Buttons().IndexOf(e.get_Button()))

{

//cancel

case 0:

this.sub_Cancel();

break;

}

}

private void ToolBar7_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar7.get_Buttons().IndexOf(e.get_Button()))

{

//search

case 0:

this.sub_find();

break;

}

}

private void ToolBar8_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar8.get_Buttons().IndexOf(e.get_Button()))

{

//print

case 0:

this.sub_print();

break;

}

}

private void ToolBar9_ButtonClick (Object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

switch(this.ToolBar9.get_Buttons().IndexOf(e.get_Button()))

{

//exit

case 0:

this.Close();

break;

}

}

//book_note navigation events ... *****************************

private void NavFirst()

{

this.get_BindingContext().get_Item(objbook_dset,"book").set_Position(0);

this.objbook_dset_PositionChanged();

}

private void objbook_dset_PositionChanged()

{

this.editbirth.set_Text(System.Convert.ToString(this.DateTime_birth.get_Value().get_Month()) + "/" + System.Convert.ToString(this.DateTime_birth.get_Value().get_Day()) + "/" + System.Convert.ToString(this.DateTime_birth.get_Value().get_Year()));

this.lblNavLocation.set_Text(((String.valueOf((this.get_BindingContext().
get_Item(objbook_dset,"book").get_Position() + 1)) + " of ")

+ String.valueOf(this.get_BindingContext().get_Item(objbook_dset,"book").get_Count())));

// mbaddflag or mbeditflag variables

if (mbaddflag == false || mbeditflag == false)

{

visible_control(false);

// Navigation controls enabled

if ((this.get_BindingContext().get_Item(objbook_dset,"book").get_Position() + 1) == 1)

{

NavigationFP(false);

NavigationNL(true);

if (this.ToolBaradd.get_Enabled() == false)

Enabled_AMS(true);

if (this.ToolBarsearch.get_Enabled() == false)

Enabled_CFP(true);

}

else

{

if ((this.get_BindingContext().get_Item(objbook_dset,"book").get_Position() +1) == (this.get_BindingContext().get_Item(objbook_dset,"book").get_Count()))

{

NavigationFP(true);

NavigationNL(false);

if (this.ToolBaradd.get_Enabled() == false)

Enabled_AMS(true);

if (this.ToolBarsearch.get_Enabled() == false)

Enabled_CFP(true);

}

else

{

NavigationFP(true);

NavigationNL(true);

if (this.ToolBaradd.get_Enabled() == false)

Enabled_AMS(true);

if (this.ToolBarsearch.get_Enabled() == false)

Enabled_CFP(true);

}

}

}

else

{

if (mbaddflag == true || mbeditflag == true)

{

if (mbaddflag == true)

lboperation.set_Text("add operation");

if (mbeditflag == true)

this.lboperation.set_Text("mudify operation");

visible_control(true);

NavigationFP(false);

NavigationNL(false);

Enabled_AMS(false);

Enabled_CFP(false);

}

}

//show photo

sub_showphoto();

this.lblNavLocation.Focus();

}

private void visible_control( boolean bval)

{

this.cmbname.set_Visible(bval);

this.cmbfirst_name.set_Visible(bval);

this.cmbfather_name.set_Visible(bval);

this.DateTime_birth.set_Visible(bval);

this.cmbsex.set_Visible(bval);

this.cmbcivil_status.set_Visible(bval);

this.cmbcountry.set_Visible(bval);

this.cmbcity.set_Visible(bval);

this.editname.set_Visible(!bval);

this.editfirst_name.set_Visible(!bval);

this.editfather_name.set_Visible(!bval);

this.editbirth.set_Visible(!bval);

this.editcivil_status.set_Visible(!bval);

this.editsex.set_Visible(!bval);

this.editcountry.set_Visible(!bval);

this.editcity.set_Visible(!bval);

this.editname.set_Left(this.cmbname.get_Left());

this.editname.set_Width(this.cmbname.get_Width());

this.editname.set_Top(this.cmbname.get_Top());

this.editfirst_name.set_Left(this.cmbfirst_name.get_Left());

this.editfirst_name.set_Width(this.cmbfirst_name.get_Width());

this.editfirst_name.set_Top(this.cmbfirst_name.get_Top());

this.editfather_name.set_Left(this.cmbfather_name.get_Left());

this.editfather_name.set_Width(this.cmbfather_name.get_Width());

this.editfather_name.set_Top(this.cmbfather_name.get_Top());

this.editbirth.set_Left(this.DateTime_birth.get_Left());

this.editbirth.set_Width(this.DateTime_birth.get_Width());

this.editbirth.set_Top(this.DateTime_birth.get_Top());

this.editsex.set_Left(this.cmbsex.get_Left());

this.editsex.set_Width(this.cmbsex.get_Width());

this.editsex.set_Top(this.cmbsex.get_Top());

this.editcivil_status.set_Left(this.cmbcivil_status.get_Left());

this.editcivil_status.set_Width(this.cmbcivil_status.get_Width());

this.editcivil_status.set_Top(this.cmbcivil_status.get_Top());

this.editcountry.set_Left(this.cmbcountry.get_Left());

this.editcountry.set_Width(this.cmbcountry.get_Width());

this.editcountry.set_Top(this.cmbcountry.get_Top());

this.editcity.set_Left(this.cmbcity.get_Left());

this.editcity.set_Width(this.cmbcity.get_Width());

this.editcity.set_Top(this.cmbcity.get_Top());

}

private void NavigationFP( boolean bval)

{

this.ToolBarfirst.set_Enabled(bval);

this.ToolBarpreview.set_Enabled(bval);

}

private void NavigationNL( boolean bval)

{

this.ToolBarnext.set_Enabled(bval);

this.ToolBarlast.set_Enabled(bval);

}

private void Enabled_AMS( boolean bval)

{

this.ToolBaradd.set_Enabled(bval);

this.ToolBarmodify.set_Enabled(bval);

this.ToolBarsave.set_Enabled(!bval);

this.ToolBarcancel.set_Enabled(bval);

this.lblNavLocation.set_Enabled(bval);

}

private void Enabled_CFP(boolean bval)

{

//this.ToolBarcancel.Enabled = bval;

this.ToolBarsearch.set_Enabled(bval);

this.ToolBarprint.set_Enabled(bval);

}

//**************

//show photo

private void sub_showphoto()

{

if (mbaddflag == false)

{

if (this.editphoto_photo.get_Text().Trim() != "")

{

if (System.IO.File.Exists(this.editphoto_photo.get_Text().Trim()) == true)

{

this.Panel_photo.set_BorderStyle(BorderStyle.None);

this.Pic_photo.set_Image(Image.FromFile(this.editphoto_photo.get_Text().Trim()));

this.Pic_photo.set_Left((this.Panel_photo.get_Width() - this.Pic_photo.get_Width()) / 2);

this.Pic_photo.set_Top((this.Panel_photo.get_Height() - this.Pic_photo.get_Height()) / 2);

this.Btnphoto_del.set_Enabled(false);

this.Btnphoto_new.set_Enabled(false);

if (mbeditflag == true)

{

this.Btnphoto_del.set_Enabled(true);

this.Btnphoto_new.set_Enabled(true);

}

}

else

{

//goto PP2;

this.Pic_photo.set_Image(null); //nothing

this.Panel_photo.set_BorderStyle(BorderStyle.FixedSingle);

if (mbeditflag == true)

{

this.Btnphoto_new.set_Enabled(true);

}

else

{

this.Btnphoto_new.set_Enabled(false);

}

this.Btnphoto_del.set_Enabled(false);

return;

}

}

else

{

//PP2:

this.Pic_photo.set_Image(null); //nothing

this.Panel_photo.set_BorderStyle(BorderStyle.FixedSingle);

if (mbeditflag == true)

{

this.Btnphoto_new.set_Enabled(true);

}

else

{

this.Btnphoto_new.set_Enabled(false);

}

this.Btnphoto_del.set_Enabled(false);

return;

}

}

}

private void NavPrev()

{

this.get_BindingContext().get_Item(objbook_dset,"book").set_Position((this.
get_BindingContext().get_Item(objbook_dset,"book").get_Position() - 1));

this.objbook_dset_PositionChanged();

}

private void NavNext()

{

this.get_BindingContext().get_Item(objbook_dset,"book").set_Position((this.
get_BindingContext().get_Item(objbook_dset,"book").get_Position() + 1));

this.objbook_dset_PositionChanged();

}

private void NavLast()

{

this.get_BindingContext().get_Item(objbook_dset,"book").set_Position((this.
get_BindingContext().get_Item(objbook_dset,"book").get_Count() - 1));

this.objbook_dset_PositionChanged();

}

//book_note Add event ... *****************************

private void sub_add()

{

this.cmbname.set_SelectedIndex(-1);

this.cmbfirst_name.set_SelectedIndex(-1);

this.cmbfather_name.set_SelectedIndex(-1);

this.cmbsex.set_SelectedIndex(-1);

this.cmbcivil_status.set_SelectedIndex(-1);

this.cmbcountry.set_SelectedIndex(-1);

this.cmbcity.set_SelectedIndex(-1);

try

{

// Clear out the current edits

this.get_BindingContext().get_Item(objbook_dset,"book").EndCurrentEdit();

this.get_BindingContext().get_Item(objbook_dset,"book").AddNew();

mbaddflag = true;

}

catch (System.Exception eEndEdit)

{

System.Windows.Forms.MessageBox.Show(eEndEdit.get_Message());

}

//show photo ...

this.Btnphoto_del.set_Enabled(false);

this.Btnphoto_new.set_Enabled(true);

this.objbook_dset_PositionChanged();

}

private void Btnphoto_new_Click (Object sender, System.EventArgs e)

{

if ((mbaddflag == true) || (mbeditflag == true))

{

//OpenFileDialog control, displays the Photo corresponding and save it ...

sub_addphoto();

}

}

//OpenFileDialog control, displays the Photo corresponding and save it ...

private void sub_addphoto()

{

String vfilename;

this.OpenFileDialog1.set_FileName("Book note, Select Picture");

this.OpenFileDialog1.set_Filter("All Files|*.*|JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif");

this.OpenFileDialog1.set_FilterIndex(3);

// Show the Dialog, if the user clicked in the dialog and a picture file was selected, open it.

if (OpenFileDialog1.ShowDialog() == DialogResult.OK)

{

//add record to table per_appphoto

vfilename = OpenFileDialog1.get_FileName();

this.Panel_photo.set_BorderStyle(BorderStyle.None);

this.Pic_photo.set_Image(Image.FromFile(OpenFileDialog1.get_FileName()));

this.Pic_photo.set_Left((this.Panel_photo.get_Width() - this.Pic_photo.get_Width()) / 2);

this.Pic_photo.set_Top((this.Panel_photo.get_Height() - this.Pic_photo.get_Height()) / 2);

this.editphoto_photo.set_Text(vfilename);

this.Btnphoto_del.set_Enabled(true);

}

}

private void Btnphoto_del_Click (Object sender, System.EventArgs e)

{

if(( mbaddflag == true) || (mbeditflag == true))

{

//remove/delete photo and clear the file photo name corresponding

sub_removephoto();

}

}

// remove/delete photo and clear the file photo name corresponding

private void sub_removephoto()

{

System.Windows.Forms.DialogResult response;

String msg_inf;

msg_inf = "are you sure want to remove the photo of - " + this.editfirst_name.get_Text() + " " + this.editname.get_Text();

response = MessageBox.Show(msg_inf, work_VJnet.mainform.mainform_cl.Title, MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Information);

//Gets the result of the MessageBox display.

if (response == DialogResult.Yes)

{

//clear photo ...

Panel_photo.set_BorderStyle(BorderStyle.FixedSingle);

Pic_photo.get_Image().Dispose();

Pic_photo.set_Image(null); //nothing;

editphoto_photo.set_Text("");

Btnphoto_del.set_Enabled(false);

return;

}

if (response == DialogResult.No)

{

return;

}

}

//book_note Activated event ... *****************************

//book_note Activated event (responses from book_search form )

private void book_note_Activated (Object sender, System.EventArgs e)

{

if (work_VJnet.book_search.book_search_cl.findedit_Flag == true)

{

if (book_note_cl.booknote_type.Trim().Equals("find"))

{

sub_findok();

work_VJnet.book_search.book_search_cl.findedit_Flag = false;

return;

}

if (book_note_cl.booknote_type.Trim().Equals("edit"))

{

sub_modifyok();

work_VJnet.book_search.book_search_cl.findedit_Flag = false;

return;

}

}

if (work_VJnet.book_search.book_search_cl.findedit_Flag == false)

{

Searchedit_cancel();

}

}

private void Searchedit_cancel()

{

mbeditflag = false;

objbook_dset_PositionChanged();

}

 

//book_note modify/edit event ... *****************************

private void sub_modify()

{

book_search fbook_search = new book_search();

book_note_cl.booknote_type = "edit";

mbeditflag = true;

sub_Searchedit();

fbook_search.Show();

}

private void sub_modifyok()

{

this.get_BindingContext().get_Item(objbook_dset,"book").set_Position(work_VJnet.
book_search.book_search_cl.book_recno);

this.objbook_dset_PositionChanged();

this.cmbname.set_Text(this.editname.get_Text());

this.cmbfirst_name.set_Text(this.editfirst_name.get_Text());

this.cmbfather_name.set_Text(this.editfather_name.get_Text());

this.DateTime_birth.set_Text(this.editbirth.get_Text());

this.cmbsex.set_Text(this.editsex.get_Text());

this.cmbcivil_status.set_Text(this.editcivil_status.get_Text());

this.cmbcountry.set_Text(this.editcountry.get_Text());

this.cmbcity.set_Text(this.editcity.get_Text());

}

private void sub_Searchedit()

{

NavigationFP(false);

NavigationNL(false);

Enabled_AMS(false);

Enabled_CFP(false);

this.ToolBarsave.set_Enabled(false);

this.ToolBarcancel.set_Enabled(false);

}

//book_note update/save event ... *****************************

private void sub_Update()

{

System.Windows.Forms.DialogResult response;

//convert, comboboxes to textboxes

this.editname.set_Text(this.cmbname.get_Text());

this.editfirst_name.set_Text(this.cmbfirst_name.get_Text());

this.editfather_name.set_Text(this.cmbfather_name.get_Text());

this.editbirth.set_Text(this.DateTime_birth.get_Text());

this.editsex.set_Text(this.cmbsex.get_Text());

this.editcivil_status.set_Text(this.cmbcivil_status.get_Text());

this.editcountry.set_Text(this.cmbcountry.get_Text());

this.editcity.set_Text(this.cmbcity.get_Text());

this.editoriginalfirst_name.set_Text(this.cmbfirst_name.get_Text());

this.editbirth_d.set_Text(System.Convert.ToString(this.DateTime_birth.get_Value().get_Day()));

this.editbirth_m.set_Text(System.Convert.ToString(this.DateTime_birth.get_Value().get_Month()));

this.editbirth_y.set_Text(System.Convert.ToString(this.DateTime_birth.get_Value().get_Year()));

if (mbeditflag || mbaddflag)

{

if ((this.editname.get_Text().Trim().Equals("")) || (this.editfirst_name.get_Text().Trim().Equals("")) || (this.editfather_name.get_Text().Trim().Equals("")))

{

response = MessageBox.Show("save operation aborted - name box, first name box or father name box empty(ies) ...",
work_VJnet.mainform.mainform_cl.Title, MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);

if (response == DialogResult.Yes)

return;

if (response == DialogResult.No)

sub_Cancel();

}

else

{

sub_updateok(this.editname.get_Text().Trim(), this.editfirst_name.get_Text().Trim(),
this
.editfather_name.get_Text().Trim());

try

{

// Attempt to update the datasource.

this.UpdateDataSet();

}

catch (System.Exception eUpdate)

{

// Display error message

System.Windows.Forms.MessageBox.Show(eUpdate.get_Message());

}

mbeditflag = false;

mbaddflag = false;

this.objbook_dset_PositionChanged();

}

}

}

//add data to comboboxes

private void sub_updateok(String v_name, String v_first, String v_father)

{

int v_ord;

vselect1 = new System.Data.OleDb.OleDbCommand("SELECT bookid, name,
first_name, originalfirst_name, father_name FROM book WHERE ((name = '" + v_name + "') And
(originalfirst_name = '" + v_first + "') And
(father_name = '" + v_father + "')) ORDER BY bookid");

vda1 = new System.Data.OleDb.OleDbDataAdapter(vselect1);

vdset1 = new System.Data.DataSet();

vselect1.set_Connection(this.oleDbConnection1);

vdset1.set_EnforceConstraints(false);

try

{

this.oleDbConnection1.Open();

vda1.Fill(vdset1, "book");

}

catch (System.Exception fillException)

{

System.Windows.Forms.MessageBox.Show(fillException.get_Message());

}

vdset1.set_EnforceConstraints(true);

this.oleDbConnection1.Close();

if (vdset1.get_Tables().get_Item("book").get_Rows().get_Count() > 0)

{

v_ord = (vdset1.get_Tables().get_Item("book").get_Rows().get_Count() - 1);

this.editfirst_name.set_Text(this.editoriginalfirst_name.get_Text().Trim() +
System.Convert.ToString(v_ord).Trim());

}

}

public void UpdateDataSet () throws System.Exception

{

// Create a new dataset to hold the changes that have been made to the main dataset.

work_VJnet.book_dset objDataSetChanges = new work_VJnet.book_dset();

// Stop any current edits.

this.get_BindingContext().get_Item(objbook_dset,"book").EndCurrentEdit();

// Get the changes that have been made to the main dataset.

objDataSetChanges = ((work_VJnet.book_dset)(objbook_dset.GetChanges()));

// Check to see if any changes have been made.

if ((objDataSetChanges != null))

{

try

{

// There are changes that need to be made, so attempt to update the datasource by

// calling the update method and passing the dataset and any parameters.

this.UpdateDataSource(objDataSetChanges);

objbook_dset.Merge(objDataSetChanges);

objbook_dset.AcceptChanges();

}

catch (System.Exception eUpdate)

{

// Add your error handling code here.

throw eUpdate;

}

// Add your code to check the returned dataset for any errors that may have been

// pushed into the row object's error.

}

}

public void UpdateDataSource (work_VJnet.book_dset ChangedRows) throws System.Exception

{

try

{

// The data source only needs to be updated if there are changes pending.

if ((ChangedRows != null))

{

// Open the connection.

this.oleDbConnection1.Open();

// Attempt to update the data source.

oleDbDataAdapter1.Update(ChangedRows);

}

}

catch (System.Exception updateException)

{

// Add your error handling code here.

throw updateException;

}

finally

{

// Close the connection whether or not the exception was thrown.

this.oleDbConnection1.Close();

}

}

//book_note Cancel event ... *****************************

private void sub_Cancel()

{

mbeditflag = false;

mbaddflag = false;

this.get_BindingContext().get_Item(objbook_dset,"book").CancelCurrentEdit();

this.objbook_dset_PositionChanged();

}

//book_note find/search event ... *****************************

private void sub_find()

{

book_search fbook_search = new book_search();

book_note_cl.booknote_type = "find";

sub_Searchedit();

fbook_search.Show();

}

private void sub_findok()

{

this.get_BindingContext().get_Item(objbook_dset,"book").
set_Position(work_VJnet.book_search.book_search_cl.book_recno);

this.objbook_dset_PositionChanged();

}

private void sub_print()

{

}

 

 

 

}

 

   
  
 



 

      Return