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

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


入库

边栏推荐
- About inquirerjs
- Wikipedia User Guide
- [WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx
- np. Understanding of axis in concatenate
- MySQL - use field alias after where
- Leetcode 05 tree
- Understanding of the detach() function of pytorch
- [从零开始学习FPGA编程-21]:进阶篇 - 架构 - VerilogHDL编码规范
- Tweets movement description and chart display
- How many times does the constructor execute?
猜你喜欢
![[andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail](/img/b5/7ea603775dc0448368d209de037a43.png)
[andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail

Stack and queue practice (C language): Demon King's language

Memory learning book reference

How to print infinite symbol in WPS

MySQL connection query

Page optimization - Notes

Stmarl: a spatio temporal multi agentreinforcement learning approach for cooperative traffic

Leetcode question brushing 06 bit operation

URI, URL and urn difference, relation and syntax diagram
![[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx](/img/e9/4e08e07c2de2f99c2938e79f7f1c44.png)
[WSL2]WSL2迁移虚拟磁盘文件ext4.vhdx
随机推荐
Note: common gadgets in project architecture
About retrieving ignored files in cornerstone
Wildcard usage of go standard library FMT
Detailed explanation of audience characteristics
Run Presto under docker to access redis and Bi presentation
csdn涨薪技术之Jmeter接口测试数据库断言的实现与设计
受众群体应该选择观察模式还是定位模式?
Loss calculation in pytorch
Unity JsonUtility 无法序列化List
Tweens of phaser3
[wsl2]wsl2 migrate virtual disk file ext4 vhdx
ng-tv-focusable
Summary of various installation methods of Lab View
Minimum score of one question per day
[从零开始学习FPGA编程-21]:进阶篇 - 架构 - VerilogHDL编码规范
Stone from another mountain: Web3 investment territory of a16z
如何利用您的自有数据来实现营销目标?
[soft test] software designer knowledge points sorting (to be updated)
leetcode. 349. intersection of two arrays
leetcode743. 网络延迟时间(中等, dijkstra)