You are on page 1of 122

Project Report

on

Name of Project

Submitted towards partial fulfillment for the award of the degree of

MASTER OF COMPUTER APPLICATION

At

College logo

Uttaranchal Institute of Management, Dehradun

Submitted by:

Name: ______________

MCA VI Semester

Under the Guidance of Internal Guide:

Mr.___________ Mr. ______________

Project Manager
(Lecturer)

Name of Company UIM Dehradun

Dehradun

CERTIFICATE

DECLARATION
ACKNOWLEGEMENT
CHAPTER.1
iNTRODUCTIO
N
1. INTRODUCTION
a. ABOUT COMPANY

b. ABOUT PROJECT

A manual Dispensary Management system is performed entirely by hand. A


computerized Management system allows a company to process its
management via dedicated managment software. A manual system is
usually a slow, laborious process; a computerized system helps to reduce
errors and speeds up the process. Computerized Dispensary Management
systems boast a number of other advantages as well.

This project will be used to manage employee dispensary system within


organization and generating a meaningful report. I am making this project
for Ambuja cement pvt. Ltd. \Company’s employees. It will store all the data
as daily basis as well as calculate various things about the stocks and
medicines. This will be great help to any organization to manage their
employee’s dispensary system because manually performing such operation
for huge number of employee is such a big task in terms of generation report
and calculating the number of operations so dispensary management system
speed up the process as well as reduce the various error.

The system covers all the tasks starting from the new patient registration up
to his investigation by the doctor and his billing. Contains facility to store
current as well as history records and getting proper reports based on them.
The system has been divided into 3 modules:

1) Case Registration and records history.


2) Billing.
3) Medicine Inventory.
Case registration and records history:
- New cases registration
- Medicine prescription and Lab test records for each patient
- Systematic handling of daily queue of patients for the doctor’s visit.

Billing:
- OPD bill
- Laboratory bill

Medicine Inventory:

- Deals with small-scale medicine inventories, which are run, together with
the dispensary
for selling medicines.
Scope:-
It can be used in any Hospital, Clinic, Dispensary or Pathology labs for
maintaining patient details and their test results.

CHAPTER.2
Project Analysis
2. PROJECT ANALYSIS

By analysis we mean the detailed study of the various Operations


performed by system and their relationship within and outside of the
system.
Technology plays an important growing role in the Medicines Industry today.
Dispensary management offers a full menu of services encompassing all
aspects of operations in the hospitality industry. Experienced corporate
management staff represents a multi-disciplined team of professionals highly
skilled in operations, accounting, marketing, information technology, and
human resources. The needs of ownership and competent management go
hand in hand. The Dispensary management services are available as a
complete package or individually tailored to specific projects or needs. Each
client is kept thoroughly informed through timely individualized reports on all
aspects of the management activity. Resources and capabilities can be
allocated and directed to meet the special needs of each hotel in the most
cost-effective manner.

One aspect of analysis is defining the boundaries of the system


and determining whether or not a candidate system should consider
other related systems.During analysis,data are collected on the available
files , decision point , and transaction handled by the present system
.DFD and on-site observations are some examples. Training, experience
and common sense are required for collection of the information
needed to do the analysis. Once the analysis is completed,the analysis
has a firm understanding of what is to be done.

2.1 FEASIBILITY STUDY:- This study deals with-

i. ECONOMICAL

It deals with the cost benefit analysis. It includes the expenses like
H/W, S/W, installation cost, Medicines’ , MR, wages, salaries etc.
ii. TECHNICAL (H/W & S/W SPECIFICATION)

It is related with the technical specifications of the projects. It focuses on the


three major questions:

Component Requirement
Software MSAccess 2000 or 2001 or 2003 or ant new version of MS
office

Hard Disk Disk space requirements will vary with the MS Access
components you install. Minimum 4 GB memory .

RAM And 512 MB RAM and processor with 733MHz Processor


Processors

iii. OPERATIONAL

It basically concern with the operational environment capabilities of a


project . It focuses on ability of users, user friendliness of the projects,
nature of working environment provided & ergonomics.
CHAPTER.3
design
It is the most creative and challenging phase of system development. It
deals with converting input into output design, input design, file or
database design and processing design.

3.1 ER DIAGRAMs:-
3.2DFD’s:-
3.3DATABASE DESIGN TABLES:-
CHAPTER.4
coding
1. Login Form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;
using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

{
public partial class frm_LogIn : Form

OleDbConnection connection;
OleDbCommand command;
OleDbDataAdapter da;
DataSet ds;
public string username;

public int userid;

public frm_LogIn()

InitializeComponent();

private void frm_LogIn_Load(object sender, EventArgs e)

cmb_username.Focus();

try
{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("Select UserName from


UserDetail Where (IsDeleted = 0) Order By UserName", connection);

da = new OleDbDataAdapter(command);

ds = new DataSet();
da.Fill(ds, "UserDetail");

int i = 0;

do

cmb_username.Items.Add(ds.Tables[0].Rows[i]
[0].ToString().ToString());

cmb_username.Text = ds.Tables[0].Rows[0][0].ToString();

i++;

while (ds.Tables[0].Rows[i][0].ToString() != " ");

catch (Exception)

finally

connection.Close();

}
// Cmb_OPDYear.Text = Convert.ToString(DateTime.Now.Year);

private void btnlogin_Click(object sender, EventArgs e)

if (cmb_username.Text == "Admin" && txt_userpassword.Text ==


"Admin")

frm_AdminLogIn obj_AdminLogIn = new frm_AdminLogIn();


obj_AdminLogIn.UserName = cmb_username.Text;

obj_AdminLogIn.Password = txt_userpassword.Text;

obj_AdminLogIn.Show();

this.Hide();

else

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("Select UserName,


UserPassword,ID from UserDetail Where (UserName = @UserName) AND
(IsDeleted = 0)", connection);

da = new OleDbDataAdapter(command);
command.Parameters.AddWithValue("@UserName",
cmb_username.Text);

ds = new DataSet();

da.Fill(ds, "UserDetail");

command.ExecuteNonQuery();

if (cmb_username.Text == ds.Tables[0].Rows[0]
[0].ToString().Trim() && txt_userpassword.Text == ds.Tables[0].Rows[0]
[1].ToString().Trim())

{
userid = Convert.ToInt32(ds.Tables[0].Rows[0][2]);

username = cmb_username.Text;

frm_DispensoryMGT obj_DispensoryMGT = new


frm_DispensoryMGT();

obj_DispensoryMGT.username = username;

obj_DispensoryMGT.userid = userid;

this.Hide();

obj_DispensoryMGT.Show();

else

MessageBox.Show("Please Enter Correct combination of User


Name and Password.","User Name & Password not
Match",MessageBoxButtons.OK,MessageBoxIcon.Warning);

txt_userpassword.ResetText();

}
catch (Exception)

finally

connection.Close();

}
}

private void btncancel_Click(object sender, EventArgs e)

this.Hide();

Application.Exit();

private void txt_userpassword_KeyPress(object sender,


KeyPressEventArgs e)

if (e.KeyChar == 13)

btnlogin_Click(sender, e);

private void cmb_username_Leave(object sender, EventArgs e)

txt_userpassword.Focus();

}
private void cmb_username_KeyUp(object sender, KeyEventArgs e)

if (e.KeyCode == Keys.Enter)

cmb_username_Leave(sender, e);

2. Select_option form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

public partial class frm_SelectOptions : Form

OleDbConnection connection;

OleDbCommand command;

OleDbDataAdapter da;
DataSet ds;

public string SendingType = "";

public int SendPuser_ID =0;

public DataSet GotDS;

public frm_SelectOptions()

InitializeComponent();

private void frm_SelectOptions_Load(object sender, EventArgs e)

if (SendingType == "PatientReport")

lbl_selecttype.Text = "Select Report Type :";

lbl_select.Text = "Select Now:";

cmb_selecttype.Items.Add("Yearly");

cmb_selecttype.Items.Add("Monthly");

cmb_selecttype.Items.Add("Date Wise");

cmb_Nowselect.Text = "-Select-";

else if (SendingType == "MedicineStock")

lbl_selecttype.Text = "Select Report Type :";

lbl_select.Text = "Select Now:";

cmb_selecttype.Items.Add("Yearly");

cmb_selecttype.Items.Add("Monthly");
cmb_selecttype.Items.Add("Date Wise");

cmb_Nowselect.Text = "-Select-";

private void cmb_selecttype_SelectedIndexChanged(object sender,


EventArgs e)

if (SendingType == "PatientReport")
{

cmb_Nowselect.Items.Clear();

cmb_Nowselect.Text = "-Select-";

if (cmb_selecttype.Text == "Monthly")

lbl_select.Text = "Select Month:";

cmb_Nowselect.Items.Add("1");

cmb_Nowselect.Items.Add("2");

cmb_Nowselect.Items.Add("3");

cmb_Nowselect.Items.Add("4");

cmb_Nowselect.Items.Add("5");

cmb_Nowselect.Items.Add("6");

cmb_Nowselect.Items.Add("7");

cmb_Nowselect.Items.Add("8");

cmb_Nowselect.Items.Add("9");

cmb_Nowselect.Items.Add("10");

cmb_Nowselect.Items.Add("11");

cmb_Nowselect.Items.Add("12");
}

else if (cmb_selecttype.Text == "Yearly")

lbl_select.Text = "Select Year:";

cmb_Nowselect.Items.Add("2009");

cmb_Nowselect.Items.Add("2010");

cmb_Nowselect.Items.Add("2011");

else if (cmb_selecttype.Text == "Date Wise")


{

lbl_select.Text = "Select Date:";

cmb_Nowselect.Text = "-Select-";

//To Get Recent Dates in Combobox

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT DISTINCT


FORMAT(PDate, 'dd/mm/yyyy') FROM PatientRecord WHERE
(FORMAT(PDate, 'yyyy') = @SelectYear)", connection); //ORDER BY MName
ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@SelectYear",
DateTime.Now.Year);

da = new OleDbDataAdapter(command);
ds = new DataSet();

da.Fill(ds, "PatientRecord");

int j = 0;

do

cmb_Nowselect.Items.Add(Convert.ToDateTime(ds.Tables[
0].Rows[j][0]).ToShortDateString());

j++;

} while (ds.Tables[0].Rows[j][0].ToString() != "");


}

catch (IndexOutOfRangeException)

//finally

//{

// connection.Close();

//}

else if (SendingType == "MedicineStock")

cmb_Nowselect.Items.Clear();

cmb_Nowselect.Text = "-Select-";

if (cmb_selecttype.Text == "Monthly")

lbl_select.Text = "Select Month:";


cmb_Nowselect.Items.Add("1");

cmb_Nowselect.Items.Add("2");

cmb_Nowselect.Items.Add("3");

cmb_Nowselect.Items.Add("4");

cmb_Nowselect.Items.Add("5");

cmb_Nowselect.Items.Add("6");

cmb_Nowselect.Items.Add("7");

cmb_Nowselect.Items.Add("8");

cmb_Nowselect.Items.Add("9");
cmb_Nowselect.Items.Add("10");

cmb_Nowselect.Items.Add("11");

cmb_Nowselect.Items.Add("12");

else if (cmb_selecttype.Text == "Yearly")

lbl_select.Text = "Select Year:";

cmb_Nowselect.Items.Add("2009");

cmb_Nowselect.Items.Add("2010");

cmb_Nowselect.Items.Add("2011");

else if (cmb_selecttype.Text == "Date Wise")

lbl_select.Text = "Select Expiry Date:";

cmb_Nowselect.Text = "-Select-";

//To Get Recent Dates in Combobox

try
{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT DISTINCT


FORMAT(MExpiryDate, 'dd/mm/yyyy') FROM
MedicineStockRecord WHERE (FORMAT(MExpiryDate, 'yyyy') =
@SelectYear)", connection); //ORDER BY MName ASC

command.Parameters.Clear();
command.Parameters.AddWithValue("@SelectYear",
DateTime.Now.Year);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

int j = 0;

do

cmb_Nowselect.Items.Add(Convert.ToDateTime(ds.Tables[
0].Rows[j][0]).ToShortDateString());

j++;

} while (ds.Tables[0].Rows[j][0].ToString() != "");

catch (IndexOutOfRangeException)

//finally

//{

// connection.Close();
//}

private void btn_Next_Click(object sender, EventArgs e)

if (SendingType == "PatientReport")
{

try

cls_PatientReport obj_PatientReport = new cls_PatientReport();

obj_PatientReport.Puser_ID = SendPuser_ID;

ds = new DataSet();

ds =
obj_PatientReport.SendDataSet(cmb_selecttype.Text.Trim(),
cmb_Nowselect.Text.Trim());

if (ds.Tables[0].Rows[0][0].ToString() == "")

MessageBox.Show("Data Not Saved.");

else

ds.WriteXml("C:\\Program Files\\My
Project\\Dispensory\\Xml\\PatientRecord.xml");

frm_Reports obj_Reports = new frm_Reports();


obj_Reports.ReportName = "PatientRecord";

obj_Reports.Show();

this.Hide();

catch (IndexOutOfRangeException)

MessageBox.Show("Data Not Saved.");

}
}

else if (SendingType == "MedicineStock")

try

cls_MedicineReport obj_MedicineReport = new


cls_MedicineReport();

obj_MedicineReport.Puser_ID = SendPuser_ID;

ds = new DataSet();

ds =
obj_MedicineReport.SendDataSetMedicine(cmb_selecttype.Text.Trim(),
cmb_Nowselect.Text.Trim());

if (ds.Tables[0].Rows[0][0].ToString() == "")

MessageBox.Show("Data Not Saved.");

else

{
ds.WriteXml("C:\\Program Files\\My
Project\\Dispensory\\Xml\\MedicineStock.xml");

frm_Reports obj_Reports = new frm_Reports();

obj_Reports.ReportName = "PatientRecord";

obj_Reports.Show();

this.Hide();

catch (IndexOutOfRangeException)
{

MessageBox.Show("Data Not Saved.");

3.Patient Details form:-

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;
using System.Data.OleDb;

namespace DispensoryMGTSystem

public partial class frm_PatientDetails : Form

OleDbConnection connection;

OleDbCommand command;

OleDbDataAdapter da;

DataSet ds;
public int Puser_ID = 0;

DataSet Public_DS;

DateTime Start_Date, End_Date;

public frm_PatientDetails()

InitializeComponent();

private void frm_PatientDetails_Load(object sender, EventArgs e)

//To Get Recent Dates in Combobox

//

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");
connection.Open();

//SELECT (SELECT (COUNT(*) + 1) FROM


MedicineStockRecord TMSR WHERE (TMSR.MID < MSR.MID)) AS [Sr No],
MName, MType, MBatchNo, MExpiryDate, MQuantity, MQuantityRemaining
FROM MedicineStockRecord MSR ORDER BY MID ASC

command = new OleDbCommand("SELECT DISTINCT FORMAT(PDate,


'dd/mm/yyyy') FROM PatientRecord", connection); //ORDER BY
MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@SelectMonthDate",
DateTime.Now.Month);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

Public_DS = ds;

int j = 0;

do

Start_Date = Convert.ToDateTime(ds.Tables[0].Rows[0][0]);

cmb_datefrom.Items.Add(Convert.ToDateTime(ds.Tables
[0].Rows[j][0]).ToShortDateString());

cmb_dateto.Items.Add(Convert.ToDateTime(ds.Tables[0]
.Rows[j][0]).ToShortDateString());

j++;

} while (ds.Tables[0].Rows[j][0].ToString() != "");

catch (IndexOutOfRangeException)

{
}

//finally

//{

// connection.Close();

//}

//try

//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

//SELECT (SELECT (COUNT(*) + 1) FROM


MedicineStockRecord TMSR WHERE (TMSR.MID < MSR.MID)) AS [Sr No],
MName, MType, MBatchNo, MExpiryDate, MQuantity, MQuantityRemaining
FROM MedicineStockRecord MSR ORDER BY MID ASC

command = new OleDbCommand("SELECT (SELECT (COUNT(*)


+ 1) FROM PatientRecord TPR WHERE (TPR.ID < PR.ID) AND
(PUserID = @PUserID) AND (IsDeleted = 0)) AS [Sr No], POPDNoYearly,
POPDNoMonthly, FORMAT(PDate, 'dd/mm/yyyy'), PName, PSex, PAge, PType,
PDiagnosis FROM PatientRecord PR WHERE (PUserID = @PUserID)
AND (IsDeleted = 0) ORDER BY ID ASC", connection); //ORDER BY MName
ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@UID", Puser_ID);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

Public_DS = ds;

// Get the table from the data set


DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView


lv_PatientDetails.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally
//{

// connection.Close();

//}

private void rd_SingleDay_CheckedChanged(object sender, EventArgs


e)

if (rd_SingleDay.Checked == true)

panel1.Enabled = true;

label4.Visible = true;

cmb_datefrom.Visible = true;

label5.Visible = false;

cmb_dateto.Visible = false;

else if(rd_Period.Checked == true)

{
panel1.Enabled = true;

label5.Visible = true;

cmb_dateto.Visible = true;

else

panel1.Enabled = false;

//try

//{
connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM PatientRecord TPR WHERE (TPR.ID <
PR.ID) AND (PUserID = @PUserID) AND (IsDeleted = 0)) AS [Sr No],
POPDNoYearly, POPDNoMonthly, FORMAT(PDate, 'dd/mm/yyyy'), PName,
PSex, PAge, PType, PDiagnosis FROM PatientRecord PR WHERE
(PUserID = @PUserID) AND (IsDeleted = 0) ORDER BY ID ASC",
connection); //ORDER BY MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@UID", Puser_ID);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "MedicineStockRecord");

Public_DS = ds;

// Get the table from the data set

DataTable dtable = ds.Tables[0];


//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView


lv_PatientDetails.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally

//{
// connection.Close();

//}

private void btn_ShowDetails_Click(object sender, EventArgs e)

if (rd_SingleDay.Checked == true)

if (cmb_datefrom.Text == "-Select-")

MessageBox.Show("Please Select Date.");

else

{
//try

//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM PatientRecord TPR WHERE (TPR.ID <
PR.ID) AND (PUserID = @PUserID) AND (IsDeleted = 0) AND (TPR.PDate
BETWEEN @PTreatmentDate1 AND @PTreatmentDate2)) AS [Sr No],
POPDNoYearly, POPDNoMonthly, FORMAT(PDate, 'dd/mm/yyyy'), PName,
PSex, PAge, PType, PDiagnosis FROM
PatientRecord PR WHERE (PUserID = @PUserID) AND (IsDeleted = 0)
AND (PDate BETWEEN @PTreatmentDate1 AND @PTreatmentDate2) ORDER
BY ID ASC", connection); //ORDER BY MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@PUserID", Puser_ID);

command.Parameters.AddWithValue("@PTreatmentDate1",
Convert.ToDateTime(cmb_datefrom.Text).AddDays(-
1).ToShortDateString()); //@PTreatmentDate

command.Parameters.AddWithValue("@PTreatmentDate2",
Convert.ToDateTime(cmb_datefrom.Text).AddDays(1).ToShortDateString()); /
/@PTreatmentDate

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

Public_DS = ds;

// Get the table from the data set


DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

{
DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());
// Add the list items to the ListView

lv_PatientDetails.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally
//{

// connection.Close();

//}

else if (rd_Period.Checked == true)

if (cmb_datefrom.Text == "-Select-" || cmb_dateto.Text == "-


Select-")

MessageBox.Show("Please Select Date.");

else

//try
//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM PatientRecord TPR WHERE (TPR.ID <
PR.ID) AND (PUserID = @PUserID) AND (IsDeleted = 0) AND (TPR.PDate
BETWEEN @PTreatmentDate1 AND @PTreatmentDate2)) AS [Sr No],
POPDNoYearly, POPDNoMonthly, FORMAT(PDate, 'dd/mm/yyyy'), PName,
PSex, PAge, PType, PDiagnosis FROM
PatientRecord PR WHERE (PUserID = @PUserID) AND (IsDeleted = 0)
AND (PDate BETWEEN @PTreatmentDate1 AND @PTreatmentDate2) ORDER
BY ID ASC", connection); //ORDER BY MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@PUserID", Puser_ID);

command.Parameters.AddWithValue("@PTreatmentDate1",
Convert.ToDateTime(cmb_datefrom.Text).AddDays(-
1).ToShortDateString()); //@PTreatmentDate

command.Parameters.AddWithValue("@PTreatmentDate2",
Convert.ToDateTime(cmb_dateto.Text).AddDays(1).ToShortDateString());
//@PTreatmentDate

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

Public_DS = ds;

// Get the table from the data set

DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];
// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted


if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView

lv_PatientDetails.Items.Add(lvi);

}
}

//}

//catch (Exception)

//{

//}

//finally

//{
// connection.Close();

//}

else

//try

//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM PatientRecord TPR WHERE (TPR.ID <
PR.ID) AND (PUserID = @PUserID) AND (IsDeleted = 0)) AS [Sr No],
POPDNoYearly, POPDNoMonthly, FORMAT(PDate, 'dd/mm/yyyy'), PName,
PSex, PAge, PType, PDiagnosis FROM PatientRecord PR WHERE
(PUserID = @PUserID) AND (IsDeleted = 0) ORDER BY ID ASC",
connection); //ORDER BY MName ASC

command.Parameters.Clear();
command.Parameters.AddWithValue("@PUserID", Puser_ID);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

Public_DS = ds;

// Get the table from the data set


DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());
lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView

lv_PatientDetails.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally

//{

// connection.Close();

//}

}
private void btn_print_Click(object sender, EventArgs e)

Public_DS.WriteXml("C:\\Program Files\\My
Project\\Dispensory\\Xml\\PatientRecord.xml");

frm_Reports obj_Reports = new frm_Reports();

obj_Reports.ReportName = "PatientRecord";

obj_Reports.Show();

private void btn_close_Click(object sender, EventArgs e)

this.Hide();

4.Patient_record details

//------------------------------------------------------------------------------

// <auto-generated>

// This code was generated by a tool.

// Runtime Version:2.0.50727.4959

//

// Changes to this file may cause incorrect behavior and will be lost if

// the code is regenerated.

// </auto-generated>

//------------------------------------------------------------------------------
namespace DispensoryMGTSystem {

using System;

using System.ComponentModel;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportSource;

using CrystalDecisions.CrystalReports.Engine;

public class rpt_PatientRecord : ReportClass {

public rpt_PatientRecord() {

public override string ResourceName {

get {

return "rpt_PatientRecord.rpt";

set {

// Do nothing

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public CrystalDecisions.CrystalReports.Engine.Section Section1 {


get {

return this.ReportDefinition.Sections[0];

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public CrystalDecisions.CrystalReports.Engine.Section Section2 {


get {

return this.ReportDefinition.Sections[1];

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public CrystalDecisions.CrystalReports.Engine.Section Section3 {

get {

return this.ReportDefinition.Sections[2];

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public CrystalDecisions.CrystalReports.Engine.Section Section4 {

get {
return this.ReportDefinition.Sections[3];

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public CrystalDecisions.CrystalReports.Engine.Section Section5 {

get {
return this.ReportDefinition.Sections[4];

[System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.
ExportOptions), "report.bmp")]

public class Cachedrpt_PatientRecord : Component, ICachedReport {

public Cachedrpt_PatientRecord() {

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public virtual bool IsCacheable {

get {

return true;

}
set {

//

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public virtual bool ShareDBLogonInfo {


get {

return false;

set {

//

[Browsable(false)]

[DesignerSerializationVisibilityAttribute(System.ComponentModel.Desig
nerSerializationVisibility.Hidden)]

public virtual System.TimeSpan CacheTimeOut {

get {

return CachedReportConstants.DEFAULT_TIMEOUT;

set {

//

}
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument
CreateReport() {

rpt_PatientRecord rpt = new rpt_PatientRecord();

rpt.Site = this.Site;

return rpt;

public virtual string GetCustomizedCacheKey(RequestContext request)


{
String key = null;

// // The following is the code used to generate the default

// // cache key for caching report jobs in the ASP.NET Cache.

// // Feel free to modify this code to suit your needs.

// // Returning key == null causes the default cache key to

// // be generated.

//

// key = RequestContext.BuildCompleteCacheKey(

// request,

// null, // sReportFilename

// this.GetType(),

// this.ShareDBLogonInfo );

return key;

5.Find_patient Form:-
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

public partial class frm_FindPatient : Form

OleDbConnection connection;

OleDbCommand command;

OleDbDataAdapter da;

OleDbCommand command1;

OleDbDataAdapter da1;

DataSet ds;

public int OPDNumber = 0, SelectedYear;

public frm_FindPatient()

InitializeComponent();

private void btn_Search_Click(object sender, EventArgs e)

{
if (rd_OPDNo.Checked == true)

// obj_Reports.PFileName = txt_OPDNoYearly.Text + "_" +


dtp_Date.Value.Day.ToString() + "_" + dtp_Date.Value.Year.ToString();

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");
connection.Open();

command = new OleDbCommand("SELECT PatientOPDNo,


TTreatmentVisitNo, TTreatmentDate, TUserID FROM MedicineIssued
WHERE (TUserID = 1) AND (PatientOPDNo = @PatientOPDNo) AND
(DatePart('yyyy', TTreatmentDate) = @Year_Treatment) ", connection); //OR
(PDepartment LIKE '*@PDepartment*') (PName LIKE '*@PName*') OR 7

command.Parameters.Clear();

command.Parameters.AddWithValue("@PatientOPDNo",
txt_Find.Text);

command.Parameters.AddWithValue("@Year_Treatment",Select
edYear);

// command.Parameters.AddWithValue("@PDepartment",
txt_Find.Text);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "MedicineIssued");

//

command1 = new OleDbCommand("SELECT POPDNoYearly,


PName, PSex, PAge, PDiagnosis FROM PatientRecord WHERE
(POPDNoYearly = @PatientOPDNo) AND (DatePart('yyyy',PDate) =
@PDate_Year) ", connection); //OR (PDepartment LIKE '*@PDepartment*')
(PName LIKE '*@PName*') OR 7

command1.Parameters.Clear();
command1.Parameters.AddWithValue("@PatientOPDNo",
txt_Find.Text);

command1.Parameters.AddWithValue("@PDate_Year",
SelectedYear);

// command.Parameters.AddWithValue("@PDepartment",
txt_Find.Text);

da1 = new OleDbDataAdapter(command1);

da1.Fill(ds, "PatientRecord");

// Get the table from the data set

DataTable dtable = ds.Tables[0];


//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(ds.Tables[1].Rows[0][1].ToString());
lvi.SubItems.Add(ds.Tables[1].Rows[0][2].ToString());

lvi.SubItems.Add(ds.Tables[1].Rows[0][3].ToString());

// Add the list items to the ListView

lv_PatientDetails.Items.Add(lvi);

catch (NullReferenceException)

catch (InvalidCastException)

//catch (Exception)

//{

//}

finally

connection.Close();

//else if (rd_name.Checked == true)

//{

// // obj_Reports.PFileName = txt_OPDNoYearly.Text + "_" +


dtp_Date.Value.Day.ToString() + "_" + dtp_Date.Value.Year.ToString();

// try
// {

// connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

// connection.Open();

// command = new OleDbCommand("SELECT


ID,POPDNoYearly, POPDNoMonthly, PName, PSex, PAge, PType, PAddress,
PDepartment, PDiagnosis, PSiteInjury, PContractorName, PDate, PUserID,
IsDeleted, PRemark FROM PatientRecord WHERE (PName LIKE
'%@PName%')", connection); //OR (PDepartment LIKE '*@PDepartment*')
(PName LIKE '*@PName*') OR

// command.Parameters.Clear();

// command.Parameters.AddWithValue("@PName",
txt_Find.Text);

// //command.Parameters.AddWithValue("@PName",
txt_Find.Text);

// // command.Parameters.AddWithValue("@PDepartment",
txt_Find.Text);

// da = new OleDbDataAdapter(command);

// ds = new DataSet();

// da.Fill(ds, "PatientRecord");

// // Get the table from the data set

// DataTable dtable = ds.Tables[0];

// //_DataSet.Tables["Titles"];

// // Clear the ListView control

// lv_PatientDetails.Items.Clear();
// // Display items in the ListView control

// for (int i = 0; i < dtable.Rows.Count; i++)

// {

// DataRow drow = dtable.Rows[i];

// // Only row that have not been deleted

// if (drow.RowState != DataRowState.Deleted)

// {

// // Define the list items


// ListViewItem lvi = new ListViewItem(drow[1].ToString());

// lvi.SubItems.Add(drow[3].ToString());

// lvi.SubItems.Add(drow[5].ToString());

// lvi.SubItems.Add(drow[7].ToString());

// lvi.SubItems.Add(drow[12].ToString());

// // Add the list items to the ListView

// lv_PatientDetails.Items.Add(lvi);

// }

// }

// }

// catch (NullReferenceException)

// {

// }

// catch (InvalidCastException)

// {

// }

// //catch (Exception)
// //{

// //}

// finally

// {

// connection.Close();

// }

//}

private void lv_PatientDetails_DoubleClick(object sender, EventArgs e)

// OPDNumber = Convert.ToInt32();

string FindFileName =
"P_"+lv_PatientDetails.SelectedItems[0].SubItems[0].Text + "_" +
Convert.ToDateTime(lv_PatientDetails.SelectedItems[0].SubItems[2].Text).D
ay.ToString() + "_" +
Convert.ToDateTime(lv_PatientDetails.SelectedItems[0].SubItems[2].Text).M
onth.ToString() + "_" +
Convert.ToDateTime(lv_PatientDetails.SelectedItems[0].SubItems[2].Text).Ye
ar.ToString() + ".pdf";

FindFileName = "C:\\Program Files\\My Project\\Dispensory\\Slips\\" +


FindFileName;

if (System.IO.File.Exists(FindFileName))

// System.IO.File.Open(FindFileName, System.IO.FileMode.Open);

System.Diagnostics.Process.Start(FindFileName);

else

{
MessageBox.Show("File Not Found.");

private void lv_PatientDetails_SelectedIndexChanged(object sender,


EventArgs e)

private void txt_Find_KeyUp(object sender, KeyEventArgs e)

if (e.KeyCode == Keys.Enter)

btn_Search_Click(sender, e);

6.Add_Medicene form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;
using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

public partial class frm_AddMedicineToStock : Form

OleDbConnection connection;
OleDbCommand command;

OleDbDataAdapter da;

DataSet ds;

public string username;

public int mdusrid = 0;

public frm_AddMedicineToStock()

InitializeComponent();

private void frm_AddMedicineToStock_Load(object sender, EventArgs e)

//To Get Medicine Name as A Medicine Name in ComboBox for


Suggest Append Mode

AutoCompleteStringCollection MmedicineNewCollection = new


AutoCompleteStringCollection();

//Get Stock Detail of Medicine


try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT MName FROM


MedicineStockRecord WHERE (MUserID = @MUserID)", connection);

command.Parameters.Clear();
command.Parameters.AddWithValue("@MUserID", mdusrid);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "MedicineStockRecord");

int i = 0;

do

MmedicineNewCollection.Add(ds.Tables[0].Rows[i]
[0].ToString().ToString());

i++;

} while (ds.Tables[0].Rows[i][0].ToString() != "");

catch (IndexOutOfRangeException)

//catch (Exception)
//{

//}

finally

connection.Close();

//To Get Medicine Names to ComboBox That Already in DataBase

txt_mname.AutoCompleteMode =
AutoCompleteMode.SuggestAppend;

txt_mname.AutoCompleteSource =
AutoCompleteSource.CustomSource;

txt_mname.AutoCompleteCustomSource = MmedicineNewCollection;

private void btn_save_Click(object sender, EventArgs e)

//Validations

if (txt_mname.Text == "")

lbl_Vmname.Visible = true;

if (cmb_mtype.Text == "-Select-")

lbl_Vmtype.Visible = true;

if (txt_mBatchNo.Text == "")
{

lbl_Vmbatch.Visible = true;

if (dtp_mExpiryDate.Value.ToShortDateString() ==
DateTime.Now.ToShortDateString())

lbl_Vmexpirydate.Visible = true;

if (txt_mquantity.Text == "")
{

lbl_VmQuantity.Visible = true;

if (cmb_mSupplierName.Text == "-Select-")

lbl_VmSupplierName.Visible = true;

MessageBox.Show("Enter Details.");

else

//Store Medicine in DataBase

int result = 0;

Boolean IsDeletedMD = false;

int MedicineRemaining = 0;

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("INSERT INTO


MedicineStockRecord (MName, MType, MBatchNo, MExpiryDate,
MQuantity, MQuantityRemaining, MSupplierName, MDate, MRemark,
MUserID, IsDeleted) Values (@MName, @MType, @MBatchNo,
@MExpiryDate, @MQuantity, @MQuantityRemaining, @MSupplierName,
@MDate, @MRemark, @MUserID, @IsDeleted)", connection);

command.Parameters.AddWithValue("@MName",
txt_mname.Text);

command.Parameters.AddWithValue("@MType",
cmb_mtype.Text);

command.Parameters.AddWithValue("@MBatchNo",
txt_mBatchNo.Text);

command.Parameters.AddWithValue("@MExpiryDate",
dtp_mExpiryDate.Value.ToShortDateString());

command.Parameters.AddWithValue("@MQuantity",
txt_mquantity.Text);

MedicineRemaining = Convert.ToInt32(txt_mquantity.Text);

command.Parameters.AddWithValue("@MQuantityRemaining",
MedicineRemaining);

command.Parameters.AddWithValue("@MSupplierName",
cmb_mSupplierName.Text);

command.Parameters.AddWithValue("@MDate",
dtp_Date.Value.ToString());

command.Parameters.AddWithValue("@MRemark",
txt_remarks.Text);

command.Parameters.AddWithValue("@MUserID", mdusrid);

command.Parameters.AddWithValue("@IsDeleted",
IsDeletedMD);

result = command.ExecuteNonQuery();

if (result > 0)

{
MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper()
+ " is Saved Successfully.");

else

MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper()


+ " is Not Saved at this time Please Try After Sometime.");

catch (Exception)
{

MessageBox.Show("There is Some Problems in Saving user,


Please Again Login the System.");

finally

connection.Close();

txt_mname.ResetText();

cmb_mtype.Refresh();

cmb_mtype.Text = "-Select-";

txt_mBatchNo.ResetText();

txt_mquantity.ResetText();

cmb_mSupplierName.Refresh();

cmb_mSupplierName.Text = "-Select-";

dtp_Date.Refresh();

txt_remarks.ResetText();
}

private void btn_reset_Click(object sender, EventArgs e)

//MName, MType, MBatchNo, MExpiryDate, MQuantity,


MQuantityRemaining, MSupplierName, MDate, MRemark, MUid, IsDeleted

txt_mname.ResetText();

cmb_mtype.Refresh();

cmb_mtype.Text = "-Select-";
txt_mBatchNo.ResetText();

txt_mquantity.ResetText();

cmb_mSupplierName.Refresh();

cmb_mSupplierName.Text = "-Select-";

dtp_Date.Refresh();

txt_remarks.ResetText();

private void btn_close_Click(object sender, EventArgs e)

this.Hide();

private void txt_mname_TextChanged(object sender, EventArgs e)

if (txt_mname.Text != "")

lbl_Vmname.Visible = false;
}

private void txt_mname_Validating(object sender, CancelEventArgs e)

private void txt_mname_KeyDown(object sender, KeyEventArgs e)


{

7.Update_Medicine Stock form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

{
public partial class frm_UpdateMedicineStock : Form

OleDbConnection connection;

OleDbCommand command;

OleDbDataAdapter da;

DataSet ds, Glb_DS;

public int MedicineUserID = 0;

int MedicineID = 0;
public int TotalQuantity = 0;

public frm_UpdateMedicineStock()

InitializeComponent();

private void frm_UpdateMedicineStock_Load(object sender, EventArgs


e)

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT


DISTINCT(MName)FROM MedicineStockRecord WHERE (MUserID =
@MUserID) AND (IsDeleted = 0) ORDER BY MName ASC", connection);

command.Parameters.Clear();
command.Parameters.AddWithValue("@MUserID",
MedicineUserID);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "MedicineStockRecord");

int i = 0;

do

cmb_MedName.Items.Add(ds.Tables[0].Rows[i][0].ToString());
i++;

} while (ds.Tables[0].Rows[i][0].ToString() != "");

catch (Exception)

finally

connection.Close();

LoadListView_Medicines();

private void btn_ShowStock_Click(object sender, EventArgs e)

{
if (cmb_MedName.Text == "--All Medicines--")

LoadListView_Medicines();

else

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM MedicineStockRecord TMSR WHERE (TMSR.ID <
MSR.ID) AND (TMSR.MUserID = @MUserID) AND (TMSR.IsDeleted = 0) AND
(TMSR.MName = @MName)) AS [Sr No], MName AS [Medicine Name], MType
AS [Medicine Type], FORMAT(MExpiryDate, 'dd/mm/yyyy') AS [Medicine
Expiry Date], MBatchNo AS [Batch No], MQuantity AS [Total Stock],
MQuantityRemaining AS [Total Stock Remaining], MSupplierName AS
[Supplier Name], ID FROM MedicineStockRecord MSR WHERE (MUserID =
@MUserID) AND (IsDeleted = 0) AND (MName = @MName) ORDER BY ID
ASC", connection);

command.Parameters.Clear();

command.Parameters.AddWithValue("@MUserID",
MedicineUserID);

command.Parameters.AddWithValue("@MName",
cmb_MedName.Text);

da = new OleDbDataAdapter(command);

ds = new DataSet();

Glb_DS = new DataSet();

da.Fill(ds, "MedicineStockRecord");
da.Fill(Glb_DS,"MedicineStockRecord");

// Get the table from the data set

DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_MedicalStock.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());
lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView

lv_MedicalStock.Items.Add(lvi);

catch (Exception)

{
}

finally

connection.Close();

private void lv_MedicalStock_DoubleClick(object sender, EventArgs e)

txt_mquantity.Enabled = true;

txt_mname.Text =
lv_MedicalStock.SelectedItems[0].SubItems[1].Text;

cmb_mtype.Text =
lv_MedicalStock.SelectedItems[0].SubItems[2].Text;

dtp_mExpiryDate.Value =
Convert.ToDateTime(lv_MedicalStock.SelectedItems[0].SubItems[3].Text);
txt_mBatchNo.Text =
lv_MedicalStock.SelectedItems[0].SubItems[4].Text;

txt_mquantity.Text =
lv_MedicalStock.SelectedItems[0].SubItems[5].Text;

txt_mRemaining.Text =
lv_MedicalStock.SelectedItems[0].SubItems[6].Text;

cmb_mSupplierName.Text =
lv_MedicalStock.SelectedItems[0].SubItems[7].Text;

MedicineID =
Convert.ToInt32(lv_MedicalStock.SelectedItems[0].SubItems[8].Text);

TotalQuantity = Convert.ToInt32(txt_mquantity.Text);
}

private void btn_update_Click(object sender, EventArgs e)

//Store Medicine in DataBase

int result = 0;

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("UPDATE


MedicineStockRecord SET MName =@MName, MType =@MType, MBatchNo
=@MBatchNo, MExpiryDate =@MExpiryDate, MQuantity
=@MQuantity,MQuantityRemaining = @MQuantityRemaining,
MSupplierName = @MSupplierName WHERE (ID = @ID) AND (IsDeleted =
0)", connection);

command.Parameters.AddWithValue("@MName",
txt_mname.Text);
command.Parameters.AddWithValue("@MType", cmb_mtype.Text);

command.Parameters.AddWithValue("@MBatchNo",
txt_mBatchNo.Text);

command.Parameters.AddWithValue("@MExpiryDate",
dtp_mExpiryDate.Value.ToShortDateString());

command.Parameters.AddWithValue("@MQuantity",
txt_mquantity.Text);

command.Parameters.AddWithValue("@MQuantityRemaining",
txt_mRemaining.Text);

command.Parameters.AddWithValue("@MSupplierName",
cmb_mSupplierName.Text);
command.Parameters.AddWithValue("@ID", MedicineID);

result = command.ExecuteNonQuery();

if (result > 0)

MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper() +


" is Updated Successfully.");

else

MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper() +


" is Not Updated at this time Please Try After Sometime.");

catch (Exception)

MessageBox.Show("There is Some Problems in Saving user, Please


Again Login the System.");

finally
{

connection.Close();

//Reload The ListView After UpdateData data

LoadListView_Medicines();

private void btn_close_Click(object sender, EventArgs e)

{
this.Hide();

private void btn_Delete_Click(object sender, EventArgs e)

//Store Medicine in DataBase

int result = 0;

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("UPDATE


MedicineStockRecord SET IsDeleted = 1 WHERE (ID = @ID) AND (IsDeleted
= 0)", connection);

command.Parameters.AddWithValue("@ID", MedicineID);
result = command.ExecuteNonQuery();

if (result > 0)

MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper() +


" is Deleted Successfully.");

//Empty the Textboxes after delete Data

txt_mname.Text = "";

cmb_mtype.Refresh();
cmb_mtype.Text = "-Select-";

txt_mBatchNo.ResetText();

txt_mquantity.Text = "";

cmb_mSupplierName.Refresh();

cmb_mSupplierName.Text = "-Select-";

dtp_mExpiryDate.Refresh();

txt_mRemaining.Text = "";

else

MessageBox.Show("Medicine " + (txt_mname.Text).ToUpper() +


" is Not Deleted at this time Please Try After Sometime.");

catch (Exception)

MessageBox.Show("There is Some Problems in Saving user, Please


Again Login the System.");

}
finally

connection.Close();

//Reload ListView After Deletiing Data

LoadListView_Medicines();

public void LoadListView_Medicines()


{

//To Get Complete Stock in ListView

//try

//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT (COUNT(*) +


1) FROM MedicineStockRecord TMSR WHERE (TMSR.ID < MSR.ID)
AND (TMSR.MUserID = @MUserID) AND (TMSR.IsDeleted = 0) ) AS [Sr No],
MName AS [Medicine Name], MType AS [Medicine Type],
FORMAT(MExpiryDate, 'dd/mm/yyyy') AS [Medicine Expiry Date], MBatchNo
AS [Batch No], MQuantity AS [Total Stock], MQuantityRemaining AS [Total
Stock Remaining], MSupplierName AS [Supplier Name], ID FROM
MedicineStockRecord MSR WHERE (MUserID = @MUserID) AND (IsDeleted =
0) ORDER BY ID ASC ", connection); //ORDER BY MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@MUserID", MedicineUserID);

da = new OleDbDataAdapter(command);
ds = new DataSet();

Glb_DS = new DataSet();

da.Fill(ds, "MedicineStockRecord");

da.Fill(Glb_DS,"MedicineStockRecord");

// Get the table from the data set

DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_MedicalStock.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());
lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

// Add the list items to the ListView

lv_MedicalStock.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally

//{

// connection.Close();

//}

private void txt_mquantity_Leave(object sender, EventArgs e)

int newquan = 0;

if (Convert.ToInt32(txt_mquantity.Text) > TotalQuantity)

newquan = Convert.ToInt32(txt_mquantity.Text) - TotalQuantity;


txt_mRemaining.Text =
Convert.ToString(Convert.ToInt32(txt_mRemaining.Text) + newquan);

else

newquan = TotalQuantity - Convert.ToInt32(txt_mquantity.Text);

txt_mRemaining.Text =
Convert.ToString(Convert.ToInt32(txt_mRemaining.Text) - newquan);

txt_mquantity.Enabled = false;
}

private void btn_print_Click(object sender, EventArgs e)

Glb_DS.WriteXml("C:\\Program Files\\My
Project\\Dispensory\\Xml\\MedicineStock.xml");

frm_Reports obj_Reports = new frm_Reports();

obj_Reports.ReportName = "MedicineStock";

obj_Reports.Show();

8.Update_Delete_patient form

using System;

using System.Collections.Generic;
using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

{
public partial class frm_UpdateDeletePatient : Form

public int Puser_ID = 0;

OleDbConnection connection;

OleDbCommand command;

OleDbDataAdapter da;

DataSet ds;

int Patient_ID = 0;

public frm_UpdateDeletePatient()

InitializeComponent();

private void frm_UpdateDeletePatient_Load(object sender, EventArgs e)

AutoCompleteStringCollection P_OPDCollection = new


AutoCompleteStringCollection();
try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT


DISTINCT(POPDNoYearly) FROM PatientRecord WHERE (IsDeleted = 0)
ORDER BY POPDNoYearly DESC", connection);
command.Parameters.Clear();

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

int i = 0;

do

cmb_PatientOPD.Items.Add(ds.Tables[0].Rows[i][0].ToString());

P_OPDCollection.Add(ds.Tables[0].Rows[i][0].ToString());

i++;

} while (ds.Tables[0].Rows[i][0].ToString() != "");

catch (IndexOutOfRangeException)

}
//finally

//{

// connection.Close();

//}

///LoadListView_Medicines();

cmb_PatientOPD.AutoCompleteMode = AutoCompleteMode.Suggest;

cmb_PatientOPD.AutoCompleteSource =
AutoCompleteSource.CustomSource;

cmb_PatientOPD.AutoCompleteCustomSource = P_OPDCollection;
LoadListView_Patient();

private void btn_UpdateDeleteAppointments_Click(object sender,


EventArgs e)

//frm_UpdateDeletdPatientTreatment
obj_UpdateDeletdPatientTreatment = new
frm_UpdateDeletdPatientTreatment();

//obj_UpdateDeletdPatientTreatment.Show();

public void LoadListView_Patient()

//To Get Complete Stock in ListView

//try

//{
connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT (COUNT(*)


+ 1) FROM PatientRecord TPR WHERE
(TPR.ID < PR.ID) AND (TPR.PUserID = 1) AND (TPR.IsDeleted = 0)) AS [Sr No],
POPDNoYearly, POPDNoMonthly, PName, PSex, PAge,
PDiagnosis, PAddress, PType, PDepartment, PContractorName, PSiteInjury,
PRemark, ID, PDate, PUserID, IsDeleted FROM PatientRecord PR WHERE
(PUserID = @PUserID) AND (IsDeleted = 0) ORDER BY ID", connection);
//ORDER BY MName ASC

command.Parameters.Clear();

command.Parameters.AddWithValue("@PUserID", Puser_ID);

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

// Get the table from the data set

DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control

lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < dtable.Rows.Count; i++)

{
DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());
lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

lvi.SubItems.Add(drow[9].ToString());

lvi.SubItems.Add(drow[10].ToString());

lvi.SubItems.Add(drow[11].ToString());

lvi.SubItems.Add(drow[12].ToString());

lvi.SubItems.Add(drow[13].ToString());

// Add the list items to the ListView

lv_PatientDetails.Items.Add(lvi);

//}
//catch (Exception)

//{

//}

//finally

//{

// connection.Close();

//}

private void lv_PatientDetails_DoubleClick(object sender, EventArgs e)

string SexIs = "";

txt_PatientOPD_No.Text =
lv_PatientDetails.SelectedItems[0].SubItems[1].Text;

txt_OPD_NO_Monthly.Text =
lv_PatientDetails.SelectedItems[0].SubItems[2].Text;

txt_pname.Text =
lv_PatientDetails.SelectedItems[0].SubItems[3].Text;

SexIs = lv_PatientDetails.SelectedItems[0].SubItems[4].Text;

if (SexIs == "Male")

rd_pmale.Checked = true;

else

rd_pfemale.Checked = true;
}

cmb_pAge.Text =
lv_PatientDetails.SelectedItems[0].SubItems[5].Text;

txt_pDiagnosis.Text =
lv_PatientDetails.SelectedItems[0].SubItems[6].Text;

txt_pAddress.Text =
lv_PatientDetails.SelectedItems[0].SubItems[7].Text;

cmb_ptype.Text =
lv_PatientDetails.SelectedItems[0].SubItems[8].Text;

cmb_pDept.Text =
lv_PatientDetails.SelectedItems[0].SubItems[9].Text;
txt_pcontractorName.Text =
lv_PatientDetails.SelectedItems[0].SubItems[10].Text;

txt_pSiteInjury.Text =
lv_PatientDetails.SelectedItems[0].SubItems[11].Text;

txt_premarks.Text =
lv_PatientDetails.SelectedItems[0].SubItems[12].Text;

Patient_ID =
Convert.ToInt32(lv_PatientDetails.SelectedItems[0].SubItems[13].Text);

private void btn_Show_Click(object sender, EventArgs e)

if (cmb_PatientOPD.Text == "--All Patients--")

LoadListView_Patient();

else

//To Get Complete Stock in ListView


//try

//{

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("SELECT (SELECT


(COUNT(*) + 1) FROM PatientRecord TPR
WHERE (TPR.ID < PR.ID) AND (TPR.PUserID = 1) AND (TPR.IsDeleted = 0))
AS [Sr No], POPDNoYearly, POPDNoMonthly, PName, PSex, PAge,
PDiagnosis, PAddress, PType, PDepartment, PContractorName, PSiteInjury,
PRemark, ID,PUserID, IsDeleted ,PDate FROM PatientRecord PR WHERE
(PUserID = @PUserID) AND (IsDeleted = 0) AND
(POPDNoYearly=@POPDNoYearly) ORDER BY ID", connection); //ORDER BY
MName ASC

//

command.Parameters.Clear();

command.Parameters.AddWithValue("@PUserID", Puser_ID);

command.Parameters.AddWithValue("@POPDNoYearly",
cmb_PatientOPD.Text.Trim());

da = new OleDbDataAdapter(command);

ds = new DataSet();

da.Fill(ds, "PatientRecord");

// Get the table from the data set

DataTable dtable = ds.Tables[0];

//_DataSet.Tables["Titles"];

// Clear the ListView control


lv_PatientDetails.Items.Clear();

// Display items in the ListView control

for (int i = 0; i < 1; i++)

DataRow drow = dtable.Rows[i];

// Only row that have not been deleted

if (drow.RowState != DataRowState.Deleted)
{

// Define the list items

ListViewItem lvi = new ListViewItem(drow[0].ToString());

lvi.SubItems.Add(drow[1].ToString());

lvi.SubItems.Add(drow[2].ToString());

lvi.SubItems.Add(drow[3].ToString());

lvi.SubItems.Add(drow[4].ToString());

lvi.SubItems.Add(drow[5].ToString());

lvi.SubItems.Add(drow[6].ToString());

lvi.SubItems.Add(drow[7].ToString());

lvi.SubItems.Add(drow[8].ToString());

lvi.SubItems.Add(drow[9].ToString());

lvi.SubItems.Add(drow[10].ToString());

lvi.SubItems.Add(drow[11].ToString());

lvi.SubItems.Add(drow[12].ToString());

lvi.SubItems.Add(drow[13].ToString());

// Add the list items to the ListView


lv_PatientDetails.Items.Add(lvi);

//}

//catch (Exception)

//{

//}

//finally
//{

// connection.Close();

//}

private void txt_PatientOPD_No_TextChanged(object sender, EventArgs


e)

panel3.Enabled = true;

btn_UpdateDeleteAppointments.Enabled = true;

private void btn_update_Click(object sender, EventArgs e)

//Patient Gender Set

string PGender = "";

if (rd_pmale.Checked == true)
{

PGender = "Male";

else

PGender = "Female";

//Save Patient Details in DataBase


int result = 0;

Boolean IsDeletedPatient = false;

//try

// {

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();

command = new OleDbCommand("Update PatientRecord Set


POPDNoYearly = @POPDNoYearly, POPDNoMonthly = @POPDNoMonthly,
PName = @PName, PSex = @PSex, PAge = @PAge, PType = @PType,
PAddress = @PAddress, PDepartment = @PDepartment, PDiagnosis =
@PDiagnosis, PSiteInjury = @PSiteInjury, PContractorName =
@PContractorName, PUserID = @PUserID, IsDeleted = @IsDeleted, PRemark
= @PRemark Where (ID = @ID) AND (IsDeleted = 0)", connection);

command.Parameters.AddWithValue("@POPDNoYearly",
txt_PatientOPD_No.Text);

command.Parameters.AddWithValue("@POPDNoMonthly",
txt_OPD_NO_Monthly.Text);

// command.Parameters.AddWithValue("@PVisitNo", txt_VisitNo.Text);

command.Parameters.AddWithValue("@PName", txt_pname.Text);
command.Parameters.AddWithValue("@PSex", PGender);

command.Parameters.AddWithValue("@PAge", cmb_pAge.Text);

command.Parameters.AddWithValue("@PType", cmb_ptype.Text);

command.Parameters.AddWithValue("@PAddress",
txt_pAddress.Text);

command.Parameters.AddWithValue("@PDepartment",
cmb_pDept.Text);

command.Parameters.AddWithValue("@PDiagnosis",
txt_pDiagnosis.Text);

command.Parameters.AddWithValue("@PSiteInjury",
txt_pSiteInjury.Text);

command.Parameters.AddWithValue("@PContractorName",
txt_pcontractorName.Text);

command.Parameters.AddWithValue("@PUserID", Puser_ID);

command.Parameters.AddWithValue("@IsDeleted", IsDeletedPatient);

command.Parameters.AddWithValue("@PRemark",
txt_premarks.Text);

command.Parameters.AddWithValue("@ID", Patient_ID);

result = command.ExecuteNonQuery();

if (result > 0)

MessageBox.Show("Patient " + txt_pname.Text.ToUpper() + "OPD


NO. [ " + txt_PatientOPD_No.Text.ToUpper() + " ] is Updated Successfully.",
"Patient Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);

else

MessageBox.Show("Patient is Not Updated at this time Please Try


After Sometime.", "Patient Not Updated", MessageBoxButtons.OK,
MessageBoxIcon.Error);

}
//}

//catch (Exception)

//{

// MessageBox.Show("There is Some Problems in Saving Treatment,


Please Again Login the System.");

//}

//finally

//{

// connection.Close();
//}

LoadListView_Patient();

private void btn_Delete_Click(object sender, EventArgs e)

//Patient Gender Set

string PGender = "";

if (rd_pmale.Checked == true)

PGender = "Male";

else

PGender = "Female";

}
//Save Patient Details in DataBase

int result = 0;

try

connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

connection.Open();
command = new OleDbCommand("Update PatientRecord Set
IsDeleted = 1 Where (PUserID = @PUserID) AND (ID = @ID) AND (IsDeleted
= 0)", connection);

command.Parameters.AddWithValue("@PUserID", Puser_ID);

command.Parameters.AddWithValue("@ID", Patient_ID);

result = command.ExecuteNonQuery();

if (result > 0)

MessageBox.Show("Patient is Deleted Successfully.", "Patient


Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);

else

MessageBox.Show("Patient is Not Deleted at this time Please Try


After Sometime.", "Patient Not Deleted", MessageBoxButtons.OK,
MessageBoxIcon.Error);

catch (Exception)

{
MessageBox.Show("There is Some Problems in Saving Treatment,
Please Again Login the System.");

finally

connection.Close();

LoadListView_Patient();

}
}

9.Import_patient_From_excel Form

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

namespace DispensoryMGTSystem

public partial class frm_ImportPatientfromExcel : Form

{
OleDbConnection Connection;

OleDbCommand Command;

OleDbDataAdapter da;

DataSet ds;

OleDbConnection ConnectionP;

OleDbCommand CommandP;

int resultimport ;

OpenFileDialog OFD = new OpenFileDialog();


public int USR_ID;

public frm_ImportPatientfromExcel()

InitializeComponent();

private void btn_OpenTemplete_Click(object sender, EventArgs e)

System.Diagnostics.Process.Start(@"C:\Program Files\My
Project\Dispensory\Excel Templete\ExcelTempletePatientData.xls");

private void btn_ImportPatient_Click(object sender, EventArgs e)

OFD.Title ="Select Patient file";

OFD.Filter = "xls Files|*.xls";

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

{
try

Connection = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" +
OFD.FileName + ";Extended Properties=Excel 8.0");

Connection.Open();

Command = new OleDbCommand("Select * from


[PaitiantDetails$]", Connection);

da = new OleDbDataAdapter(Command);

ds = new DataSet();
da.Fill(ds, "[PaitiantDetails$]");

int i =0;

if (ds.Tables[0].Rows.Count > 0)

do

//Save All the Patients that are in Excel File

resultimport = 0;

Boolean IsDeletedPatient = false;

ConnectionP = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Program Files\\My
Project\\Dispensory\\Data\\DispensaryMgtSystem.mdb;Persist Security
Info=False");

ConnectionP.Open();

CommandP = new OleDbCommand("Insert Into


PatientRecord (POPDNoYearly,POPDNoMonthly, PName,PSex,
PAge,PType,PAddress,PDepartment, PContractorName, PDiagnosis,
PSiteInjury, PTreatmentDate, ID, IsDeleted, TMedicineName1,
TMedicineName2, TMedicineName3, TMedicineName4,
TMedicineName5,TMedicineQNT1, TMedicineQNT2, TMedicineQNT3,
TMedicineQNT4,TMedicineQNT5) Values (@POPDNoYearly,@POPDNoMonthly,
@PName, @PSex, @PAge, @PType,@PAddress,@PDepartment,
@PContractorName, @PDiagnosis, @PSiteInjury,@PTreatmentDate, @UID,
@IsDeleted, @TMedicineName1, @TMedicineName2, @TMedicineName3,
@TMedicineName4,@TMedicineName5, @TMedicineQNT1, @TMedicineQNT2,
@TMedicineQNT3, @TMedicineQNT4, @TMedicineQNT5) ", ConnectionP);

CommandP.Parameters.AddWithValue("@POPDNoYearly",
ds.Tables[0].Rows[i][0].ToString().Trim());

CommandP.Parameters.AddWithValue("@POPDNoMonthly",
ds.Tables[0].Rows[i][1].ToString().Trim());

CommandP.Parameters.AddWithValue("@PName",
ds.Tables[0].Rows[i][3].ToString().Trim());

CommandP.Parameters.AddWithValue("@PSex",
ds.Tables[0].Rows[i][5].ToString().Trim());
CommandP.Parameters.AddWithValue("@PAge",
ds.Tables[0].Rows[i][4].ToString().Trim());

CommandP.Parameters.AddWithValue("@PType",
ds.Tables[0].Rows[i][7].ToString().Trim());

CommandP.Parameters.AddWithValue("@PAddress",
ds.Tables[0].Rows[i][6].ToString().Trim());

CommandP.Parameters.AddWithValue("@PDepartment",
ds.Tables[0].Rows[i][8].ToString().Trim());

CommandP.Parameters.AddWithValue("@PDiagnosis",
ds.Tables[0].Rows[i][10].ToString().Trim());

CommandP.Parameters.AddWithValue("@PSiteInjury",
ds.Tables[0].Rows[i][21].ToString().Trim());

CommandP.Parameters.AddWithValue("@PContractorName
", ds.Tables[0].Rows[i][9].ToString().Trim());

CommandP.Parameters.AddWithValue("@PTreatmentDate"
, Convert.ToDateTime(ds.Tables[0].Rows[i][2]));

CommandP.Parameters.AddWithValue("@UID", USR_ID);

CommandP.Parameters.AddWithValue("@IsDeleted",
IsDeletedPatient);

CommandP.Parameters.AddWithValue("@TMedicineName1
", ds.Tables[0].Rows[i][11].ToString().Trim());
CommandP.Parameters.AddWithValue("@TMedicineName2
", ds.Tables[0].Rows[i][13].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineName3
", ds.Tables[0].Rows[i][15].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineName4
", ds.Tables[0].Rows[i][17].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineName5
", ds.Tables[0].Rows[i][19].ToString().Trim());

//command.Parameters.AddWithValue("@TMedicineName6
", cmb_md6.Text);

//command.Parameters.AddWithValue("@TMedicineName7
", cmb_md7.Text);

//command.Parameters.AddWithValue("@TMedicineName8
", cmb_md8.Text);

//command.Parameters.AddWithValue("@TMedicineName9
", cmb_md9.Text);

//command.Parameters.AddWithValue("@TMedicineName1
0", cmb_md10.Text);

CommandP.Parameters.AddWithValue("@TMedicineQNT1",
ds.Tables[0].Rows[i][12].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineQNT2",
ds.Tables[0].Rows[i][14].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineQNT3",
ds.Tables[0].Rows[i][16].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineQNT4",
ds.Tables[0].Rows[i][18].ToString().Trim());

CommandP.Parameters.AddWithValue("@TMedicineQNT5",
ds.Tables[0].Rows[i][20].ToString().Trim());

//command.Parameters.AddWithValue("@TMedicineQNT6",
cmb_mdquan6.Text);

//command.Parameters.AddWithValue("@TMedicineQNT7",
cmb_mdquan7.Text);

//command.Parameters.AddWithValue("@TMedicineQNT8",
cmb_mdquan8.Text);
//command.Parameters.AddWithValue("@TMedicineQNT9",
cmb_mdquan9.Text);

//command.Parameters.AddWithValue("@TMedicineQNT10"
, cmb_mdquan10.Text);

resultimport = CommandP.ExecuteNonQuery();

i++;

} while (ds.Tables[0].Rows[i][0].ToString() != "");

gdv_PatientData.DataSource = ds.Tables[0];

if (resultimport > 0)
{

MessageBox.Show("Patients are Imported Successfully.",


"Importing Patients",MessageBoxButtons.OK,MessageBoxIcon.Information);

else

MessageBox.Show("Patients are Imported Not Successfully,


Try After Some Time.", "Importing Patients", MessageBoxButtons.OK,
MessageBoxIcon.Error);

catch (Exception)

finally

ConnectionP.Close();

Connection.Close();
}

private void frm_ImportPatientfromExcel_Load(object sender, EventArgs


e)

private void btn_close_Click(object sender, EventArgs e)

this.Hide();

}
CHAPTER.5
testing
5.1 System Testing:-

System Testing is an important stage in any system development life


cycle. Testing is a process of executing a program with the intention of
finding errors. The importance of software testing and its implications with
respect to software quality cannot be overemphasized. Software testing is a
critical element of software quality assurance and represents the ultimate
review of specification, design and coding. A good test case is one that has a
high probability of finding a yet undiscovered error.
Testing is the set of activities that can be planned in advance and conducted
systematically. Different test conditions should be thoroughly checked and
the bugs detected should be fixed. The testing strategies formed by the user
are performed to prove that the software is free and clear from errors. To do
this, there are many ways of testing the system’s reliability, completeness
and maintainability.

5.1.1Unit Testing:

In the unit testing the analyst tests the program making up a system. The
software units in a system are the modules and routines that are assembled
and integrated to perform a specific function. In a large system, many
modules on different levels are needed.
Unit testing can be performed from the bottom up starting with the
smallest and lowest level modules and proceeding one at a time. For each
module in a bottom-up testing, a short program executes the module and
provides the needed data.

5.1.2 Integration Testing:

Integration testing is a systematic technique for constructing the program


structure while conducting test to uncover errors associate with interfacing.
Objectives are used to take unit test modules and built program structure
that has been directed by design.

The integration testing is performed for this Hospital Management System


when all the modules where to make it a complete system. After integration
the project works successfully.

5.1.2 Validation Testing:

Validation testing can be defined in many ways, but a simple definition is


that can be reasonably expected by the customer. After validation test has
been conducted, one of two possible conditions exists.

•The functions or performance characteristics confirm to specification


and are accepted.

•A deviation from specification is uncovered and a deficiency list is


created.

Proposed system under consideration has been tested by using


validation testing and found to be working satisfactorily.

For example, in this project validation testing is performed against inpatient


search module. This module is tested with the following valid and invalid
inputs for the field patientname.

5.1.2 White Box Testing:-


White box testing, sometimes called glass-box testing is a test case design
method that uses the control structure of the procedural design to derive
test cases. Using white box testing methods, the software engineer can
derive test cases that•Guarantee that all independent paths with in a
module have been exercised at least once.

This method treats the coded module as a black box. The module runs with
inputs that are likely to cause errors. Then the output is checked to see if
any error occurred. This method cannot be used to test all errors, because
some errors may depend on the code or algorithm used to implement the
module. This method treats the coded module as a black box. The module
runs with inputs that are likely to cause errors. Then the output is checked to
see if any error occurred. This method cannot be used to test all errors,
because some errors may depend on the code or algorithm used to
implement the module.
For example in this project white box testing is performed against inpatient
module. Without entering text if we apply it displays the message “First add
record then save it” else it should be saved.

5.1.3 Black Box Testing:-

This method treats the coded module as a black box. The module runs with
inputs that are likely to cause errors. Then the output is checked to see if
any error occurred. This method cannot be used to test all errors, because
some errors may depend on the code or algorithm used to implement the
module.

CHAPTER.6
snapshots
1. Login form:-
2. Select_Option Form:-

3. Patient_and Medicene record Form


4. Add_Patient Form:-
5.Update_Patient Form

6.
8.

9.
.
CHAPTER.7
Conclusion
7. 1 CONCLUSION:-

The project Dispensary Management System (DMS) is for computerizing the


working in

a hospital. The software takes care of all the requirements of an average


hospital and is

capable to provide easy and effective storage of information related to


patients that

come up to the hospital.

It generates test reports; provide prescription details including various tests,


diet advice,
and medicines prescribed to patient and doctor. It also provides injection
details and

billing facility on the basis of patient’s status whether it is an indoor or


outdoor patient.

The system also provides the facility of backup as per the requirement.
CHAPTER.8
Bibliegraphy
1. Visual studio 2008
2. http://www.comptechdoc.org/independent/database/begin/sqlstructure.html
3. www.wisegeek.com/what-is-dispensory.htm
4. www.citehr.com/29179-hospitalstock-system.html

You might also like