当前位置:网站首页>四、入库管理功能的完善
四、入库管理功能的完善
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表中找个账号密码,直接用户登录

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


入库

边栏推荐
- 详细受众特征详细解释
- Add default right-click menu
- This of phaser3 add. add. image
- Alexnet implements image classification of caltech101 dataset (pytorch Implementation)
- Docker install MySQL
- Auto commit attribute of MySQL
- 【斯坦福計網CS144項目】Lab1: StreamReassembler
- pycharm add configutions
- Temporary objects and compilation optimization
- 【斯坦福计网CS144项目】Lab1: StreamReassembler
猜你喜欢

Lecture on Compilation Principles

关于tkinter.Canvas 不显示图片的问题

Work and life

Method of cleaning C disk

DFS and BFS notes (II): depth first search (implemented in C language)

Uuid/guid introduction, generation rules and generation codes

Tangent and tangent plane

Leetcode find duplicates

Summary of various installation methods of Lab View

Leetcode question brushing 07 double pointer
随机推荐
ES6 deconstruction assignment
Thread code learning notes
Happy string
DFS and BFS notes (II): depth first search (implemented in C language)
Leetcode question brushing 04 string
csdn涨薪技术之Jmeter接口测试数据库断言的实现与设计
路径字段是什么? ——竞价广告
Wikipedia API User Guide
Rasa dialogue robot helpdesk (III)
Set and array conversion, list, array
Ecological convergence NFT attacks, metaverse ape leads the new paradigm revolution of Web 3.0 meta universe
A summary of global variables and typedef
Vector|hdu-4841 round table questions
[official document summary] writing standards for academic dissertations of National University of science and technology
MySQL download and installation
【MathType】利用MathType输出LaTex样式的公式
[MathType] use MathType to output latex style formula
Unity jsonutility failed to serialize list
谷歌的受众群体是如何发挥作用的?
受众群体应该选择观察模式还是定位模式?