一、數據庫的建立
在fiber_yy數據庫下創建yy_textile_record表
可以先手動填入幾條數據信息
初始數據庫信息
第一條數據的username是空格不是null
number為織物的品號(唯一的)
stock為出貨量
username為哪個賬號
time為出貨時間
二、頁面的完善
登錄注冊頁面我就不演示了,前幾篇博文也都有介紹
flow_query流水查詢頁面完善
三、代碼實現
flow_query流水查詢頁面
using System;
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 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);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"];}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);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"];}catch{MessageBox.Show("讀取失敗");}/*SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);mDataAdapter1 = new SqlDataAdapter("select * from yy_user_record) where username='" + account + "'", conn);MessageBox.Show("-----");dsall1 = new DataSet();mDataAdapter1.Fill(dsall1, "hard");MessageBox.Show(dsall1.ToString());dataGridView1.DataSource = dsall1.Tables["hard"];*/}private void button3_Click(object sender, EventArgs e){try{SqlConnection conn = new SqlConnection(constr);conn = new SqlConnection(constr);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"];}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);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"];}catch{MessageBox.Show("讀取失敗");}}}
}
四、效果演示
程序運行
注冊我就不演示了,請參考前幾篇博文
從yy_user表中找個賬號密碼,直接用戶登錄
用戶一旦成功登錄系統,會記錄時間和用戶信息
登錄成功
進入系統
先出庫,出庫管理功能
出庫5份
演示流水查詢
用戶登錄查詢再第七篇博文以及演示了,這里就不再贅述
現在演示紡織品出庫查詢
emmm,這里纖維品號選擇的不太好都成了1014了,不過功能大體都是實現了,輸入品號就會進行篩選
品號111查找,不存在