📄 wupinxiaofei.h
字号:
int m=row2->Item[0]->ToString()->ToInt32(0);
m++;
this->textBox11->Text=m.ToString();
String *SQUANTITY=this->textBox11->Text->Trim()->ToString();
oleDbUpdateCommand1->CommandText=String::Concat(S"update 出售表 set ",S"SQUANTITY='",SQUANTITY,S"'",S" where SID='",WID,S"'" );
oleDbSelectCommand1->CommandText=String::Concat(S"select SID as 物品ID,SNAME as 名称, SMODEL as 型号,SPRODUCER as 生产商,SSELLPRICE as 出售价格,SQUANTITY as 数量,SDATE as 日期,YID as 销售员ID,SWNAME as 销售员姓名 from 出售表 ");
oleDbConnection1->Open();
oleDbUpdateCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table3=new DataTable();
oleDbDataAdapter1->Fill(table3);
this->dataGrid1->DataSource=table3;
oleDbSelectCommand1->CommandText=String::Concat(S"select SID,SNAME,SMODEL,SSELLPRICE,SQUANTITY,SPRODUCER from 出售表 where ",S"SID='",WID,S"'" );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table16=new DataTable();
oleDbDataAdapter1->Fill(table16);
this->dataGrid2->DataSource=table16;
int nindex2=dataGrid2->CurrentRowIndex;
DataTable *table17=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row3=table17->Rows->Item[nindex2];
this->textBox2->Text=row3->Item[1]->ToString();
this->textBox3->Text=row3->Item[2]->ToString();
this->textBox4->Text=row3->Item[3]->ToString();
this->textBox5->Text=row3->Item[4]->ToString();
this->textBox6->Text=row3->Item[5]->ToString();
int sum=0;
oleDbSelectCommand1->CommandText=String::Concat(S"select * from 出售表 " );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table8=new DataTable();
oleDbDataAdapter1->Fill(table8);
this->dataGrid1->DataSource=table8;
int nindex4=dataGrid1->CurrentRowIndex;
if(nindex4<0) this->textBox7->Text="0";
else{ DataTable *table20=__try_cast<DataTable*>(dataGrid1->DataSource);
for(nindex4=0;nindex4<i;nindex4++)
{
DataRow * row4=table20->Rows->Item[nindex4];
int shuliang=row4->Item[5]->ToString()->ToInt32(0);
int jiage=row4->Item[4]->ToString()->ToInt32(0);
sum=shuliang*jiage+sum;
}
this->textBox7->Text=sum.ToString();
}
}
}
else{
DataTable *table4=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row1=table4->Rows->Item[nindex1];
String *SID=row1->Item[0]->ToString();
String *SNAME=row1->Item[1]->ToString();
String *SMODEL=row1->Item[2]->ToString();
String *SPRODUCER=row1->Item[3]->ToString();
String *SSELLPRICE=row1->Item[4]->ToString();
DateTime dtime=System::DateTime::Now;;
String *SDATE=dtime.ToShortDateString();
String *SQUANTITY="1";
oleDbDeleteCommand1->CommandText=String::Concat(S"delete from 出售表 ");
oleDbConnection1->Open();
oleDbDeleteCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
oleDbInsertCommand1->CommandText=String::Concat(S"insert into 出售表 (", S"SID,SNAME,SMODEL,SPRODUCER,SSELLPRICE,SQUANTITY,SWNAME,SDATE,YID) values ('", SID,S"','",SNAME,S"','",SMODEL,S"','",SPRODUCER,S"','",SSELLPRICE,S"','",SQUANTITY,S"','",YNAME,S"','",SDATE,S"','",YID,S"')" );
oleDbSelectCommand1->CommandText=String::Concat(S"select SID as 物品ID,SNAME as 名称, SMODEL as 型号,SPRODUCER as 生产商,SSELLPRICE as 出售价格,SQUANTITY as 数量,SDATE as 日期,YID as 销售员ID,SWNAME as 销售员姓名 from 出售表 ");
oleDbConnection1->Open();
oleDbInsertCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table5=new DataTable();
oleDbDataAdapter1->Fill(table5);
this->dataGrid1->DataSource=table5;
oleDbSelectCommand1->CommandText=String::Concat(S"select SID,SNAME,SMODEL,SSELLPRICE,SQUANTITY,SPRODUCER from 出售表 where ",S"SID='",WID,S"'" );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table6=new DataTable();
oleDbDataAdapter1->Fill(table6);
this->dataGrid2->DataSource=table6;
int nindex2=dataGrid2->CurrentRowIndex;
DataTable *table7=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row2=table7->Rows->Item[nindex2];
this->textBox2->Text=row2->Item[1]->ToString();
this->textBox3->Text=row2->Item[2]->ToString();
this->textBox4->Text=row2->Item[3]->ToString();
this->textBox5->Text=row2->Item[4]->ToString();
this->textBox6->Text=row2->Item[5]->ToString();
i++;
this->textBox10->Text=i.ToString();
int sum=0;
oleDbSelectCommand1->CommandText=String::Concat(S"select * from 出售表 " );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table8=new DataTable();
oleDbDataAdapter1->Fill(table8);
this->dataGrid1->DataSource=table8;
int nindex3=dataGrid1->CurrentRowIndex;
if(nindex3<0) this->textBox7->Text="0";
else{ DataTable *table20=__try_cast<DataTable*>(dataGrid1->DataSource);
for(nindex3=0;nindex3<i;nindex3++)
{
DataRow * row4=table20->Rows->Item[nindex3];
int shuliang=row4->Item[5]->ToString()->ToInt32(0);
int jiage=row4->Item[4]->ToString()->ToInt32(0);
sum=shuliang*jiage+sum;
}
this->textBox7->Text=sum.ToString();
this->textBox8->Text="0";
this->textBox9->Text="0";
}
}
}
}
private: System::Void dataGrid1_CurrentCellChanged(System::Object * sender, System::EventArgs * e)
{int nindex=dataGrid1->CurrentRowIndex;
if(nindex<0)
{this->textBox1->Text=S"";
this->textBox2->Text=S"";
this->textBox3->Text=S"";
this->textBox4->Text=S"";
this->textBox5->Text=S"";
this->textBox6->Text=S"";
return;
}
DataTable *table2=__try_cast<DataTable*>(dataGrid1->DataSource);
DataRow * row=table2->Rows->Item[nindex];
this->textBox1->Text=row->Item[0]->ToString();
this->textBox2->Text=row->Item[1]->ToString();
this->textBox3->Text=row->Item[2]->ToString();
this->textBox4->Text=row->Item[4]->ToString();
this->textBox5->Text=row->Item[5]->ToString();
this->textBox6->Text=row->Item[3]->ToString();
}
private: System::Void button2_Click(System::Object * sender, System::EventArgs * e)
{ int i=this->textBox10->Text->Trim()->ToInt32(0);
if(i==0) MessageBox::Show("操作错误");
else{
int sum=0;
String *WID=this->textBox1->Text->Trim();
oleDbDeleteCommand1->CommandText=String::Concat(S"delete from 出售表 where ",S"SID='",WID,S"'");
oleDbConnection1->Open();
oleDbDeleteCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
i--;
this->textBox10->Text=i.ToString();
oleDbSelectCommand1->CommandText=String::Concat(S"select * from 出售表 " );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table8=new DataTable();
oleDbDataAdapter1->Fill(table8);
this->dataGrid1->DataSource=table8;
int nindex3=dataGrid1->CurrentRowIndex;
if(nindex3<0) this->textBox7->Text="0";
else{ DataTable *table20=__try_cast<DataTable*>(dataGrid1->DataSource);
for(nindex3=0;nindex3<i;nindex3++)
{
DataRow * row4=table20->Rows->Item[nindex3];
int shuliang=row4->Item[5]->ToString()->ToInt32(0);
int jiage=row4->Item[4]->ToString()->ToInt32(0);
sum=shuliang*jiage+sum;
}
this->textBox7->Text=sum.ToString();
}
}
}
private: System::Void button5_Click(System::Object * sender, System::EventArgs * e)
{ int i=this->textBox10->Text->Trim()->ToInt32(0);
if(i==0) MessageBox::Show("错误操作");
else{
int zongji=this->textBox7->Text->Trim()->ToString()->ToInt32(0);
int shishou=this->textBox8->Text->Trim()->ToString()->ToInt32(0);
if(zongji<=shishou){
int zhaoling=shishou-zongji;
this->textBox9->Text=zhaoling.ToString();
oleDbSelectCommand1->CommandText=String::Concat(S"select * from 出售表 " );
oleDbConnection1->Open();
oleDbSelectCommand1->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table1=new DataTable();
oleDbDataAdapter1->Fill(table1);
this->dataGrid1->DataSource=table1;
int nindex=dataGrid1->CurrentRowIndex;
DataTable *table2=__try_cast<DataTable*>(dataGrid1->DataSource);
for(nindex=0;nindex<i;nindex++)
{
DataRow * row=table2->Rows->Item[nindex];
String *SID=row->Item[0]->ToString();
String *SNAME=row->Item[1]->ToString();
String *SMODEL=row->Item[2]->ToString();
String *SPRODUCER=row->Item[3]->ToString();
String *SSELLPRICE=row->Item[4]->ToString();
String *SQUANTITY=row->Item[5]->ToString();
String *SWNAME=row->Item[6]->ToString();
String *SDATE=row->Item[7]->ToString();
String *YID=row->Item[8]->ToString();
int xiaofei=row->Item[5]->ToString()->ToInt32(0);
oleDbInsertCommand4->CommandText=String::Concat(S"insert into 消费表 (", S"SID,SNAME,SMODEL,SPRODUCER,SSELLPRICE,SQUANTITY,SWNAME,SDATE,YID) values ('", SID, S"','",SNAME,S"','",SMODEL,S"','",SPRODUCER,S"','",SSELLPRICE,S"','",SQUANTITY,S"','",SWNAME,S"','",SDATE,S"','",YID,S"')" );
oleDbConnection1->Open();
oleDbInsertCommand4->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table10=new DataTable();
oleDbDataAdapter4->Fill(table10);
oleDbSelectCommand3->CommandText=String::Concat(S"select * from 物品表 where ",S"WID='",SID,S"'");
oleDbConnection1->Open();
oleDbSelectCommand3->ExecuteNonQuery();
oleDbConnection1->Close();
DataTable *table31=new DataTable();
oleDbDataAdapter3->Fill(table31);
this->dataGrid2->DataSource=table31;
int nindex6=dataGrid2->CurrentRowIndex;
DataTable *table32=__try_cast<DataTable*>(dataGrid2->DataSource);
DataRow * row16=table32->Rows->Item[nindex6];
int wupin=row16->Item[6]->ToString()->ToInt32(0);
int gengxin=wupin-xiaofei;
String *SQUANTITY1=gengxin.ToString();
oleDbUpdateCommand3->CommandText=String::Concat(S"update 物品表 set ",S"STOCK='",SQUANTITY1,S"'",S" where WID='",SID,S"'" );
oleDbConnection1->Open();
oleDbUpdateCommand3->ExecuteNonQuery();
oleDbConnection1->Close();
}
this->textBox10->Text="0";
}
else{ MessageBox::Show("靠,老师没教数学啊");}
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -