📄 bjgl.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ShFwMain.h"
#include "BjGl.h"
#include "kcqd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ColorButton"
#pragma resource "*.dfm"
TBjGlForm *BjGlForm;
//---------------------------------------------------------------------------
__fastcall TBjGlForm::TBjGlForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::FormClose(TObject *Sender, TCloseAction &Action)
{
MainForm->ADOConnection1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::FormCreate(TObject *Sender)
{
MainForm->ADOConnection1->Open();
Button1->Enabled = false;
ADOQuery1->Close();
ADOQuery2->Close();
ADOTable1->Close();
ADOTable1->Open();
if(ADOTable1->RecordCount > 0) {
DBLookupComboBox1->KeyValue = ADOTable1->FieldByName("flbh")->AsString;
ADOQuery2->Open();
if(ADOQuery2->RecordCount > 0) {
DBLookupComboBox2->KeyValue = ADOQuery2->FieldByName("pzbh")->AsString;
ADOQuery1->Open();
}
}
RadioButton1->Checked = true;
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::DBLookupComboBox1Click(TObject *Sender)
{
ADOQuery1->Close();
ADOQuery2->Close();
if(DBLookupComboBox1->Text.Trim()=="")
Abort();
ADOQuery2->Open();
if(ADOQuery2->RecordCount > 0) {
DBLookupComboBox2->KeyValue = ADOQuery2->FieldByName("pzbh")->AsString;
ADOQuery1->Open();
}
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::Button1Click(TObject *Sender)
{
AnsiString str;
if(MaskEdit1->Text.Trim() == "" || MaskEdit1->Text.ToInt() < 1 ) {
Application->MessageBox("请输入数量","错误",MB_OK+MB_ICONERROR);
Abort();
}
if(RadioButton1->Checked == true) {
str = "当前库存数量为"+ADOQuery1->FieldByName("kcsl")->AsString+",增加"+MaskEdit1->Text.Trim()+"吗?";
if( Application->MessageBox(str.c_str(),"确认",MB_OKCANCEL+MB_ICONERROR)!=IDOK)
Abort();
ADOQuery1->Edit();
ADOQuery1->FieldByName("kcsl")->Value = ADOQuery1->FieldByName("kcsl")->AsString.ToInt() + MaskEdit1->Text.ToInt();
ADOQuery1->Post();
} else {
str = "当前库存数量为"+ADOQuery1->FieldByName("kcsl")->AsString+",冲销"+MaskEdit1->Text.Trim()+"吗?";
if( Application->MessageBox(str.c_str(),"确认",MB_OKCANCEL+MB_ICONERROR)!=IDOK)
Abort();
if(ADOQuery1->FieldByName("kcsl")->AsString.ToInt() - MaskEdit1->Text.ToInt() < 0) {
Application->MessageBox("库存数量不足","错误",MB_OK+MB_ICONERROR);
Abort();
}
ADOQuery1->Edit();
ADOQuery1->FieldByName("kcsl")->Value = ADOQuery1->FieldByName("kcsl")->AsString.ToInt() - MaskEdit1->Text.ToInt();
ADOQuery1->Post();
}
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::ADOQuery1AfterPost(TDataSet *DataSet)
{
AnsiString sql,lx;
ADOQuerytmp->Close();
ADOQuerytmp->SQL->Clear();
lx = RadioButton1->Checked == true ? "入库":"冲销";
sql = "insert into wxpjxx values(:P_dabh,:P_khbh,:P_rybh,:P_clrm,:P_pjbh,:P_pjmc,:P_gsfl,:P_flmc,:P_gspz,:P_pzmc,";
sql += ":P_lx,:P_dj,:P_sl,:P_je,:P_clrq,:P_slrq,:P_cllx,:P_bz,:P_endflag,:P_sjsl,:P_cbdj,:P_lsdj)";
ADOQuerytmp->SQL->Add(sql);
ADOQuerytmp->Parameters->ParamByName("P_dabh")->Value = 0;
ADOQuerytmp->Parameters->ParamByName("P_khbh")->Value = 0;
ADOQuerytmp->Parameters->ParamByName("P_rybh")->Value = MainForm->MyLoginBh;
ADOQuerytmp->Parameters->ParamByName("P_clrm")->Value = MainForm->MyLoginName;
ADOQuerytmp->Parameters->ParamByName("P_pjbh")->Value = ADOQuery1->FieldByName("pjbh")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_pjmc")->Value = ADOQuery1->FieldByName("mc")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_gsfl")->Value = ADOQuery1->FieldByName("flbh")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_flmc")->Value = DBLookupComboBox1->Text;
ADOQuerytmp->Parameters->ParamByName("P_gspz")->Value = ADOQuery1->FieldByName("pzbh")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_pzmc")->Value = DBLookupComboBox2->Text;
ADOQuerytmp->Parameters->ParamByName("P_lx")->Value = "保修";
ADOQuerytmp->Parameters->ParamByName("P_dj")->Value = ADOQuery1->FieldByName("bxdj")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_sl")->Value = MaskEdit1->Text;
ADOQuerytmp->Parameters->ParamByName("P_je")->Value = MaskEdit1->Text.ToInt() * ADOQuery1->FieldByName("bxdj")->AsFloat;
ADOQuerytmp->Parameters->ParamByName("P_clrq")->Value = Date();
ADOQuerytmp->Parameters->ParamByName("P_slrq")->Value = Date();
ADOQuerytmp->Parameters->ParamByName("P_cllx")->Value = lx;
ADOQuerytmp->Parameters->ParamByName("P_bz")->Value = Edit1->Text;
ADOQuerytmp->Parameters->ParamByName("P_sjsl")->Value = 0;
ADOQuerytmp->Parameters->ParamByName("P_endflag")->Value = "是";
ADOQuerytmp->Parameters->ParamByName("P_cbdj")->Value = ADOQuery1->FieldByName("bxdj")->AsString;
ADOQuerytmp->Parameters->ParamByName("P_lsdj")->Value = ADOQuery1->FieldByName("lsdj")->AsString;
ADOQuerytmp->ExecSQL();
MaskEdit1->Text ="";
Edit1->Text ="";
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::Button3Click(TObject *Sender)
{
AnsiString sql;
ADOQuerytmp->Close();
ADOQuerytmp->SQL->Clear();
switch(RadioGroup1->ItemIndex) {
case 0:
if( DBLookupComboBox1->Text.Trim()=="" ) {
Application->MessageBox("请确定分类","错误",MB_OK+MB_ICONERROR);
Abort();
}
sql = "select flxx.flmc,pjpzxx.mc,pjkc.* from pjkc,flxx,pjpzxx where flxx.flbh=pjpzxx.flbh and pjpzxx.flbh=pjkc.flbh and pjkc.pzbh=pjpzxx.pzbh ";
sql += " and pjkc.flbh='"+ DBLookupComboBox1->KeyValue+"' order by pjkc.pzbh,pjkc.pjbh";
ADOQuerytmp->SQL->Add(sql);
ADOQuerytmp->Open();
break;
case 1:
if( DBLookupComboBox1->Text.Trim()=="" ) {
Application->MessageBox("请确定分类","错误",MB_OK+MB_ICONERROR);
Abort();
}
if( DBLookupComboBox2->Text.Trim()=="" ) {
Application->MessageBox("请确定种类","错误",MB_OK+MB_ICONERROR);
Abort();
}
sql = "select flxx.flmc,pjpzxx.mc,pjkc.* from pjkc,flxx,pjpzxx where flxx.flbh=pjpzxx.flbh and pjpzxx.flbh=pjkc.flbh and pjkc.pzbh=pjpzxx.pzbh ";
sql += " and pjkc.flbh='"+ DBLookupComboBox1->KeyValue+"' and pjkc.pzbh='"+DBLookupComboBox2->KeyValue+"' order by pjkc.pjbh";
ADOQuerytmp->SQL->Add(sql);
ADOQuerytmp->Open();
break;
case 2:
sql = "select flxx.flmc,pjpzxx.mc,pjkc.* from pjkc,flxx,pjpzxx where flxx.flbh=pjpzxx.flbh and pjpzxx.flbh=pjkc.flbh and pjkc.pzbh=pjpzxx.pzbh order by pjkc.flbh,pjkc.pzbh,pjkc.pjbh";
ADOQuerytmp->SQL->Add(sql);
ADOQuerytmp->Open();
break;
}
if(ADOQuerytmp->RecordCount < 1 ) {
ADOQuerytmp->Close();
Application->MessageBox("没有符合条件的记录可打印","错误",MB_OK+MB_ICONERROR);
return;
}
TKcQdForm *KcQdForm;
try
{
KcQdForm = new TKcQdForm(Application);
KcQdForm->QuickRep1->Preview();
delete KcQdForm;
}
catch(...)
{
delete KcQdForm;
Application->MessageBox("运行出现错误!","警告",MB_OK+MB_ICONWARNING);
}
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::DBLookupComboBox2Click(TObject *Sender)
{
if( DBLookupComboBox1->Text.Trim()=="")
Abort();
if( DBLookupComboBox2->Text.Trim()=="")
Abort();
ADOQuery1->Close();
ADOQuery1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TBjGlForm::DataSource4StateChange(TObject *Sender)
{
if(ADOQuery1->State == dsBrowse ) {
if(ADOQuery1->RecordCount > 0)
Button1->Enabled = true;
else
Button1->Enabled = false;
} else
Button1->Enabled = false;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -