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

📄 prevdlg.cpp

📁 民航飞机生产管理系统,实现了飞机定检坚控,小时卡起落卡等的坚控,并能生成工作任务包
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "prevdlg.h"
#include "dm.h"
#include "qryplane.h"
#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "KsSkinButtons"
#pragma link "KsSkinComboBoxs"
#pragma link "KsSkinForms"
#pragma link "KsSkinGroupBoxs"
#pragma link "KsSkinLabels"
#pragma link "KsSkinPanels"
#pragma link "se_controls"
#pragma link "XLSReadWriteII"
#pragma resource "*.dfm"
TForm7 *Form7;
bool pick1,pick2;
extern TMemo *memo;
AnsiString yearstr,monthstr;
extern bool fjyb;
extern String danwei;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm7::Button1Click(TObject *Sender)
{
int prezhengchang[20];
 yearstr=ComboBox1->Text;
 monthstr=ComboBox2->Text;
 int fhzong1[20],fhzong2[20],zixiuli[20],benyue1[20],benyue2[20];
 int qixiu[20],qi[20],benlian[20],xiuhoulian[20],zonglian[20],zfxfh[20],zffh[20];
 int zfxx[20],zfx[20],yfxfh[20],yffh[20],yfxx[20],yfx[20];
 if(yearstr!=""&&monthstr!="")

 {       yearstr="年= '"+yearstr+"'";
        monthstr="月份= '"+monthstr+"'";
        yearstr=yearstr+" AND "+monthstr;
        DataModule1->fjyb->Filtered=false;
        DataModule1->fjyb->Filter=yearstr;
        DataModule1->fjyb->Filtered=true;
        if(DataModule1->fjyb->RecordCount!=0)
        {
        if(!fjyb)return;
        TForm12* Form12=new TForm12(Application);
        Form12->QuickRep1->Preview();
        delete Form12;
        }
        else
        {
         if(!(pick1&&pick2))
                if(Application->MessageBoxA("请选择起止日期","月报设置",MB_OK)==IDOK)
                {    DateTimePicker1->Enabled=true;
                     DateTimePicker2->Enabled=true;
                     goto out;

                }

        TIndexOptions opt;
    opt << ixDescending;

//  DataModule1->fjyb->AddIndex("riqiindex","年",opt,"","",1);
  DataModule1->fjyb->IndexFieldNames="年";
         for(int i=0;i<memo->Lines->Count;i++)
          {
        if(ComboBox2->Text.operator ==("1"))
        monthstr="年= '"+IntToStr(StrToInt(ComboBox1->Text)-1)+"' AND 月份= '"+IntToStr(12)+"'";
        else
        monthstr="年= '"+ComboBox1->Text+"' AND 月份= '"+IntToStr(StrToInt(ComboBox2->Text)-1)+"'";
        monthstr=monthstr+" AND 机号 = '"+memo->Lines->Strings[i]+"'";
        DataModule1->fjyb->Filtered=false;
        DataModule1->fjyb->Filter=monthstr;
        DataModule1->fjyb->Filtered=true;
        xiuhoulian[i]= DataModule1->xiuhoulianxu->AsInteger;
        zonglian[i]=DataModule1->zonglianxu->AsInteger;
        prezhengchang[i]=DataModule1->zongzhengchang->AsInteger;

          }

          for(int i=0;i<memo->Lines->Count;i++)
          {
          DataModule1->dayreport->Filtered=false;
          DataModule1->dayreport->Filter="日期 <= '"+DateToStr(DateTimePicker2->Date)+"' AND 机号= '"+
          memo->Lines->Strings[i]+"'";

          DataModule1->dayreport->Filtered=true;
          DataModule1->dayreport->IndexFieldNames="机身总";
          DataModule1->dayreport->UpdateStatus();
          DataModule1->dayreport->Last();
          fhzong1[i]=DataModule1->dayreportField4->AsInteger;
          benyue1[i]=DataModule1->dayreportField10->AsInteger;
          zixiuli[i]=DataModule1->dayreportField3->AsInteger;
          qixiu[i]=DataModule1->dayreportField9->AsInteger;
          zfxfh[i]=DataModule1->dayreportField5->AsInteger;
          zffh[i]=DataModule1->dayreportField6->AsInteger;

          zfx[i]=DataModule1->dayreportField11->AsInteger;
          zfxx[i]=zfx[i];
          yfxfh[i]=DataModule1->dayreportField7->AsInteger;
          yffh[i]=DataModule1->dayreportField8->AsInteger;

          yfx[i]=DataModule1->dayreportField12->AsInteger;
          yfxx[i]=yfx[i];
           DataModule1->dayreport->Filtered=false;
           DataModule1->dayreport->Filter="日期 < '"+DateToStr(DateTimePicker1->Date)+"' AND 机号= '"+
          memo->Lines->Strings[i]+"'";
          DataModule1->dayreport->Filtered=true;
                  DataModule1->dayreport->IndexFieldNames="机身总";
          DataModule1->dayreport->UpdateStatus();
          DataModule1->dayreport->Last();
          fhzong2[i]=DataModule1->dayreportField4->AsInteger;
          benyue2[i]=DataModule1->dayreportField10->AsInteger;
          DataModule1->dayreport->First();
          int lian=0;
           DataModule1->dayreport->Filtered=false;
          DataModule1->dayreport->Filter="日期 >= '"+DateToStr(DateTimePicker1->Date)+"' AND 日期 <= '"+DateToStr(DateTimePicker2->Date)+"' AND 机号= '"+
          memo->Lines->Strings[i]+"'";
          DataModule1->dayreport->Filtered=true;
          //DataModule1->dayreport->IndexName="jishenindex";
          DataModule1->dayreport->UpdateStatus();

           for(int j=0;j<DataModule1->dayreport->RecordCount;j++)
           {

            lian=DataModule1->dayreportField13->AsInteger+lian;
            DataModule1->dayreport->Next();
            }



           benlian[i]=lian;
          }
          for(int i=0;i<memo->Lines->Count;i++)
          {
          DataModule1->fjyb->ReadOnly=false;
          DataModule1->fjyb->Append();

          DataModule1->year->AsInteger=StrToInt(ComboBox1->Text);
          DataModule1->month->Value=StrToInt(ComboBox2->Text);
          DataModule1->jihao->AsString=memo->Lines->Strings[i];
          DataModule1->air->AsInteger=fhzong1[i]-fhzong2[i];
          DataModule1->earth->AsInteger=(fhzong1[i]-fhzong2[i])+10*(benyue1[i]-benyue2[i]+benlian[i]);
          DataModule1->xiuhou->AsInteger=zixiuli[i];
          DataModule1->zongshijian->AsInteger=fhzong1[i];
          DataModule1->zhengchang->AsInteger=benyue1[i]-prezhengchang[i];
          DataModule1->lianxu->AsInteger=benlian[i];
          DataModule1->xiuhouzhengchang->AsInteger=qixiu[i];
          DataModule1->xiuhoulianxu->AsInteger= xiuhoulian[i]+benlian[i];
          DataModule1->zonglianxu->AsInteger=zonglian[i]+benlian[i];
          DataModule1->zongzhengchang->AsInteger=benyue1[i]-zonglian[i]-benlian[i];
          DataModule1->xiuhoufa->AsInteger=zfxfh[i];
          DataModule1->zongfa->AsInteger=zffh[i];
          DataModule1->xiuhouxunhuan->AsInteger=zfxx[i];
          DataModule1->zongxunhuan->AsInteger=zfx[i];
          DataModule1->xiuhouyoufa->AsInteger=yfxfh[i];
          DataModule1->zongyoufa->AsInteger=yffh[i];
          DataModule1->xiuhouyouxunhuan->AsInteger=yfxx[i];
          DataModule1->zongyouxunhuan->AsInteger=yfx[i];
          DataModule1->fjyb->Post();

           }
        yearstr="年= '"+ComboBox1->Text+"'";
        monthstr="月份= '"+ComboBox2->Text+"'";
        yearstr=yearstr+" AND "+monthstr;
        DataModule1->fjyb->Filtered=false;
        DataModule1->fjyb->Filter=yearstr;
        DataModule1->fjyb->Filtered=true;
        if(DataModule1->fjyb->RecordCount!=0)
        { if(!fjyb)return;
        TForm12* Form12=new TForm12(Application);
        Form12->QuickRep1->Preview();
        delete Form12;
        }

        }

    }
    out:

}
//---------------------------------------------------------------------------

void __fastcall TForm7::FormActivate(TObject *Sender)
{
pick1=false;
pick2=false;        
}
//---------------------------------------------------------------------------

void __fastcall TForm7::DateTimePicker1Change(TObject *Sender)
{
pick1=true;        
}
//---------------------------------------------------------------------------

void __fastcall TForm7::DateTimePicker2Change(TObject *Sender)
{
pick2=true;        
}
//---------------------------------------------------------------------------

void __fastcall TForm7::ComboBox1Change(TObject *Sender)
{
if(ComboBox1->Text!=NULL&&ComboBox2->Text!=NULL)
{

        DataModule1->fjyb->Filtered=false;
        DataModule1->fjyb->Filter="年= '"+ComboBox1->Text+"' AND 月份= '"+ComboBox2->Text+"'";
        DataModule1->fjyb->Filtered=true;
        if(DataModule1->fjyb->RecordCount==0)
        {
        DateTimePicker1->Enabled=true;
        DateTimePicker2->Enabled=true;
        }
        else
        {
         DateTimePicker1->Enabled=false;
        DateTimePicker2->Enabled=false;
        }
}
}
//---------------------------------------------------------------------------

void __fastcall TForm7::FormCreate(TObject *Sender)
{
DateTimePicker1->Date=Now();
DateTimePicker2->Date=Now();        
}
//---------------------------------------------------------------------------

void __fastcall TForm7::SeSkinButton1Click(TObject *Sender)
{

    String yearstr="年= '"+ComboBox1->Text+"'";
    String    monthstr="月份= '"+ComboBox2->Text+"'";
        yearstr=yearstr+" AND "+monthstr;
        DataModule1->fjyb->Filtered=false;
        DataModule1->fjyb->Filter=yearstr;
        DataModule1->fjyb->Filtered=true;
        int i_max=DataModule1->fjyb->RecordCount;
        if(i_max==0)
        {
        ShowMessage("无满足条件纪录!");
        return;
        }
        Screen->Cursor=crHourGlass;
if(S1->Execute())
{
    XLS->Clear();
    XLS->Filename=ExtractFileDir(Application->ExeName)+"\\fjfxyb.xls";
    XLS->Read();
    String s_ny=ComboBox1->Text+"年"+ComboBox2->Text+"月";
    XLS->Sheets->Items[0]->WriteWideString(0,1,-1,s_ny);
    XLS->Sheets->Items[0]->WriteWideString(10,1,-1,danwei);
    int i_line=5;
    String s_tmp;
    int i_fh,i_fhxl,i_fhz,i_xh,i_zks;

  DataModule1->fjyb->First();
  for(int i=0;i<i_max;i++)
  {
       s_tmp=DataModule1->fjyb->FieldByName("机号")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(0,i_line,-1,s_tmp);
        i_fh=DataModule1->fjyb->FieldByName("空中飞行")->AsInteger;
        s_tmp=FormatFloat("####0.00",i_fh/60.0);
       XLS->Sheets->Items[0]->WriteWideString(1,i_line,-1,s_tmp);
        s_tmp=FormatFloat("####0.00",i_fh*1.1/60.0);
       XLS->Sheets->Items[0]->WriteWideString(2,i_line,-1,s_tmp);
        i_fhxl=DataModule1->fjyb->FieldByName("修后")->AsInteger;
        s_tmp=FormatFloat("####0.00",i_fhxl/60.0);
       XLS->Sheets->Items[0]->WriteWideString(3,i_line,-1,s_tmp);
        i_fhz=DataModule1->fjyb->FieldByName("总时间")->AsInteger;
        s_tmp=FormatFloat("####0.00",i_fhz/60.0);
       XLS->Sheets->Items[0]->WriteWideString(4,i_line,-1,s_tmp);
        s_tmp=DataModule1->fjyb->FieldByName("正常起落")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(5,i_line,-1,s_tmp);
        s_tmp=DataModule1->fjyb->FieldByName("连续起落")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(5,i_line+1,-1,s_tmp);
        s_tmp=DataModule1->fjyb->FieldByName("修后正常")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(6,i_line,-1,s_tmp);
        s_tmp=DataModule1->fjyb->FieldByName("修后连续")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(6,i_line+1,-1,s_tmp);
       s_tmp=DataModule1->fjyb->FieldByName("总正常")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(7,i_line,-1,s_tmp);
s_tmp=DataModule1->fjyb->FieldByName("总连续")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(7,i_line+1,-1,s_tmp);
       i_xh=DataModule1->fjyb->FieldByName("修后发动机")->AsInteger;
        s_tmp=FormatFloat("###,###0.00",i_xh/60.0);
       XLS->Sheets->Items[0]->WriteWideString(8,i_line,-1,s_tmp);
            i_xh=DataModule1->fjyb->FieldByName("修后右发")->AsInteger;
        s_tmp=FormatFloat("###,###0.00",i_xh/60.0);
       XLS->Sheets->Items[0]->WriteWideString(8,i_line+1,-1,s_tmp);
       i_xh=DataModule1->fjyb->FieldByName("总发动机")->AsInteger;
        s_tmp=FormatFloat("###,###0.00",i_xh/60.0);
       XLS->Sheets->Items[0]->WriteWideString(9,i_line,-1,s_tmp);
            i_xh=DataModule1->fjyb->FieldByName("总右发")->AsInteger;
        s_tmp=FormatFloat("###,###0.00",i_xh/60.0);
       XLS->Sheets->Items[0]->WriteWideString(9,i_line+1,-1,s_tmp);
       s_tmp=DataModule1->fjyb->FieldByName("修后循环")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(10,i_line,-1,s_tmp);
       s_tmp=DataModule1->fjyb->FieldByName("修后右循环")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(10,i_line+1,-1,s_tmp);
       s_tmp=DataModule1->fjyb->FieldByName("总循环")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(11,i_line,-1,s_tmp);
       s_tmp=DataModule1->fjyb->FieldByName("总右循环")->AsString;
       XLS->Sheets->Items[0]->WriteWideString(11,i_line+1,-1,s_tmp);
              i_line+=2;
       DataModule1->fjyb->Next();
     }

      XLS->Sheets->Items[0]->WriteWideString(2,22,-1,Date().DateString());


    XLS->Filename=S1->FileName+".XLS";

    XLS->Write();
}
Screen->Cursor=crDefault;
        
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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