📄 fdjsd.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "fdJSD.h"
#include "DataModule.h"
#include "login.h"
//#include "report.h"
#include "CuToCNum.cpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfdJSForm *fdJSForm;
//---------------------------------------------------------------------------
__fastcall TfdJSForm::TfdJSForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfdJSForm::CheckListBox1Click(TObject *Sender)
{
AnsiString str;
sum=0.0;
for(int i=0;i<CheckListBox1->Items->Count;i++)
if(CheckListBox1->Checked[i]){
str=CheckListBox1->Items->Text;
str=str.SubString(15,str.Length()-14);
sum+=str.Trim().ToDouble();
}
if(sum==0)
{
postBtn->Enabled=false;
printBtn->Enabled=false;
}else{
postBtn->Enabled=true;
printBtn->Enabled=true;
if(sum<0){
Label4->Caption="付款单";
Label5->Caption="今付给";
}else{
Label4->Caption="收款单";
Label5->Caption="今收到";
}
}
Money->Text=sum;
}
//---------------------------------------------------------------------------
void __fastcall TfdJSForm::postBtnClick(TObject *Sender)
{
postBtn->Enabled=false;
DM->ADOQ->Close();
DM->ADOQ->SQL->Clear();
DM->ADOQ->SQL->Add("select * from 结算清单表");
DM->ADOQ->Open();
int sum;
if(DM->ADOQ->RecordCount==0)
sum=1610000001;
else{
DM->ADOQ->Last();
sum=DM->ADOQ->FieldByName("编号")->AsInteger+1;
}
DM->ADOQ->Insert();
DM->ADOQ->FieldByName("编号")->AsInteger=sum;
if(sum<0){
DM->ADOQ->FieldByName("收支类型")->Value="应付";
}else{
DM->ADOQ->FieldByName("收支类型")->Value="应收";
}
DM->ADOQ->FieldByName("客户名称")->Value=KHname->Text;
DM->ADOQ->FieldByName("人民币")->Value=Money->Text;
DM->ADOQ->FieldByName("备注")->Value=BZ->Text;
DM->ADOQ->Post();
for(int i=0;i<CheckListBox1->Items->Count;i++)
if(CheckListBox1->Checked[i]){
AnsiString str=CheckListBox1->Items->Text;
str=str.SubString(1,10);
//int n=str.ToInt();
DM->ADOQ->Close();
DM->ADOQ->SQL->Clear();
str="select * from 应收应付明细表 where 单号='"+str;
str+="'";
DM->ADOQ->SQL->Add(str);
DM->ADOQ->Open();
DM->ADOQ->Edit();
DM->ADOQ->FieldByName("结算单号")->Value=sum;
DM->ADOQ->Post();
}
DM->ADOQ->Close();
DM->ADOQ->SQL->Clear();
DM->ADOQ->SQL->Add("select * from 应收应付明细表");
DM->ADOQ->Open();
DM->ADOQ->Insert();
DM->ADOQ->FieldByName("时间")->Value=Now().CurrentDateTime().DateTimeString();
DM->ADOQ->FieldByName("单号")->Value=sum;
DM->ADOQ->FieldByName("事务")->Value="分单结算";
DM->ADOQ->FieldByName("结余金额")->Value=0;
DM->ADOQ->FieldByName("结算人")->Value=LoginForm->Edituser->Text;
DM->ADOQ->FieldByName("结算金额")->Value=Money->Text;
DM->ADOQ->FieldByName("备注")->Value=BZ->Text;
DM->ADOQ->FieldByName("挂帐方式")->Value="现金";
DM->ADOQ->FieldByName("结算单号")->Value=sum;
DM->ADOQ->FieldByName("客户名称")->Value=KHname->Text;
DM->ADOQ->Post();
DM->ADOQ->Close();
}
//---------------------------------------------------------------------------
void __fastcall TfdJSForm::printBtnClick(TObject *Sender)
{
//ShowMessage("暂时无法打印");
Variant vWordApp,vTable,vCell;
try
{
vWordApp = Variant::CreateObject("Word.Application");
}
catch(...)
{
MessageBox(0, "启动 Word 出错, 可能是没有安装Word.","DBGrid2Word", MB_OK | MB_ICONERROR);
vWordApp = Unassigned;
return;
}
// 隐藏Word界面
vWordApp.OlePropertySet("Visible", true);
// 新建一个文档
vWordApp.OlePropertyGet("Documents").OleFunction("Add");
Variant vSelect = vWordApp.OlePropertyGet("Selection");
// 设置一下字体,大小
vSelect.OlePropertyGet("Font").OlePropertySet("Size", 24);
vSelect.OlePropertyGet("Font").OlePropertySet("Name", Label4->Font->Name.c_str());
AnsiString str=" "+Label4->Caption;
str+="\n "+Label5->Caption+KHname->Text.Trim();
str+="结算款人民币(小写)"+Money->Text;
str+=",大写"+Edit3->Text;
str+="。\n 备注:"+BZ->Text;
str+="。\n 客户签名: ";
str+="\n ";
AnsiString strPtrDate =Now().CurrentDate().DateString();//取当前日期
str+=strPtrDate;
vSelect.OlePropertySet("Text",str.c_str());
}
//---------------------------------------------------------------------------
void __fastcall TfdJSForm::closeBtnClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfdJSForm::MoneyChange(TObject *Sender)
{
float sum=Money->Text.Trim().ToDouble();
Edit3->Text=CurrToChnNum(sum,false,0);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -