📄 xiaoshoutongji.h
字号:
this->button1->Click += new System::EventHandler(this, button1_Click);
//
// label4
//
this->label4->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label4->Location = System::Drawing::Point(184, 56);
this->label4->Name = S"label4";
this->label4->Size = System::Drawing::Size(56, 23);
this->label4->TabIndex = 50;
this->label4->Text = S"时间:";
this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// label3
//
this->label3->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label3->Location = System::Drawing::Point(272, 55);
this->label3->Name = S"label3";
this->label3->Size = System::Drawing::Size(56, 23);
this->label3->TabIndex = 49;
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(88, 56);
this->textBox1->Name = S"textBox1";
this->textBox1->Size = System::Drawing::Size(104, 21);
this->textBox1->TabIndex = 48;
this->textBox1->Text = S"";
//
// label2
//
this->label2->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label2->Location = System::Drawing::Point(24, 55);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing::Size(64, 23);
this->label2->TabIndex = 47;
this->label2->Text = S"用户ID:";
this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// oleDbDataAdapter1
//
this->oleDbDataAdapter1->InsertCommand = this->oleDbInsertCommand1;
this->oleDbDataAdapter1->SelectCommand = this->oleDbSelectCommand1;
System::Data::Common::DataTableMapping* __mcTemp__1[] = new System::Data::Common::DataTableMapping*[1];
System::Data::Common::DataColumnMapping* __mcTemp__2[] = new System::Data::Common::DataColumnMapping*[9];
__mcTemp__2[0] = new System::Data::Common::DataColumnMapping(S"SID", S"SID");
__mcTemp__2[1] = new System::Data::Common::DataColumnMapping(S"SNAME", S"SNAME");
__mcTemp__2[2] = new System::Data::Common::DataColumnMapping(S"SMODEL", S"SMODEL");
__mcTemp__2[3] = new System::Data::Common::DataColumnMapping(S"SPRODUCER", S"SPRODUCER");
__mcTemp__2[4] = new System::Data::Common::DataColumnMapping(S"SSELLPRICE", S"SSELLPRICE");
__mcTemp__2[5] = new System::Data::Common::DataColumnMapping(S"SQUANTITY", S"SQUANTITY");
__mcTemp__2[6] = new System::Data::Common::DataColumnMapping(S"SWNAME", S"SWNAME");
__mcTemp__2[7] = new System::Data::Common::DataColumnMapping(S"SDATE", S"SDATE");
__mcTemp__2[8] = new System::Data::Common::DataColumnMapping(S"YID", S"YID");
__mcTemp__1[0] = new System::Data::Common::DataTableMapping(S"Table", S"消费表", __mcTemp__2);
this->oleDbDataAdapter1->TableMappings->AddRange(__mcTemp__1);
//
// dataGrid2
//
this->dataGrid2->DataMember = S"";
this->dataGrid2->HeaderForeColor = System::Drawing::SystemColors::ControlText;
this->dataGrid2->Location = System::Drawing::Point(344, 192);
this->dataGrid2->Name = S"dataGrid2";
this->dataGrid2->TabIndex = 63;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(576, 56);
this->textBox4->Name = S"textBox4";
this->textBox4->Size = System::Drawing::Size(80, 21);
this->textBox4->TabIndex = 64;
this->textBox4->Text = S"";
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(496, 128);
this->textBox5->Name = S"textBox5";
this->textBox5->Size = System::Drawing::Size(88, 21);
this->textBox5->TabIndex = 65;
this->textBox5->Text = S"";
//
// label1
//
this->label1->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label1->Location = System::Drawing::Point(664, 56);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing::Size(24, 23);
this->label1->TabIndex = 66;
this->label1->Text = S"元";
this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// label10
//
this->label10->Font = new System::Drawing::Font(S"宋体", 10.5F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)134);
this->label10->Location = System::Drawing::Point(592, 128);
this->label10->Name = S"label10";
this->label10->Size = System::Drawing::Size(24, 23);
this->label10->TabIndex = 67;
this->label10->Text = S"元";
this->label10->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
//
// xiaoshoutongji
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(688, 478);
this->Controls->Add(this->label10);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button3);
this->Controls->Add(this->label7);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label6);
this->Controls->Add(this->label9);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->dataGrid1);
this->Controls->Add(this->label5);
this->Controls->Add(this->button1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label8);
this->Controls->Add(this->button4);
this->Controls->Add(this->dataGrid2);
this->Name = S"xiaoshoutongji";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = S"销售统计";
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataGrid1))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dataGrid2))->EndInit();
this->ResumeLayout(false);
}
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{String *YID=this->textBox1->Text->Trim();
String *SDATE=this->textBox2->Text->Trim();
oleDbSelectCommand1->CommandText=String::Concat(S"select SID as 物品ID,SNAME as 名称,SMODEL as 型号,SPRODUCER as 生产商,SSELLPRICE as 出售价格 ,SQUANTITY as 销售数量,YID as 用户ID,SWNAME as 出售人员,SDATE as 日期 from 消费表 where ",S"YID='",YID,S"'and SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
}
private: System::Void button3_Click(System::Object * sender, System::EventArgs * e)
{ if(this->textBox1->Text->CompareTo("")==0||this->textBox2->Text->CompareTo("")==0) MessageBox::Show("搜索信息错误");
else{
String *YID=this->textBox1->Text->Trim();
String *SDATE=this->textBox2->Text->Trim();
oleDbSelectCommand1->CommandText=String::Concat(S"select count(*) from 消费表 where ",S"YID='",YID,S"'and SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid2->DataSource=table1;
int nindex=dataGrid2->CurrentRowIndex;
if(nindex<0) MessageBox::Show("没有出售记录");
else{
DataTable *table2=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row=table2->Rows->Item[nindex];
int i=row->Item[0]->ToString()->ToInt32(0);
int sum=0;
oleDbSelectCommand1->CommandText=String::Concat(S"select SSELLPRICE,SQUANTITY from 消费表 where ",S"YID='",YID,S"'and SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table3=new DataTable();
oleDbDataAdapter1->Fill(table3);
this->dataGrid2->DataSource=table3;
int nindex1=dataGrid2->CurrentRowIndex;
DataTable *table4=__try_cast<DataTable*>(dataGrid2->DataSource);
for(nindex1=0;nindex1<i;nindex1++)
{DataRow * row=table4->Rows->Item[nindex1];
int jige=row->Item[0]->ToString()->ToInt32(0);
int shuliang=row->Item[1]->ToString()->ToInt32(0);
int zongji=jige*shuliang;
sum=sum+zongji;
}
this->textBox4->Text=sum.ToString();
}
}
}
private: System::Void button2_Click(System::Object * sender, System::EventArgs * e)
{
String *SDATE=this->textBox3->Text->Trim();
oleDbSelectCommand1->CommandText=String::Concat(S"select SID as 物品ID,SNAME as 名称,SMODEL as 型号,SPRODUCER as 生产商,SSELLPRICE as 出售价格 ,SQUANTITY as 销售数量,YID as 用户ID,SWNAME as 出售人员,SDATE as 日期 from 消费表 where ",S"SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
}
private: System::Void button4_Click(System::Object * sender, System::EventArgs * e)
{ if(this->textBox3->Text->CompareTo("")==0) MessageBox::Show("搜索信息错误");
else{
String *SDATE=this->textBox3->Text->Trim();
oleDbSelectCommand1->CommandText=String::Concat(S"select count(*) from 消费表 where ",S"SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid2->DataSource=table1;
int nindex=dataGrid2->CurrentRowIndex;
if(nindex<0) MessageBox::Show("没有出售记录");
else{
DataTable *table2=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row=table2->Rows->Item[nindex];
int i=row->Item[0]->ToString()->ToInt32(0);
int sum=0;
oleDbSelectCommand1->CommandText=String::Concat(S"select SSELLPRICE,SQUANTITY from 消费表 where ",S"SDATE='",SDATE,S"'");
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table3=new DataTable();
oleDbDataAdapter1->Fill(table3);
this->dataGrid2->DataSource=table3;
int nindex1=dataGrid2->CurrentRowIndex;
DataTable *table4=__try_cast<DataTable*>(dataGrid2->DataSource);
for(nindex1=0;nindex1<i;nindex1++)
{DataRow * row=table4->Rows->Item[nindex1];
int jige=row->Item[0]->ToString()->ToInt32(0);
int shuliang=row->Item[1]->ToString()->ToInt32(0);
int zongji=jige*shuliang;
sum=sum+zongji;
}
this->textBox5->Text=sum.ToString();
}
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -