Dastur asosiy ikki oynada iborat:
Dastur kodining matni:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "admin" || textBox2.Text == "pass")
{
MessageBox.Show("Hush kelibsiz Admin. Siz tizimga muvaffaqiyatli kirdingiz.");
this.Visible = false;
Home obj1 = new Home();
obj1.ShowDialog();
textBox1.Text = "";
textBox2.Text = "";
}
else
{
MessageBox.Show("Invalid Username Or Password.");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "admin" || textBox2.Text == "pass")
{
MessageBox.Show("Hush kelibsiz Admin. Siz tizimga muvaffaqiyatli kirdingiz.");
this.Visible = false;
Home obj1 = new Home();
obj1.ShowDialog();
textBox1.Text = "";
textBox2.Text = "";
}
else
{
MessageBox.Show("Invalid Username Or Password.");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "admin" || textBox2.Text == "pass")
{
MessageBox.Show("Hush kelibsiz Admin. Siz tizimga muvaffaqiyatli kirdingiz.");
this.Visible = false;
Home obj1 = new Home();
obj1.ShowDialog();
textBox1.Text = "";
textBox2.Text = "";
}
else
{
MessageBox.Show("Invalid Username Or Password.");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalManagementSystemCSharp
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
private void patientRegistrationToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientRegistration obj = new PatientRegistration();
obj.ShowDialog();
}
private void patientInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientInformation obj1 = new PatientInformation();
obj1.ShowDialog();
}
private void checkoutToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientCheckOut obj2 = new PatientCheckOut();
obj2.ShowDialog();
}
private void roomInfoToolStripMenuItem_Click(object sender, EventArgs e)
{
RoomInfo obj3 = new RoomInfo();
obj3.ShowDialog();
}
private void addStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
StaffInformation obj4 = new StaffInformation();
obj4.ShowDialog();
}
private void viewCheckoutToolStripMenuItem_Click(object sender, EventArgs e)
{
ViewwPatientCheckOut obj5 = new ViewwPatientCheckOut();
obj5.ShowDialog();
}
private void aboutDeveloperToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Tuzuvchi: Eldor Alijonov");
}
private void closeApplicationToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HospitalManagementSystemCSharp
{
public partial class Home : Form
{
public Home()
{
InitializeComponent();
}
private void patientRegistrationToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientRegistration obj = new PatientRegistration();
obj.ShowDialog();
}
private void patientInformationToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientInformation obj1 = new PatientInformation();
obj1.ShowDialog();
}
private void checkoutToolStripMenuItem_Click(object sender, EventArgs e)
{
PatientCheckOut obj2 = new PatientCheckOut();
obj2.ShowDialog();
}
private void roomInfoToolStripMenuItem_Click(object sender, EventArgs e)
{
RoomInfo obj3 = new RoomInfo();
obj3.ShowDialog();
}
private void addStaffToolStripMenuItem_Click(object sender, EventArgs e)
{
StaffInformation obj4 = new StaffInformation();
obj4.ShowDialog();
}
private void viewCheckoutToolStripMenuItem_Click(object sender, EventArgs e)
{
ViewwPatientCheckOut obj5 = new ViewwPatientCheckOut();
obj5.ShowDialog();
}
private void aboutDeveloperToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Tuzuvchi: Eldor Alijonov");
}
private void closeApplicationToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class PatientCheckOut : Form
{
public PatientCheckOut()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
if (textBox1.Text != "")
{
try
{
string getCust = "select name,gen,age,cont,addr,disease from patient where id=" + Convert.ToInt32(textBox1.Text) + " ;";
SqlCommand cmd = new SqlCommand(getCust, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox2.Text = dr.GetValue(0).ToString();
if (dr[1].ToString() == "Male")
{
radioButton1.Checked = true;
}
else
{
radioButton2.Checked = true;
}
textBox3.Text = dr.GetValue(2).ToString();
textBox5.Text = dr.GetValue(3).ToString();
textBox6.Text = dr.GetValue(4).ToString();
textBox7.Text = dr.GetValue(5).ToString();
}
else
{
MessageBox.Show(" Sorry, This ID, " + textBox1.Text + " patient is not Available. ");
textBox1.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = "INSERT INTO checkout(name,gen,age,contact,addr,disease,date_in,date_out,build,r_no,r_type,status,med_price,total) VALUES('" + textBox2.Text + "','" + gen + "','" + textBox3.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "','" + textBox11.Text + "','" + textBox12.Text + "','" + textBox14.Text + "','" + textBox13.Text + "','" + textBox15.Text + "'); ";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(Id) from checkout;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Patient Checkout Information Saved Successfully..");
textBox2.Text = "";
textBox3.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox13.Text = "";
textBox14.Text = "";
textBox15.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "";
textBox3.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox13.Text = "";
textBox14.Text = "";
textBox15.Text = "";
}
private void label15_Click(object sender, EventArgs e)
{
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class PatientInformation : Form
{
public PatientInformation()
{
InitializeComponent();
}
private void PatientInformation_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'hospitalDataSet1.patient' table. You can move, or remove it, as needed.
this.patientTableAdapter.Fill(this.hospitalDataSet1.patient);
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM patient";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
if (textBox1.Text != "")
{
try
{
string getCust = "select name,gen,age,date,cont,addr,disease,status,r_type,building,r_no,price from patient where id=" + Convert.ToInt32(textBox1.Text) + " ;";
SqlCommand cmd = new SqlCommand(getCust, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox2.Text = dr.GetValue(0).ToString();
if (dr[1].ToString() == "Male")
{
radioButton1.Checked = true;
}
else
{
radioButton2.Checked = true;
}
textBox3.Text = dr.GetValue(2).ToString();
textBox4.Text = dr.GetValue(3).ToString();
textBox5.Text = dr.GetValue(4).ToString();
textBox6.Text = dr.GetValue(5).ToString();
textBox7.Text = dr.GetValue(6).ToString();
textBox8.Text = dr.GetValue(7).ToString();
textBox10.Text = dr.GetValue(8).ToString();
textBox9.Text = dr.GetValue(9).ToString();
textBox11.Text = dr.GetValue(10).ToString();
textBox12.Text = dr.GetValue(11).ToString();
}
else
{
MessageBox.Show(" Sorry, This ID, " + textBox1.Text + " Staff is not Available. ");
textBox1.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = " Update patient set name='" + textBox2.Text + "',gen='" + gen + "',age='" + textBox3.Text + "',date='" + textBox4.Text + "',cont='" + textBox5.Text + "',addr='" + textBox6.Text + "',disease='" + textBox7.Text + "',status='" + textBox8.Text + "',r_type='" + textBox10.Text + "',building='" + textBox9.Text + "',r_no='" + textBox11.Text + "',price='" + textBox12.Text + "' where id='" + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(id) from patient;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM patient";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
try
{
string str = "DELETE FROM patient WHERE id = '" + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show(" Patient Record Delete Successfully");
using (con)
{
string str2 = "SELECT * FROM patient";
SqlCommand cmd2 = new SqlCommand(str2, con);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show("Please Enter Patient Id..");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class PatientRegistration : Form
{
public PatientRegistration()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = "INSERT INTO patient(name,gen,age,date,cont,addr,disease,status,r_type,building,r_no,price) VALUES('" + textBox2.Text + "','" + gen + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox10.Text + "','" + textBox9.Text + "','" + textBox11.Text + "','" + textBox12.Text + "'); ";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(Id) from patient;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Patient Information Saved Successfully..");
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void PatientRegistration_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string str1 = "select max(id) from patient;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
string val = dr[0].ToString();
if (val == "")
{
textBox1.Text = "1";
}
else
{
int a;
a = Convert.ToInt32(dr[0].ToString());
a = a + 1;
textBox1.Text = a.ToString();
}
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
textBox9.Text = "";
textBox10.Text = "";
textBox11.Text = "";
textBox12.Text = "";
textBox1.Text = "";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class RoomInfo : Form
{
public RoomInfo()
{
InitializeComponent();
}
private void RoomInfo_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'hospitalDataSet2.room' table. You can move, or remove it, as needed.
this.roomTableAdapter.Fill(this.hospitalDataSet2.room);
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM room";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
try
{
string str = "INSERT INTO room(building,r_type,r_no,no_bed,price,r_status) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "'); ";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(Id) from room;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("room Information Saved Successfully..");
textBox2.Text = "";
textBox1.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM room";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class StaffInformation : Form
{
public StaffInformation()
{
InitializeComponent();
}
private void StaffInformation_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'hospitalDataSet.staff' table. You can move, or remove it, as needed.
this.staffTableAdapter.Fill(this.hospitalDataSet.staff);
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string str1 = "select max(id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
string val = dr[0].ToString();
if (val == "")
{
textBox1.Text = "1";
}
else
{
int a;
a = Convert.ToInt32(dr[0].ToString());
a = a + 1;
textBox1.Text = a.ToString();
}
}
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = "INSERT INTO staff(name,gender,position,salary,contact,address) VALUES('" + textBox2.Text + "','" + gen + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'); ";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(Id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Staff Information Saved Successfully..");
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
if (textBox1.Text != "")
{
try
{
string getCust = "select name,gender,position,salary,contact,address from staff where id=" + Convert.ToInt32(textBox1.Text) + " ;";
SqlCommand cmd = new SqlCommand(getCust, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox2.Text = dr.GetValue(0).ToString();
if (dr[1].ToString() == "Male")
{
radioButton1.Checked = true;
}
else
{
radioButton2.Checked = true;
}
textBox4.Text = dr.GetValue(2).ToString();
textBox5.Text = dr.GetValue(3).ToString();
textBox6.Text = dr.GetValue(4).ToString();
textBox7.Text = dr.GetValue(5).ToString();
}
else
{
MessageBox.Show(" Sorry, This ID, " + textBox1.Text + " Staff is not Available. ");
textBox1.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
}
private void button4_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = " Update staff set name='" + textBox2.Text + "',gender='" + gen + "',position='" + textBox4.Text + "',salary='" + textBox5.Text + "',contact='" + textBox6.Text + "',address='" + textBox7.Text + "' where id='" + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button3_Click(object sender, EventArgs e)
{
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox1.Text = "";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class StaffInformation : Form
{
public StaffInformation()
{
InitializeComponent();
}
private void StaffInformation_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'hospitalDataSet.staff' table. You can move, or remove it, as needed.
this.staffTableAdapter.Fill(this.hospitalDataSet.staff);
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string str1 = "select max(id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
string val = dr[0].ToString();
if (val == "")
{
textBox1.Text = "1";
}
else
{
int a;
a = Convert.ToInt32(dr[0].ToString());
a = a + 1;
textBox1.Text = a.ToString();
}
}
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = "INSERT INTO staff(name,gender,position,salary,contact,address) VALUES('" + textBox2.Text + "','" + gen + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'); ";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(Id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("Staff Information Saved Successfully..");
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
if (textBox1.Text != "")
{
try
{
string getCust = "select name,gender,position,salary,contact,address from staff where id=" + Convert.ToInt32(textBox1.Text) + " ;";
SqlCommand cmd = new SqlCommand(getCust, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
textBox2.Text = dr.GetValue(0).ToString();
if (dr[1].ToString() == "Male")
{
radioButton1.Checked = true;
}
else
{
radioButton2.Checked = true;
}
textBox4.Text = dr.GetValue(2).ToString();
textBox5.Text = dr.GetValue(3).ToString();
textBox6.Text = dr.GetValue(4).ToString();
textBox7.Text = dr.GetValue(5).ToString();
}
else
{
MessageBox.Show(" Sorry, This ID, " + textBox1.Text + " Staff is not Available. ");
textBox1.Text = "";
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
}
private void button4_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True");
con.Open();
string gen = string.Empty;
if (radioButton1.Checked)
{
gen = "Male";
}
else
{
gen = "Female";
}
try
{
string str = " Update staff set name='" + textBox2.Text + "',gender='" + gen + "',position='" + textBox4.Text + "',salary='" + textBox5.Text + "',contact='" + textBox6.Text + "',address='" + textBox7.Text + "' where id='" + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
string str1 = "select max(id) from staff;";
SqlCommand cmd1 = new SqlCommand(str1, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM staff";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
catch (SqlException excep)
{
MessageBox.Show(excep.Message);
}
con.Close();
}
private void button3_Click(object sender, EventArgs e)
{
textBox2.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox1.Text = "";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace HospitalManagementSystemCSharp
{
public partial class ViewwPatientCheckOut : Form
{
public ViewwPatientCheckOut()
{
InitializeComponent();
}
private void ViewwPatientCheckOut_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'hospitalDataSet3.checkout' table. You can move, or remove it, as needed.
this.checkoutTableAdapter.Fill(this.hospitalDataSet3.checkout);
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM checkout";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
private void button1_Click(object sender, EventArgs e)
{
using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\SmartCity\Downloads\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf;Integrated Security=True"))
{
string str2 = "SELECT * FROM checkout where id='"+textBox1.Text +"'";
SqlCommand cmd2 = new SqlCommand(str2, con1);
SqlDataAdapter da = new SqlDataAdapter(cmd2);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = new BindingSource(dt, null);
}
}
}
}
Dostları ilə paylaş: |