DiTec Esoft C# Project Free
DiTec Project Esoft (C#)
Cource: Diploma in Information Technology With E commerce
Obtained Grade B For This Project
Do not direct copy form this project. This project was uploaded to enhance your IT
knowledge.I think this project may be very helpful to understand procedure of C# project
for DiTEC.
Welcome Start & Window
Enter Button
private void BtnEnter_Click(object sender, EventArgs e)
{
FrmWelcome fr = new FrmWelcome();
fr.Show();
this.Hide();
}
Exit Button
private void BtnExit_Click(object sender, EventArgs e)
{
DialogResult d1;
d1 = MessageBox.Show("Are You Sure Do You Want To Exit
?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (d1.ToString() == "Yes")
{
Application.Exit();
}
}
Welcome & Loading Window
Timer control
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 100)
{
progressBar1.Value = progressBar1.Value + 2;
}
else
{
timer1.Enabled=false;
FrmUser fr = new FrmUser();
fr.Show();
this.Hide();
}
Timer Properties
Login Window
Submit Button
string username = "kasun";
string password = "8620";
private void button1_Click(object sender, EventArgs e)
{
if (TxtUsername.Text == username && TxtPassword.Text == password)
{
DialogResult m2;
m2 = MessageBox.Show("Thank
You!", "Sucsess",MessageBoxButtons.OK, MessageBoxIcon.Information);
if (m2.ToString() == "OK")
{
MDISystem md1 = new MDISystem();
md1.Show();
this.Hide();
}
}
else
{
DialogResult m2;
m2 = MessageBox.Show("Incorrect Username & Password
","Error!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (m2.ToString() == "Retry")
{
TxtUsername.Clear();
TxtPassword.Clear();
TxtUsername.Focus();
Clear Button
TxtUsername.Text = "";
TxtPassword.Text = "";
TxtUsername.Focus();
Exit Button
DialogResult d1;
d1 = MessageBox.Show("Are You Sure Do You Want To Exit
?","Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (d1.ToString() == "Yes")
{
Application.Exit();
}
MDI Window (Inside Menu Bar)
Appointment Details Window
FrmAppoinment_Details frm = new FrmAppoinment_Details();
frm.MdiParent = this;
frm.Show();
Medical Details Window
FrmMedical_Detals frm= new FrmMedical_Detals();
frm.MdiParent = this;
frm.Show();
Patient Details Window
FrmPatient_Details frm = new FrmPatient_Details();
frm.MdiParent = this;
frm.Show();
Doctor Details Window
FrmDoctor frm = new FrmDoctor();
frm.MdiParent = this;
frm.Show();
Medical Packages Window
FrmDoctor frm = new FrmDoctor();
frm.MdiParent = this;
frm.Show();
Help Window
FrmHelp frm = new FrmHelp();
frm.MdiParent = this;
frm.Show();
Author Window
FrmAuthor frm = new FrmAuthor();
frm.MdiParent = this;
frm.Show();
Appointment Details Window
Add Button
string connectionstring,commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring="INSERT INTO app
VALUES('"+CboRef.Text+"','"+txtpatname.Text+"','"+txtcontact.Text+"','"+txtad
dress.Text+"','"+cbogender.Text+"','"+comboBox1.Text+"','"+txtamount.Text+"')
";
MessageBox.Show("OK","Add Data ?",MessageBoxButtons.OK,MessageBoxIcon.Error);
OleDbConnection conn=new OleDbConnection(connectionstring);
OleDbCommand comm=new OleDbCommand(commandstring,conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Click OK","Data Added Successfully",MessageBoxButtons.OK);
conn.Close();
Search Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM app WHERE rn='" + CboRef.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader=null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("Completed !"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
txtpatname.Text = reader[1].ToString();
txtcontact.Text = reader[2].ToString();
txtaddress.Text = reader[3].ToString();
cbogender.Text = reader[4].ToString();
comboBox1.Text = reader[5].ToString();
txtamount.Text = reader[6].ToString();
}
reader.Close();
Update Button
String connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "UPDATE app SET rn='" + CboRef.Text +"',pn='" +
txtpatname.Text + "',co='" + txtcontact.Text + "',ad='" + txtaddress.Text
+ "',gn='" + cbogender.Text + "',pt='" + comboBox1.Text + "',am='" +
txtamount.Text + "'";
MessageBox.Show("Are u Sure", "Do You Want Update
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Success", "Data Added
Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error);
conn.Close();
Clear Button
CboRef.Text = "";
txtpatname.Text = "";
txtcontact.Text = "";
txtaddress.Text = "";
cbogender.Text = "";
comboBox1.Text = "";
txtamount.Text = "";
Delete Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "DELETE*FROM app WHERE rn='"+CboRef.Text+ "'";
if (MessageBox.Show("Are You Sure Do You Want Delete This Record
?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
CboRef.Text = "";
txtpatname.Clear();
txtcontact.Clear();
txtaddress.Clear();
cbogender.Text = "";
comboBox1.Text = "";
txtamount.Clear();
conn.Close();
Exit Button
this.Hide();
Medical Details Window
Add Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "INSERT INTO medical VALUES('" + comboBox1.Text
+ "','" + textBox3.Text + "','" + textBox2.Text +"','" + textBox1.Text
+ "','" + comboBox2.Text + "')";
MessageBox.Show("OK", "Add Data
?", MessageBoxButtons.OK,MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Click OK", "Data Added
Successfully",MessageBoxButtons.OK);
conn.Close();
Search Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM medical WHERE pno='" +
comboBox1.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("Completed !"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
textBox3.Text = reader[1].ToString();
textBox2.Text = reader[2].ToString();
textBox1.Text = reader[3].ToString();
comboBox2.Text = reader[4].ToString();
}
reader.Close();
Update Button
String connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "UPDATE medical SET pno='" + comboBox1.Text
+ "',pn='" + textBox3.Text + "',q='" + textBox2.Text +"',pp='" +
textBox1.Text + "',de='" + comboBox2.Text + "'";
MessageBox.Show("Are u Sure", "Do You Want Update
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Success", "Data Added
Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error);
conn.Close();
Clear Button
comboBox1.Text = "";
textBox3.Text = "";
textBox2.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
Delete Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "DELETE*FROM medical WHERE pno='" +
comboBox1.Text + "'";
if (MessageBox.Show("Are You Sure Do You Want Delete This Record
?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
textBox3.Clear();
textBox2.Clear();
textBox1.Clear();
comboBox2.Text = "";
comboBox1.Text = "";
conn.Close();
Exit Button
this.Hide();
Patient Details Window
Add Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text
+ "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text
+ "','" + textBox3.Text + "','" + textBox4.Text + "')";
MessageBox.Show("OK", "Add Data
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Click OK", "Data Added
Successfully",MessageBoxButtons.OK);
conn.Close();
Search Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM patient WHERE pno='" +
comboBox1.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("Completed !"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
textBox1.Text = reader[1].ToString();
comboBox2.Text = reader[2].ToString();
textBox2.Text = reader[3].ToString();
textBox3.Text = reader[4].ToString();
textBox4.Text = reader[5].ToString();
}
reader.Close();
Update Button
String connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "UPDATE patient SET pno='" + comboBox1.Text
+ "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" +
textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'";
MessageBox.Show("Are u Sure", "Do You Want Update
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Success", "Data Added
Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error);
conn.Close();
Clear Button
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
Delete Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "DELETE*FROM patient WHERE pno='" +
comboBox1.Text + "'";
if (MessageBox.Show("Are You Sure Do You Want Delete This Record
?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Clear();
textBox3.Clear();
textBox4.Text = "";
Exit Button
this.Hide();
Doctor Details Window
Add Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text
+ "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text
+ "','" + textBox3.Text + "','" + textBox4.Text + "')";
MessageBox.Show("OK", "Add Data
?", MessageBoxButtons.OK,MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Click OK", "Data Added
Successfully",MessageBoxButtons.OK);
conn.Close();
Search Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM patient WHERE pno='" +
comboBox1.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("Completed !"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
textBox1.Text = reader[1].ToString();
comboBox2.Text = reader[2].ToString();
textBox2.Text = reader[3].ToString();
textBox3.Text = reader[4].ToString();
textBox4.Text = reader[5].ToString();
}
reader.Close();
Update Button
String connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "UPDATE patient SET pno='" + comboBox1.Text
+ "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" +
textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'";
MessageBox.Show("Are u Sure", "Do You Want Update
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Success", "Data Added
Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error);
conn.Close();
Exit Button
this.Hide();
Delete Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "DELETE*FROM patient WHERE pno='" +
comboBox1.Text + "'";
if (MessageBox.Show("Are You Sure Do You Want Delete This Record
?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Clear();
textBox3.Clear();
textBox4.Text = "";
Clear Button
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
Medical Packages Window
Add Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text
+ "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text
+ "','" + textBox3.Text + "','" + textBox4.Text + "')";
MessageBox.Show("OK", "Add Data
?", MessageBoxButtons.OK,MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Click OK", "Data Added
Successfully",MessageBoxButtons.OK);
conn.Close();
Search Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM patient WHERE pno='" +
comboBox1.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("Completed !"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
textBox1.Text = reader[1].ToString();
comboBox2.Text = reader[2].ToString();
textBox2.Text = reader[3].ToString();
textBox3.Text = reader[4].ToString();
textBox4.Text = reader[5].ToString();
}
reader.Close();
Update Button
String connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "UPDATE patient SET pno='" + comboBox1.Text
+ "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" +
textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'";
MessageBox.Show("Are u Sure", "Do You Want Update
?",MessageBoxButtons.OK, MessageBoxIcon.Error);
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Success", "Data Added
Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error);
conn.Close();
Clear Button
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
Delete Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "DELETE*FROM patient WHERE pno='" +
comboBox1.Text + "'";
if (MessageBox.Show("Are You Sure Do You Want Delete This Record
?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
== DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
comboBox1.Text = "";
textBox1.Text = "";
comboBox2.Text = "";
textBox2.Clear();
textBox3.Clear();
textBox4.Text = "";
Exit Button
this.Hide();
Help Window
Select Button
string connectionstring, commandstring;
connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:Hosptal Management Systemesoft.mdb";
commandstring = "SELECT*FROM help WHERE se='" + comboBox1.Text
+ "'";
OleDbConnection conn = newOleDbConnection(connectionstring);
OleDbCommand comm = new OleDbCommand(commandstring, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show("......"); }
reader = comm.ExecuteReader();
while (reader.Read())
{
textBox2.Text = reader[1].ToString();
}
reader.Close();
Exit Button
this.Hide();
Author Window
Exit Button
this.Hide();
Now I think you earned good knowledge about project . Now I hope to give you additional
codes to solve some problems. ( These are additional codes )
privatevoid btnadd_Click(object sender, EventArgs e)
{
string connectionString, commandString;
connectionString
=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital
SystemHMS.mdb";
commandString = "INSERT INTO Appoinment VALUES ('"+
cborefno.Text + "','" + txtpatname.Text + "','" + txtcontact.Text
+ "','" + txtaddress.Text + "','" + cbogender.Text + "','" +
cboPayment.Text + "','" + txtamount.Text + "')";
OleDbConnection conn = newOleDbConnection(connectionString);
OleDbCommand comm = newOleDbCommand(commandString, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Added Succesfully");
cborefno.Items.Add(cborefno.Text);
Clear();
cborefno.Focus();
conn.Close();
}
privatevoid cborefno_SelectedIndexChanged(object sender,EventArgs e
)
{
string connectionString, commandString;
connectionString
=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital
SystemHMS.mdb";
commandString = "SELECT * FROM Appoinment WHERE
RefNo='" + cborefno.Text + "'";
OleDbConnection conn = newOleDbConnection(connectionString);
OleDbCommand comm = newOleDbCommand(commandString, conn);
OleDbDataReader reader = null;
try
{ conn.Open(); }
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
reader = comm.ExecuteReader();
while (reader.Read())
{
txtpatname.Text = reader[1].ToString();
txtcontact.Text = reader[2].ToString();
txtaddress.Text = reader[3].ToString();
cbogender.Text = reader[4].ToString();
cboPayment.Text = reader[5].ToString();
txtamount.Text = reader[6].ToString(); }
reader.Close();
conn.Close();
}
privatevoid Form1_Load(object sender, EventArgs e)
{
string connectionString, commandString;
connectionString
=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital
SystemHMS.mdb";
commandString = "SELECT RefNo FROM Appoinment";
OleDbConnection conn = newOleDbConnection(connectionString);
OleDbCommand comm = newOleDbCommand(commandString, conn);
OleDbDataReader reader = null;
try
{
conn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
reader = comm.ExecuteReader();
while (reader.Read())
{
cborefno.Items.Add(reader[0]);
}
reader.Close();
conn.Close();
}
privatevoid btnupdate_Click(object sender, EventArgs e)
{
string connectionString, commandString;
connectionString
=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital
SystemHMS.mdb";
commandString = "UPDATE Appoinment SET PatName = '"+
txtpatname.Text + "', Contact = '" + txtcontact.Text + "', Address
= '" + txtaddress.Text + "', Gender = '" + cbogender.Text
+ "',PayType = '" + cboPayment.Text +"',Amount='" + txtamount.Text
+ "' where RefNo = '" + cborefno.Text + "'";
if (MessageBox.Show("Are you sure, you want to Update this
record?", "Sure?", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionString);
OleDbCommand comm = newOleDbCommand(commandString, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Updated Succesfully");
Clear();
cborefno.Focus();
conn.Close();
}
privatevoid btndelete_Click(object sender, EventArgs e)
{
string connectionString, commandString;
connectionString
=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital
SystemHMS.mdb";
commandString = "DELETE Appoinment.RefNo FROM
Appoinment where Appoinment.RefNo = '" + cborefno.Text + "'";
if (MessageBox.Show("Are you sure, you want to delete this
record?", "Sure?", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
OleDbConnection conn = newOleDbConnection(connectionString);
OleDbCommand comm = newOleDbCommand(commandString, conn);
conn.Open();
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted Successfully");
conn.Close();
cborefno.Items.Remove(cborefno.Text);
cborefno.Focus();
Clear();
}
privatevoid Clear()
{
cborefno.Text = "";
txtpatname.Clear();
txtcontact.Clear();
txtaddress.Clear();
cbogender.Text = "";
cboPayment.Text = "";
txtamount.Clear();
cborefno.Focus();
}
privatevoid btnclear_Click(object sender, EventArgs e)
{
Clear();
}
privatevoid btnexit_Click(object sender, EventArgs e)
{
this.Hide();
}
********************************
About Me !
********************************
Kasun Madhusanka
Phone:+94770597830
Email:kktmadhusanka@gmail.com
To Make likes me on facebook click below link
https://www.facebook.com/KKTMadhusanka
To make connection with me !
https://www.linkedin.com/in/kktmadhusanka
http://www.slideshare.net/kktmadhusanka
Posted by Kasun Madhusanka at 3:44 PM

Ditec esoft C# project

  • 1.
    DiTec Esoft C#Project Free DiTec Project Esoft (C#) Cource: Diploma in Information Technology With E commerce Obtained Grade B For This Project Do not direct copy form this project. This project was uploaded to enhance your IT knowledge.I think this project may be very helpful to understand procedure of C# project for DiTEC.
  • 4.
    Welcome Start &Window Enter Button private void BtnEnter_Click(object sender, EventArgs e) { FrmWelcome fr = new FrmWelcome(); fr.Show(); this.Hide();
  • 5.
    } Exit Button private voidBtnExit_Click(object sender, EventArgs e) { DialogResult d1; d1 = MessageBox.Show("Are You Sure Do You Want To Exit ?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (d1.ToString() == "Yes") { Application.Exit(); } } Welcome & Loading Window Timer control private void timer1_Tick(object sender, EventArgs e) { if (progressBar1.Value < 100) { progressBar1.Value = progressBar1.Value + 2; } else { timer1.Enabled=false; FrmUser fr = new FrmUser(); fr.Show(); this.Hide(); } Timer Properties
  • 6.
    Login Window Submit Button stringusername = "kasun"; string password = "8620"; private void button1_Click(object sender, EventArgs e) { if (TxtUsername.Text == username && TxtPassword.Text == password) { DialogResult m2; m2 = MessageBox.Show("Thank You!", "Sucsess",MessageBoxButtons.OK, MessageBoxIcon.Information); if (m2.ToString() == "OK") { MDISystem md1 = new MDISystem(); md1.Show(); this.Hide(); } }
  • 7.
    else { DialogResult m2; m2 =MessageBox.Show("Incorrect Username & Password ","Error!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (m2.ToString() == "Retry") { TxtUsername.Clear(); TxtPassword.Clear(); TxtUsername.Focus(); Clear Button TxtUsername.Text = ""; TxtPassword.Text = ""; TxtUsername.Focus(); Exit Button DialogResult d1; d1 = MessageBox.Show("Are You Sure Do You Want To Exit ?","Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (d1.ToString() == "Yes") { Application.Exit(); } MDI Window (Inside Menu Bar) Appointment Details Window FrmAppoinment_Details frm = new FrmAppoinment_Details(); frm.MdiParent = this; frm.Show(); Medical Details Window FrmMedical_Detals frm= new FrmMedical_Detals(); frm.MdiParent = this; frm.Show(); Patient Details Window FrmPatient_Details frm = new FrmPatient_Details(); frm.MdiParent = this; frm.Show(); Doctor Details Window
  • 8.
    FrmDoctor frm =new FrmDoctor(); frm.MdiParent = this; frm.Show(); Medical Packages Window FrmDoctor frm = new FrmDoctor(); frm.MdiParent = this; frm.Show(); Help Window FrmHelp frm = new FrmHelp(); frm.MdiParent = this; frm.Show(); Author Window FrmAuthor frm = new FrmAuthor(); frm.MdiParent = this; frm.Show(); Appointment Details Window Add Button string connectionstring,commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring="INSERT INTO app VALUES('"+CboRef.Text+"','"+txtpatname.Text+"','"+txtcontact.Text+"','"+txtad dress.Text+"','"+cbogender.Text+"','"+comboBox1.Text+"','"+txtamount.Text+"') "; MessageBox.Show("OK","Add Data ?",MessageBoxButtons.OK,MessageBoxIcon.Error); OleDbConnection conn=new OleDbConnection(connectionstring); OleDbCommand comm=new OleDbCommand(commandstring,conn);
  • 9.
    conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Click OK","Data AddedSuccessfully",MessageBoxButtons.OK); conn.Close(); Search Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM app WHERE rn='" + CboRef.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader=null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("Completed !"); } reader = comm.ExecuteReader(); while (reader.Read()) { txtpatname.Text = reader[1].ToString(); txtcontact.Text = reader[2].ToString(); txtaddress.Text = reader[3].ToString(); cbogender.Text = reader[4].ToString(); comboBox1.Text = reader[5].ToString(); txtamount.Text = reader[6].ToString(); } reader.Close(); Update Button String connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "UPDATE app SET rn='" + CboRef.Text +"',pn='" + txtpatname.Text + "',co='" + txtcontact.Text + "',ad='" + txtaddress.Text + "',gn='" + cbogender.Text + "',pt='" + comboBox1.Text + "',am='" + txtamount.Text + "'"; MessageBox.Show("Are u Sure", "Do You Want Update ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Success", "Data Added Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error); conn.Close(); Clear Button CboRef.Text = ""; txtpatname.Text = "";
  • 10.
    txtcontact.Text = ""; txtaddress.Text= ""; cbogender.Text = ""; comboBox1.Text = ""; txtamount.Text = ""; Delete Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "DELETE*FROM app WHERE rn='"+CboRef.Text+ "'"; if (MessageBox.Show("Are You Sure Do You Want Delete This Record ?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); CboRef.Text = ""; txtpatname.Clear(); txtcontact.Clear(); txtaddress.Clear(); cbogender.Text = ""; comboBox1.Text = ""; txtamount.Clear(); conn.Close(); Exit Button this.Hide(); Medical Details Window
  • 11.
    Add Button string connectionstring,commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "INSERT INTO medical VALUES('" + comboBox1.Text + "','" + textBox3.Text + "','" + textBox2.Text +"','" + textBox1.Text + "','" + comboBox2.Text + "')"; MessageBox.Show("OK", "Add Data ?", MessageBoxButtons.OK,MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Click OK", "Data Added Successfully",MessageBoxButtons.OK); conn.Close(); Search Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM medical WHERE pno='" + comboBox1.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("Completed !"); } reader = comm.ExecuteReader();
  • 12.
    while (reader.Read()) { textBox3.Text =reader[1].ToString(); textBox2.Text = reader[2].ToString(); textBox1.Text = reader[3].ToString(); comboBox2.Text = reader[4].ToString(); } reader.Close(); Update Button String connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "UPDATE medical SET pno='" + comboBox1.Text + "',pn='" + textBox3.Text + "',q='" + textBox2.Text +"',pp='" + textBox1.Text + "',de='" + comboBox2.Text + "'"; MessageBox.Show("Are u Sure", "Do You Want Update ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Success", "Data Added Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error); conn.Close(); Clear Button comboBox1.Text = ""; textBox3.Text = ""; textBox2.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; Delete Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "DELETE*FROM medical WHERE pno='" + comboBox1.Text + "'"; if (MessageBox.Show("Are You Sure Do You Want Delete This Record ?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open();
  • 13.
    comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); textBox3.Clear(); textBox2.Clear(); textBox1.Clear(); comboBox2.Text= ""; comboBox1.Text = ""; conn.Close(); Exit Button this.Hide(); Patient Details Window Add Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text + "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')"; MessageBox.Show("OK", "Add Data ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open();
  • 14.
    comm.ExecuteNonQuery(); MessageBox.Show("Click OK", "DataAdded Successfully",MessageBoxButtons.OK); conn.Close(); Search Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM patient WHERE pno='" + comboBox1.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("Completed !"); } reader = comm.ExecuteReader(); while (reader.Read()) { textBox1.Text = reader[1].ToString(); comboBox2.Text = reader[2].ToString(); textBox2.Text = reader[3].ToString(); textBox3.Text = reader[4].ToString(); textBox4.Text = reader[5].ToString(); } reader.Close(); Update Button String connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "UPDATE patient SET pno='" + comboBox1.Text + "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" + textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'"; MessageBox.Show("Are u Sure", "Do You Want Update ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Success", "Data Added Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error); conn.Close(); Clear Button comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = "";
  • 15.
    Delete Button string connectionstring,commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "DELETE*FROM patient WHERE pno='" + comboBox1.Text + "'"; if (MessageBox.Show("Are You Sure Do You Want Delete This Record ?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Clear(); textBox3.Clear(); textBox4.Text = ""; Exit Button this.Hide(); Doctor Details Window
  • 16.
    Add Button string connectionstring,commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text + "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')"; MessageBox.Show("OK", "Add Data ?", MessageBoxButtons.OK,MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Click OK", "Data Added Successfully",MessageBoxButtons.OK); conn.Close(); Search Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM patient WHERE pno='" + comboBox1.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("Completed !"); } reader = comm.ExecuteReader(); while (reader.Read()) { textBox1.Text = reader[1].ToString(); comboBox2.Text = reader[2].ToString(); textBox2.Text = reader[3].ToString(); textBox3.Text = reader[4].ToString(); textBox4.Text = reader[5].ToString(); } reader.Close(); Update Button String connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb";
  • 17.
    commandstring = "UPDATEpatient SET pno='" + comboBox1.Text + "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" + textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'"; MessageBox.Show("Are u Sure", "Do You Want Update ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Success", "Data Added Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error); conn.Close(); Exit Button this.Hide(); Delete Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "DELETE*FROM patient WHERE pno='" + comboBox1.Text + "'"; if (MessageBox.Show("Are You Sure Do You Want Delete This Record ?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Clear(); textBox3.Clear(); textBox4.Text = ""; Clear Button comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; Medical Packages Window
  • 18.
    Add Button string connectionstring,commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "INSERT INTO patient VALUES('" + comboBox1.Text + "','" + textBox1.Text + "','" + comboBox2.Text +"','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')"; MessageBox.Show("OK", "Add Data ?", MessageBoxButtons.OK,MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Click OK", "Data Added Successfully",MessageBoxButtons.OK); conn.Close(); Search Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM patient WHERE pno='" + comboBox1.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("Completed !"); }
  • 19.
    reader = comm.ExecuteReader(); while(reader.Read()) { textBox1.Text = reader[1].ToString(); comboBox2.Text = reader[2].ToString(); textBox2.Text = reader[3].ToString(); textBox3.Text = reader[4].ToString(); textBox4.Text = reader[5].ToString(); } reader.Close(); Update Button String connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "UPDATE patient SET pno='" + comboBox1.Text + "',pn='" + textBox1.Text + "',db='" + comboBox2.Text + "',bg='" + textBox2.Text + "',da='" + textBox3.Text + "',dr='" + textBox4.Text + "'"; MessageBox.Show("Are u Sure", "Do You Want Update ?",MessageBoxButtons.OK, MessageBoxIcon.Error); OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Success", "Data Added Sucsessfully!",MessageBoxButtons.OK, MessageBoxIcon.Error); conn.Close(); Clear Button comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; Delete Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "DELETE*FROM patient WHERE pno='" + comboBox1.Text + "'"; if (MessageBox.Show("Are You Sure Do You Want Delete This Record ?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionstring);
  • 20.
    OleDbCommand comm =new OleDbCommand(commandstring, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); comboBox1.Text = ""; textBox1.Text = ""; comboBox2.Text = ""; textBox2.Clear(); textBox3.Clear(); textBox4.Text = ""; Exit Button this.Hide(); Help Window Select Button string connectionstring, commandstring; connectionstring =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Hosptal Management Systemesoft.mdb"; commandstring = "SELECT*FROM help WHERE se='" + comboBox1.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionstring); OleDbCommand comm = new OleDbCommand(commandstring, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show("......"); } reader = comm.ExecuteReader();
  • 21.
    while (reader.Read()) { textBox2.Text =reader[1].ToString(); } reader.Close(); Exit Button this.Hide(); Author Window Exit Button this.Hide(); Now I think you earned good knowledge about project . Now I hope to give you additional codes to solve some problems. ( These are additional codes ) privatevoid btnadd_Click(object sender, EventArgs e) { string connectionString, commandString; connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital SystemHMS.mdb"; commandString = "INSERT INTO Appoinment VALUES ('"+ cborefno.Text + "','" + txtpatname.Text + "','" + txtcontact.Text
  • 22.
    + "','" +txtaddress.Text + "','" + cbogender.Text + "','" + cboPayment.Text + "','" + txtamount.Text + "')"; OleDbConnection conn = newOleDbConnection(connectionString); OleDbCommand comm = newOleDbCommand(commandString, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Added Succesfully"); cborefno.Items.Add(cborefno.Text); Clear(); cborefno.Focus(); conn.Close(); } privatevoid cborefno_SelectedIndexChanged(object sender,EventArgs e ) { string connectionString, commandString; connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital SystemHMS.mdb"; commandString = "SELECT * FROM Appoinment WHERE RefNo='" + cborefno.Text + "'"; OleDbConnection conn = newOleDbConnection(connectionString); OleDbCommand comm = newOleDbCommand(commandString, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } reader = comm.ExecuteReader(); while (reader.Read()) { txtpatname.Text = reader[1].ToString(); txtcontact.Text = reader[2].ToString(); txtaddress.Text = reader[3].ToString(); cbogender.Text = reader[4].ToString(); cboPayment.Text = reader[5].ToString(); txtamount.Text = reader[6].ToString(); } reader.Close(); conn.Close(); } privatevoid Form1_Load(object sender, EventArgs e) {
  • 23.
    string connectionString, commandString; connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=D:Hospital SystemHMS.mdb"; commandString = "SELECT RefNo FROM Appoinment"; OleDbConnection conn = newOleDbConnection(connectionString); OleDbCommand comm = newOleDbCommand(commandString, conn); OleDbDataReader reader = null; try { conn.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } reader = comm.ExecuteReader(); while (reader.Read()) { cborefno.Items.Add(reader[0]); } reader.Close(); conn.Close(); } privatevoid btnupdate_Click(object sender, EventArgs e) { string connectionString, commandString; connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital SystemHMS.mdb"; commandString = "UPDATE Appoinment SET PatName = '"+ txtpatname.Text + "', Contact = '" + txtcontact.Text + "', Address = '" + txtaddress.Text + "', Gender = '" + cbogender.Text + "',PayType = '" + cboPayment.Text +"',Amount='" + txtamount.Text + "' where RefNo = '" + cborefno.Text + "'"; if (MessageBox.Show("Are you sure, you want to Update this record?", "Sure?", MessageBoxButtons.YesNo) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionString); OleDbCommand comm = newOleDbCommand(commandString, conn);
  • 24.
    conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Updated Succesfully"); Clear(); cborefno.Focus(); conn.Close(); } privatevoidbtndelete_Click(object sender, EventArgs e) { string connectionString, commandString; connectionString =@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:Hospital SystemHMS.mdb"; commandString = "DELETE Appoinment.RefNo FROM Appoinment where Appoinment.RefNo = '" + cborefno.Text + "'"; if (MessageBox.Show("Are you sure, you want to delete this record?", "Sure?", MessageBoxButtons.YesNo) == DialogResult.No) { return; } OleDbConnection conn = newOleDbConnection(connectionString); OleDbCommand comm = newOleDbCommand(commandString, conn); conn.Open(); comm.ExecuteNonQuery(); MessageBox.Show("Record Deleted Successfully"); conn.Close(); cborefno.Items.Remove(cborefno.Text); cborefno.Focus(); Clear(); } privatevoid Clear() { cborefno.Text = ""; txtpatname.Clear(); txtcontact.Clear(); txtaddress.Clear(); cbogender.Text = ""; cboPayment.Text = ""; txtamount.Clear(); cborefno.Focus(); } privatevoid btnclear_Click(object sender, EventArgs e)
  • 25.
    { Clear(); } privatevoid btnexit_Click(object sender,EventArgs e) { this.Hide(); } ******************************** About Me ! ******************************** Kasun Madhusanka Phone:+94770597830 Email:kktmadhusanka@gmail.com To Make likes me on facebook click below link https://www.facebook.com/KKTMadhusanka To make connection with me ! https://www.linkedin.com/in/kktmadhusanka http://www.slideshare.net/kktmadhusanka
  • 26.
    Posted by KasunMadhusanka at 3:44 PM