当前位置:网站首页>四、入库管理功能的完善
四、入库管理功能的完善
2022-06-13 01:35:00 【beyond谚语】
一、数据库的创建
在fiber_yy数据库下创建yy_textile表

先随便添加几条数据
二、页面的完善
登录注册页面我就不演示了,前几篇博文也都有介绍
warehousing入库页面
main_page页面进行功能完善
三、代码实现
warehousing页面
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 warehousing : Form
{
public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";
public warehousing()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog ofdlgTest = new OpenFileDialog();
//ofdlgTest.Filter = "*.jpg|*.png"; //文件过滤 筛选可以打开的文件
ofdlgTest.Filter = "";
ofdlgTest.Multiselect = false; //设置不可以选择多个文件
//显示文件打开对话框
DialogResult result = ofdlgTest.ShowDialog();
//选择打开按钮的时候,将文件名显示到文本框中
if (result == DialogResult.OK) //判断是否打开文件
{
this.textBox11.Text = ofdlgTest.FileName;
pictureBox1.Image = Image.FromFile(ofdlgTest.FileName);
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string path = textBox11.Text;
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); //将指定路径的图片添加到FileStream类中
BinaryReader br = new BinaryReader(fs);//通过FileStream对象实例化BinaryReader对象
byte[] imgBytesIn = br.ReadBytes(Convert.ToInt32(fs.Length));//将图片转为二进制数据
//Save(imgBytesIn);//调用(自己写的一个方法)
SqlConnection conn = new SqlConnection(constr);
conn.Open();
string name = textBox1.Text;
int number = int.Parse(textBox2.Text);
float warp_density = float.Parse(textBox3.Text);
float weft_density = float.Parse(textBox4.Text);
float warp_linear_density = float.Parse(textBox5.Text);
float weft_linear_density = float.Parse(textBox6.Text);
string material = textBox7.Text;
float square_meter_weight = float.Parse(textBox8.Text);
float width_of_cloth = float.Parse(textBox9.Text);
float horse_length = float.Parse(textBox10.Text);
string organization = textBox12.Text;
int stock = int.Parse(textBox13.Text);
SqlCommand cmd = new SqlCommand("insert into yy_textile (name,number,warp_density,weft_density,warp_linear_density,weft_linear_density,material,square_meter_weight,width_of_cloth,horse_length,picture,organization,stock) " +
"values(@name,@number,@warp_density,@weft_density,@warp_linear_density,@weft_linear_density,@material,@square_meter_weight,@width_of_cloth,@horse_length,@picture,@organization,@stock);", conn); //SQL语句
cmd.Parameters.Add("@name", SqlDbType.VarChar);
cmd.Parameters["@name"].Value = name;
cmd.Parameters.Add("@number", SqlDbType.Int);
cmd.Parameters["@number"].Value = number;
cmd.Parameters.Add("@warp_density", SqlDbType.Float);
cmd.Parameters["@warp_density"].Value = warp_density;
cmd.Parameters.Add("@weft_density", SqlDbType.Float);
cmd.Parameters["@weft_density"].Value = weft_density;
cmd.Parameters.Add("@warp_linear_density", SqlDbType.Float);
cmd.Parameters["@warp_linear_density"].Value = warp_linear_density;
cmd.Parameters.Add("@weft_linear_density", SqlDbType.Float);
cmd.Parameters["@weft_linear_density"].Value = weft_linear_density;
cmd.Parameters.Add("@material", SqlDbType.VarChar);
cmd.Parameters["@material"].Value = material;
cmd.Parameters.Add("@square_meter_weight", SqlDbType.Float);
cmd.Parameters["@square_meter_weight"].Value = square_meter_weight;
cmd.Parameters.Add("@width_of_cloth", SqlDbType.Float);
cmd.Parameters["@width_of_cloth"].Value = width_of_cloth;
cmd.Parameters.Add("@horse_length", SqlDbType.Float);
cmd.Parameters["@horse_length"].Value = horse_length;
cmd.Parameters.Add("@picture", SqlDbType.Image);
cmd.Parameters["@picture"].Value = imgBytesIn;
cmd.Parameters.Add("@organization", SqlDbType.VarChar);
cmd.Parameters["@organization"].Value = organization;
cmd.Parameters.Add("@stock", SqlDbType.Int);
cmd.Parameters["@stock"].Value = stock;
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("图片上传成功");
}
catch
{
MessageBox.Show("请核对输入信息");
}
}
private void button3_Click(object sender, EventArgs e)
{
new main_page().Show();
this.Hide();
}
}
}
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表中找个账号密码,直接用户登录

登录成功
进入系统
首先演示下入库管理功能


入库

边栏推荐
- Note: common gadgets in project architecture
- RSA encryption colloquial explanation
- leetcode 206. Reverse linked list
- 关于#数据库#的问题,如何解决?
- MySQL download and installation
- About retrieving ignored files in cornerstone
- Idea installation tutorial
- leetcode. 151. flip the words in the string
- Go JWT learning summary
- 【斯坦福计网CS144项目】Lab1: StreamReassembler
猜你喜欢

Tweets movement description and chart display

项目实训(十七)---个人工作总结

MySQL connection query

Leetcode question brushing 07 double pointer

受众群体应该选择观察模式还是定位模式?

Minimum score of one question per day

Go JWT learning summary

Leetcode 05 tree

Use koa to mock data and set cross domain issues

Stack and queue practice (C language): Demon King's language
随机推荐
#pragma comment(lib,“urlmon.lib“)
Introduction to common activation functions
Alexnet implements image classification of caltech101 dataset (pytorch Implementation)
About inquirerjs
Add default right-click menu
[从零开始学习FPGA编程-21]:进阶篇 - 架构 - VerilogHDL编码规范
Tkinter library installation
Large end storage and small end storage
Traversal of binary tree - first order traversal, middle order traversal, and second order traversal
[WSL2]限制WSL2可访问的硬件资源(CPU/内存)
Install pycharm process
Go JWT learning summary
【斯坦福计网CS144项目】Lab1: StreamReassembler
Unity JsonUtility 无法序列化List
How to print infinite symbol in WPS
About retrieving ignored files in cornerstone
My crawler learning notes
The interviewer only asked me five questions and the interview was over
Wangdao machine test - Chapter 6 - maximum common divisor GCD and minimum common multiple LCM
[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx