基本信息
源码名称:C# 超市商品管理系统入门级源码(含数据库)
源码大小:2.97M
文件格式:.zip
开发语言:C#
更新时间:2017-12-12
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
分类管理各项商品 ,入门级示例源码,适合新手
附加上数据库后,修改 DBHelper.cs中的 数据库 Pwd 密码 即可,登陆账号 jbit 密码 123
using System;
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.Threading.Tasks;
using System.Windows.Forms;
namespace SuperMarket
{
public partial class frmProductlist : Form
{
public frmProductlist()
{
InitializeComponent();
}
DataSet ds = new DataSet();//创建数据集
#region 窗体加载事件
//窗体加载事件
private void frmProductlist_Load(object sender, EventArgs e)
{
Bind();
}
#endregion
#region 初始化
public void Bind()
{
this.dgvspxs.AutoGenerateColumns = false;
string sql = "select c.*,s.SortName from Commodity c,CommoditySort s where c.SortID = s.SortID";
SqlDataAdapter adapter = new SqlDataAdapter(sql, DBHelper.ConnString);
if (ds.Tables["Commodity"] != null)
{
ds.Tables["Commodity"].Clear();
}
adapter.Fill(ds, "Commodity");
this.dgvspxs.DataSource = ds.Tables["Commodity"];
}
#endregion
#region 单击退出
private void tstc_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
#region 选中后事件
//选中后事件
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
Cood();
}
#endregion
#region 筛选
//筛选
public void Cood()
{
DataView dv = new DataView(ds.Tables["Commodity"]);//获取深度
TreeNode tv = this.tvree.SelectedNode;
if (tv.Level != 0)
{
dv.RowFilter = "IsDiscount = '" tv.Tag "'";
}
this.dgvspxs.DataSource = dv;
}
#endregion
#region 单击增加
private void tszj_Click(object sender, EventArgs e)
{
frmCompile ws = new frmCompile();
ws.ShowDialog();
this.Bind();
}
#endregion
#region 单击删除
private void tssc_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32(this.dgvspxs.CurrentRow.Cells[0].Value);
DialogResult result = MessageBox.Show("确定要删除吗", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
if (result == DialogResult.OK)
{
SqlConnection conn = new SqlConnection(DBHelper.ConnString);
conn.Open();
string sql = "delete Commodity where CommodityID=" num;
SqlCommand comm = new SqlCommand(sql, conn);
int sum = comm.ExecuteNonQuery();
if (sum >= 1)
{
MessageBox.Show("删除成功");
Bind();
}
else
{
MessageBox.Show("删除失败");
}
conn.Close();
}
}
#endregion
#region 单击修改
private void tsxg_Click(object sender, EventArgs e)
{
frmCompile qs = new frmCompile();
qs.num = Convert.ToInt32(this.dgvspxs.SelectedCells[0].Value);
qs.ShowDialog();
this.Bind();
}
#endregion
}
}