十、纺织品库存管理系统全部功能展示

一、系统主页面—Form1

系统运行加载页面,主要包含三个功能,①登录、②注册、③退出系统
在这里插入图片描述

程序运行图:

在这里插入图片描述

登录功能,跳转到登录页面

在这里插入图片描述

注册功能,跳转到注册页面

在这里插入图片描述

退出系统,程序结束运行

在这里插入图片描述

代码如下:

using System;
using System.Windows.Forms;namespace fiber_yy
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){this.Hide();new login().Show();}private void button3_Click(object sender, EventArgs e){MessageBox.Show("see you again~");Application.Exit();  //退出进程}private void button2_Click(object sender, EventArgs e){this.Hide();new register().Show();}}
}

二、用户注册—register

统一创建数据库fiber_yy

用户注册功能,用户需要填写账号、密码、性别、手机号
在这里插入图片描述
对应表名为yy_user,id为主键自增、username为账号、password为密码、sex为性别、phone为手机号
在这里插入图片描述
在这里插入图片描述
其中账号和密码长度为3-8,并且账号不允许重复,性别通过选择Checked方法来获取用户点击性别,手机号为11位数
若输入都符合要求,点击用户注册按钮,旁边的label6-label9会显示,提示用户输入格式全部正确
若账号重复会弹窗提示此账号已存在~~~,点击确定,账号输入框自动清除,其他输入框保持原始记录
若账号、密码、手机号长度不对也会给予相应的弹窗提示
若全部格式输入成功,点击用户注册,弹窗提示注册成功!,点击确定,自动跳转Form1系统主页面

返回主页面按钮会返回到From1系统主页面

用户注册

在这里插入图片描述
当然,√也可以设置为红色,这种外观自己设置吧
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;namespace fiber_yy
{public partial class register : Form{/*server  主机名称Initial Catalog  数据库名称User ID=sa  默认不变pwd  数据库密码*/public static string str_conn = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";SqlConnection conn = new SqlConnection(str_conn);public register(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){string sex="man";//默认值我设置为manlong phone_number=0;int account_number, password, sum=0;//若输入信息不满足要求sum会自加,最终判断sum为0时表示一切都符合要求account_number = textBox1.Text.Length;password = textBox2.Text.Length;phone_number = long.Parse(textBox3.Text);if (account_number <= 3 || account_number >= 8){label6.Text = "账号长度应该在3~8字符之间";sum++;}else{label6.Text = "校验成功";}if (password <= 3 || password >= 8){label7.Text = "密码长度应该在3~8字符之间";sum++;}else{label7.Text = "校验成功";}if (radioButton1.Checked){sex = "man";label8.Text = "校验成功";}else if (radioButton2.Checked){sex = "woman";label8.Text = "校验成功";}else{label8.Text = "请选择性别";}if (phone_number < 10000000000 || phone_number > 99999999999){label9.Text = "请输入正确的手机号";sum++;}else{label9.Text = "校验成功";}if (sum == 0){label6.Text = "√";label7.Text = "√";label8.Text = "√";label9.Text = "√";try{string sql = string.Format("select count(*) from yy_user where username='{0}'", textBox1.Text);SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();int a = (int)cmd.ExecuteScalar();//返回一个值,看用户是否存在    1存在 0不存在StringBuilder strsql = new StringBuilder();if(a==1){MessageBox.Show("此账号已存在~~~");textBox1.Text = "";label6.Text = "";label7.Text = "";label8.Text = "";label9.Text = "";}else{string INSERT_sql = string.Format("INSERT INTO yy_user VALUES ('{0}','{1}','{2}','{3}')", textBox1.Text.Trim(), textBox2.Text.Trim(), sex, textBox3.Text.Trim());SqlCommand INSERT_cmd = new SqlCommand(INSERT_sql, conn);int count = INSERT_cmd.ExecuteNonQuery();if (count > 0){MessageBox.Show("注册成功!");conn.Close();this.Close();new Form1().Show();}else {MessageBox.Show("注册失败!");}}}catch(Exception ex){MessageBox.Show(ex.Message);}}}private void button2_Click(object sender, EventArgs e){this.Close();new Form1().Show();}}
}

三、用户登录—login

用户输入账号和密码以及验证码,验证码为随机生成的5个随机数

用户登录所用到的表为yy_user

用户登录

在这里插入图片描述
在这里插入图片描述在这里插入图片描述
登录成功跳转到主页面main_page
登录的时候,同时会将用户的信息以及登录时间存入表yy_user_record
在这里插入图片描述
yy_user_record表设计如下
username为登录账号、sex为账号用户的性别、phone为账号用户的手机号、time为此账号登录时间
没有存储密码是为了安全起见,此记录会在流水查询功能中进行展示
在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data.SqlClient;namespace fiber_yy
{public partial class login : Form{public string name = "";public static string str_conn = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";SqlConnection conn = new SqlConnection(str_conn);public string identification = null;public login(){InitializeComponent();}private void button1_Click(object sender, EventArgs e)//登录{string sex = "";string phone = "";string day = DateTime.Now.ToLocalTime().ToString();//获取当前时间string username = textBox1.Text;string password = textBox2.Text;string identify = textBox3.Text;if (username.Equals("") || password.Equals("") || identify.Equals(""))//不能为空{MessageBox.Show("提示:请输入用户名、密码、验证码!", "警告");}else{string sqlSel = "select count(*) from yy_user where username = '" + username + "' and password = '" + password + "'";SqlCommand cmd = new SqlCommand(sqlSel, conn);conn.Open();if (Convert.ToInt32(cmd.ExecuteScalar()) > 0 )//账号密码正确{string sql = "select username,sex,phone from yy_user where username = '" + username + "'";SqlCommand com = new SqlCommand(sql, conn);SqlDataReader read = com.ExecuteReader();while (read.Read())//获取yy_user表中的username,sex,phone{name = read["username"].ToString();sex = read["sex"].ToString();phone = read["phone"].ToString();}read.Close();if (identify==identification)//判断验证码是否输入正确{string INSERT_sql = string.Format("INSERT INTO yy_user_record VALUES ('{0}','{1}','{2}','{3}')", name,sex,phone, DateTime.Now.ToLocalTime());SqlCommand INSERT_cmd = new SqlCommand(INSERT_sql, conn);int count = INSERT_cmd.ExecuteNonQuery();if (count > 0){MessageBox.Show("登录成功");conn.Close();new main_page().Show();this.Close();}else{MessageBox.Show("记录用户失败");conn.Close();}}else {MessageBox.Show("验证码输入错误");conn.Close();}}else{MessageBox.Show("请检查账号密码");conn.Close();}}}private void pictureBox1_Click(object sender, EventArgs e)//验证码{Random r = new Random();string str = null;for (int i = 0; i < 5; i++){int n = r.Next(0, 10);str += n;//包括字符串在内}identification = str;Bitmap b = new Bitmap(100, 15);Graphics g = Graphics.FromImage(b);for (int i = 0; i < 5; i++){String[] fonts = { "宋体", "黑体", "隶书", "仿宋", "微软雅黑" };//字体数组Color[] colors = { Color.Red, Color.Black, Color.Blue,Color.YellowGreen ,Color.Green };//颜色数组Font f = new Font(fonts[r.Next(0, 5)], 25, FontStyle.Bold);SolidBrush s = new SolidBrush(colors[r.Next(0, 5)]);//定义一个单独的画笔,使每个字符的颜色随机Point p = new Point(i * 20, 0);//每个字符间隔20g.DrawString(str[i].ToString(), Font, s, p);}for (int a = 0; a < 5; a++){Point p1 = new Point(r.Next(0, b.Width), r.Next(0, b.Height));Point p2 = new Point(r.Next(0, b.Width), r.Next(0, b.Height));//线的两点不能超过图片的长和宽Pen pen = new Pen(Brushes.Cyan);//青色线段g.DrawLine(pen, p1, p2);}pictureBox1.Image = b;}private void button2_Click(object sender, EventArgs e){new Form1().Show();this.Close();}private void button3_Click(object sender, EventArgs e){new retrieve_password().Show();this.Close();}}
}

四、找回密码—retrieve_password

找回密码

输入账号和注册时填写的手机号即可进行校验,校验通过进行修改密码,跳转change_password修改密码页面
在这里插入图片描述
可以设置显示验证码框
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
验证通过跳转change_password修改密码页面
在这里插入图片描述

代码如下:

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data.SqlClient;namespace fiber_yy
{public partial class retrieve_password : Form{public string name = "";public string identification = null;public string phone = "";public string phone_db = "";public string username = "";public string username_db = "";public string identify = "";public static string str_conn = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";SqlConnection conn = new SqlConnection(str_conn);public retrieve_password(){InitializeComponent();}private void pictureBox1_Click(object sender, EventArgs e){Random r = new Random();string str = null;for (int i = 0; i < 5; i++){int n = r.Next(0, 10);str += n;//包括字符串在内}identification = str;Bitmap b = new Bitmap(100, 15);Graphics g = Graphics.FromImage(b);for (int i = 0; i < 5; i++){String[] fonts = { "宋体", "黑体", "隶书", "仿宋", "微软雅黑" };//字体数组Color[] colors = { Color.Red, Color.Black, Color.Blue, Color.YellowGreen, Color.Green };//颜色数组Font f = new Font(fonts[r.Next(0, 5)], 25, FontStyle.Bold);SolidBrush s = new SolidBrush(colors[r.Next(0, 5)]);//定义一个单独的画笔,使每个字符的颜色随机Point p = new Point(i * 20, 0);//每个字符间隔20g.DrawString(str[i].ToString(), Font, s, p);}for (int a = 0; a < 5; a++){Point p1 = new Point(r.Next(0, b.Width), r.Next(0, b.Height));Point p2 = new Point(r.Next(0, b.Width), r.Next(0, b.Height));//线的两点不能超过图片的长和宽Pen pen = new Pen(Brushes.Cyan);//青色线段g.DrawLine(pen, p1, p2);}pictureBox1.Image = b;}private void button1_Click(object sender, EventArgs e){username = textBox1.Text;phone = textBox2.Text;identify = textBox3.Text;if (identify == identification)//判断验证码是否输入正确{conn.Open();string sql = "select username,phone from yy_user where username = '" + username + "'";SqlCommand com = new SqlCommand(sql, conn);SqlDataReader read = com.ExecuteReader();while (read.Read())//获取yy_user表中的username,sex,phone{username_db = read["username"].ToString();phone_db = read["phone"].ToString();}read.Close();if(phone_db==phone){conn.Close();MessageBox.Show("校验通过");new change_password(username).Show();this.Close();}else {conn.Close();MessageBox.Show("注册手机号不对");}}else{conn.Close();MessageBox.Show("验证码输入错误");}}private void button2_Click(object sender, EventArgs e){new login().Show();this.Hide();}}}

五、修改密码—change_password

修改yy_user表中账号对应的密码
在这里插入图片描述在这里插入图片描述
点击确定,自动跳转至登录页面login
在这里插入图片描述

代码如下:

using System;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace fiber_yy
{public partial class change_password : Form{public string name = "";public string password = "";public string password1 = "";public string username = "";public static string str_conn = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";SqlConnection conn = new SqlConnection(str_conn);public change_password(){InitializeComponent();}public change_password(string yy)//接收登录用户的账号信息{InitializeComponent();username = yy;}private void button1_Click(object sender, EventArgs e){password = textBox1.Text;password1 = textBox2.Text;conn.Open();if (password.Length <= 3 || password.Length >= 8){label3.Text = "密码长度应该在3~8字符之间";conn.Close();}else if(password != password1){label3.Text = "两次输入密码不一致";conn.Close();}else if(password==password1){string sql = "update yy_user set password = '"+ password + "'   where username = '" + username + "'";SqlCommand com = new SqlCommand(sql, conn);com.ExecuteNonQuery();//返回值为操作的条数MessageBox.Show("修改成功");conn.Close();new login().Show();this.Close();}}}
}

六、主页面—main_page

主页面也就起到跳转的作用

在这里插入图片描述

代码如下:

using System;
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();}private void button5_Click(object sender, EventArgs e){this.Close();new flow_query().Show();}}
}

七、入库管理功能—warehousing

所用到yy_textile
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

入库管理页面warehousing

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
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 = "";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.Close();}}
}

八、出库管理功能—shipment

出库管理功能,用户通过查询数据库中织物信息,通过织物唯一编号来查看织物信息,输入出库数量即可出库。此时的出库信息将会被记录到数据表yy_textile_record中,用户可以通过流水查询功能进行查看。并且,若织物库存小于100,则检索时会进行库存不足提示

涉及到出库记录表yy_textile_record
用于记录什么时候哪个账号,该账号手机号是多少,出库了哪个织物多少库存信息
在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
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 login login = new login();public shipment(){InitializeComponent();try{string username = login.name;MessageBox.Show(username);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);if (a > 100){SqlConnection conn2 = new SqlConnection(constr);conn2 = 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  where number='" + number + "'", conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");dataGridView1.DataSource = dsall.Tables["hard"];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 {conn.Close();MessageBox.Show("库存不足100请及时补充!!!");}}catch{MessageBox.Show("读取失败 over");}}private void button3_Click(object sender, EventArgs e)//出库{string time = DateTime.Now.ToLocalTime().ToString();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);if (a>count) {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("出库成功!!!");string username = "";string sql2 = "SELECT TOP 1 username from yy_user_record order by id desc";SqlCommand com = new SqlCommand(sql2, conn);SqlDataReader read = com.ExecuteReader();while (read.Read())//获取yy_user表中的username,sex,phone{username = read["username"].ToString();MessageBox.Show(username);}read.Close();string INSERT_sql = string.Format("INSERT INTO yy_textile_record VALUES ('{0}','{1}','{2}','{3}')", number, count, username, DateTime.Now.ToLocalTime());SqlCommand INSERT_cmd = new SqlCommand(INSERT_sql, conn);int count1 = INSERT_cmd.ExecuteNonQuery();if (count1 > 0){MessageBox.Show("记录纤维出库信息成功!");conn.Close();}else{MessageBox.Show("记录纤维出库信息失败");conn.Close();}}else {MessageBox.Show("库存不足无法出库");conn.Close();}}catch (Exception ex) { MessageBox.Show(ex.Message); }finally{ }}private void button4_Click(object sender, EventArgs e){new main_page().Show();this.Close();}}
}

九、库存查询—query

库存查询所用数据表为yy_textile和七中表一样,查询表中的指定数据信息

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Data.SqlClient;namespace fiber_yy
{public partial class query : Form{private DataSet dsall;public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";private SqlDataAdapter mDataAdapter;public query(){InitializeComponent();comboBox1.Items.Add("根据面料名称查询");comboBox1.Items.Add("根据品号查询");}private void button1_Click(object sender, EventArgs e){try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);conn.Open();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"];conn.Close();}catch {MessageBox.Show("读取失败,请检查是否存在该织物");}}private void button2_Click(object sender, EventArgs e){new main_page().Show();this.Close();}private void button3_Click(object sender, EventArgs e){try{string model = comboBox1.SelectedItem.ToString();string command = textBox1.Text;byte[] MyData = new byte[0];SqlConnection conn = new SqlConnection(constr);conn.Open();SqlCommand cmd = new SqlCommand();cmd.Connection = conn;if (model == "根据面料名称查询"){cmd.CommandText = "select * from yy_textile where name='" + command + "'";model = "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 where name='" + command + "'";}if (model == "根据品号查询"){cmd.CommandText = "select * from yy_textile where number='" + command + "'";model = "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 where number='" + command + "'";}SqlDataReader sdr = cmd.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("读取成功");conn = new SqlConnection(constr);mDataAdapter = new SqlDataAdapter(model, conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");dataGridView1.DataSource = dsall.Tables["hard"];conn.Close();}catch{MessageBox.Show("读取失败,请检查是否存在该织物");}}}
}

十、流水查询—flow_query

流水查询功能主要包括用户登录信息的查询以及所有出库纺织品信息,用到yy_user_record表和yy_textile_record表

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

代码如下:

using System;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace fiber_yy
{public partial class flow_query : Form{private DataSet dsall;public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";private SqlDataAdapter mDataAdapter;public flow_query(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);conn.Open();mDataAdapter = new SqlDataAdapter("SELECT username AS '用户',sex AS '性别',phone AS '手机号',time AS '登录时间' FROM yy_user_record", conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");MessageBox.Show(dsall.ToString());dataGridView1.DataSource = dsall.Tables["hard"];conn.Close();}catch{MessageBox.Show("读取失败");}}private void button2_Click(object sender, EventArgs e){string account = textBox1.Text;try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);conn.Open();mDataAdapter = new SqlDataAdapter("SELECT username AS '用户',sex AS '性别',phone AS '手机号',time AS '登录时间' FROM yy_user_record WHERE username='" + account + "'", conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");dataGridView1.DataSource = dsall.Tables["hard"];conn.Close();}catch{MessageBox.Show("读取失败");}}private void button3_Click(object sender, EventArgs e){try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);conn.Open();mDataAdapter = new SqlDataAdapter("SELECT username AS '用户',number AS '纤维品号',stock AS '取货数量',time AS '出货时间' FROM yy_textile_record", conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");MessageBox.Show(dsall.ToString());dataGridView2.DataSource = dsall.Tables["hard"];conn.Close();}catch{MessageBox.Show("读取失败");}}private void button4_Click(object sender, EventArgs e){string number = textBox2.Text;try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);conn.Open();mDataAdapter = new SqlDataAdapter("SELECT username AS '用户',number AS '纤维品号',stock AS '取货数量',time AS '出货时间' FROM yy_textile_record WHERE number='" + number + "'", conn);dsall = new DataSet();mDataAdapter.Fill(dsall, "hard");dataGridView2.DataSource = dsall.Tables["hard"];conn.Close();}catch{MessageBox.Show("读取失败");}}}
}

后续仍会进行优化…
未完待续…

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/377671.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

leetcode 376. 摆动序列 思考分析

目录题目思路分析代码总结题目 如果连续数字之间的差严格地在正数和负数之间交替&#xff0c;则数字序列称为摆动序列。第一个差&#xff08;如果存在的话&#xff09;可能是正数或负数。少于两个元素的序列也是摆动序列。 例如&#xff0c; [1,7,4,9,2,5] 是一个摆动序列&am…

[EF在VS2010中应用Entity framework与MySQL

在VS2010中应用Entity framework与MySQL 罗朝辉 (http://www.cnblogs.com/kesalin/) 本文遵循“署名-非商业用途-保持一致”创作公用协议本文讲述了在VS2010中使用EF与MySQL的一个简单示例。 工具安装&#xff1a; 1&#xff0c;MySQL MySQL Community Server Connector/NET 6…

十、美化界面

一、背景图片 二、透明化处理 BackColor—web—Transparent 三、数据库建表语句 数据库 USE [fiber_yy] GO /****** Object: Table [dbo].[yy_user_record] Script Date: 06/20/2022 18:54:48 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADD…

VS 如何修改C++编译标准

第一步&#xff0c;打开项目资源管理器的属性页面 第二步&#xff0c;选择配置属性->C/C>语言->C语言标准 第三步&#xff0c;选择合适的标准&#xff0c;一般来说选最新即可

十一、纺织面料下架功能的实现

一、数据库 数据库仍用yy_textile表&#xff0c;前几篇博文都叙述过这里就不再叙述 在fiber_yy数据库下创建yy_textile表 初始数据库信息 二、页面 admin_undercarriage 三、代码实现 admin_undercarriage using System; using System.IO; using System.Data; using S…

svg和canvas的应用场景分析【转载】

原文地址&#xff1a;http://blogs.msdn.com/b/weizhong/archive/2011/07/16/canvas-svg.aspx 思考什么时候使用Canvas 和SVG wzhong 15 Jul 2011 9:07 PM 0HTML5 Canvas 和 SVG 是 IE9 中引入的两项令人激动的图形功能。上周在拉斯维加斯举办的 MIX11 大会对这两个功能进行了介…

【C++grammar】文件系统以及path类使用

目录1.文件系统概述1、关于路径2、如何将某个路径下的所有文件递归地找出来&#xff1f;2.路径类及操作1、path类的成员函数2、path类的非成员函数示例1&#xff1a;展示C17中的path对象的用法示例2&#xff1a;展示Path类中用于分解路径成分的函数示例3&#xff1a;展示path相…

十二、所有功能实现效果演示

一、系统项目架构 Ⅰ&#xff0c;fiber_yy数据库下有五张表 yy_admin&#xff1a;管理员登录账号和密码 yy_textile&#xff1a;纺织面料数据信息 yy_textile_record&#xff1a;用户购买纺织面料信息所存储的面料流水信息 yy_user&#xff1a;用户登录注册信息 yy_user_reco…

leetcode 322. 零钱兑换 思考分析

目录1、题目2、思路分析3、参考链接1、题目 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额&#xff0c;返回 -1。 你可以认为每种硬币的数量是无限的。 提示&#xff1a; 1 …

二、训练fashion_mnist数据集

一、加载fashion_mnist数据集 fashion_mnist数据集中数据为28*28大小的10分类衣物数据集 其中训练集60000张&#xff0c;测试集10000张 from tensorflow import keras import tensorflow as tf import matplotlib.pyplot as plt import numpy as npfashion_mnist keras.data…

四、卷积神经网络(Convolution Neural Networks)

一、CNN(Convolution Neural Networks) 卷积神经网络基本思想&#xff1a;识别物体的特征&#xff0c;来进行判断物体 卷积Convolution&#xff1a;过滤器filter中的数值与图片像素值对应相乘再相加&#xff0c;6 * 6卷积一次(步数为1)变成4 * 4 Max Pooling&#xff1a;对卷积…

POJ3096Surprising Strings(map)

题意&#xff1a;输入很多字符串&#xff0c;以星号结束。判断每个字符串是不是“Surprising Strings”&#xff0c;判断方法是&#xff1a;以“ZGBG”为例&#xff0c;“0-pairs”是ZG&#xff0c;GB&#xff0c;BG&#xff0c;这三个子串不相同&#xff0c;所以是“0-unique”…

五、项目实战---识别人和马

一、准备训练数据 下载数据集 validation验证集 train训练集 数据集结构如下&#xff1a; 将数据集解压到自己选择的目录下就行 最后的结构效果如下&#xff1a; 二、构建模型 ImageDataGenerator 真实数据中&#xff0c;往往图片尺寸大小不一&#xff0c;需要裁剪成一样…

leetcode 122. 买卖股票的最佳时机 II 思考分析

目录题目贪心法题目 给定一个数组&#xff0c;它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易&#xff08;多次买卖一支股票&#xff09;。 注意&#xff1a;你不能同时参与多笔交易&#xff08;你必…

css设置a连接禁用样式_使用CSS禁用链接

css设置a连接禁用样式Question: 题&#xff1a; Links are one of the most essential aspects of any web page or website. They play a very important role in making our website or web page quite responsive or interactive. So the topic for discussion is quite pe…

leetcode 55. 跳跃游戏 思考分析

题目 给定一个非负整数数组&#xff0c;你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 判断你是否能够到达最后一个位置。 示例1&#xff1a; 输入: [2,3,1,1,4] 输出: true 解释: 我们可以先跳 1 步&#xff0c;从位置 0 到达 位置 1…

六、项目实战---识别猫和狗

一、准备数据集 kagglecatsanddogs网上一搜一大堆&#xff0c;这里我就不上传了&#xff0c;需要的话可以私信 导包 import os import zipfile import random import shutil import tensorflow as tf from tensorflow.keras.optimizers import RMSprop from tensorflow.kera…

Origin绘制热重TG和微分热重DTG曲线

一、导入数据 二、传到Origin中 三、热重TG曲线 temp为横坐标、mass为纵坐标 绘制折线图 再稍微更改下格式 字体加粗&#xff0c;Times New Roman 曲线宽度设置为2 横纵坐标数值格式为Times New Roman 根据实际情况改下横纵坐标起始结束位置 四、微分热重DTG曲线 点击曲线…

【嵌入式系统复习】嵌入式网络与协议栈

目录开放式系统互连模型总线通信的报文组形式以及传递方式报文组形式报文传递方式网络分配与调度嵌入式TCP/IP蓝牙技术蓝牙的节能状态纠错方案蓝牙协议栈开放式系统互连模型 ISO/OSI七层模型展示了网络结构与各层的功能。 应用层&#xff1a; 提供了终端用户程序和网络之间的应…

Windows Phone 7 自定义事件

在Windows Phone的应用开发里面&#xff0c;对于事件这种东西我们可以随处可见&#xff0c;系统本来就已经封装好了各种各样的事件机制&#xff0c;如按钮的单击事件等等的。在实际的开发中&#xff0c;我们需要自己去给相关的类自定义一些事件来满足业务的要求&#xff0c;特别…