十、紡織品庫存管理系統全部功能展示

一、系統主頁面—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.pswp.cn/news/377671.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377671.shtml
英文地址,請注明出處:http://en.pswp.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…

c++ cdi+示例_C ++“和”關鍵字示例

c cdi示例"and" is an inbuilt keyword that has been around since at least C98. It is an alternative to && (Logical AND) operator and it mostly uses with the conditions. “ and”是一個內置關鍵字&#xff0c;至少從C 98起就存在。 它是&&am…

Python上個手

Python&#xff0c;由吉多范羅蘇姆&#xff08;Guido van Rossum&#xff09;在1989打發圣誕節放假時間的一門“課余”編程項目&#xff0c;至今已有二十多年的歷史&#xff0c;語法簡潔清晰&#xff0c;深受喜愛&#xff1b; 小窺 # 查看版本 python -V # 輸出 print "he…

十、美化界面

一、背景圖片 二、透明化處理 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…

如何寫出優美的代碼(二)

&#xff08;本文思想基本來自于經典著作《重構》一書&#xff09; 上一篇 http://www.cnblogs.com/ceys/archive/2012/03/05/2379842.html#commentform 上一篇文章主要講了怎么給函數整容。現在我們大家基本上都使用面向對象語言&#xff0c;什么樣的“對象”才是優美的呢&…

轉:鏈表相交問題 詳解

源地址&#xff1a;http://blog.163.com/bbluesnow126/blog/static/27784545201251051156817/ 鏈表相交問題 2012-06-10 17:15:37| 分類&#xff1a; 算法 | 標簽&#xff1a;微軟面試題 |字號 訂閱 1、如何判斷一個單鏈表有環 2、如何判斷一個環的入口點在哪里 3、如何知…

VS 如何修改C++編譯標準

第一步&#xff0c;打開項目資源管理器的屬性頁面 第二步&#xff0c;選擇配置屬性->C/C>語言->C語言標準 第三步&#xff0c;選擇合適的標準&#xff0c;一般來說選最新即可

維吉尼亞密碼和一次性密碼本_密碼學中的一次性密碼

維吉尼亞密碼和一次性密碼本The One-time Pad cipher is almost similar to the Vernam cipher, as, like the vernam cipher, this cipher technique also encrypts the plain text by working on the binary level of the text. The only difference between the two is that…

十一、紡織面料下架功能的實現

一、數據庫 數據庫仍用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相…

scala hashmap_如何在Scala中將Hashmap轉換為Map?

scala hashmapLets first understand what are maps and hashmaps? 首先讓我們了解什么是map和hashmap &#xff1f; map in Scala is a collection that stores its elements as key-value pairs, like a dictionary. Scala中的map是一個集合&#xff0c;將其元素存儲為鍵值…

十二、所有功能實現效果演示

一、系統項目架構 Ⅰ&#xff0c;fiber_yy數據庫下有五張表 yy_admin&#xff1a;管理員登錄賬號和密碼 yy_textile&#xff1a;紡織面料數據信息 yy_textile_record&#xff1a;用戶購買紡織面料信息所存儲的面料流水信息 yy_user&#xff1a;用戶登錄注冊信息 yy_user_reco…

行業軟件之PTV微觀軟件VISSIM4.3 5.0 5.1 5.2 5.3 5.4下載和相關資料

他是干什么的&#xff1a;http://baike.baidu.com/view/3656765.htm 中國代理銷售的公司的網址&#xff1a;辟途威交通科技(上海)有限公司 官網&#xff1a;http://www.ptvchina.cn/ 看看視頻中軟件的運行效果&#xff1a;http://v.youku.com/v_show/id_XMzExMjg1MDEy.html 如何…

一、單個神經元網絡構建

一、本人使用編譯器為Jupyter Notebook&#xff0c;tensorflow版本為1.13.1 import tensorflow as tf print(tf.__version__) """ 1.13.1 """二、訓練單個神經元網絡 x為-1.0, 0.0, 1.0, 2.0, 3.0, 4.0 y為-3.0, -1.0, 1.0, 3.0, 5.0, 7.0 人用…

ruby 生成隨機字符串_Ruby程序生成隨機數

ruby 生成隨機字符串產生隨機數 (Generating random number) The task is to generate and print random number. 任務是生成并打印隨機數。 Generating random numbers means that any number can be provided to you which is not dependent on any pre-specified condition…

leetcode 322. 零錢兌換 思考分析

目錄1、題目2、思路分析3、參考鏈接1、題目 給定不同面額的硬幣 coins 和一個總金額 amount。編寫一個函數來計算可以湊成總金額所需的最少的硬幣個數。如果沒有任何一種硬幣組合能組成總金額&#xff0c;返回 -1。 你可以認為每種硬幣的數量是無限的。 提示&#xff1a; 1 …

linux上的英文字體monospace可以在windows用嗎?

linux的字體都是開源的&#xff0c;應該可以官方下載本地下載轉載于:https://www.cnblogs.com/52linux/archive/2012/03/14/2396103.html

Flash Builder 創建CSS

1.global 選擇器將樣式應用于所有控件 在 Flash Builder 中創建新MXML 文件并切換到設計模式 屬性視圖右側的外觀視圖可更改外觀 Flash Builder 自動創建CSS 文件 CSS 文件有2 個命名空間&#xff1a; s 指 Spark 組件 mx 指 MX 組件 1. Global 與Application 選擇器 global …