当前位置:网站首页>六、出库管理功能的实现
六、出库管理功能的实现
2022-06-13 01:35:00 【beyond谚语】
一、数据库的建立
这里仍使用yy_textile表
在fiber_yy数据库下创建yy_textile表

初始数据库信息
二、页面的完善
登录注册页面我就不演示了,前几篇博文也都有介绍
shipment出库管理页面
main_page页面进行功能完善
三、代码实现
shipment出库管理页面
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
namespace fiber_yy
{
public partial class shipment : Form
{
private DataSet dsall;
public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";
private SqlDataAdapter mDataAdapter;
public shipment()
{
InitializeComponent();
try
{
SqlConnection conn = new SqlConnection(constr);
conn = new SqlConnection(constr);
mDataAdapter = new SqlDataAdapter("SELECT name AS '纺织品名称',number AS '纺织品品号',warp_density AS '经密度' ,weft_density AS '纬密度',warp_linear_density AS '经纱线密度',weft_linear_density AS '纬纱线密度',material AS '原料成分',square_meter_weight AS '平方米重量',width_of_cloth AS '幅宽',horse_length AS '匹长',organization AS '所用组织',stock AS '库存量' FROM yy_textile", conn);
dsall = new DataSet();
mDataAdapter.Fill(dsall, "hard");
dataGridView1.DataSource = dsall.Tables["hard"];
}
catch
{
MessageBox.Show("读取失败,请检查是否存在该织物");
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(constr);
conn = new SqlConnection(constr);
mDataAdapter = new SqlDataAdapter("SELECT name AS '纺织品名称',number AS '纺织品品号',warp_density AS '经密度' ,weft_density AS '纬密度',warp_linear_density AS '经纱线密度',weft_linear_density AS '纬纱线密度',material AS '原料成分',square_meter_weight AS '平方米重量',width_of_cloth AS '幅宽',horse_length AS '匹长',organization AS '所用组织',stock AS '库存量' FROM yy_textile", conn);
dsall = new DataSet();
mDataAdapter.Fill(dsall, "hard");
dataGridView1.DataSource = dsall.Tables["hard"];
}
catch
{
MessageBox.Show("读取失败");
}
}
private void button2_Click(object sender, EventArgs e)//查看织物信息
{
try
{
string number = textBox1.Text;
byte[] MyData = new byte[0];
string sql = "SELECT stock FROM yy_textile WHERE number='" + number + "'";
SqlConnection conn = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
string account = cmd.ExecuteScalar().ToString();
int a = int.Parse(account);
//MessageBox.Show(a.ToString());
if (a > 100)
{
SqlConnection conn1 = new SqlConnection(constr);
conn1.Open();
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = conn1;
cmd1.CommandText = "select * from yy_textile where number='" + number + "'";
SqlDataReader sdr = cmd1.ExecuteReader();
sdr.Read();
object o = sdr["picture"];
MyData = (byte[])sdr["picture"];//读取第一个图片的位流
MemoryStream memoryStream = null;
memoryStream = new MemoryStream(MyData);
pictureBox1.Image = Image.FromStream(memoryStream);//将图片赋给pictureBox1控件
MessageBox.Show("读取成功");
}
else
{
MessageBox.Show("库存不足100请及时补充!!!");
}
}
catch
{
MessageBox.Show("读取失败 over");
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
string sql1;
string number = this.textBox1.Text;
int count = int.Parse(textBox2.Text);
SqlConnection conn = new SqlConnection(constr);
conn = new SqlConnection(constr);
string sql = "SELECT number FROM yy_textile WHERE number='" + number + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
string amount = cmd.ExecuteScalar().ToString();
int a = int.Parse(amount);
sql1 = "update yy_textile set stock = stock - '" + count + "' where number='" + number + "'";
mDataAdapter = new SqlDataAdapter(sql1, conn);
dsall = new DataSet();
mDataAdapter.Fill(dsall, "hard");
dataGridView1.DataSource = dsall.Tables["hard"];
MessageBox.Show("出库成功!!!");
}
catch (Exception ex) {
MessageBox.Show(ex.Message); }
finally
{
}
}
private void button4_Click(object sender, EventArgs e)
{
this.Hide();
new main_page().Show();
}
}
}
main_page页面
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 fiber_yy
{
public partial class main_page : Form
{
public main_page()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("退出成功");
this.Close();
new Form1().Show();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
new warehousing().Show();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
new shipment().Show();
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
new query().Show();
}
}
}
四、效果演示
程序运行
注册我就不演示了,请参考前几篇博文
从yy_user表中找个账号密码,直接用户登录

登录成功
进入系统
演示出库管理功能

查看织物信息
出库20

检索一下
当库存低于100的时候会提醒,且这时候就不能再出库了,需要补充织物
边栏推荐
- Leetcode-78- subset (medium)
- [learn FPGA programming from scratch -22]: Advanced chapter - Architecture - Design and modeling of FPGA internal hardware circuit
- [andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail
- A summary of global variables and typedef
- Work and life
- Argparse command line passes list type parameter
- [official document summary] writing standards for academic dissertations of National University of science and technology
- How to print infinite symbol in WPS
- 机器学习基础 SVM(支持向量机)
- Realization of flip animation
猜你喜欢

Traversal of binary tree - first order traversal, middle order traversal, and second order traversal

leetcode743. 网络延迟时间(中等, dijkstra)

Leetcode question brushing 07 double pointer

Introduction to convolutional neural network

The second round of mesa

【斯坦福計網CS144項目】Lab1: StreamReassembler

Leetcode-19- delete the penultimate node of the linked list (medium)

Crypto JS reports uglifyjs error

Work and life

MySQL performance optimization
随机推荐
[leetcode] valid phone number Bash
leetode. 242. valid Letter heteronyms
MySQL download and installation
Tkinter library installation
leetcode 206. Reverse linked list
Calculate sentence confusion ppl using Bert and gpt-2
np.concatenate中axis的理解
Run Presto under docker to access redis and Bi presentation
【官方文件汇总】国科大学位论文撰写规范
leetcode743. 网络延迟时间(中等, dijkstra)
[learn FPGA programming from scratch -22]: Advanced chapter - Architecture - Design and modeling of FPGA internal hardware circuit
September 3, 2021 visual notes
Leetcode question brushing 03 stack
About inquirerjs
[WSL2]限制WSL2可访问的硬件资源(CPU/内存)
[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx
Transaction characteristics and isolation levels
Spit bubbles (stack)
leetcode. 349. intersection of two arrays
Startup, connection and stop of MySQL service