110,561
社区成员
发帖
与我相关
我的任务
分享
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[producttmtab]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[producttmtab]
GO
CREATE TABLE [dbo].[producttmtab] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[th] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[spec] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[model] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[amount] [decimal](38, 0) NULL ,
[grade] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
private void button1_Click(object sender, EventArgs e)
{
reportViewer1.Reset();
if (checkBox1.Checked == false)
this.reportViewer1.LocalReport.ReportEmbeddedResource = "news.Report1.rdlc";
else
this.reportViewer1.LocalReport.ReportEmbeddedResource = "news.Report2.rdlc";
if (textBox1.Text == "" || textBox2.Text == "" || textBox1.Text.Length != 8 || textBox2.Text.Length != 8)
return;
th1 = textBox1.Text.Trim();
th2 = textBox2.Text.Trim();
string cmds = "exec update_temp_bc2 '" + th1 + "','" + th2 + "'";
SqlCommand cmd = new SqlCommand(cmds, con);
string cmds1 = "select * from temp_bc2";
string cmds2 = "select * from temp_th2";
SqlCommand cmd1 = new SqlCommand(cmds1, con);
SqlCommand cmd2 = new SqlCommand(cmds2, con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
if (con.State != ConnectionState.Open)
con.Open();
cmd.ExecuteNonQuery();
tmDS tmDS1 = new tmDS();
tmDS1.Clear();
da1.Fill(tmDS1.temp_bc2);
da2.Fill(tmDS1.temp_th2);
con.Close();
//下面代码就是复制出来的
////////////////////////////////////////
ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
ReportDataSource reportDataSource2 = new Microsoft.Reporting.WinForms.ReportDataSource();
this.temp_bc2BindingSource = new System.Windows.Forms.BindingSource(this.components);
this.temp_th2BindingSource = new System.Windows.Forms.BindingSource(this.components);
//((System.ComponentModel.ISupportInitialize)(this.temp_bc2BindingSource)).BeginInit();
//((System.ComponentModel.ISupportInitialize)(this.tmDS)).BeginInit();
//((System.ComponentModel.ISupportInitialize)(this.temp_th2BindingSource)).BeginInit();
this.temp_bc2BindingSource.DataMember = "temp_bc2";
this.temp_bc2BindingSource.DataSource = tmDS1;
//
// tmDS
//
tmDS1.DataSetName = "tmDS1";
tmDS1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// temp_th2BindingSource
//
this.temp_th2BindingSource.DataMember = "temp_th2";
this.temp_th2BindingSource.DataSource = tmDS1;
reportDataSource1.Name = "tmDS_temp_bc2";
reportDataSource1.Value = this.temp_bc2BindingSource;
reportDataSource2.Name = "tmDS_temp_th2";
reportDataSource2.Value = this.temp_th2BindingSource;
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource2);
////////////////////////////////////////////////////////////////////////////////
this.reportViewer1.RefreshReport();
}
private void Form1_Load(object sender, EventArgs e)
{
string datastr = GetRegistData("datastr");
string ServerName = GetRegistData("ServerName");
string str = "Server =" + ServerName + ";User id =wlms;Pwd=mymsserver;" + "Database = " + datastr;
con = new SqlConnection(str);
}
select opwork 班别,Model 定量,spec 型号,grade 等品,count(amount) 数量,sum(amount) 重量,
case opwork
when '早班' then 1
when '中班' then 2
when '晚班' then 3
end orderby
from P_ProductTMTab
where grade<>'等外品'
group by opwork,Model,spec,grade
--order by orderby,Model,spec