rtb901a10 c-sharp termpaper

43
TOPIC NAME: - HOTEL RESERVATION AND ROOM ALLOCATION SUBMITTED TO: - Mr. RAM SINGH SUBMITTED: - NARINDER PAL ROLLNO: - RTB901A10 CLASS: - MSC (cs) DEPARTMENT: - COMPUTER SCINCE SUBJECT CODE: - CAP 406 SUBJECT NAME: - MODERN PROGRAMING TOOLS AND TECHNIQUES Term Paper- Review:- TOPICNAME: - Automation of Hotel Management: (Reservation & Room allocation modules)

Upload: narinder-pal-saini

Post on 08-Apr-2015

60 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: RTB901A10 C-sharp Termpaper

TOPIC NAME: - HOTEL RESERVATION AND ROOM ALLOCATION

SUBMITTED TO: - Mr. RAM SINGH

SUBMITTED: - NARINDER PAL

ROLLNO: - RTB901A10

CLASS: - MSC (cs)

DEPARTMENT: - COMPUTER SCINCE

SUBJECT CODE: - CAP 406

SUBJECT NAME: - MODERN PROGRAMING TOOLS AND TECHNIQUES

Term Paper- Review:-

TOPICNAME: - Automation of Hotel Management: (Reservation & Room

allocation modules)

INDEX:-

Page 2: RTB901A10 C-sharp Termpaper

1) ABSTRACT2) STUDY OF PROBLEM 3) BACK END USED4) DATA TYPES USED IN TERM PAPER 5) CONTROL STATEMENTS USED IN TERM PAPER 6) WORKING OF THE PROJECT 7) FORM DESIGNING8) CODING

DETAIL DESCRIPTION:-

1. Abstract : -

We are creating this project for hotel reservation and room

allocation using MSACCESS and C-SHARP. By using this project we can save the

records of hotel customers like (C_ID, C_Name, C_Address, C_In Out time, Room

detail) etc. and Hotel Management software is aimed at computerizing the

activities involved in a Hotel. The prime activities figured out in a Hotel include

checkin and checkout of customers, room reservation management , in out

detail ,bill detail and other services consumed by the customer.

2. Study of Problem : -

for proper management we have to maintain the record of al

the customers if we can not record the information of all customers then we have to

face the problem in management. The problems are arising when we can not

implement our problems. The major problem arises in coding section but we can

try to solve the all problems.

3. Back End used : -

Every project have front end and back end. The back

end is that whose dealing with our data stored in secondary storage device. The

Page 3: RTB901A10 C-sharp Termpaper

front is interface of our project by this we can do our queries. To make this

project we are use MSACCESS for back end and c# for front end.

INTRODUCTION OF MSACCESS: -

MS Access is relational database management

software of Microsoft that combines the relational MS Jet Database Engine with a

graphical user interface and software development tools. In MSACCESS we can

create simple database solutions. Access tables support a variety of standard fields

types and referential integrity. Access also includes a query interface forms to

display and enter data. The underlying Jet database which contains these objects is

multiuser-aware and handles record-locking and referential integrity including

cascading updates and deletes data in database.

Following some features of MSACCESS:-

In MSACCSS we can create tables to maintain the records.

MSACCESS is used to create simple database solutions. Access tables

support a variety of standard field types, indices, and referential integrity.

It is very popular among non-programmers who can create visually pleasing

and relatively advanced solutions on their own.

MSACCESS is also a file server-based database. Unlike client-server

relational database management systems (RDBMS) Microsoft Access does

not implement database triggers stored procedures or transaction logging.

By using it is also easy to place a database on a network and have multiple

users share and update data without overwriting each other’s work.

The original concept of Access was for end users to be able to “access” data

from any source e.g.:- Outlook, ASCII, dBase, Paradox, FoxPro, SQL

Server, Oracle, ODBC, C# etc.

Page 4: RTB901A10 C-sharp Termpaper

One of the benefits of MSACCESS from a programmer perspective is its

relative compatibility with SQL (structured query language) queries can be

viewed graphically or edited as SQL statements, and SQL statements can be

used directly in Macros and VBA Modules to manipulate Access tables.

Users can mix and use both VBA and "Macros" for programming forms and

logic and offers object-oriented possibilities.

Steps to create our database in MSACCESS:-

1) Select msaccess from ms office tools and click on it.

2) Then select the new file from file menu and select blank database give the

name to database and click on ok.

3) The new popup window arise as:-

Select create table option to create tables after creating table click on save to

save the table and that time it present the message to give the name of table

after giving name click ok to save the table.

Table names that used in this project:-

Page 5: RTB901A10 C-sharp Termpaper

1) Customer detail table

CUSDETAILCUSID CUSROMNO CUSNAME CUSPHNO CUSADDRESS ROOM RENT

2) Customer room detail table

ROOMDETAILCUSID ROOMSTANDARD ROOMRENT

3) Customer in out time table

CUSINOUTCUSID CUSINDATE CUSOUTDATE

4) Customer total bill detail table

CUSAMOUNTCUSID LIVINGTIME TOTALAMOUNT

4. DATA TYPES USED IN TERM PAPER :- DATA TYPES USED IN MSACCESS WRITTEN BELLOW:-

Data types used in customer detail table is:-

Page 6: RTB901A10 C-sharp Termpaper

Data types used in room detail table is:-

Data types used in customer in out detail table:-

Data types used in customer total bill detail table is:-

DATA TYPES USED IN C-SHARP WRITTEN BELLOW:-

Data type name variable name and semicolon;Int I;Double ff;String name;

5. CONTROL STATEMENTS USED IN TERM PAPER :- We are use following control statements in our project in c# as:-

1) If statement:-If (condition){

Page 7: RTB901A10 C-sharp Termpaper

Statements;}

2) If Else statement:-If (condition){Statements;}Else{Statement;}

3) Looping statements:For (initial value; test condition; increment /decrement){Body of the loop;}

6. WORKING OF THE PROJECT

Benefits of project:-

Before software’s we maintain data in registers it very difficult to maintain our data. It may take much time to view and add new records. Due to miss happening the data can be lost it is very difficult to recover the data. But with the help‘s of software it easy to maintain our record and we can easy recover the data if it lost.

The software’s made man’s work easy and we can do more work. It also reduce the work of humans.

Working of project:-

Page 8: RTB901A10 C-sharp Termpaper

The Project Working On Hotel Room Reservation and Room Allocation. The Project Contains The Records Of All Customers Whose Reserved The Rooms’ It Must Contains The All Information Of Customer, In Out Time Detail, Room Standard And Total Bill. In This Form We Can Add New Records, View Records, Check Total Bill Of Customer.

We Use Ms Access to Save Data base.

To Access Customer Data We Use Ms Access.

Ms Access connected with c-sharp to access data from ms access.

In C# We Create Forms According To Data Tables.

The tables show data according to user order (first, next, last, previous, add, save) etc.

7. FORM DESIGNING :-

Snapshots of forms:-1. MDIFORM :-

Page 9: RTB901A10 C-sharp Termpaper

2. CUSTOMER DETAIL AND ROOM ALLOCATION FORM :-

3. CUSTOMER ROOM DETAIL FORM :-

Page 10: RTB901A10 C-sharp Termpaper

4. CUSTOMER IN OUT DETAIL FORM :-

5. CUSTOMER BILL DETAIL FORM :-

Page 11: RTB901A10 C-sharp Termpaper

8. Coding :-

CODING OF MDIFORM:-

public partial class hotel_master : hotel_master

{

public hotel_master()

{

InitializeComponent();

}

private void customerDetailAndRoomAllocationToolStripMenuItem_Click(object sender,

EventArgs e)

{

cusdetailandroomallocation OBJ = new cusdetailandroomallocation();

OBJ.Show();

}

private void customerRoomDetailToolStripMenuItem_Click(object sender, EventArgs e)

Page 12: RTB901A10 C-sharp Termpaper

{

CUSROOMDETAIL OBJDETAIL = new CUSROOMDETAIL();

OBJDETAIL.Show();

}

private void customerINOUTDATETIMEToolStripMenuItem_Click(object sender,

EventArgs e)

{

CUSINOUTDETAIL OBJINOUT = new CUSINOUTDETAIL();

OBJINOUT.Show();

}

private void customerBillDetailToolStripMenuItem_Click(object sender, EventArgs e)

{

CUSBILLDETAIL OBJBILL = new CUSBILLDETAIL();

OBJBILL.Show();

}

1. CUSTOMER DETAIL AND ROOM ALLOCATION FORM

using System.Data.OleDb;

namespace C_SHARPTERMPAPER

{

public partial class cusdetailandroomallocation : Form

{

public cusdetailandroomallocation()

{

InitializeComponent();

}

Page 13: RTB901A10 C-sharp Termpaper

OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0; Data

Source =D:\\DATABASEONE.mdb");

OleDbDataAdapter da = new OleDbDataAdapter();

DataSet ds = new DataSet();

OleDbDataReader dr;

DataTable dt;

int totalrecords, i;

private void cusdetailandroomallocation_Load(object sender, EventArgs e)

{

da.SelectCommand = new OleDbCommand();

da.SelectCommand.Connection = conn;

da.SelectCommand.CommandText = "select * from CUSDETAIL ORDER BY CUSID";

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "cusdetail");

conn.Close();

dataGridView1.DataSource = ds.Tables[0];

dt = ds.Tables[0];

totalrecords = ds.Tables[0].Rows.Count;

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTROOMNO.Text = dt.Rows[i]["cusromno"].ToString();

TXTNAME.Text = dt.Rows[i]["cusname"].ToString();

TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

MessageBox.Show("DON'T TENSHION database Loaded Successfully");

}

Page 14: RTB901A10 C-sharp Termpaper

private void BTNFIRST_Click(object sender, EventArgs e)

{

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTROOMNO.Text = dt.Rows[i]["cusromno"].ToString();

TXTNAME.Text = dt.Rows[i]["cusname"].ToString();

TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

private void BTNNEXT_Click(object sender, EventArgs e)

{

if (i < totalrecords - 1)

{

i = i + 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTROOMNO.Text = dt.Rows[i]["cusromno"].ToString();

TXTNAME.Text = dt.Rows[i]["cusname"].ToString();

TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

else

{

MessageBox.Show("YOU ARE AT LAST RECOR");

}

Page 15: RTB901A10 C-sharp Termpaper

}

private void BTNLAST_Click(object sender, EventArgs e)

{

if (i == totalrecords - 1)

{

MessageBox.Show("YOU ARE AT LAST RECORD");

}

else

{

i = totalrecords - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTROOMNO.Text = dt.Rows[i]["cusromno"].ToString();

TXTNAME.Text = dt.Rows[i]["cusname"].ToString();

TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

}

private void BTNprev_Click(object sender, EventArgs e)

{

if (i > 0)

{

i = i - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTROOMNO.Text = dt.Rows[i]["cusromno"].ToString();

TXTNAME.Text = dt.Rows[i]["cusname"].ToString();

Page 16: RTB901A10 C-sharp Termpaper

TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

else

{

MessageBox.Show("you are at FIRST record");

}

}

private void BTNSAVE_Click(object sender, EventArgs e)

{

da.InsertCommand = new OleDbCommand();

da.InsertCommand.Connection = conn;

da.InsertCommand.CommandText = "INSERT INTO

cusdetail(cusid,cusromno,cusname,cusphno,cusaddress,roomrent)values("+TXTID.Text+","

+TXTROOMNO.Text+",'" + TXTNAME.Text + "',"+TXTPNO.Text+",'" +

TXTADDRESS.Text + "',"+TXTRENT.Text+")";

da.InsertCommand.CommandType = CommandType.Text;

conn.Open();

da.InsertCommand.ExecuteNonQuery();

da.Fill(ds, "cusdetail");

dt = ds.Tables[0];

totalrecords =dt.Rows.Count;

MessageBox.Show("ok one record added sucessfully");

}

private void BTNADD_Click(object sender, EventArgs e)

{

Page 17: RTB901A10 C-sharp Termpaper

TXTID.Text = "";

TXTNAME.Text = "";

TXTPNO.Text = "";

TXTADDRESS.Text = "";

TXTRENT.Text = "";

TXTROOMNO.Text = "";

TXTID.Focus();

}

private void BTNDELETE_Click(object sender, EventArgs e)

{

//da.DeleteCommand = new OleDbCommand();

//da.DeleteCommand.Connection = conn;

da.DeleteCommand = new OleDbCommand();

da.DeleteCommand.Connection = conn;

da.DeleteCommand.CommandText = "deleted from cusdetail Where CUSID="+TXTID;

da.DeleteCommand.CommandType = CommandType.Text;

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "cusdetail");

conn.Close();

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("one record is deleted in database");

}

private void btnupdate_Click(object sender, EventArgs e)

{

da.UpdateCommand = new OleDbCommand();

da.UpdateCommand.Connection = conn;

Page 18: RTB901A10 C-sharp Termpaper

da.UpdateCommand.CommandText = "update cusdetail set cusid=" + TXTID.Text +

",cusromno=" + TXTROOMNO.Text + ",cusname= '" + TXTNAME.Text + "',cusphno=" +

TXTPNO.Text + ",cusaddress='" + TXTADDRESS.Text + "',roomrent=" + TXTRENT.Text + "

where cusid=" + TXTID.Text;

da.UpdateCommand .CommandType = CommandType.Text;

conn.Open();

da.UpdateCommand.ExecuteNonQuery();

da.Fill(ds, "cusdetail");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("ok one record UPDATED sucessfully");

}

private void BTNFONT_Click(object sender, EventArgs e)

{

FontDialog fd = new FontDialog();

fd.ShowDialog();

TXTID.Font = fd.Font ;

TXTNAME.Font = fd.Font;

TXTADDRESS.Font = fd.Font;

TXTPNO.Font = fd.Font;

TXTRENT.Font = fd.Font;

TXTROOMNO.Font = fd.Font;

}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs

e)

{

Page 19: RTB901A10 C-sharp Termpaper

}

}

}

2. CUSTOMER ROOM DETAIL FORM :-

using System.Data.OleDb;

namespace C_SHARPTERMPAPER

{

public partial class CUSROOMDETAIL : Form

{

public CUSROOMDETAIL()

{

InitializeComponent();

}

OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0; Data

Source =D:\\DATABASEONE.mdb");

OleDbDataAdapter da = new OleDbDataAdapter();

DataSet ds = new DataSet();

OleDbDataReader dr;

DataTable dt;

int totalrecords, i;

private void CUSROOMDETAIL_Load(object sender, EventArgs e)

{

Page 20: RTB901A10 C-sharp Termpaper

da.SelectCommand = new OleDbCommand();

da.SelectCommand.Connection = conn;

da.SelectCommand.CommandText = "select * from roomdetail ORDER BY CUSID";

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "roomdetail");

conn.Close();

dataGridView1.DataSource = ds.Tables[0];

dt = ds.Tables[0];

totalrecords = ds.Tables[0].Rows.Count;

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTSTANDARD.Text = dt.Rows[i]["ROOMSTANDARD"].ToString();

TXTRENT .Text= dt.Rows[i]["roomrent"].ToString();

//TXTPNO.Text = dt.Rows[i]["cusphno"].ToString();

//TXTADDRESS.Text = dt.Rows[i]["cusaddress"].ToString();

//TXTRENT.Text = dt.Rows[i]["room rent"].ToString();

MessageBox.Show("database Loaded Successfully");

}

private void BTNFIRST_Click(object sender, EventArgs e)

{

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTSTANDARD.Text = dt.Rows[i]["ROOMSTANDARD"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

Page 21: RTB901A10 C-sharp Termpaper

private void BTNNEXT_Click(object sender, EventArgs e)

{

if (i < totalrecords - 1)

{

i = i + 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTSTANDARD.Text = dt.Rows[i]["ROOMSTANDARD"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

else

{

MessageBox.Show("you are at last record");

}

}

private void BTNprev_Click(object sender, EventArgs e)

{

if (i > 0)

{

i = i - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTSTANDARD.Text = dt.Rows[i]["ROOMSTANDARD"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

else

{

MessageBox.Show("You are at FIRST RECORD");

}

}

private void BTNLAST_Click(object sender, EventArgs e)

Page 22: RTB901A10 C-sharp Termpaper

{

if (i == totalrecords - 1)

{

MessageBox.Show("you are at last record");

}

else

{

i = totalrecords - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTSTANDARD.Text = dt.Rows[i]["ROOMSTANDARD"].ToString();

TXTRENT.Text = dt.Rows[i]["roomrent"].ToString();

}

}

private void BTNSAVE_Click(object sender, EventArgs e)

{

da.InsertCommand = new OleDbCommand();

da.InsertCommand.Connection = conn;

da.InsertCommand.CommandText = "INSERT INTO

roomdetail(cusid,ROOMSTANDARD,roomrent)values(" + TXTID.Text + ",'" +

TXTSTANDARD.Text + "'," + TXTRENT.Text + ")";

da.InsertCommand.CommandType = CommandType.Text;

conn.Open();

da.InsertCommand.ExecuteNonQuery();

da.Fill(ds, "roomdetail");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("record added sucessfully");

Page 23: RTB901A10 C-sharp Termpaper

}

private void BTNADD_Click(object sender, EventArgs e)

{

TXTID.Text = "";

TXTSTANDARD.Text = "";

TXTRENT.Text = "";

}

private void BTNDELETE_Click(object sender, EventArgs e)

{

da.DeleteCommand = new OleDbCommand();

da.DeleteCommand.Connection = conn;

da.DeleteCommand.CommandText = "deleted from roomdetail Where CUSID=" +

TXTID;

da.DeleteCommand.CommandType = CommandType.Text;

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "db1");

conn.Close();

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("one record is deleted in database");

}

private void btnupdate_Click(object sender, EventArgs e)

{

da.UpdateCommand = new OleDbCommand();

Page 24: RTB901A10 C-sharp Termpaper

da.UpdateCommand.Connection = conn;

da.UpdateCommand.CommandText = "update roomdetail set cusid="+ TXTID.Text +

",ROOMSTANDARD='" + TXTSTANDARD.Text + "',roomrent=" + TXTRENT.Text +" where

cusid=" + TXTID.Text;

da.UpdateCommand.CommandType = CommandType.Text;

conn.Open();

da.UpdateCommand.ExecuteNonQuery();

da.Fill(ds, "roomdetail");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("ok one record UPDATED sucessfully");

}

}

}

3. CUSTOMER IN OUT DETAIL FORM :-

using System.Data.OleDb;

namespace C_SHARPTERMPAPER

{

public partial class CUSINOUTDETAIL : Form

{

public CUSINOUTDETAIL()

{

InitializeComponent();

}

OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0; Data

Source =D:\\DATABASEONE.mdb");

OleDbDataAdapter da = new OleDbDataAdapter();

DataSet ds = new DataSet();

Page 25: RTB901A10 C-sharp Termpaper

OleDbDataReader dr;

DataTable dt;

int totalrecords, i;

private void button1_Click(object sender, EventArgs e)

{

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTINDATE.Text = dt.Rows[i]["cusindate"].ToString();

TXTOUTDATE.Text = dt.Rows[i]["cusoutdate"].ToString();

}

private void TXTID_TextChanged(object sender, EventArgs e)

{

}

private void CUSINOUTDETAIL_Load(object sender, EventArgs e)

{

da.SelectCommand = new OleDbCommand();

da.SelectCommand.Connection = conn;

da.SelectCommand.CommandText = "select * from CUSINOUT ORDER BY CUSID";

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "cusinout");

conn.Close();

dataGridView1.DataSource = ds.Tables[0];

dt = ds.Tables[0];

totalrecords = ds.Tables[0].Rows.Count;

Page 26: RTB901A10 C-sharp Termpaper

i = 0;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTINDATE.Text = dt.Rows[i]["cusindate"].ToString();

TXTOUTDATE.Text = dt.Rows[i]["cusoutdate"].ToString();

MessageBox.Show("DON'T TENSHION database Loaded Successfully");

}

private void BTNNEXT_Click(object sender, EventArgs e)

{

if (i < totalrecords - 1)

{

i = i + 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTINDATE.Text = dt.Rows[i]["cusindate"].ToString();

TXTOUTDATE.Text = dt.Rows[i]["cusoutdate"].ToString();

}

else

{

MessageBox.Show("you are at last record");

}

}

private void BTNLAST_Click(object sender, EventArgs e)

{

if (i == totalrecords - 1)

{

MessageBox.Show("you are at last record");

}

else

{

Page 27: RTB901A10 C-sharp Termpaper

i = totalrecords - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTINDATE.Text = dt.Rows[i]["cusindate"].ToString();

TXTOUTDATE.Text = dt.Rows[i]["cusoutdate"].ToString();

}

}

private void BTNADD_Click(object sender, EventArgs e)

{

TXTID.Text = "";

TXTINDATE.Text = "";

TXTOUTDATE.Text = "";

}

private void BTNSAVE_Click(object sender, EventArgs e)

{

da.InsertCommand = new OleDbCommand();

da.InsertCommand.Connection = conn;

da.InsertCommand.CommandText = "INSERT INTO

cusinout(cusid,cusindate,cusoutdate)values("+TXTID.Text+",

'+TXTINDATE.Text+','+TXTOUTDATE.Text+')";

da.InsertCommand.CommandType = CommandType.Text;

conn.Open();

da.InsertCommand.ExecuteNonQuery();

da.Fill(ds, "cusinout");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("record add");

}

Page 28: RTB901A10 C-sharp Termpaper

private void BTNPREV_Click(object sender, EventArgs e)

{

if (i > 0)

{

i = i - 1;

TXTID.Text = dt.Rows[i]["cusid"].ToString();

TXTINDATE.Text = dt.Rows[i]["cusindate"].ToString();

TXTOUTDATE.Text = dt.Rows[i]["cusoutdate"].ToString();

}

else

{

MessageBox.Show("YOU ARE AT FIRST RECORD");

}

}

private void BTNDELETE_Click(object sender, EventArgs e)

{

da.DeleteCommand = new OleDbCommand();

da.DeleteCommand.Connection = conn;

da.DeleteCommand.CommandText = "deleted from cusinout Where CUSID=" + TXTID;

da.DeleteCommand.CommandType = CommandType.Text;

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "db1");

conn.Close();

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("one record is deleted in database");

Page 29: RTB901A10 C-sharp Termpaper

}

private void btnupdate_Click(object sender, EventArgs e)

{

da.UpdateCommand = new OleDbCommand();

da.UpdateCommand.Connection = conn;

da.UpdateCommand.CommandText = "update cusinout set CUSID ="+ TXTID.Text +

",cusindate= '+TXTINDATE.Text+',cusoutdate='+TXTOUTDATE.Text+' where cusid=" +

TXTID.Text;

da.UpdateCommand.CommandType = CommandType.Text;

conn.Open();

da.UpdateCommand.ExecuteNonQuery();

da.Fill(ds, "cusinout");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("ok one record UPDATED sucessfully");

}

}

}

4. CUSTOMER BILL DETAIL FORM :-

using System.Data.OleDb;

namespace C_SHARPTERMPAPER

{

public partial class CUSBILLDETAIL : Form

{

public CUSBILLDETAIL()

{

Page 30: RTB901A10 C-sharp Termpaper

InitializeComponent();

}

OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0; Data

Source =D:\\DATABASEONE.mdb");

OleDbDataAdapter da = new OleDbDataAdapter();

DataSet ds = new DataSet();

OleDbDataReader dr;

DataTable dt;

int totalrecords, i;

private void CUSBILLDETAIL_Load(object sender, EventArgs e)

{

da.SelectCommand = new OleDbCommand();

da.SelectCommand.Connection = conn;

da.SelectCommand.CommandText = "select * from cusamount ORDER BY CUSID";

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "cusamount");

conn.Close();

dataGridView1.DataSource = ds.Tables[0];

dt = ds.Tables[0];

totalrecords = ds.Tables[0].Rows.Count;

i = 0;

CUSID.Text = dt.Rows[i]["cusid"].ToString();

CUSLIVINGTIME.Text = dt.Rows[i]["livingtime"].ToString();

CUSAMOUNT.Text = dt.Rows[i]["totalamount"].ToString();

}

private void BTNFIRST_Click(object sender, EventArgs e)

{

i = 0;

Page 31: RTB901A10 C-sharp Termpaper

CUSID.Text = dt.Rows[i]["cusid"].ToString();

CUSLIVINGTIME.Text = dt.Rows[i]["livingtime"].ToString();

CUSAMOUNT.Text = dt.Rows[i]["totalamount"].ToString();

}

private void BTNNEXT_Click(object sender, EventArgs e)

{

if (i < totalrecords - 1)

{

i = i + 1;

CUSID.Text = dt.Rows[i]["cusid"].ToString();

CUSLIVINGTIME.Text = dt.Rows[i]["livingtime"].ToString();

CUSAMOUNT.Text = dt.Rows[i]["totalamount"].ToString();

}

else

{

MessageBox.Show("you are a last record");

}

}

private void BTNADD_Click(object sender, EventArgs e)

{

CUSID.Text = "";

CUSLIVINGTIME.Text = "";

CUSAMOUNT.Text = "";

}

private void BTNSAVE_Click(object sender, EventArgs e)

{

da.InsertCommand = new OleDbCommand();

da.InsertCommand.Connection = conn;

Page 32: RTB901A10 C-sharp Termpaper

da.InsertCommand.CommandText = "INSERT INTO

cusamount(cusid,livingtime,totalamount)values(" + CUSID.Text + ",'" +

CUSLIVINGTIME.Text + "'," + CUSAMOUNT.Text + ")";

da.InsertCommand.CommandType = CommandType.Text;

conn.Open();

da.InsertCommand.ExecuteNonQuery();

da.Fill(ds, "cusamount");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("one record added sucessfully");

}

private void BTNPREV_Click(object sender, EventArgs e)

{

if (i > 0)

{

i = i - 1;

CUSID.Text = dt.Rows[i]["cusid"].ToString();

CUSLIVINGTIME.Text = dt.Rows[i]["livingtime"].ToString();

CUSAMOUNT.Text = dt.Rows[i]["totalamount"].ToString();

}

else

{

MessageBox.Show("YOU ARE AT LAST RECORD");

}

}

private void BTNLAST_Click(object sender, EventArgs e)

{

Page 33: RTB901A10 C-sharp Termpaper

if (i == totalrecords - 1)

{

MessageBox.Show("YOU ARE AT LAST RECORD");

}

else

{

i = totalrecords - 1;

CUSID.Text = dt.Rows[i]["cusid"].ToString();

CUSLIVINGTIME.Text = dt.Rows[i]["livingtime"].ToString();

CUSAMOUNT.Text = dt.Rows[i]["totalamount"].ToString();

}

}

private void BTNDELETE_Click(object sender, EventArgs e)

{

da.DeleteCommand = new OleDbCommand();

da.DeleteCommand.Connection = conn;

da.DeleteCommand.CommandText = "deleted from cusamount Where CUSID=" +

CUSID;

da.DeleteCommand.CommandType = CommandType.Text;

conn.Open();

da.SelectCommand.ExecuteNonQuery();

da.Fill(ds, "db1");

conn.Close();

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("one record is deleted in database");

}

private void btnupdate_Click(object sender, EventArgs e)

Page 34: RTB901A10 C-sharp Termpaper

{

da.UpdateCommand = new OleDbCommand();

da.UpdateCommand.Connection = conn;

da.UpdateCommand.CommandText = "update cusamount set cusid="+ CUSID.Text +

",livingtime='" + CUSLIVINGTIME.Text + "',totalamount=" + CUSAMOUNT.Text + " where

cusid=" + CUSID.Text;

da.UpdateCommand.CommandType = CommandType.Text;

conn.Open();

da.UpdateCommand.ExecuteNonQuery();

da.Fill(ds, "cusamount");

dt = ds.Tables[0];

totalrecords = dt.Rows.Count;

MessageBox.Show("ok one record UPDATED sucessfully");

}

}

}