找传奇、传世资源到传世资源站!

C# 超市商品管理系统入门级源码(含数据库)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

分类管理各项商品 ,入门级示例源码,适合新手附加上数据库后,修改 DBHelper.cs中的 数据库 Pwd 密码 即可,登陆账号 jbit 密码 123from clipboardfrom clipboard
from clipboard
from clipboard
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 }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复