一、数据库的建立
在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查找,不存在