Splash Page Code
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 Pharmacy_Management_System
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
int Startpoint = 0;
private void Timer1_Tick(object sender, EventArgs e)
{
Startpoint += 1;
ProgressBar1.Value = Startpoint;
Percentage.Text = Startpoint + "%";
if (ProgressBar1.Value == 100)
{
ProgressBar1.Value = 0;
Timer1.Stop();
Login Obj = new Login();
this.Hide();
Obj.Show();
}
}
private void Form1_Load(object sender, EventArgs e)
{
Timer1.Start();
}
}
}
User Login Page
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 Pharmacy_Management_System
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnAdmin_Click(object sender, EventArgs e)
{
Admin Obj = new Admin();
this.Hide();
Obj.Show();
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
public static string User;
private void btnLogin_Click(object sender, EventArgs e)
{
if(txtUserName.Text == "" || txtPassword.Text == "")
{
MessageBox.Show("Enter Username and Password to Login");
}else
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from SellerTbl where SellerName='" + txtUserName.Text + "' and SellerPassword='" + txtPassword.Text + "'", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
if(dt.Rows[0][0].ToString() == "1")
{
User = txtUserName.Text;
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
Con.Close();
}
else
{
MessageBox.Show("You have entered wrong Username and Password");
}
Con.Close();
}
}
}
}
Admin Login Page
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 Pharmacy_Management_System
{
public partial class Admin : Form
{
public Admin()
{
InitializeComponent();
}
private void btnBack_Click(object sender, EventArgs e)
{
Login Obj = new Login();
this.Hide();
Obj.Show();
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (txtAdminPassword.Text == "")
{
} else if(txtAdminPassword.Text == "Admin"){
Dashboard Obj = new Dashboard();
this.Hide();
Obj.Show();
}else
{
MessageBox.Show("You have entered wrong Admin Password");
txtAdminPassword.Text = "";
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Customer Page
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 Pharmacy_Management_System
{
public partial class Customers : Form
{
public Customers()
{
InitializeComponent();
ShowCustomer();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void ShowCustomer()
{
Con.Open();
string Query = “Select * from CustomerTbl”;
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVCustomers.DataSource = ds.Tables[0];
Con.Close();
}
private void Reset()
{
txtCustomerName.Text = “”;
txtAddress.Text = “”;
txtMobileNo.Text = “”;
txtGender.SelectedIndex = 0;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (txtCustomerName.Text == “” || txtAddress.Text == “” || txtMobileNo.Text == “” || txtGender.SelectedIndex == -1)
{
MessageBox.Show(“Missing Information”);
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand(“insert into CustomerTbl(CustomerName,CustomerAddress,CustomerMobileNo,CustomerDOB,CustomerGender)values(@CN,@CA,@CMN,@CD,@CG)”, Con);
cmd.Parameters.AddWithValue(“@CN”, txtCustomerName.Text);
cmd.Parameters.AddWithValue(“@CA”, txtAddress.Text);
cmd.Parameters.AddWithValue(“@CMN”, txtMobileNo.Text);
cmd.Parameters.AddWithValue(“@CD”, txtDOB.Value.Date);
cmd.Parameters.AddWithValue(“@CG”, txtGender.SelectedItem.ToString());
cmd.ExecuteNonQuery();
MessageBox.Show(“Customer Added Successfully”);
Con.Close();
ShowCustomer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
int Key = 0;
private void DGVCustomers_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtCustomerName.Text = DGVCustomers.SelectedRows[0].Cells[1].Value.ToString();
txtAddress.Text = DGVCustomers.SelectedRows[0].Cells[2].Value.ToString();
txtMobileNo.Text = DGVCustomers.SelectedRows[0].Cells[3].Value.ToString();
txtDOB.Text = DGVCustomers.SelectedRows[0].Cells[4].Value.ToString();
txtGender.SelectedItem = DGVCustomers.SelectedRows[0].Cells[5].Value.ToString();
if (txtCustomerName.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(DGVCustomers.SelectedRows[0].Cells[0].Value.ToString());
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (Key == 0)
{
MessageBox.Show("Select the Customer");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Delete from CustomerTbl where CustomerId=@CKey", Con);
cmd.Parameters.AddWithValue("@CKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Customer Deleted Successfully");
Con.Close();
ShowCustomer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (txtCustomerName.Text == "" || txtAddress.Text == "" || txtMobileNo.Text == "" || txtGender.SelectedIndex == -1)
{
MessageBox.Show("Missing Information");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Update CustomerTbl Set CustomerName=@CN,CustomerAddress=@CA,CustomerMobileNo=@CMN,CustomerDOB=@CD,CustomerGender=@CG where CustomerId=@CKey", Con);
cmd.Parameters.AddWithValue("@CN", txtCustomerName.Text);
cmd.Parameters.AddWithValue("@CA", txtAddress.Text);
cmd.Parameters.AddWithValue("@CMN", txtMobileNo.Text);
cmd.Parameters.AddWithValue("@CD", txtDOB.Value.Date);
cmd.Parameters.AddWithValue("@CG", txtGender.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@CKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Customer Updated Successfully");
Con.Close();
ShowCustomer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void GoDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void btnManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void GoManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void btnMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void GoMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void btnSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void GoSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void btnSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void btnLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
private void GoLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
}
}
Medicine Page
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 Pharmacy_Management_System
{
public partial class Medicines : Form
{
public Medicines()
{
InitializeComponent();
ShowMedicine();
GetManufecturer();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void ShowMedicine()
{
Con.Open();
string Query = “Select * from MedicineTbl”;
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVMedicine.DataSource = ds.Tables[0];
Con.Close();
}
private void Reset()
{
txtMedicineName.Text = “”;
txtMedicineType.SelectedIndex = 0;
txtQuantity.Text = “”;
txtPrice.Text = “”;
txtManufecturerName.Text = “”;
Key = 0;
}
private void GetManufecturer()
{
Con.Open();
SqlCommand cmd = new SqlCommand(“Select ManufecturerId from ManufecturerTbl”, Con);
SqlDataReader Rdr;
Rdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add(“ManufecturerId”, typeof(int));
dt.Load(Rdr);
txtManufecturer.ValueMember = “ManufecturerId”;
txtManufecturer.DataSource = dt;
Con.Close();
}
private void GetManufecturerName()
{
Con.Open();
string Query = “Select * from ManufecturerTbl where ManufecturerId='” + txtManufecturer.SelectedValue.ToString() + “‘”;
SqlCommand cmd = new SqlCommand(Query, Con);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
foreach(DataRow dr in dt.Rows)
{
txtManufecturerName.Text = dr[“ManufecturerName”].ToString();
}
Con.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
if (txtMedicineName.Text == “” || txtMedicineType.SelectedIndex== -1 || txtQuantity.Text == “” || txtQuantity.Text == “” || txtManufecturer.SelectedIndex== -1 || txtManufecturerName.Text == “”)
{
MessageBox.Show(“Missing Information”);
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand(“insert into MedicineTbl(MedicineName,MedicineType,MedicineQnty,MedicinePrice,MedicineManuId,MedicineManufecturer)values(@MN,@MT,@MQ,@MP,@MMI,@MM)”, Con);
cmd.Parameters.AddWithValue(“@MN”, txtMedicineName.Text);
cmd.Parameters.AddWithValue(“@MT”, txtMedicineType.SelectedItem.ToString());
cmd.Parameters.AddWithValue(“@MQ”, txtQuantity.Text);
cmd.Parameters.AddWithValue(“@MP”, txtPrice.Text);
cmd.Parameters.AddWithValue(“@MMI”, txtManufecturer.SelectedValue.ToString());
cmd.Parameters.AddWithValue(“@MM”, txtManufecturerName.Text);
cmd.ExecuteNonQuery();
MessageBox.Show(“Medicine Added Successfully”);
Con.Close();
ShowMedicine();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void txtManufecturer_SelectionChangeCommitted(object sender, EventArgs e)
{
GetManufecturerName();
}
int Key = 0;
private void DGVMedicine_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtMedicineName.Text = DGVMedicine.SelectedRows[0].Cells[1].Value.ToString();
txtMedicineType.SelectedItem = DGVMedicine.SelectedRows[0].Cells[2].Value.ToString();
txtQuantity.Text = DGVMedicine.SelectedRows[0].Cells[3].Value.ToString();
txtPrice.Text = DGVMedicine.SelectedRows[0].Cells[4].Value.ToString();
txtManufecturer.SelectedValue = DGVMedicine.SelectedRows[0].Cells[5].Value.ToString();
txtManufecturerName.Text = DGVMedicine.SelectedRows[0].Cells[6].Value.ToString();
if (txtMedicineName.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(DGVMedicine.SelectedRows[0].Cells[0].Value.ToString());
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (Key == 0)
{
MessageBox.Show("Select the Medicine");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Delete from MedicineTbl where MedicineId=@MKey", Con);
cmd.Parameters.AddWithValue("@MKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Medicine Deleted Successfully");
Con.Close();
ShowMedicine();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (txtMedicineName.Text == "" || txtMedicineType.SelectedIndex == -1 || txtQuantity.Text == "" || txtQuantity.Text == "" || txtManufecturer.SelectedIndex == -1 || txtManufecturerName.Text == "")
{
MessageBox.Show("Missing Information");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Update MedicineTbl Set MedicineName=@MN,MedicineType=@MT,MedicineQnty=@MQ,MedicinePrice=@MP,MedicineManuId=@MMI,MedicineManufecturer=@MM where MedicineId=@MKey", Con);
cmd.Parameters.AddWithValue("@MN", txtMedicineName.Text);
cmd.Parameters.AddWithValue("@MT", txtMedicineType.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@MQ", txtQuantity.Text);
cmd.Parameters.AddWithValue("@MP", txtPrice.Text);
cmd.Parameters.AddWithValue("@MMI", txtManufecturer.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@MM", txtManufecturerName.Text);
cmd.Parameters.AddWithValue("@MKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Medicine Updated Successfully");
Con.Close();
ShowMedicine();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void GoDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void btnManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void GoManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void btnCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void GoCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void btnSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void GoSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void btnSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
}
}
Manufacturer Page
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 Pharmacy_Management_System
{
public partial class Manufecturer : Form
{
public Manufecturer()
{
InitializeComponent();
ShowManufecturer();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void ShowManufecturer()
{
Con.Open();
string Query = “Select * from ManufecturerTbl”;
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVManufecturer.DataSource = ds.Tables[0];
Con.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
if(txtManufecturerName.Text == “” || txtAddress.Text == “” || txtMobileNo.Text == “”)
{
MessageBox.Show(“Missing Information”);
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand(“insert into ManufecturerTbl(ManufecturerName,ManufecturerAddress,ManufecturerMobileNo,ManufecturerDate)values(@MN,@MA,@MMN,@MD)”, Con);
cmd.Parameters.AddWithValue(“@MN”, txtManufecturerName.Text);
cmd.Parameters.AddWithValue(“@MA”, txtAddress.Text);
cmd.Parameters.AddWithValue(“@MMN”, txtMobileNo.Text);
cmd.Parameters.AddWithValue(“@MD”, txtJoinDate.Value.Date);
cmd.ExecuteNonQuery();
MessageBox.Show(“Manufecturer Added Successfully”);
Con.Close();
ShowManufecturer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
int Key = 0;
private void DGVManufecturer_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtManufecturerName.Text = DGVManufecturer.SelectedRows[0].Cells[1].Value.ToString();
txtAddress.Text = DGVManufecturer.SelectedRows[0].Cells[2].Value.ToString();
txtMobileNo.Text = DGVManufecturer.SelectedRows[0].Cells[3].Value.ToString();
txtJoinDate.Text = DGVManufecturer.SelectedRows[0].Cells[4].Value.ToString();
if(txtManufecturerName.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(DGVManufecturer.SelectedRows[0].Cells[0].Value.ToString());
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (Key == 0)
{
MessageBox.Show("Select the Manufecturer");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Delete from ManufecturerTbl where ManufecturerId=@MKey", Con);
cmd.Parameters.AddWithValue("@MKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Manufecturer Deleted Successfully");
Con.Close();
ShowManufecturer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void Reset()
{
txtManufecturerName.Text = "";
txtAddress.Text = "";
txtMobileNo.Text = "";
Key = 0;
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (txtManufecturerName.Text == "" || txtAddress.Text == "" || txtMobileNo.Text == "")
{
MessageBox.Show("Missing Information");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Update ManufecturerTbl Set ManufecturerName=@MN,ManufecturerAddress=@MA,ManufecturerMobileNo=@MMN,ManufecturerDate=@MD where ManufecturerId=@MKey", Con);
cmd.Parameters.AddWithValue("@MN", txtManufecturerName.Text);
cmd.Parameters.AddWithValue("@MA", txtAddress.Text);
cmd.Parameters.AddWithValue("@MMN", txtMobileNo.Text);
cmd.Parameters.AddWithValue("@MD", txtJoinDate.Value.Date);
cmd.Parameters.AddWithValue("@MKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Manufecturer Updated Successfully");
Con.Close();
ShowManufecturer();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void GoDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void btnMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void GoMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void btnCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void GoCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void btnSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void GoSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void btnSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void btnLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
private void GoLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
}
}
Seller Page
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 Pharmacy_Management_System
{
public partial class Sellers : Form
{
public Sellers()
{
InitializeComponent();
ShowSeller();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void ShowSeller()
{
Con.Open();
string Query = “Select * from SellerTbl”;
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVSellers.DataSource = ds.Tables[0];
Con.Close();
}
private void Reset()
{
txtSellerName.Text = “”;
txtAddress.Text = “”;
txtMobileNo.Text = “”;
txtGender.SelectedIndex = 0;
txtPassword.Text = “”;
Key = 0;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (txtSellerName.Text == “” || txtAddress.Text == “” || txtMobileNo.Text == “” || txtGender.SelectedIndex == -1 || txtPassword.Text == “”)
{
MessageBox.Show(“Missing Information”);
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand(“insert into SellerTbl(SellerName,SellerAddress,SellerMobileNo,SellerDOB,SellerGender,SellerPassword)values(@SN,@SA,@SMN,@SD,@SG,@SP)”, Con);
cmd.Parameters.AddWithValue(“@SN”, txtSellerName.Text);
cmd.Parameters.AddWithValue(“@SA”, txtAddress.Text);
cmd.Parameters.AddWithValue(“@SMN”, txtMobileNo.Text);
cmd.Parameters.AddWithValue(“@SD”, txtDOB.Value.Date);
cmd.Parameters.AddWithValue(“@SG”, txtGender.SelectedItem.ToString());
cmd.Parameters.AddWithValue(“@SP”, txtPassword.Text);
cmd.ExecuteNonQuery();
MessageBox.Show(“Seller Added Successfully”);
Con.Close();
ShowSeller();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
int Key = 0;
private void DGVSellers_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtSellerName.Text = DGVSellers.SelectedRows[0].Cells[1].Value.ToString();
txtAddress.Text = DGVSellers.SelectedRows[0].Cells[2].Value.ToString();
txtMobileNo.Text = DGVSellers.SelectedRows[0].Cells[3].Value.ToString();
txtDOB.Text = DGVSellers.SelectedRows[0].Cells[4].Value.ToString();
txtGender.SelectedItem = DGVSellers.SelectedRows[0].Cells[5].Value.ToString();
txtPassword.Text = DGVSellers.SelectedRows[0].Cells[2].Value.ToString();
if (txtSellerName.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(DGVSellers.SelectedRows[0].Cells[0].Value.ToString());
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (Key == 0)
{
MessageBox.Show("Select the Seller");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Delete from SellerTbl where SellerId=@SKey", Con);
cmd.Parameters.AddWithValue("@SKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Seller Deleted Successfully");
Con.Close();
ShowSeller();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (txtSellerName.Text == "" || txtAddress.Text == "" || txtMobileNo.Text == "" || txtGender.SelectedIndex == -1 || txtPassword.Text == "")
{
MessageBox.Show("Missing Information");
}
else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("Update Sellertbl Set SellerName=@SN,SellerAddress=@SA,SellerMobileNo=@SMN,SellerDOB=@SD,SellerGender=@SG,SellerPassword=@SP where SellerId=@SKey", Con);
cmd.Parameters.AddWithValue("@SN", txtSellerName.Text);
cmd.Parameters.AddWithValue("@SA", txtAddress.Text);
cmd.Parameters.AddWithValue("@SMN", txtMobileNo.Text);
cmd.Parameters.AddWithValue("@SD", txtDOB.Value.Date);
cmd.Parameters.AddWithValue("@SG", txtGender.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@SP", txtPassword.Text);
cmd.Parameters.AddWithValue("@SKey", Key);
cmd.ExecuteNonQuery();
MessageBox.Show("Seller Updated Successfully");
Con.Close();
ShowSeller();
Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void btnDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void GoDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void btnManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void GoManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void btnMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void GoMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void btnCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void GoCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void btnSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void btnLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
private void pictureBox10_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
}
}
Selling Page
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 Pharmacy_Management_System
{
public partial class Sellings : Form
{
public Sellings()
{
InitializeComponent();
ShowMedicine();
ShowBill();
GetCustomer();
LblSellerName.Text = Login.User;
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void GetCustomer()
{
Con.Open();
SqlCommand cmd = new SqlCommand(“Select CustomerId from CustomerTbl”, Con);
SqlDataReader Rdr;
Rdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add(“CustomerId”, typeof(int));
dt.Load(Rdr);
txtCustomerID.ValueMember = “CustomerId”;
txtCustomerID.DataSource = dt;
Con.Close();
}
private void GetCustomerName()
{
Con.Open();
string Query = “Select * from CustomerTbl where CustomerId='” + txtCustomerID.SelectedValue.ToString() + “‘”;
SqlCommand cmd = new SqlCommand(Query, Con);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
txtCustomerName.Text = dr[“CustomerName”].ToString();
}
Con.Close();
}
private void UpdateQnty()
{
try
{
int NewQnty = Stock – Convert.ToInt32(txtQuantity.Text);
Con.Open();
SqlCommand cmd = new SqlCommand(“Update MedicineTbl Set MedicineQnty=@MQ where MedicineId=@MKey”, Con);
cmd.Parameters.AddWithValue(“@MQ”, NewQnty);
cmd.Parameters.AddWithValue(“@MKey”, Key);
cmd.ExecuteNonQuery();
MessageBox.Show(“Medicine Updated Successfully”);
Con.Close();
ShowMedicine();
//Reset();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
private void InsertBill()
{
if(txtCustomerName.Text == "")
{
}else
{
try
{
Con.Open();
SqlCommand cmd = new SqlCommand("insert into BillTbl(SellerName,CustomerId,CustomerName,BillDate,BillAmount)values(@SN,@CI,@CN,@BD,@BA)", Con);
cmd.Parameters.AddWithValue("@SN", LblSellerName.Text);
cmd.Parameters.AddWithValue("@CI", txtCustomerID.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@CN", txtCustomerName.Text);
cmd.Parameters.AddWithValue("@BD", DateTime.Today.Date);
cmd.Parameters.AddWithValue("@BA", GrdTotal);
cmd.ExecuteNonQuery();
MessageBox.Show("Bill Saved Successfully");
Con.Close();
ShowBill();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
private void ShowBill()
{
Con.Open();
string Query = "Select * from BillTbl where SellerName='"+LblSellerName.Text+"'";
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVTransactions.DataSource = ds.Tables[0];
Con.Close();
}
private void ShowMedicine()
{
Con.Open();
string Query = "Select * from MedicineTbl";
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
DGVMedicineStock.DataSource = ds.Tables[0];
Con.Close();
}
int n = 0,GrdTotal=0;
private void btnAddToBill_Click(object sender, EventArgs e)
{
if(txtQuantity.Text == "" || Convert.ToInt32(txtQuantity.Text)> Stock)
{
MessageBox.Show("Enter Correct Quantity");
}else
{
int total = Convert.ToInt32(txtQuantity.Text) * Convert.ToInt32(txtPrice.Text);
DataGridViewRow newRow = new DataGridViewRow();
newRow.CreateCells(DGVBill);
newRow.Cells[0].Value = n + 1;
newRow.Cells[1].Value = txtMedicine.Text;
newRow.Cells[2].Value = txtQuantity.Text;
newRow.Cells[3].Value = txtPrice.Text;
newRow.Cells[4].Value = total;
DGVBill.Rows.Add(newRow);
GrdTotal = GrdTotal + total;
LblTotal.Text = "Rs " + GrdTotal;
n++;
UpdateQnty();
}
}
int Key = 0,Stock;
int MedId, MedPrice, MedQty, MedTot;
private void txtCustomerID_SelectionChangeCommitted(object sender, EventArgs e)
{
GetCustomerName();
}
private void btnDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void GoDashboard_Click(object sender, EventArgs e)
{
Dashboard Obj = new Dashboard();
Obj.Show();
this.Hide();
}
private void btnManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void GoManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void btnMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void GoMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void btnCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void GoCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void btnSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void GoSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void btnLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
private void GoLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
string MedName;
private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString("Pacify Pharmacy", new Font("Century Gothic", 12, FontStyle.Bold), Brushes.Red, new Point(80));
e.Graphics.DrawString("ID Medicine Price Quantity Total", new Font("Century Gothic", 10, FontStyle.Bold), Brushes.Red, new Point(26, 40));
foreach (DataGridViewRow row in DGVBill.Rows)
{
MedId = Convert.ToInt32(row.Cells["Column1"].Value);
MedName = "" + row.Cells["Column2"].Value;
MedPrice = Convert.ToInt32(row.Cells["Column3"].Value);
MedQty = Convert.ToInt32(row.Cells["Column4"].Value);
MedTot = Convert.ToInt32(row.Cells["Column5"].Value);
e.Graphics.DrawString("" + MedId, new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Blue, new Point(26, Pos));
e.Graphics.DrawString("" + MedName, new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Blue, new Point(45, Pos));
e.Graphics.DrawString("" + MedPrice, new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Blue, new Point(128, Pos));
e.Graphics.DrawString("" + MedQty, new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Blue, new Point(170, Pos));
e.Graphics.DrawString("" + MedTot, new Font("Century Gothic", 8, FontStyle.Bold), Brushes.Blue, new Point(235, Pos));
Pos = Pos + 20;
}
e.Graphics.DrawString("Grand Total:Rs" + GrdTotal, new Font("Century Gothic", 10, FontStyle.Bold), Brushes.Crimson, new Point(50, Pos + 50));
e.Graphics.DrawString("***********Pacify Pharmacy**********", new Font("Century Gothic", 10, FontStyle.Bold), Brushes.Crimson, new Point(10, Pos + 85));
DGVBill.Rows.Clear();
DGVBill.Refresh();
Pos = 100;
GrdTotal = 0;
n = 0;
}
int Pos = 60;
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("pprnm",285,600);
if(PrintPreviewDialog.ShowDialog() == DialogResult.OK)
{
PrintDocument.Print();
}
InsertBill();
}
private void DGVMedicineStock_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtMedicine.Text = DGVMedicineStock.SelectedRows[0].Cells[1].Value.ToString();
//txtMedicineType.SelectedItem = DGVMedicineStock.SelectedRows[0].Cells[2].Value.ToString();
Stock = Convert.ToInt32(DGVMedicineStock.SelectedRows[0].Cells[3].Value.ToString());
txtPrice.Text = DGVMedicineStock.SelectedRows[0].Cells[4].Value.ToString();
//txtManufecturer.SelectedValue = DGVMedicineStock.SelectedRows[0].Cells[5].Value.ToString();
//txtManufecturerName.Text = DGVMedicineStock.SelectedRows[0].Cells[6].Value.ToString();
if (txtMedicine.Text == "")
{
Key = 0;
}
else
{
Key = Convert.ToInt32(DGVMedicineStock.SelectedRows[0].Cells[0].Value.ToString());
}
}
}
}
Dashboard Page
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 Pharmacy_Management_System
{
public partial class Dashboard : Form
{
public Dashboard()
{
InitializeComponent();
CountMedicine();
CountCustomer();
CountSeller();
SumAmount();
GetSeller();
SumAmountBySellers();
GetBestCustomer();
GetBestSeller();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\Pharmacy Management System\Pharmacy Management System\PMSDB.mdf;Integrated Security=True”);
private void Dashboard_Load(object sender, EventArgs e)
{
}
private void CountMedicine()
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from MedicineTbl", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblMedicines.Text = dt.Rows[0][0].ToString();
Con.Close();
}
private void CountCustomer()
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from CustomerTbl", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblCustomers.Text = dt.Rows[0][0].ToString();
Con.Close();
}
private void CountSeller()
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from SellerTbl", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblSellers.Text = dt.Rows[0][0].ToString();
Con.Close();
}
private void SumAmount()
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Sum(BillAmount) from BillTbl", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblSellAmount.Text = "Rs " + dt.Rows[0][0].ToString();
Con.Close();
}
private void SumAmountBySellers()
{
Con.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select Sum(BillAmount) from BillTbl where SellerName='" + SelectSeller.SelectedValue.ToString() +"'", Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblSellAmountBySeller.Text = "Rs " + dt.Rows[0][0].ToString();
Con.Close();
}
private void GetSeller()
{
Con.Open();
SqlCommand cmd = new SqlCommand("Select SellerName from SellerTbl", Con);
SqlDataReader Rdr;
Rdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("SellerName", typeof(string));
dt.Load(Rdr);
SelectSeller.ValueMember = "SellerName";
SelectSeller.DataSource = dt;
Con.Close();
}
private void GetBestCustomer()
{
try
{
Con.Open();
string InnerQuery = "select Max(BillAmount) from BillTbl";
DataTable dt1 = new DataTable();
SqlDataAdapter sda1 = new SqlDataAdapter(InnerQuery, Con);
sda1.Fill(dt1);
string Query = "select CustomerName from BillTbl where BillAmount = '"+ dt1.Rows[0][0].ToString() +"'";
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblBestCustomer.Text = dt.Rows[0][0].ToString();
Con.Close();
}
catch (Exception Ex)
{
Con.Close();
}
}
private void GetBestSeller()
{
try
{
Con.Open();
string InnerQuery = "select Max(BillAmount) from BillTbl";
DataTable dt1 = new DataTable();
SqlDataAdapter sda1 = new SqlDataAdapter(InnerQuery, Con);
sda1.Fill(dt1);
string Query = "select SellerName from BillTbl where BillAmount = '" + dt1.Rows[0][0].ToString() + "'";
SqlDataAdapter sda = new SqlDataAdapter(Query, Con);
DataTable dt = new DataTable();
sda.Fill(dt);
LblBestSeller.Text = dt.Rows[0][0].ToString();
Con.Close();
}
catch (Exception Ex)
{
Con.Close();
}
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
private void SelectSeller_SelectionChangeCommitted(object sender, EventArgs e)
{
SumAmountBySellers();
}
private void btnManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void GoManufacturer_Click(object sender, EventArgs e)
{
Manufecturer Obj = new Manufecturer();
Obj.Show();
this.Hide();
}
private void btnMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void GoMedicines_Click(object sender, EventArgs e)
{
Medicines Obj = new Medicines();
Obj.Show();
this.Hide();
}
private void btnCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void GoCustomers_Click(object sender, EventArgs e)
{
Customers Obj = new Customers();
Obj.Show();
this.Hide();
}
private void btnSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void GoSellers_Click(object sender, EventArgs e)
{
Sellers Obj = new Sellers();
Obj.Show();
this.Hide();
}
private void btnSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoSelling_Click(object sender, EventArgs e)
{
Sellings Obj = new Sellings();
Obj.Show();
this.Hide();
}
private void GoLogout_Click(object sender, EventArgs e)
{
Login Obj = new Login();
Obj.Show();
this.Hide();
}
}
}