SuperMarket Management System Source Code

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 SuperMarket_Management_System
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void btnClose_Click(object sender, EventArgs e)
    {

    }
    int startpoint = 0;
    private void timer1_Tick(object sender, EventArgs e)
    {

    }

    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Start();
    }

    private void timer1_Tick_1(object sender, EventArgs e)
    {
        startpoint += 1;
        ProgressBar1.Value = startpoint;
        if (ProgressBar1.Value == 100)
        {
            ProgressBar1.Value = 0;
            timer1.Stop();
            Login log = new Login();
            this.Hide();
            log.Show();
        }
    }

    private void btnClose_Click_1(object sender, EventArgs e)
    {
        Application.Exit();
    }
}

}

Login 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;
using System.Data.SqlClient;
namespace SuperMarket_Management_System
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
public static string Sellername = “”;
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\SuperMarket Management System\SuperMarket Management System\SMMS.mdf;Integrated Security=True;Connect Timeout=30″);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

    private void btnLogin_Click(object sender, EventArgs e)
    {
        if (txtUsername.Text == "" || txtPassword.Text == "")
        {
            MessageBox.Show("Please Enter the Username and Password");
        }
        else
        {
            if (cbSelectRole.SelectedIndex > -1)
            {
                if (cbSelectRole.SelectedItem.ToString() == "Admin")
                {
                    if (txtUsername.Text == "Admin" && txtPassword.Text == "Password")
                    {
                        Product_Form Prod = new Product_Form();
                        Prod.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("If You are Admin, Enter the Correct Username and Password");
                    }
                }
                else
                {
                    //MessageBox.Show("You are in the Seller Section");
                    Con.Open();
                    SqlDataAdapter sda = new SqlDataAdapter("select count(*) from SellersTbl where SellerName='" + txtUsername.Text + "' and SellerPassword='" + txtPassword.Text + "'", Con);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    if (dt.Rows[0][0].ToString() == "1")
                    {
                        Sellername = txtUsername.Text;
                        Selling_Form sell = new Selling_Form();
                        sell.Show();
                        this.Hide();
                        Con.Close();
                    }
                    else
                    {
                        MessageBox.Show("Wrong Username and Password");
                    }
                    Con.Close();
                }
            }
            else
            {
                MessageBox.Show("Select the Role to Login");
            }
        }
    }

    private void btnReset_Click(object sender, EventArgs e)
    {
        txtUsername.Text = "";
        txtPassword.Text = "";
    }
}

}

Category 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;
using System.Data.SqlClient;
namespace SuperMarket_Management_System
{
public partial class Category_Form : Form
{
public Category_Form()
{
InitializeComponent();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\SuperMarket Management System\SuperMarket Management System\SMMS.mdf;Integrated Security=True;Connect Timeout=30″);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void populate()
{
Con.Open();
string query = “select * from CategoriesTbl”;
SqlDataAdapter sda = new SqlDataAdapter(query, Con);
SqlCommandBuilder builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
CategoriesDGV.DataSource = ds.Tables[0];
Con.Close();
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
Con.Open();
string query = “insert into CategoriesTbl values(” + txtCategoryID.Text + “,'” + txtCategoryName.Text + “‘,'” + txtCategoryDescription.Text + “‘)”;
SqlCommand cmd = new SqlCommand(query, Con);
cmd.ExecuteNonQuery();
MessageBox.Show(“Category Added Successfully”);
Con.Close();
populate();
txtCategoryID.Text = “”;
txtCategoryName.Text = “”;
txtCategoryDescription.Text = “”;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

    private void Category_Form_Load(object sender, EventArgs e)
    {
        populate();
    }

    private void CategoriesDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        txtCategoryID.Text = CategoriesDGV.SelectedRows[0].Cells[0].Value.ToString();
        txtCategoryName.Text = CategoriesDGV.SelectedRows[0].Cells[1].Value.ToString();
        txtCategoryDescription.Text = CategoriesDGV.SelectedRows[0].Cells[2].Value.ToString();
    }

    private void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtCategoryID.Text == "" || txtCategoryName.Text == "" || txtCategoryDescription.Text == "")
            {
                MessageBox.Show("Missing Information");
            }
            else
            {
                Con.Open();
                string query = "update CategoriesTbl set CatName='" + txtCategoryName.Text + "',CatDesc='" + txtCategoryDescription.Text + "' where CatId=" + txtCategoryID.Text + "";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Category has been updated Successfully");
                Con.Close();
                populate();
                txtCategoryID.Text = "";
                txtCategoryName.Text = "";
                txtCategoryDescription.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtCategoryID.Text == "")
            {
                MessageBox.Show("Select Category Id to Delete");
            }
            else
            {
                Con.Open();
                string query = "delete from CategoriesTbl where CatId=" + txtCategoryID.Text + "";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Category has been deleted successfully");
                Con.Close();
                populate();
                txtCategoryID.Text = "";
                txtCategoryName.Text = "";
                txtCategoryDescription.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void btnLogout_Click(object sender, EventArgs e)
    {
        this.Hide();
        Login login = new Login();
        login.Show();
    }

    private void btnSellers_Click(object sender, EventArgs e)
    {
        Seller_Form Sell = new Seller_Form();
        Sell.Show();
        this.Hide();
    }

    private void btnProducts_Click(object sender, EventArgs e)
    {
        Product_Form Prod = new Product_Form();
        Prod.Show();
        this.Hide();
    }

    private void btnSelling_Click(object sender, EventArgs e)
    {
        Selling_Form sell = new Selling_Form();
        sell.Show();
        this.Hide();
    }
}

}

Product 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;
using System.Data.SqlClient;
namespace SuperMarket_Management_System
{
public partial class Product_Form : Form
{
public Product_Form()
{
InitializeComponent();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\SuperMarket Management System\SuperMarket Management System\SMMS.mdf;Integrated Security=True;Connect Timeout=30″);
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
Con.Open();
string query = “insert into ProductsTbl values(” + txtProductID.Text + “,'” + txtProductName.Text + “‘,” + txtProductQuantity.Text + “,” + txtProductPrice.Text + “,'” + cbSelectCategory.SelectedValue.ToString() + “‘)”;
SqlCommand cmd = new SqlCommand(query, Con);
cmd.ExecuteNonQuery();
MessageBox.Show(“Product Added Successfully”);
Con.Close();
populate();
txtProductID.Text = “”;
txtProductName.Text = “”;
txtProductQuantity.Text = “”;
txtProductPrice.Text = “”;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void FillCategory()
{
//This Method will bind the Combobox with the Database
Con.Open();
SqlCommand cmd = new SqlCommand(“select CatName from CategoriesTbl”, Con);
SqlDataReader rdr;
rdr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add(“CatName”, typeof(string));
dt.Load(rdr);
cbSearchCategory.ValueMember = “CatName”;
cbSearchCategory.DataSource = dt;
cbSelectCategory.ValueMember = “CatName”;
cbSelectCategory.DataSource = dt;
Con.Close();
}
private void populate()
{
Con.Open();
string query = “select * from ProductsTbl”;
SqlDataAdapter sda = new SqlDataAdapter(query, Con);
SqlCommandBuilder builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
ProductsDGV.DataSource = ds.Tables[0];
Con.Close();
}
private void Product_Form_Load(object sender, EventArgs e)
{
FillCategory();
populate();
}

    private void btnClose_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void ProductsDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        txtProductID.Text = ProductsDGV.SelectedRows[0].Cells[0].Value.ToString();
        txtProductName.Text = ProductsDGV.SelectedRows[0].Cells[1].Value.ToString();
        txtProductQuantity.Text = ProductsDGV.SelectedRows[0].Cells[2].Value.ToString();
        txtProductPrice.Text = ProductsDGV.SelectedRows[0].Cells[3].Value.ToString();
        cbSelectCategory.SelectedValue = ProductsDGV.SelectedRows[0].Cells[4].Value.ToString();
    }

    private void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtProductID.Text == "" || txtProductName.Text == "" || txtProductQuantity.Text == "" || txtProductPrice.Text == "")
            {
                MessageBox.Show("Missing Information");

            }
            else
            {
                Con.Open();
                string query = "update ProductsTbl set ProdName='" + txtProductName.Text + "',ProdQty=" + txtProductQuantity.Text + ",ProdPrice=" + txtProductPrice.Text + ",ProdCat='" + cbSelectCategory.SelectedValue.ToString() + "' where ProdId=" + txtProductID.Text + "; ";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Product Successfully Updated");
                Con.Close();
                populate();
                txtProductID.Text = "";
                txtProductName.Text = "";
                txtProductQuantity.Text = "";
                txtProductPrice.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtProductID.Text == "")
            {
                MessageBox.Show("Select the Product to Delete");
            }
            else
            {
                Con.Open();
                string query = "delete from ProductsTbl where ProdId=" + txtProductID.Text + "";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Product deleted successfully");
                Con.Close();
                populate();
                txtProductID.Text = "";
                txtProductName.Text = "";
                txtProductQuantity.Text = "";
                txtProductPrice.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void cbSearchCategory_SelectionChangeCommitted(object sender, EventArgs e)
    {
        Con.Open();
        string query = "select * from ProductsTbl where ProdCat='" + cbSearchCategory.SelectedValue.ToString() + "'";
        SqlDataAdapter sda = new SqlDataAdapter(query, Con);
        SqlCommandBuilder builder = new SqlCommandBuilder(sda);
        var ds = new DataSet();
        sda.Fill(ds);
        ProductsDGV.DataSource = ds.Tables[0];
        Con.Close();
    }

    private void btnLogout_Click(object sender, EventArgs e)
    {
        this.Hide();
        Login login = new Login();
        login.Show();
    }

    private void btnSelling_Click(object sender, EventArgs e)
    {
        Selling_Form sell = new Selling_Form();
        sell.Show();
        this.Hide();
    }

    private void btnCategories_Click(object sender, EventArgs e)
    {
        Category_Form Cat = new Category_Form();
        Cat.Show();
        this.Hide();
    }

    private void btnSellers_Click(object sender, EventArgs e)
    {
        Seller_Form Sell = new Seller_Form();
        Sell.Show();
        this.Hide();
    }
}

}

Sellers 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;
using System.Data.SqlClient;
namespace SuperMarket_Management_System
{
public partial class Seller_Form : Form
{
public Seller_Form()
{
InitializeComponent();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\SuperMarket Management System\SuperMarket Management System\SMMS.mdf;Integrated Security=True;Connect Timeout=30″);
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

    private void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            Con.Open();
            string query = "insert into SellersTbl values(" + txtSellerID.Text + ",'" + txtSellerName.Text + "'," + txtSellerAge.Text + "," + txtSellerMobileNo.Text + ",'" + txtSellerPassword.Text + "')";
            SqlCommand cmd = new SqlCommand(query, Con);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Seller Added Successfully");
            Con.Close();
            populate();
            txtSellerID.Text = "";
            txtSellerName.Text = "";
            txtSellerAge.Text = "";
            txtSellerMobileNo.Text = "";
            txtSellerPassword.Text = "";
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtSellerID.Text == "" || txtSellerName.Text == "" || txtSellerAge.Text == "" || txtSellerMobileNo.Text == "" || txtSellerPassword.Text == "")
            {
                MessageBox.Show("Missing Information");

            }
            else
            {
                Con.Open();
                string query = "update SellersTbl set SellerName='" + txtSellerName.Text + "',SellerAge=" + txtSellerAge.Text + ",SellerMobileNo=" + txtSellerMobileNo.Text + ",SellerPassword=" + txtSellerPassword.Text + " where SellerId=" + txtSellerID.Text + "; ";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Seller Successfully Updated");
                Con.Close();
                populate();
                txtSellerID.Text = "";
                txtSellerName.Text = "";
                txtSellerAge.Text = "";
                txtSellerMobileNo.Text = "";
                txtSellerPassword.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

    private void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtSellerID.Text == "")
            {
                MessageBox.Show("Select the Seller to Delete");
            }
            else
            {
                Con.Open();
                string query = "delete from SellersTbl where SellerId=" + txtSellerID.Text + "";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Seller Deleted Successfully");
                Con.Close();
                populate();
                txtSellerID.Text = "";
                txtSellerName.Text = "";
                txtSellerAge.Text = "";
                txtSellerMobileNo.Text = "";
                txtSellerPassword.Text = "";
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
    private void populate()
    {
        Con.Open();
        string query = "select * from SellersTbl";
        SqlDataAdapter sda = new SqlDataAdapter(query, Con);
        SqlCommandBuilder builder = new SqlCommandBuilder(sda);
        var ds = new DataSet();
        sda.Fill(ds);
        SellersDGV.DataSource = ds.Tables[0];
        Con.Close();
    }
    private void Seller_Form_Load(object sender, EventArgs e)
    {
        populate();
    }

    private void btnLogout_Click(object sender, EventArgs e)
    {
        this.Hide();
        Login login = new Login();
        login.Show();
    }

    private void btnSelling_Click(object sender, EventArgs e)
    {
        Selling_Form sell = new Selling_Form();
        sell.Show();
        this.Hide();
    }

    private void btnCategories_Click(object sender, EventArgs e)
    {
        Category_Form Cat = new Category_Form();
        Cat.Show();
        this.Hide();
    }

    private void btnProducts_Click(object sender, EventArgs e)
    {
        Product_Form Prod = new Product_Form();
        Prod.Show();
        this.Hide();
    }

    private void SellersDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        txtSellerID.Text = SellersDGV.SelectedRows[0].Cells[0].Value.ToString();
        txtSellerName.Text = SellersDGV.SelectedRows[0].Cells[1].Value.ToString();
        txtSellerAge.Text = SellersDGV.SelectedRows[0].Cells[2].Value.ToString();
        txtSellerMobileNo.Text = SellersDGV.SelectedRows[0].Cells[3].Value.ToString();
        txtSellerPassword.Text = SellersDGV.SelectedRows[0].Cells[4].Value.ToString();
    }
}

}

Selling 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;
using System.Data.SqlClient;
namespace SuperMarket_Management_System
{
public partial class Selling_Form : Form
{
public Selling_Form()
{
InitializeComponent();
}
SqlConnection Con = new SqlConnection(@”Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Full Projects\SuperMarket Management System\SuperMarket Management System\SMMS.mdf;Integrated Security=True;Connect Timeout=30″);
private void populate()
{
Con.Open();
string query = “select ProdName,ProdQty from ProductsTbl”;
SqlDataAdapter sda = new SqlDataAdapter(query, Con);
SqlCommandBuilder builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
ProdDGV.DataSource = ds.Tables[0];
Con.Close();
}
private void populatebills()
{
Con.Open();
string query = “select * from BillsTbl”;
SqlDataAdapter sda = new SqlDataAdapter(query, Con);
SqlCommandBuilder builder = new SqlCommandBuilder(sda);
var ds = new DataSet();
sda.Fill(ds);
BillsDGV.DataSource = ds.Tables[0];
Con.Close();
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

    private void btnAddProduct_Click(object sender, EventArgs e)
    {
        if (txtProductName.Text == "" || txtProductQuantity.Text == "")
        {
            MessageBox.Show("Missing Information");
        }
        else
        {
            int total = Convert.ToInt32(txtProductPrice.Text) * Convert.ToInt32(txtProductQuantity.Text);
            DataGridViewRow newRow = new DataGridViewRow();
            newRow.CreateCells(OrdersDGV);
            newRow.Cells[0].Value = n + 1;
            newRow.Cells[1].Value = txtProductName.Text;
            newRow.Cells[2].Value = txtProductQuantity.Text;
            newRow.Cells[3].Value = txtProductPrice.Text;
            newRow.Cells[4].Value = Convert.ToInt32(txtProductPrice.Text) * Convert.ToInt32(txtProductQuantity.Text);
            OrdersDGV.Rows.Add(newRow);
            n++;
            Grdtotal = Grdtotal + total;
            lblAmount.Text = "" + Grdtotal;
        }
    }

    private void Selling_Form_Load(object sender, EventArgs e)
    {
        populate();
        populatebills();
        FillCategory();
        lblSellerName.Text = Login.Sellername;
    }

    private void ProdDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        txtProductName.Text = ProdDGV.SelectedRows[0].Cells[0].Value.ToString();
        txtProductQuantity.Text = ProdDGV.SelectedRows[0].Cells[1].Value.ToString();
    }
    int Grdtotal = 0, n = 0;
    private void panel1_Paint(object sender, PaintEventArgs e)
    {
        lblDate.Text = DateTime.Today.Day.ToString() + "/" + DateTime.Today.Month.ToString() + "/" + DateTime.Today.Year.ToString();
    }
    private void FillCategory()
    {
        //This Method will bind the Combobox with the Database
        Con.Open();
        SqlCommand cmd = new SqlCommand("select CatName from CategoriesTbl", Con);
        SqlDataReader rdr;
        rdr = cmd.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Columns.Add("CatName", typeof(string));
        dt.Load(rdr);
        //cbSearchCategory.ValueMember = "CatName";
        //cbSearchCategory.DataSource = dt;
        cbSelectCategory.ValueMember = "CatName";
        cbSelectCategory.DataSource = dt;
        Con.Close();
    }

    private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        e.Graphics.DrawString("K.M.S. SuperMarket", new Font("Century Gothic", 25, FontStyle.Bold), Brushes.Red, new Point(230));
        e.Graphics.DrawString("Bill ID:" + BillsDGV.SelectedRows[0].Cells[0].Value.ToString(), new Font("Century Gothic", 20, FontStyle.Bold), Brushes.Blue, new Point(100, 70));
        e.Graphics.DrawString("Seller Name:" + BillsDGV.SelectedRows[0].Cells[1].Value.ToString(), new Font("Century Gothic", 20, FontStyle.Bold), Brushes.Blue, new Point(100, 100));
        e.Graphics.DrawString("Bill Date:" + BillsDGV.SelectedRows[0].Cells[2].Value.ToString(), new Font("Century Gothic", 20, FontStyle.Bold), Brushes.Blue, new Point(100, 130));
        e.Graphics.DrawString("Total Amount:" + BillsDGV.SelectedRows[0].Cells[3].Value.ToString(), new Font("Century Gothic", 20, FontStyle.Bold), Brushes.Blue, new Point(100, 160));
        e.Graphics.DrawString("K.M.G.S.S.", new Font("Century Gothic", 25, FontStyle.Bold), Brushes.Red, new Point(230, 230));
    }

    private void btnPrint_Click(object sender, EventArgs e)
    {
        if (PrintPreviewDialog.ShowDialog() == DialogResult.OK)
        {
            PrintDocument.Print();
        }
    }

    private void btnRefresh_Click(object sender, EventArgs e)
    {
        populate();
    }

    private void cbSelectCategory_SelectionChangeCommitted(object sender, EventArgs e)
    {
        Con.Open();
        string query = "select ProdName,ProdQty from ProductsTbl where ProdCat='" + cbSelectCategory.SelectedValue.ToString() + "'";
        SqlDataAdapter sda = new SqlDataAdapter(query, Con);
        SqlCommandBuilder builder = new SqlCommandBuilder(sda);
        var ds = new DataSet();
        sda.Fill(ds);
        ProdDGV.DataSource = ds.Tables[0];
        Con.Close();
    }

    private void btnSellers_Click(object sender, EventArgs e)
    {
        Seller_Form Sell = new Seller_Form();
        Sell.Show();
        this.Hide();
    }

    private void btnCategories_Click(object sender, EventArgs e)
    {
        Category_Form Cat = new Category_Form();
        Cat.Show();
        this.Hide();
    }

    private void btnProducts_Click(object sender, EventArgs e)
    {
        Product_Form Prod = new Product_Form();
        Prod.Show();
        this.Hide();
    }

    private void btnLogout_Click(object sender, EventArgs e)
    {
        this.Hide();
        Login login = new Login();
        login.Show();
    }

    private void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtBillID.Text == "")
        {
            MessageBox.Show("Missing Bill Id");
        }
        else
        {
            try
            {
                Con.Open();
                string query = "insert into BillsTbl values(" + txtBillID.Text + ",'" + lblSellerName.Text + "','" + lblDate.Text + "'," + lblAmount.Text + ")";
                SqlCommand cmd = new SqlCommand(query, Con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Order Added Successfully");
                Con.Close();
                populatebills();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

}

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart