⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spsetgl.cpp

📁 售后服务系统优质的售后服务是企业生存和市场竞争的保障
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "ShFwMain.h"
#include "SpSetGl.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TSpSetForm *SpSetForm;
//---------------------------------------------------------------------------
__fastcall TSpSetForm::TSpSetForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TSpSetForm::FormCreate(TObject *Sender)
{
        MainForm->ADOConnection1->Open();
        Button1->Enabled = false;
        Button2->Enabled = false;
        Button3->Enabled = false;
        Button4->Enabled = false;
        Button5->Enabled = false;
        DBGrid1->ReadOnly = true;
        DBGrid2->ReadOnly = true;
        ADOTableflxx->Close();
        ADOTableflxx->Open();
}
//---------------------------------------------------------------------------
void __fastcall TSpSetForm::FormClose(TObject *Sender,
      TCloseAction &Action)
{
        MainForm->ADOConnection1->Close();        
}
//---------------------------------------------------------------------------
void __fastcall TSpSetForm::DataSourceflxxStateChange(TObject *Sender)
{
        if( PageControl1->ActivePageIndex != 0)
                return;
        switch(ADOTableflxx->State) {
        case dsBrowse:
                DBGrid1->ReadOnly = true;
                Button1->Enabled = true;
                if( ADOTableflxx->RecordCount>0)
                        Button2->Enabled = true;
                else
                        Button2->Enabled = false;
                Button3->Enabled = false;
                Button4->Enabled = false;
                if( ADOTableflxx->RecordCount>0)
                        Button5->Enabled = true;
                else
                        Button5->Enabled = false;
                break;
        case dsEdit:
        case dsInsert:
                DBGrid1->ReadOnly = false;
                Button1->Enabled = false;
                Button2->Enabled = false;
                Button3->Enabled = true;
                Button4->Enabled = true;
                Button5->Enabled = false;
                break;
        default:
                DBGrid1->ReadOnly = true;
                Button1->Enabled = false;
                Button2->Enabled = false;
                Button3->Enabled = false;
                Button4->Enabled = false;
                Button5->Enabled = false;
        }
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::ADOTableflxxBeforePost(TDataSet *DataSet)
{
        if(ADOTableflxx->FieldByName("flmc")->AsString.Trim()=="") {
                Application->MessageBox("请输入分类名称","错误",MB_OK+MB_ICONERROR);
                Abort();
        }
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::DataSourceppxxStateChange(TObject *Sender)
{
        if( PageControl1->ActivePageIndex != 1)
                return;
        switch(ADOQueryppxx->State) {
        case dsBrowse:
                DBGrid2->ReadOnly = true;
                DBLookupComboBox1->Enabled = true;
                Button1->Enabled = true;
                if( ADOQueryppxx->RecordCount>0)
                        Button2->Enabled = true;
                else
                        Button2->Enabled = false;
                Button3->Enabled = false;
                Button4->Enabled = false;
                if( ADOQueryppxx->RecordCount>0)
                        Button5->Enabled = true;
                else
                        Button5->Enabled = false;
                break;
        case dsEdit:
        case dsInsert:
                DBGrid2->ReadOnly = false;
                DBLookupComboBox1->Enabled = false;
                Button1->Enabled = false;
                Button2->Enabled = false;
                Button3->Enabled = true;
                Button4->Enabled = true;
                Button5->Enabled = false;
                break;
        default:
                DBGrid2->ReadOnly = true;
                DBLookupComboBox1->Enabled = true;
                Button1->Enabled = false;
                Button2->Enabled = false;
                Button3->Enabled = false;
                Button4->Enabled = false;
                Button5->Enabled = false;
        }
}
//---------------------------------------------------------------------------


void __fastcall TSpSetForm::ADOTableflxxAfterInsert(TDataSet *DataSet)
{
        ADOQuerytmp->Close();
        ADOQuerytmp->SQL->Clear();
        ADOQuerytmp->SQL->Add( "select max(flbh) from flxx ");
        ADOQuerytmp->Open();
        if(ADOQuerytmp->Fields->Fields[0]->AsString.Trim()=="")
                ADOTableflxx->FieldByName("flbh")->AsString = "0001";
        else
                ADOTableflxx->FieldByName("flbh")->AsString = ADOTableflxx->FieldByName("flbh")->AsString.sprintf("%04d",ADOQuerytmp->Fields->Fields[0]->AsString.ToInt()+1);
        ADOQuerytmp->Close();
}
//---------------------------------------------------------------------------


void __fastcall TSpSetForm::ADOQueryppxxAfterInsert(TDataSet *DataSet)
{
        AnsiString sql;
        ADOQuerytmp->Close();
        ADOQuerytmp->SQL->Clear();
        sql = "select max(ppbh) from ppxx where gsfl= '"+ DBLookupComboBox1->KeyValue+"'";
        ADOQuerytmp->SQL->Add( sql );
        ADOQuerytmp->Open();
        if(ADOQuerytmp->Fields->Fields[0]->AsString.Trim()=="")
                ADOQueryppxx->FieldByName("ppbh")->AsString = "0001";
        else
                ADOQueryppxx->FieldByName("ppbh")->AsString = ADOQueryppxx->FieldByName("ppbh")->AsString.sprintf( "%04d",ADOQuerytmp->Fields->Fields[0]->AsString.ToInt()+1);
        ADOQuerytmp->Close();
        ADOQueryppxx->FieldByName("gsfl")->AsString = DBLookupComboBox1->KeyValue;
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::ADOQueryppxxBeforePost(TDataSet *DataSet)
{
        if(ADOQueryppxx->FieldByName("mc")->AsString.Trim()=="") {
                Application->MessageBox("请输入名称","错误",MB_OK+MB_ICONERROR);
                Abort();
        }
}
//---------------------------------------------------------------------------




void __fastcall TSpSetForm::PageControl1Change(TObject *Sender)
{

        switch( PageControl1->ActivePageIndex) {
        case 0:
                ADOTableflxx->Close();
                ADOTableflxx->Open();
                ADOQueryppxx->Close();
                break;
        case 1:
                ADOTableflxx->Close();
                ADOTableflxx->Open();
                if( ADOTableflxx->RecordCount > 0) {
                        DBLookupComboBox1->KeyValue = ADOTableflxx->FieldByName("flbh")->AsString;
                        ADOQueryppxx->Close();
                        ADOQueryppxx->Open();
                }
                break;
        }
}
//---------------------------------------------------------------------------


void __fastcall TSpSetForm::DBLookupComboBox1Click(TObject *Sender)
{
        if(DBLookupComboBox1->Text.Trim()=="")
                Abort();
        ADOQueryppxx->Close();
        ADOQueryppxx->Open();
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button1Click(TObject *Sender)
{
        if(MainForm->setqx!="有") {
                Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
                        Abort();
        }
        switch(PageControl1->ActivePageIndex) {
        case 0:
                ADOTableflxx->Insert();
                break;
        case 1:
                ADOQueryppxx->Insert();
                break;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button2Click(TObject *Sender)
{
        if(MainForm->setqx!="有") {
                Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
                        Abort();
        }
        switch(PageControl1->ActivePageIndex) {
        case 0:
                ADOTableflxx->Edit();
                break;
        case 1:
                ADOQueryppxx->Edit();
                break;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button3Click(TObject *Sender)
{
        switch(PageControl1->ActivePageIndex) {
        case 0:
                ADOTableflxx->Post();
                break;
        case 1:
                ADOQueryppxx->Post();
                break;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button4Click(TObject *Sender)
{
        switch(PageControl1->ActivePageIndex) {
        case 0:
                ADOTableflxx->Cancel();
                break;
        case 1:
                ADOQueryppxx->Cancel();
                break;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button5Click(TObject *Sender)
{
        if(MainForm->setqx!="有") {
                Application->MessageBox("对不起!你无权设置信息!","错误",MB_OK+MB_ICONERROR);
                        Abort();
        }
        if(Application->MessageBox("是否删除当前记录?","确认",MB_OKCANCEL+MB_ICONERROR)!=IDOK)
                Abort();
        switch(PageControl1->ActivePageIndex) {
        case 0:
                ADOQuerytmp->Close();
                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from ppxx where gsfl='"+ADOTableflxx->FieldByName("flbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现PPXX相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }

                ADOQuerytmp->Close();
                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from ggxx where flbh='"+ADOTableflxx->FieldByName("flbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现GGXX相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();

                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from pjpzxx where flbh='"+ADOTableflxx->FieldByName("flbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现PJPZXX相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();

                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from pjkc where flbh='"+ADOTableflxx->FieldByName("flbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现PJKC相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();

                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from fwsl where flbh='"+ADOTableflxx->FieldByName("flbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现FWSL相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();
                ADOTableflxx->Delete();
                ADOTableflxx->Close();
                ADOTableflxx->Open();
                break;
        case 1:
                ADOQuerytmp->Close();
                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from ggxx where flbh='"+DBLookupComboBox1->KeyValue+"' and ppbh='"+ADOQueryppxx->FieldByName("ppbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现GGXX相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();

                ADOQuerytmp->SQL->Clear();
                ADOQuerytmp->SQL->Add("select count(*) from fwsl where flbh='"+DBLookupComboBox1->KeyValue+"' and ppbh='"+ADOQueryppxx->FieldByName("ppbh")->AsString+"'");
                ADOQuerytmp->Open();
                if(ADOQuerytmp->Fields->Fields[0]->AsInteger > 0) {
                        ADOQuerytmp->Close();
                        Application->MessageBox("发现FWSL相关的服务记录,为了保护档案的完整,你不能删除此记录","错误",MB_OK+MB_ICONERROR);
                        Abort();
                }
                ADOQuerytmp->Close();
                ADOQueryppxx->Delete();
                ADOQueryppxx->Close();
                ADOQueryppxx->Open();
                break;
        }        
}
//---------------------------------------------------------------------------

void __fastcall TSpSetForm::Button6Click(TObject *Sender)
{
        Close();        
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -