收藏 分销(赏)

超市管理系统代码.docx

上传人:xrp****65 文档编号:8934928 上传时间:2025-03-08 格式:DOCX 页数:10 大小:12.27KB 下载积分:10 金币
下载 相关 举报
超市管理系统代码.docx_第1页
第1页 / 共10页
超市管理系统代码.docx_第2页
第2页 / 共10页


点击查看更多>>
资源描述
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace 超市管理信息系统 { public partial class f_供应商基本信息 : Form { //公有变量记录选定数据 public string strOldNO = ""; public string strOldName = ""; public string strOldAdd = ""; public f_供应商基本信息() { InitializeComponent(); } private void f_供应商基本信息_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“连锁超市管理信息数据库DataSet.供应商”中。您可以根据需要移动或移除它。 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //新增数据单击事件 private void btnInsert_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { //新增写入数据库 this.供应商TableAdapter.Insert(iNO, strName, strAdd); } catch (Exception exInsert) { MessageBox.Show("新增数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //单击数据表单元格触发事件 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //获取对应行的各个单元格数据 string strNO = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string strName = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string strAdd = this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); //填充回对应的文本框 txtNO.Text = strNO; txtName.Text = strName; txtAdd.Text = strAdd; //将原数据值赋予公有变量 strOldNO = strNO; strOldName = strName; strOldAdd = strAdd; } //删除按钮事件 private void btnDelete_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { //新增写入数据库 this.供应商TableAdapter.Delete(iNO, strName, strAdd); } catch (Exception exInsert) { MessageBox.Show("删除数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //修改按钮事件 private void btnUpdate_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { this.供应商TableAdapter.Update(iNO, strName, strAdd, Convert.ToInt32(strOldNO), strOldName, strOldAdd); } catch (Exception exUpdate) { MessageBox.Show("修改数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } } }using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace 超市管理信息系统 { public partial class f_供应商基本信息 : Form { //公有变量记录选定数据 public string strOldNO = ""; public string strOldName = ""; public string strOldAdd = ""; public f_供应商基本信息() { InitializeComponent(); } private void f_供应商基本信息_Load(object sender, EventArgs e) { // TODO: 这行代码将数据加载到表“连锁超市管理信息数据库DataSet.供应商”中。您可以根据需要移动或移除它。 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //新增数据单击事件 private void btnInsert_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { //新增写入数据库 this.供应商TableAdapter.Insert(iNO, strName, strAdd); } catch (Exception exInsert) { MessageBox.Show("新增数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //单击数据表单元格触发事件 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //获取对应行的各个单元格数据 string strNO = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); string strName = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string strAdd = this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); //填充回对应的文本框 txtNO.Text = strNO; txtName.Text = strName; txtAdd.Text = strAdd; //将原数据值赋予公有变量 strOldNO = strNO; strOldName = strName; strOldAdd = strAdd; } //删除按钮事件 private void btnDelete_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { //新增写入数据库 this.供应商TableAdapter.Delete(iNO, strName, strAdd); } catch (Exception exInsert) { MessageBox.Show("删除数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } //修改按钮事件 private void btnUpdate_Click(object sender, EventArgs e) { //获取前台数据 string strName = txtName.Text; string strAdd = txtAdd.Text; string strNO = txtNO.Text; int iNO = 0; int iErrCode = 0; //对前台编号数据的格式审核 try { iNO = Convert.ToInt32(txtNO.Text.Trim()); } catch (Exception eINO) { iErrCode = 1; } //对前台名称数据的格式审核 if (strName.Length > 20) { iErrCode = 2; } if (strAdd.Length > 30) { iErrCode = 3; } if (iErrCode != 0) { MessageBox.Show("你所输入的数据有误,请核查!"); } else { try { this.供应商TableAdapter.Update(iNO, strName, strAdd, Convert.ToInt32(strOldNO), strOldName, strOldAdd); } catch (Exception exUpdate) { MessageBox.Show("修改数据发生错误,请与管理员联系!"); } } //刷新数据列数 this.供应商TableAdapter.Fill(this.连锁超市管理信息数据库DataSet.供应商); } } }
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服