📄 formxscx.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace _10901BS
{
public partial class formXscx : Form
{
SqlConnection myCon = new SqlConnection();
SqlCommand myCom = new SqlCommand();
SqlDataAdapter da;
SqlDataReader dr;
DataSet ds = new DataSet();
DataSet ds1 = new DataSet();
public formXscx()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
dbcon();
////da = new SqlDataAdapter("Select xsDjID as '单据编号',xsSum as '销售总数',xsSszje as '销售总额',hyID as '员工编号' from xszBiao where 1=2 ", myCon);
////ds.Clear();
////da.Fill(ds);
////this.dataGridView1.DataSource = ds.Tables[0];
////da = new SqlDataAdapter("Select spxqBiao.spID'商品编号',spxqBiao.spName'商品名称',spxqBiao.spBzsj'商品单价',spxqBiao.spGgxh'商品规格',spxqBiao.spJldw'商品单位',''as'商品数量',''as'商品总额',''as'员工编号'from spxqBiao where 1=2 ", myCon);
////ds1.Clear();
////da.Fill(ds1);
////this.dataGridView2.DataSource = ds1.Tables[0];
da = new SqlDataAdapter("select * from xszBiao", myCon);
//ds.Clear();
//da.Fill(ds);
////cb = new SqlCommandBuilder(da);
//this.dataGridView1.DataSource = ds.Tables[0];
da = new SqlDataAdapter("select xsDjID as 销售单据编号, xsID as 销售序号, spID as 商品编号, jhDjID as 进货单据编号, spSl as 商品数量, spSjdj as 商品实际单价, spZje as 商品总金额, spSpXsJe as 实际商品销售金额, beiZhu as 备注 from xsxqBiao", myCon);
//ds1.Clear();
//da.Fill(ds1);
////cb = new SqlCommandBuilder(da1);
//this.dataGridView2.DataSource = ds1.Tables[0];
}
public void dbcon()
{
if (myCon.State != ConnectionState.Open)
{
myCon.ConnectionString = "server=.;database=110901DB;Integrated Security=True";
myCon.Open();
//MessageBox.Show("连接成功!");
}
}
private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text != "")
{
//myCom.CommandText = "select * from xszBiao where xsDjID like '%" + this.textBox1.Text + "%'";
da = new SqlDataAdapter("select xsDjID as 销售单据编号, xsSum as 销售总数, xsSszje as 销售总额, hyID as 员工编号 from xszBiao where xsDjID like '%" + this.textBox1.Text + "%'", myCon);
ds.Clear();
da.Fill(ds);
this.dataGridView1.DataSource = ds.Tables[0];
//MessageBox.Show("查询成功!");
//for (int w = 0; w < dataGridView1.Rows.Count - 1; w++)
//{
// this.textBox1.Text = dataGridView1.Rows[w].Cells[0].Value.ToString();
// //this.textBox1.Text = "";
// this.textBox1.Clear();
//}
}
else
{
MessageBox.Show("对不起!没有您要查询的数据!");
}
//this.textBox1.Text = "";
//if (this.textBox3.Text != "")
//{
// myCom.Connection = myCon;
// myCom.CommandText = "select * from xszBiao where xsDjID like '%" + this.textBox3.Text + "%'";
// da.SelectCommand = myCom;
// ds.Clear();
// da.Fill(ds);
// this.dataGridView1.DataSource = ds.Tables[0];
//}
//else
//{
// MessageBox.Show("对不起!没有您要查询的数据!");
//}
//if (this.textBox5.Text != "")
//{
// myCom.Connection = myCon;
// myCom.CommandText = "select * from xszBiao where xsDjID like '%" + this.textBox5.Text + "%'";
// da.SelectCommand = myCom;
// ds.Clear();
// da.Fill(ds);
// this.dataGridView1.DataSource = ds.Tables[0];
//}
//else
//{
// MessageBox.Show("对不起!没有您要查询的数据!");
//}
//if (this.textBox6.Text != "")
//{
// myCom.Connection = myCon;
// myCom.CommandText = "select * from xszBiao where xsDjID like '%" + this.textBox6.Text + "%'";
// da.SelectCommand = myCom;
// ds.Clear();
// da.Fill(ds);
// this.dataGridView1.DataSource = ds.Tables[0];
// for (int b = 0; b < dataGridView1.Rows.Count - 1; b++)
// {
// this.textBox1.Text = dataGridView1.Rows[b].Cells[1].Value.ToString();
// }
//}
//else
//{
// MessageBox.Show("对不起!没有您要查询的数据!");
//}
//else
//{
// MessageBox.Show("对不起!没有您要查询的数据!");
//}
//if (this.textBox4.Text != "")
//{
// myCom.Connection = myCon;
// myCom.CommandText = "select * from xsxqBiao where spID like '%" + this.textBox4.Text + "%'";
// da.SelectCommand = myCom;
// ds1.Clear();
// da.Fill(ds1);
// this.dataGridView2.DataSource = ds1.Tables[0];
//}
//else
//{
// MessageBox.Show("对不起!没有您要查询的数据!");
//}
//da.Update(ds.Tables[0]);
//MessageBox.Show("查询成功");
//for (int l = 0; l < dataGridView1.Rows.Count - 1; l++)
//{
// this.label16.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
// this.label17.Text = this.dataGridView2.CurrentRow.Cells[1].Value.ToString();
// this.label18.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
// this.label19.Text = this.dataGridView2.CurrentRow.Cells[2].Value.ToString();
// this.label20.Text = this.dataGridView2.CurrentRow.Cells[4].Value.ToString();
// this.label21.Text = this.dataGridView2.CurrentRow.Cells[4].Value.ToString();
// this.label22.Text = this.dataGridView2.CurrentRow.Cells[4].Value.ToString();
//}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//for (int z = 0; z < dataGridView1.Rows.Count - 1; z++)
//{
//点击textBox1时,使以下清空
this.textBox1.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
this.textBox3.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
this.textBox5.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
this.textBox6.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
this.label27.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
this.label28.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
this.label29.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
this.label30.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
this.textBox2.Text = "";
this.textBox4.Text = "";
this.textBox7.Text = "";
//}
}
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//for (int h = 0; h < dataGridView2.Rows.Count - 1; h++)
//{
this.textBox2.Text = this.dataGridView2.CurrentRow.Cells[2].Value.ToString();
this.textBox4.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
this.textBox7.Text = this.dataGridView2.CurrentRow.Cells[8].Value.ToString();
this.label16.Text = this.dataGridView2.CurrentRow.Cells[2].Value.ToString();
this.label17.Text = this.dataGridView2.CurrentRow.Cells[0].Value.ToString();
this.label18.Text = this.dataGridView2.CurrentRow.Cells[4].Value.ToString();
this.label19.Text = this.dataGridView2.CurrentRow.Cells[3].Value.ToString();
this.label20.Text = this.dataGridView2.CurrentRow.Cells[5].Value.ToString();
this.label21.Text = this.dataGridView2.CurrentRow.Cells[6].Value.ToString();
this.label22.Text = this.dataGridView2.CurrentRow.Cells[7].Value.ToString();
//点击textBox2时,使以下清空
this.textBox1.Text = "";
this.textBox3.Text = "";
this.textBox5.Text = "";
this.textBox6.Text = "";
//}
}
private void label13_Click(object sender, EventArgs e)
{
// xsDjID 销售单据编号
//xsID 销售序号
//spID as 商品编号
//jhDjID as 进货单据编号
//spSl as 商品数量
//spSjdj as 商品实际单价
//spZje as 商品总金额
//spSpXsJe as 实际商品销售金额
//beiZhu as 备注
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
label16.Text = "";
label17.Text = "";
label18.Text = "";
label19.Text = "";
label20.Text = "";
label21.Text = "";
label22.Text = "";
label27.Text = "";
label28.Text = "";
label29.Text = "";
label30.Text = "";
ds.Clear();
ds1.Clear();
}
private void label29_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (this.textBox2.Text != "")
{
da = new SqlDataAdapter("select xsDjID as 销售单据编号, xsID as 销售序号, spID as 商品编号, jhDjID as 进货单据编号, spSl as 商品数量, spSjdj as 商品实际单价, spZje as 商品总金额, spSpXsJe as 实际商品销售金额, beiZhu as 备注 from xsxqBiao where spID like '%" + this.textBox2.Text + "%'", myCon);
ds1.Clear();
da.Fill(ds1);
this.dataGridView2.DataSource = ds1.Tables[0];
//for (int u = 0; u < dataGridView2.Rows.Count - 1; u++)
//{
// this.textBox2.Text = dataGridView2.Rows[u].Cells[2].Value.ToString();
//}
}
else
{
MessageBox.Show("对不起!没有您要查询的数据!");
}
//this.textBox2.Text = "";
}
//private void button3_Click(object sender, EventArgs e)
//{
// da = new SqlDataAdapter("select * from xszBiao", myCon);
// da.Fill(ds1);
// this.dataGridView1.DataSource = ds.Tables[0];
//}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -