Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
41 views

Project Code

This document defines a C# Windows Forms application class called CASHEIR that manages items in a store database. It includes methods to display item data from the database in a datagrid, insert new items, update existing items, and delete items. The application connects to a SQL Server database called "Raqiis Store" to perform CRUD operations on an "Items" table.

Uploaded by

Muse Mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Project Code

This document defines a C# Windows Forms application class called CASHEIR that manages items in a store database. It includes methods to display item data from the database in a datagrid, insert new items, update existing items, and delete items. The application connects to a SQL Server database called "Raqiis Store" to perform CRUD operations on an "Items" table.

Uploaded by

Muse Mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

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 final_project_2
{
public partial class CASHEIR : Form
{
public CASHEIR()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=DESKTOP-LA17KJS;Initial
Catalog= Raqiis Store;Integrated Security=True");
private void displaydata()
{
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("select * from CASHIER", con);
da.Fill(dt);
DGV1.DataSource = dt;
con.Close();

private void CASHEIR_Load(object sender, EventArgs e)


{
displaydata();
}

private void button1_Click(object sender, EventArgs e)


{
con.Open();
SqlCommand cmd = new SqlCommand("insert into Items values
("+txtItemID.Text+",'"+txtItemName.Text+"','"+txtItemCost.Text+"','"+txxItemDesc.Te
xt+"','"+txtItemQuantity.Text+"','"+txtBrandID.Text+"','"+txtSupplierID.Text+"','"+
txtSellerID.Text+"')",con);
cmd.ExecuteNonQuery();
MessageBox.Show("Your saved");
con.Close();
displaydata();
}

private void button2_Click(object sender, EventArgs e)


{
con.Open();
SqlCommand cmd = new SqlCommand("update Items set
ItemName='"+txtItemName.Text+"',Cost="+txtItemCost.Text+",Description='"+txxItemDes
c.Text+"',BrandID="+txtBrandID.Text+",SellerID="+txtSellerID.Text+",supplierID="+tx
tSupplierID.Text+" where ItemID="+txtItemID.Text+"", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Your data was updated");
con.Close();
displaydata();
}

private void button4_Click(object sender, EventArgs e)


{

private void btnDelete_Click(object sender, EventArgs e)


{
con.Open();
SqlCommand cmd = new SqlCommand("delete from Items where
ItemID="+txtItemID.Text + "", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Your data was delelted");
con.Close();
displaydata();
}
}
}

You might also like