📄 frmstockorderform.cs
字号:
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.groupBox4);
this.groupBox2.Location = new System.Drawing.Point(0, 40);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(968, 224);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.dataGrid1);
this.groupBox4.Location = new System.Drawing.Point(0, 0);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(968, 224);
this.groupBox4.TabIndex = 0;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "订单(父)表";
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataView1;
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(3, 17);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(962, 204);
this.dataGrid1.TabIndex = 1;
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.dataGrid2);
this.groupBox3.Location = new System.Drawing.Point(0, 264);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(968, 160);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "明细(子)表";
//
// dataGrid2
//
this.dataGrid2.DataMember = "";
this.dataGrid2.DataSource = this.dataView2;
this.dataGrid2.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid2.Location = new System.Drawing.Point(3, 17);
this.dataGrid2.Name = "dataGrid2";
this.dataGrid2.ReadOnly = true;
this.dataGrid2.Size = new System.Drawing.Size(962, 140);
this.dataGrid2.TabIndex = 3;
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=WINDOWSXP;packet size=4096;user id=sa;data source=\".\";persist secu" +
"rity info=False;initial catalog=jxcbook";
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "采购订单历史", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("订单编号", "订单编号"),
new System.Data.Common.DataColumnMapping("订单号", "订单号"),
new System.Data.Common.DataColumnMapping("供货商号", "供货商号"),
new System.Data.Common.DataColumnMapping("订货日期", "订货日期"),
new System.Data.Common.DataColumnMapping("采购员", "采购员"),
new System.Data.Common.DataColumnMapping("制单人", "制单人"),
new System.Data.Common.DataColumnMapping("税价合计", "税价合计"),
new System.Data.Common.DataColumnMapping("不含税价", "不含税价"),
new System.Data.Common.DataColumnMapping("税额", "税额"),
new System.Data.Common.DataColumnMapping("票号", "票号")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 订单编号, 订单号, 供货商号, 订货日期, 采购员, 制单人, 税价合计, 不含税价, 税额, 票号 FROM 采购订单历史";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlDataAdapter2
//
this.sqlDataAdapter2.SelectCommand = this.sqlSelectCommand2;
this.sqlDataAdapter2.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "view_采购订单明细历史", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("订单编号", "订单编号"),
new System.Data.Common.DataColumnMapping("物料编号", "物料编号"),
new System.Data.Common.DataColumnMapping("品名", "品名"),
new System.Data.Common.DataColumnMapping("规格", "规格"),
new System.Data.Common.DataColumnMapping("单位", "单位"),
new System.Data.Common.DataColumnMapping("拼音编码", "拼音编码"),
new System.Data.Common.DataColumnMapping("订货数量", "订货数量"),
new System.Data.Common.DataColumnMapping("进价", "进价"),
new System.Data.Common.DataColumnMapping("税价合计", "税价合计"),
new System.Data.Common.DataColumnMapping("扣率", "扣率"),
new System.Data.Common.DataColumnMapping("税率", "税率"),
new System.Data.Common.DataColumnMapping("不含税价", "不含税价"),
new System.Data.Common.DataColumnMapping("税额", "税额")})});
//
// sqlSelectCommand2
//
this.sqlSelectCommand2.CommandText = "SELECT 订单编号, 物料编号, 品名, 规格, 单位, 拼音编码, 订货数量, 进价, 税价合计, 扣率, 税率, 不含税价, 税额 FROM view_采" +
"购订单明细历史";
this.sqlSelectCommand2.Connection = this.sqlConnection1;
//
// stockFormDS11
//
this.stockFormDS11.DataSetName = "StockFormDS1";
this.stockFormDS11.Locale = new System.Globalization.CultureInfo("en-US");
//
// dataView1
//
this.dataView1.Table = this.stockFormDS11.采购订单历史;
//
// dataView2
//
this.dataView2.Table = this.stockFormDS11.view_采购订单明细历史;
//
// FrmStockOrderForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(968, 430);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "FrmStockOrderForm";
this.Text = "采购订单明细查询";
this.Load += new System.EventHandler(this.FrmStockOrderForm_Load);
this.Closed += new System.EventHandler(this.FrmStockOrderForm_Closed);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.stockFormDS11)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataView2)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void FrmStockOrderForm_Load(object sender, System.EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
//填充数据集
sqlDataAdapter1.Fill(stockFormDS11);
sqlDataAdapter2.Fill(stockFormDS11);
//显示时,首先显示第一个采购订单的明细
dataView2.RowFilter="订单编号='"+dataGrid1[0,0].ToString().Trim()+"'";
//明细数据根据选择的采购订单编号而变化
dataGrid1.CurrentCellChanged+=new EventHandler(dataGrid1_CurrentCellChanged);
}
catch(Exception Err)
{
MessageBox.Show("查询数据集记录为空:"+Err.Message,"信息提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
this.Cursor = Cursors.Default;
}
}
//-------------显示采购订单历史明细明细----------------
private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
{
int i=dataGrid1.CurrentRowIndex;
dataView2.RowFilter="订单编号='"+dataGrid1[i,0].ToString().Trim()+"'";
}
private void FrmStockOrderForm_Closed(object sender, System.EventArgs e)
{
if(this.sqlConnection1.State==ConnectionState.Open)
{
this.sqlConnection1.Close();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
string filter="";
if(textBox2.Text.Trim()!="")
{
filter+="订单号 like '"+textBox2.Text.Trim()+"%' AND ";
}
if(textBox1.Text.Trim()!="")
{
filter+="供货商号 like '"+textBox1.Text.Trim()+"%' AND ";
}
if(textBox3.Text.Trim()!="")
{
filter+="票号 like '"+textBox3.Text.Trim()+"%' AND ";
}
if(textBox4.Text.Trim()!="")
{
filter+="订货日期 like '"+textBox4.Text.Trim()+"%' AND ";
}
if(textBox5.Text.Trim()!="")
{
filter+="采购员 like '"+textBox5.Text.Trim()+"%' AND ";
}
int length=filter.Length;
if(length>0)
{
filter=filter.Substring(0,length-5);
}
dataView1.RowFilter=filter;
if(dataView1.Count>0)//有确定的订单数据再显示明细
{
dataView2.RowFilter="订单编号='"+dataGrid1[0,0].ToString().Trim()+"'";
}
}
catch(Exception Err)
{
MessageBox.Show("查询数据集记录操作失败:"+Err.Message,"信息提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
this.Cursor = Cursors.Default;
this.sqlConnection1.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -