三、上傳織物圖片至SQL Server并提供name進行展示織物照片

一、數據庫的建立

還是在fiber_yy數據庫下創建images表
在這里插入圖片描述
images表設計如下
在這里插入圖片描述

二、頁面完善設計

main_page頁面進行功能完善
在這里插入圖片描述
入庫管理系統
warehousing頁面
在這里插入圖片描述
庫存查詢系統
query頁面
在這里插入圖片描述

登錄注冊頁面前面幾個博文已經實現過了,這里就再贅述了,仍是沿用前面的登錄注冊頁面及數據庫

三、代碼實現

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();}}
}

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.textBox9.Text = ofdlgTest.FileName;pictureBox1.Image = Image.FromFile(ofdlgTest.FileName);}}private void button1_Click(object sender, EventArgs e){string path = textBox9.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;SqlCommand cmd = new SqlCommand("insert into images (name,image) values(@name,@Image);", conn); //SQL語句cmd.Parameters.Add("@name", SqlDbType.VarChar);cmd.Parameters["@name"].Value = name;cmd.Parameters.Add("@Image", SqlDbType.Image);cmd.Parameters["@Image"].Value = imgBytesIn;cmd.ExecuteNonQuery();conn.Close();MessageBox.Show("圖片上傳成功");}private void button3_Click(object sender, EventArgs e){new main_page().Show();this.Hide();}}
}

query頁面

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 query : Form{public string constr = "server=CY-20190824RMES;Initial Catalog=fiber_yy;User ID=sa;pwd=beyond";public query(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){try{byte[] MyData = new byte[0];SqlConnection conn = new SqlConnection(constr);string name = textBox1.Text;conn.Open();SqlCommand cmd = new SqlCommand();cmd.Connection = conn;cmd.CommandText = "select * from images where name='" + name + "'"; //寫自己要查圖片的name信息SqlDataReader sdr = cmd.ExecuteReader();sdr.Read();object o = sdr["Image"];MyData = (byte[])sdr["Image"];//讀取第一個圖片的位流MemoryStream memoryStream = null;memoryStream = new MemoryStream(MyData);pictureBox1.Image = Image.FromStream(memoryStream);//將圖片賦給pictureBox1控件MessageBox.Show("讀取成功");}catch {MessageBox.Show("讀取失敗,請檢查是否存在該織物");}}}
}

四、效果演示

程序運行
在這里插入圖片描述
注冊我就不演示了,請參考前幾篇博文
yy_user表中找個賬號密碼,直接用戶登錄
在這里插入圖片描述
在這里插入圖片描述
登錄成功
在這里插入圖片描述
進入系統
在這里插入圖片描述
目前先初步實現了入庫管理功能庫存查詢功能

先演示入庫管理系統

原先數據庫信息
在這里插入圖片描述
入庫管理功能目前主要是通過用戶輸入的面料名稱和面料照片來存儲

上傳照片
在這里插入圖片描述
在這里插入圖片描述
入庫
在這里插入圖片描述
查看數據庫信息

右擊 images選擇前1000行,更新數據庫信息
在這里插入圖片描述
最后一個為新入庫的圖片

接下來點擊返回,返回到主頁面,演示庫存查詢功能
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
點擊button1
在這里插入圖片描述

優化仍在繼續…

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377706.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377706.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377706.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

gettype_PHP gettype()函數與示例

gettypePHP gettype()函數 (PHP gettype() function) In PHP, we have a library function gettype() to identify the type of data. The function is primarily used to sanity check the type of data being input in a variable. The function can identify the data into …

ARM MMU工作原理剖析[轉]

一、MMU的產生 許多年以前,當人們還在使用DOS或是更古老的操作系統的時候,計算機的內存還非常小,一般都是以K為單位進行計算,相應的,當時的程序規模也不大,所以內存容量雖然小,但還是可以容納當…

棧與隊列在SGI STL的底層實現

棧 棧提供push和pop等接口,不提供走訪功能,也不提供迭代器。 STL中棧不被歸類為容器,而被歸類為container adapter(容器適配器),這是因為棧是以底層容器完成其所有的工作,對外提供統一的接口,底層容器是可…

【原創】SharePoint Document library List Check out 文檔時碰到的問題解決

環境:TFS(Team Foundation Server)集成的WSS 3.0(SharePoint Service 3.0) 問題:如題,祥見下圖 解決:一般碰到沒有經驗的問題,大家當然是外事不決問谷歌了,于是谷歌搜到了這篇博客 h…

getdate函數_PHP getdate()函數與示例

getdate函數PHP getdate()函數 (PHP getdate() function) getdate() function is used to get the local date/time (or it is also used to get the date/time based on the given timestamp. getdate()函數用于獲取本地日期/時間(或也用于根據給定的時間戳獲取日期/時間。 S…

四、入庫管理功能的完善

一、數據庫的創建 在fiber_yy數據庫下創建yy_textile表 先隨便添加幾條數據 二、頁面的完善 登錄注冊頁面我就不演示了,前幾篇博文也都有介紹 warehousing入庫頁面 main_page頁面進行功能完善 三、代碼實現 warehousing頁面 using System; using System.…

leetcode 232. 用棧實現隊列 思考分析

題目 請你僅使用兩個棧實現先入先出隊列。隊列應當支持一般隊列的支持的所有操作(push、pop、peek、empty): 實現 MyQueue 類: void push(int x) 將元素 x 推到隊列的末尾 int pop() 從隊列的開頭移除并返回元素 int peek() 返…

YCSB初步介紹

隨著大數據時代的到來和云計算的不斷發展,作為云計算最基礎的設施存儲產品也越來越多,開源分布式存儲系統有BigTable-like系統HBase,dynamo-like系統Cassandra,voldemort,Riak,淘寶開源的OceanBase等。當然…

kotlin實現繼承_Kotlin程序| 繼承的例子

kotlin實現繼承遺產 (Inheritance) Inheritance is a mechanism wherein a new class is derived from an existing class. 繼承是一種機制,其中新類是從現有類派生的。 All Kotlin Classes have a common Superclass Any, it is the Default Superclass with no S…

【C++grammar】動態類型轉換、typeid與RTTI

目錄動態類型轉換1、為何需要動態類型轉換2、dynamic_cast<>();運算符3、向上轉換和向下轉換( Upcasting and Downcasting)4、 基類對象和派生類對象的互操作5、Upcasting/Downcasting與繼承鏈上不同類的對象之間的賦值有什么關系和區別&#xff1f;typeid 運行時查詢類型…

nginx資源定向 css js路徑問題

今天玩玩項目&#xff0c;學學nginx發現還不錯&#xff0c;速度還可以&#xff0c;但是CSS JS確無法使用&#xff0c;原來Iginx配置時需要對不同類型的文件配置規則&#xff0c;真是很郁悶&#xff0c;不過想想也還是很有道理。閑暇之際&#xff0c;把配置貼上來。#user nobody…

五、庫存查詢功能的完善

一、數據庫的建立 由于查詢功能和之前的 入庫管理功能 所用的數據庫都一樣&#xff0c;這里仍使用yy_textile表 在fiber_yy數據庫下創建yy_textile表 初始數據庫信息 二、頁面的完善 登錄注冊頁面我就不演示了&#xff0c;前幾篇博文也都有介紹 query查詢頁面 main_page…

整合ajaxmin 和 less 到VS.net

我用的前端框架是bootstrap_extra, twitter團隊做的&#xff0c;這個是他的一個擴展&#xff0c;首先從上面下載一個。至于ajaxmin&#xff0c;請參考這里1) 從bootstrap_extra的解壓包中&#xff0c;復制build目錄下三個文件到項目中去&#xff0c;這三個文件分別是BatchSubsi…

轉:只能選擇GridView中的一個CheckBox(單選CheckBox)

方法1&#xff1a; protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e){CheckBox cbx e.Row.FindControl("cbID") as CheckBox;try{//綁定選中CheckBox 客戶端IDcbx.Attributes.Add("onclick", "Change(" cbx.Cli…

六、出庫管理功能的實現

一、數據庫的建立 這里仍使用yy_textile表 在fiber_yy數據庫下創建yy_textile表 初始數據庫信息 二、頁面的完善 登錄注冊頁面我就不演示了&#xff0c;前幾篇博文也都有介紹 shipment出庫管理頁面 main_page頁面進行功能完善 三、代碼實現 shipment出庫管理頁面 u…

數學建模:層次分析法實例以及代碼

博主聯系方式&#xff1a; QQ:1540984562 QQ交流群&#xff1a;892023501 群里會有往屆的smarters和電賽選手&#xff0c;群里也會不時分享一些有用的資料&#xff0c;有問題可以在群里多問問。 目錄層次分析法的思想層次分析法步驟具體案例(市政工程項目建設決策)1.問題提出2.…

c 僵尸進程_演示僵尸進程的C程序

c 僵尸進程僵尸進程 (Zombie process) A process which has finished its execution but still has an entry in the process table to report to its parent process is known as a zombie process. 一個已經完成執行但仍在進程表中具有要報告給其父進程的條目的進程稱為僵尸進…

探秘IntelliJ IDEA 13測試版新功能——調試器顯示本地變量

IntelliJ IDEA在業界被公認為最好的Java開發平臺之一&#xff0c;JetBrains公司將在12月正式發布IntelliJ IDEA 13版本。 現在&#xff0c;小編將和大家一起探秘密IntelliJ IDEA 13測試版本新功能——調試器顯示本地變量。這個功能非常強大&#xff0c;調試器可以顯示變量&…

C# Windows Form下的控件的Validator(數據驗證)

由于偶爾的一個想法&#xff0c;謀生了一個做一個windows form下的Validator控件&#xff0c;或者直接說類吧&#xff01; 因為webform下的Validator控件太好用了。哈哈&#xff0c;直接看代碼&#xff01; 下面這個類&#xff0c;主要是一個簡單的驗證類&#xff0c;不過只是起…

七、流水查詢---記錄用戶登錄信息

一、數據庫的建立 在fiber_yy數據庫下創建yy_user_record表 可以先手動填入幾條數據信息 初始數據庫信息 username為用戶賬號 sex為用戶注冊所填寫的性別 phone為用戶手機號 time為用戶登錄該系統的時間 二、頁面的設計 登錄注冊頁面我就不演示了&#xff0c;前幾篇博文…