📄 wxbwfyset.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "ShFwMain.h"
#include "GgSet.h"
#include "WxBwFySet.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TWxBwFySetForm *WxBwFySetForm;
//---------------------------------------------------------------------------
__fastcall TWxBwFySetForm::TWxBwFySetForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::FormCreate(TObject *Sender)
{
ADOQuerywxbw->Close();
ADOQuerywxbw->Parameters->ParamByName("P_flbh")->Value = MainForm->MyGsFl;
ADOQuerywxbw->Parameters->ParamByName("P_ppbh")->Value = MainForm->MyGsPp;
ADOQuerywxbw->Parameters->ParamByName("P_ggbh")->Value = MainForm->MyGsGg;
ADOQuerywxbw->Open();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button6Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
ADOQuerywxbw->Close();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button1Click(TObject *Sender)
{
if(MainForm->setqx!="有") {
Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
Abort();
}
DBGrid1->ReadOnly = false;
ADOQuerywxbw->Insert();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button2Click(TObject *Sender)
{
if(MainForm->setqx!="有") {
Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
Abort();
}
DBGrid1->ReadOnly = false;
ADOQuerywxbw->Edit();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button3Click(TObject *Sender)
{
ADOQuerytmp->Close();
ADOQuerytmp->SQL->Clear();
ADOQuerytmp->SQL->Add( "select max(bwbh) from wxbwfyxx where flbh='"+MainForm->MyGsFl+"' and ppbh='"+MainForm->MyGsPp+"' and ggbh='"+MainForm->MyGsGg+"'");
ADOQuerytmp->Open();
if(ADOQuerytmp->Fields->Fields[0]->AsString.Trim()=="")
ADOQuerywxbw->FieldByName("bwbh")->AsString = "0001";
else
ADOQuerywxbw->FieldByName("bwbh")->AsString = ADOQuerywxbw->FieldByName("bwbh")->AsString.sprintf("%04d",ADOQuerytmp->Fields->Fields[0]->AsString.ToInt()+1);
ADOQuerytmp->Close();
ADOQuerywxbw->FieldByName("flbh")->AsString = MainForm->MyGsFl;
ADOQuerywxbw->FieldByName("ppbh")->AsString = MainForm->MyGsPp;
ADOQuerywxbw->FieldByName("ggbh")->AsString = MainForm->MyGsGg;
ADOQuerywxbw->Post();
DBGrid1->ReadOnly = true;
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button4Click(TObject *Sender)
{
ADOQuerywxbw->Cancel();
DBGrid1->ReadOnly = true;
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::Button5Click(TObject *Sender)
{
if(MainForm->setqx!="有") {
Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
Abort();
}
if(Application->MessageBox("是否删除当前记录?","确认",MB_OKCANCEL+MB_ICONERROR)!=IDOK)
Abort();
ADOQuerytmp->Close();
ADOQuerytmp->SQL->Clear();
ADOQuerytmp->SQL->Add("select count(*) from slwxbwfy where flbh='"+MainForm->MyGsFl+"' and ppbh='"+MainForm->MyGsPp+"' and ggbh='"+MainForm->MyGsGg+"' and bwbh='"+ADOQuerywxbw->FieldByName("bwbh")->AsString+"'");
ADOQuerytmp->Open();
if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
ADOQuerytmp->Close();
Application->MessageBox("发现SLWXBWFY相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
Abort();
}
ADOQuerytmp->Close();
ADOQuerywxbw->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::ADOQuerywxbwBeforePost(TDataSet *DataSet)
{
if( ADOQuerywxbw->FieldByName("bwmc")->AsString.Trim()=="") {
Application->MessageBox("请输入部位名称","错误",MB_OK+MB_ICONERROR);
Abort();
}
if( ADOQuerywxbw->FieldByName("gysgcfwf")->AsString.Trim()=="")
ADOQuerywxbw->FieldByName("gysgcfwf")->AsFloat = 0;
if( ADOQuerywxbw->FieldByName("gyssmfwf")->AsString.Trim()=="")
ADOQuerywxbw->FieldByName("gyssmfwf")->AsFloat = 0;
if( ADOQuerywxbw->FieldByName("khfwf")->AsString.Trim()=="")
ADOQuerywxbw->FieldByName("khfwf")->AsFloat = 0;
if( ADOQuerywxbw->FieldByName("ryfwf")->AsString.Trim()=="")
ADOQuerywxbw->FieldByName("ryfwf")->AsFloat = 0;
}
//---------------------------------------------------------------------------
void __fastcall TWxBwFySetForm::DataSource1StateChange(TObject *Sender)
{
switch(ADOQuerywxbw->State) {
case dsBrowse:
Button1->Enabled = true;
if( ADOQuerywxbw->RecordCount>0){
Button2->Enabled = true;
Button5->Enabled = true;
} else {
Button2->Enabled = false;
Button5->Enabled = false;
}
Button4->Enabled = false;
Button3->Enabled = false;
break;
case dsEdit:
case dsInsert:
Button1->Enabled = false;
Button2->Enabled = false;
Button3->Enabled = true;
Button4->Enabled = true;
Button5->Enabled = false;
break;
default:
Button1->Enabled = false;
Button2->Enabled = false;
Button3->Enabled = false;
Button4->Enabled = false;
Button5->Enabled = false;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -