using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
LOGIN 1
namespace Medical_store {public partial class Login : Form {
public Login() {
InitializeComponent(); }
private void label3_Click(object sender, EventArgs e) {
}
private void panel1_Paint(object sender, PaintEventArgs e) {
}
private void button2_Click(object sender, EventArgs e) {
this.Close();
Application.Exit(); }
private void Login_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the
'medicalDataSet6.Login' table. You can move, or remove it, as needed. //this.loginTableAdapter.Fill(this.medicalDataSet6.Login); textBox1.Text = "";
textBox2.Text = ""; textBox1.Focus(); }
private void button1_Click(object sender, EventArgs e) {
try {
//Define object of SqlConnection and paasing of ConnectioString copied from database property
SqlConnection conn = new SqlConnection(); //conn.ConnectionString = @"Data Source=SAGAR- C2F6419CA;Initial Catalog=info;Integrated Security=True"; conn.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; //Connection with Database starts
//Create object of SqlAdapter and pass the query and object of ConnectionString
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn);
//Create object of Dataset DataSet ds = new DataSet();
//dataset is fiiled with dataAdapter adptr.Fill(ds);
//create object of DataTable and assign the table to it DataTable dt = ds.Tables[0];
//loops start Boolean b = false;
for (int i = 0; i < dt.Rows.Count; i++) {
//comparision with the username and password entered if ((textBox1.Text).Equals((dt.Rows[i][0]).ToString()) && (textBox2.Text).Equals((dt.Rows[i][1]).ToString()))
{
MessageBox.Show("You Are Successfully Loged in...", "Wel-Come To Medical-Store-Management-System", MessageBoxButtons.OK,
MessageBoxIcon.None);
//shows the mdi form and hide the login form Mdi_parent1 childMdi = new Mdi_parent1(); childMdi.Show(); this.Hide(); b = true; break; } }
// if User name and password are not matched if (!b)
{
MessageBox.Show("Invalid Username and Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } // Closing of database conn.Close(); } finally { } } }}
LOGIN 2
namespace Medical_store {
public partial class loginEditcs : Form {
public loginEditcs(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent; }
private void label1_Click(object sender, EventArgs e) {
}
private void button1_Click(object sender, EventArgs e) { //new Button TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); }
private void loginEditcs_Load(object sender, EventArgs e) { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); }
private void button5_Click(object sender, EventArgs e) {
//add button
//If three of one field is empty then invalid;
if (TextBox1.Text.Equals("") || TextBox2.Text.Equals("") || textBox3.Text.Equals(""))
{
MessageBox.Show("Invalid User Name Or Password", "Not Valid", MessageBoxButtons.OK, MessageBoxIcon.Error);
TextBox1.Focus(); }
else {
SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; try
{
conn.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn);
DataSet ds = new DataSet(); adptr.Fill(ds);
for (int i = 0; i < dt.Rows.Count; i++) {
//Condition for checking existance of username; if (TextBox1.Text == (dt.Rows[i][0]).ToString()) {
MessageBox.Show("Enter Different User Name", "User Name Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBox1.Focus();
break; }
}
//checking of password matching if (TextBox2.Text == textBox3.Text) {
SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO Login VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("You Account Has Been Successfully Created", "CONGRATULATION", MessageBoxButtons.OK,
MessageBoxIcon.Information); }
else {
DialogResult result = MessageBox.Show("Password Does Not Match", "Re-Enter PassWord", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result == DialogResult.Retry) { TextBox2.Focus(); } else { button5.Focus(); } } conn.Close(); } catch (Exception s) { MessageBox.Show(s.Message); } finally {
//finally it will clears all the fields; TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } } }
private void button7_Click(object sender, EventArgs e) {
//delete Account
conn.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
try {
conn.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM Login", conn);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0]; int t = 0;
for (int i = 0; i < dt.Rows.Count; i++) {
if (TextBox1.Text == (dt.Rows[i][0]).ToString() && TextBox2.Text == (dt.Rows[i][1]).ToString())
{
DialogResult result = MessageBox.Show("Do you really want to delete your account", "Confirm to delete",
MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) {
if (TextBox2.Text == textBox3.Text) {
SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "DELETE FROM Login WHERE [User-Name]= '" + TextBox1.Text + "' ";
cmd.ExecuteNonQuery(); TextBox1.Focus(); TextBox2.Text = ""; textBox3.Text = "";
MessageBox.Show("Your account has been deleted", "DELETED", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } t++; break; } } if (t == 0) {
DialogResult result = MessageBox.Show("User Name and ID didn't get Matched", "Information Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
if (result == DialogResult.Retry) {
TextBox1.Text = ""; TextBox2.Text = "";
textBox3.Text = ""; TextBox1.Focus(); } else { TextBox1.Text = ""; TextBox2.Text = ""; textBox3.Text = ""; TextBox1.Focus(); } } conn.Close(); } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button2_Click(object sender, EventArgs e) { this.Close(); } } }
Calender 3
namespace Medical_store {public partial class Calander : Form {
public Calander(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent; }
private void Calander_Load(object sender, EventArgs e) {
}
private void button2_Click(object sender, EventArgs e) {
this.Close(); }
}
namespace Medical_store {
public partial class ContactUs : Form {
public ContactUs(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent; }
private void ContactUs_Load(object sender, EventArgs e) { } } }
Customer 5
namespace Medical_store {public partial class Customermaster : Form {
public int id;
public Customermaster(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent; }
private void Customermaster_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the
'medicalDataSet3._Customer_Master' table. You can move, or remove it, as needed.
//
this.customer_MasterTableAdapter.Fill(this.medicalDataSet3._Customer_Master );
}
private void button3_Click(object sender, EventArgs e) {
this.Close(); }
private void button1_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = "";
con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }
private void button7_Click(object sender, EventArgs e) {
//insert try {
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//insert query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
//cmd.CommandText = "INSERT INTO supplier-master VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.CommandText = "INSERT INTO [Customer-Master] VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully added",
"Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); } catch (Exception s) { MessageBox.Show(s.Message); } finally
{ //textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; } }
private void button6_Click(object sender, EventArgs e) {
//update try {
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//update query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE [Customer-Master] SET [Customer- Id]='" + textBox1.Text + "',[Customer-Name]='" + textBox2.Text +
"',[Address]= '" + textBox3.Text + "',[City] = '" + textBox4.Text + "',[Mo- No] = '" + textBox5.Text + "',[Phone-No] = '" + textBox6.Text + "' WHERE [Customer-Id]= '" + textBox1.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button5_Click(object sender, EventArgs e) {
//delete query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; //con.ConnectionString = @"Data
con.Open();
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from [Customer-Master] "; DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo,
MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else {
cmd.CommandText = "DELETE FROM [Customer-Master] WHERE [Customer-Id]= '" + textBox1.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button4_Click(object sender, EventArgs e) {
}
private void button2_Click(object sender, EventArgs e) {
//Next button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button2.Enabled = true; button10.Enabled = true;
textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString(); //textBox1.Focus(); con.Close(); } else { button2.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button8_Click(object sender, EventArgs e) {
//Last button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--;
{ MessageBox.Show("Database is Empty"); } else { button8.Enabled = true; button9.Enabled = true; textBox1.Text = (dt.Rows[id][0]).ToString(); textBox2.Text = (dt.Rows[id][1]).ToString(); textBox3.Text = (dt.Rows[id][2]).ToString(); textBox4.Text = (dt.Rows[id][3]).ToString(); textBox5.Text = (dt.Rows[id][4]).ToString(); textBox6.Text = (dt.Rows[id][5]).ToString(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button9_Click(object sender, EventArgs e) {
//first button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is Empty"); } else { button9.Enabled = true; button8.Enabled = true; textBox1.Text = (dt.Rows[0][0]).ToString(); textBox2.Text = (dt.Rows[0][1]).ToString(); textBox3.Text = (dt.Rows[0][2]).ToString(); textBox4.Text = (dt.Rows[0][3]).ToString(); textBox5.Text = (dt.Rows[0][4]).ToString(); textBox6.Text = (dt.Rows[0][5]).ToString(); con.Close(); } }
catch (Exception s) { MessageBox.Show(s.Message); } }
private void button10_Click(object sender, EventArgs e) {
//previous buttom try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [Customer-Master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1; if (id > 0) { button2.Enabled = true; button10.Enabled = true;
textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); textBox4.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString();
//textBox1.Focus(); con.Close(); } else { button10.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); }
}
private void groupBox3_Enter(object sender, EventArgs e) { } } }
INFO 6
namespace Medical_store {public partial class Info : Form {
public int id;
public Info(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent;
}
private void Info_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the
'medicalDataSet.info' table. You can move, or remove it, as needed. //this.infoTableAdapter.Fill(this.medicalDataSet.info); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = ""; }
private void button5_Click(object sender, EventArgs e) {
this.Close(); }
private void button3_Click(object sender, EventArgs e) { //new button textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = "";
textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = ""; //textBox1.Focus();
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }
private void button2_Click(object sender, EventArgs e) {
//insert query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//insert query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO Info VALUES('" +
textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox1.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully added",
"Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;
catch (Exception s) { MessageBox.Show(s.Message); } finally {
//After succeesful insertion, all the fields will be cleared //textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; comboBox1.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = ""; //textBoxSrNo.Text = textBoxSrNo.Text + 1; //textBox1.Focus(); } }
private void button4_Click(object sender, EventArgs e) {
//delete query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//delete query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from [info]";
DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo,
MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else {
cmd.CommandText = "DELETE FROM [info] WHERE Id= '" + textBox1.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//cmd.CommandText = "select * from [info]";
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button6_Click(object sender, EventArgs e) {
//update query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//update query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE info SET Id ='" + textBox1.Text + "', PartyName ='" + textBox2.Text + "', Name ='" + textBox3.Text + "', Gender ='" + comboBox1.Text + "', Age ='" + textBox5.Text + "', Address ='" + textBox6.Text + "', [Contac-No] ='" + textBox7.Text + "', [Mo-No] ='" + textBox8.Text + "', [Email Address] ='" + textBox9.Text + "', Remarks ='" + textBox10.Text + "' WHERE Id = '" + textBox1.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM info", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button1_Click(object sender, EventArgs e) {
//next button try
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id + 1; if (id <= dt.Rows.Count) { button1.Enabled = true; button10.Enabled = true;
textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); comboBox1.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString(); textBox7.Text = (dt.Rows[id - 1][6]).ToString(); textBox8.Text = (dt.Rows[id - 1][7]).ToString(); textBox9.Text = (dt.Rows[id - 1][8]).ToString(); textBox10.Text = (dt.Rows[id - 1][9]).ToString();
//textBox1.Focus(); con.Close(); } else { button1.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button8_Click(object sender, EventArgs e) {
//Last button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed)
con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is empty"); } else { button3.Enabled = true; button9.Enabled = true; textBox1.Text = (dt.Rows[id][0]).ToString(); textBox2.Text = (dt.Rows[id][1]).ToString(); textBox3.Text = (dt.Rows[id][2]).ToString(); comboBox1.Text = (dt.Rows[id][3]).ToString(); textBox5.Text = (dt.Rows[id][4]).ToString(); textBox6.Text = (dt.Rows[id][5]).ToString(); textBox7.Text = (dt.Rows[id][6]).ToString(); textBox8.Text = (dt.Rows[id][7]).ToString(); textBox9.Text = (dt.Rows[id][8]).ToString(); textBox10.Text = (dt.Rows[id][9]).ToString(); //textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button9_Click(object sender, EventArgs e) {
//First button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);
adptr.Fill(ds); DataTable dt = ds.Tables[0]; int id = dt.Rows.Count; id--; if (id == 0) { MessageBox.Show("Database is Empty"); } else { button3.Enabled = true; button9.Enabled = true; textBox1.Text = (dt.Rows[0][0]).ToString(); textBox2.Text = (dt.Rows[0][1]).ToString(); textBox3.Text = (dt.Rows[0][2]).ToString(); comboBox1.Text = (dt.Rows[0][3]).ToString(); textBox5.Text = (dt.Rows[0][4]).ToString(); textBox6.Text = (dt.Rows[0][5]).ToString(); textBox7.Text = (dt.Rows[0][6]).ToString(); textBox8.Text = (dt.Rows[0][7]).ToString(); textBox9.Text = (dt.Rows[0][8]).ToString(); textBox10.Text = (dt.Rows[0][9]).ToString(); //textBox1.Focus(); con.Close(); } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button10_Click(object sender, EventArgs e) {
//previous button try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (con.State == ConnectionState.Closed) con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("Select * From [info]", con);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++) {
dt.Rows[i][0] = (i + 1); } id = int.Parse(textBox1.Text); id = id - 1; if (id > 0) { button1.Enabled = true; button10.Enabled = true;
textBox1.Text = (dt.Rows[id - 1][0]).ToString(); textBox2.Text = (dt.Rows[id - 1][1]).ToString(); textBox3.Text = (dt.Rows[id - 1][2]).ToString(); comboBox1.Text = (dt.Rows[id - 1][3]).ToString(); textBox5.Text = (dt.Rows[id - 1][4]).ToString(); textBox6.Text = (dt.Rows[id - 1][5]).ToString(); textBox7.Text = (dt.Rows[id - 1][6]).ToString(); textBox8.Text = (dt.Rows[id - 1][7]).ToString(); textBox9.Text = (dt.Rows[id - 1][8]).ToString(); textBox10.Text = (dt.Rows[id - 1][9]).ToString();
textBox1.Focus(); con.Close(); } else { button1.Enabled = false; } } catch (Exception s) { MessageBox.Show(s.Message); } }
private void panel1_Paint(object sender, PaintEventArgs e) { } } }
ITEM 7
namespace Medical_store {public partial class ItemMaster : Form {
public int ch,id;
public ItemMaster(Medical_store.Mdi_parent1 parent) {
InitializeComponent(); this.MdiParent = parent; }
private void ItemMaster_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the
'medicalDataSet1.Stock' table. You can move, or remove it, as needed. this.stockTableAdapter.Fill(this.medicalDataSet1.Stock); // TODO: This line of code loads data into the
'medicalDataSet._Item_master' table. You can move, or remove it, as needed. this.item_masterTableAdapter.Fill(this.medicalDataSet._Item_master); comboBox1.Text = ""; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; groupBox3.Enabled=false;
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item- master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }
private void button8_Click(object sender, EventArgs e) {
this.Close(); }
private void button1_Click(object sender, EventArgs e) { //new button comboBox1.Text = ""; textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = "";
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=HIREN-9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
con.Open();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item- master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; int b = (dt.Rows.Count); b++; textBox1.Text = b.ToString(); }
{
//insert query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
if (con.State == ConnectionState.Closed) con.Open();
//insert query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text; int a = 0;
cmd.CommandText = "INSERT INTO [Item-master] VALUES('" + textBox1.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')";
cmd.ExecuteNonQuery();
cmd.CommandText = "INSERT INTO Stock([Company-Name],[Item- id],[Sale-QTY],[Purchase-QTY],[Available-QTY])VALUES ('" + comboBox1.Text + "','" + textBox2.Text + "','" + a + "','" + a + "','" + a + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully added",
"Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } finally {
//After succeesful insertion, all the fields will be cleared comboBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; } }
private void button4_Click(object sender, EventArgs e) {
//update query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; con.Open();
//update query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE [Item-master] SET [Sr-NO] = '" + textBox1.Text + "',[Company-Name] = '" + comboBox1.Text + "',[Item-id]='" + textBox2.Text + "', Prize ='" + textBox3.Text + "' WHERE [Item-id] ='" + textBox2.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Record is succesfully updated", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button6_Click(object sender, EventArgs e) {
//delete query try
{
SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True";
con.Open(); //delete query
SqlCommand cmd = new SqlCommand(); cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from [Item-master]";
DialogResult result = MessageBox.Show("Do You Really Want TO Delete This Record", "Confirm", MessageBoxButtons.YesNo,
MessageBoxIcon.Question); if (result == DialogResult.No) { textBox1.Focus(); } else {
cmd.CommandText = "DELETE FROM [Item-master] WHERE [Item-id]= '" + textBox2.Text + "'";
cmd.ExecuteNonQuery();
MessageBox.Show("Selected Record is deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmd.Connection.Close();
SqlDataAdapter adptr = new SqlDataAdapter("SELECT * FROM [Item-master]", con);
DataSet ds = new DataSet(); adptr.Fill(ds); DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt; } catch (Exception s) { MessageBox.Show(s.Message); } }
private void button7_Click(object sender, EventArgs e) {
groupBox3.Enabled = true; radioButton1.Focus(); }
private void button11_Click(object sender, EventArgs e) {
//search Ok button try
{
SqlConnection conn = new SqlConnection(); conn.ConnectionString = @"Data Source=HIREN- 9CF1490E8;Initial Catalog=Medical;Integrated Security=True"; if (conn.State == ConnectionState.Closed) conn.Open();
SqlCommand cmd = new SqlCommand(); cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text; if (ch == 1)
{
cmd.CommandText = "SELECT * FROM [Item-master] WHERE [Item-id] = '" + textBox4.Text + "' ";
SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;
MessageBox.Show("Record Found", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Information); //groupBox3.Hide(); int s = int.Parse(textBox4.Text); s--; groupBox1.Show(); textBox1.Text = (dt.Rows[s][0]).ToString(); comboBox1.Text = (dt.Rows[s][1]).ToString(); textBox2.Text = (dt.Rows[s][2]).ToString(); textBox3.Text = (dt.Rows[s][3]).ToString();
textBox1.Focus(); }
if (ch == 2) {
cmd.CommandText = "SELECT * FROM [Item-master] WHERE [Company-Name] = '" + textBox5.Text + "' ";
SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn);
DataSet ds = new DataSet(); adptr.Fill(ds);
DataTable dt = ds.Tables[0]; dataGridView1.DataSource = dt;
MessageBox.Show((dt.Rows.Count).ToString(), "No.Of Record Found", MessageBoxButtons.OK);
}
if (ch == 3) {
cmd.CommandText = "SELECT * FROM [Item-master] WHERE Prize = '" + textBox6.Text + "' ";
SqlDataAdapter adptr = new SqlDataAdapter(cmd.CommandText, conn);
DataSet ds = new DataSet();