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

📄 unitmain.cpp

📁 基于MD110程控交换机的计费程序,使用C++Builder开发
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    else
        CheckBox28->Caption=A1;
    GetPrivateProfileString("BaseFunction","J09","",A1,9, FileName.c_str());
    if(AnsiString(A1).IsEmpty())
        CheckBox29->Visible=false;
    else
        CheckBox29->Caption=A1;
    GetPrivateProfileString("BaseFunction","J10","",A1,9, FileName.c_str());
    if(AnsiString(A1).IsEmpty())
        CheckBox30->Visible=false;
    else
        CheckBox30->Caption=A1;

}

unsigned short __fastcall TFormMain::SetClass()
{
    unsigned short cls=0;
    if(CheckBox1->Checked)cls|=0x0001;
    if(CheckBox2->Checked)cls|=0x0002;
    if(CheckBox3->Checked)cls|=0x0004;
    if(CheckBox21->Checked)cls|=0x0008;
    if(CheckBox22->Checked)cls|=0x0010;
    if(CheckBox23->Checked)cls|=0x0020;
    if(CheckBox24->Checked)cls|=0x0040;
    if(CheckBox25->Checked)cls|=0x0100;
    if(CheckBox26->Checked)cls|=0x0200;
    if(CheckBox27->Checked)cls|=0x0400;
    if(CheckBox28->Checked)cls|=0x0800;
    if(CheckBox29->Checked)cls|=0x1000;
    if(CheckBox30->Checked)cls|=0x2000;
    if(RadioGroup1->ItemIndex==1)cls|=0x4000;
    if(CheckBox14->Checked)cls|=0x8000;
    return cls;
}

void __fastcall TFormMain::GetClass(unsigned short cls)
{
    NoEdiet=true;
    CheckBox1->Checked=cls&0x0001;
    CheckBox2->Checked=cls&0x0002;
    CheckBox3->Checked=cls&0x0004;
    CheckBox21->Checked=cls&0x0008;
    CheckBox22->Checked=cls&0x0010;
    CheckBox23->Checked=cls&0x0020;
    CheckBox24->Checked=cls&0x0040;
    CheckBox25->Checked=cls&0x0100;
    CheckBox26->Checked=cls&0x0200;
    CheckBox27->Checked=cls&0x0400;
    CheckBox28->Checked=cls&0x0800;
    CheckBox29->Checked=cls&0x1000;
    CheckBox30->Checked=cls&0x2000;
    if(cls&0x4000)RadioGroup1->ItemIndex=1;
    else RadioGroup1->ItemIndex=0;
    CheckBox14->Checked=cls&0x8000;

    Edit3->Text="";

    NoEdiet=false;

}



void __fastcall TFormMain::CheckBox21Click(TObject *Sender)
{
    if(NoEdiet)return;
   if(!(ModuleRecord->DataSource3->State == dsEdit)&&!(ModuleRecord->DataSource3->State == dsInsert))
        ModuleRecord->Table3->Edit();
    ModuleRecord->Table3->FieldByName("ClsA")->AsInteger = SetClass();
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::Button15Click(TObject *Sender)
{
    DBNavigator2->BtnClick(nbInsert);
    ModuleRecord->Table3->FieldByName("Num")->AsString="0";

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

void __fastcall TFormMain::Button16Click(TObject *Sender)
{
    DBNavigator2->BtnClick(nbDelete);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button17Click(TObject *Sender)
{
    DBNavigator2->BtnClick(nbCancel);
    GetClass(ModuleRecord->Table3->FieldByName("ClsA")->AsInteger);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button7Click(TObject *Sender)
{

    if(!Edit3->Text.IsEmpty())
    {
        int i=ModuleRecord->Table3->RecNo;
        float j=Edit3->Text.ToDouble();
        ModuleRecord->Table3->First();
        if(!(ModuleRecord->DataSource3->State == dsEdit)&&
            !(ModuleRecord->DataSource3->State == dsInsert))
            ModuleRecord->Table3->Edit();
        ModuleRecord->Table3->FieldByName("Yfk")->AsFloat+=j;
        ModuleRecord->Table3->FieldByName("Jy")->AsFloat+=j;

        ModuleRecord->Table3->MoveBy(i-1);
        if(!(ModuleRecord->DataSource3->State == dsEdit)&&
            !(ModuleRecord->DataSource3->State == dsInsert))
            ModuleRecord->Table3->Edit();
        ModuleRecord->Table3->FieldByName("Yfk")->AsFloat+=j;
        ModuleRecord->Table3->FieldByName("Jy")->AsFloat+=j;
    }
    DBNavigator2->BtnClick(nbPost);
}
//---------------------------------------------------------------------------




void __fastcall TFormMain::Edit3KeyUp(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Edit3->Text.IsEmpty())return;
    try
    {
        Edit3->Text.ToDouble();
    }
    catch(Exception &ce )
    {
        ShowMessage("输入错误");
        Edit3->Text="";
    }
    if(!(ModuleRecord->DataSource3->State == dsEdit)&&!(ModuleRecord->DataSource3->State == dsInsert))
        ModuleRecord->Table3->Edit();
    ModuleRecord->Table3->FieldByName("Yfk")->AsFloat+=0;
}
//---------------------------------------------------------------------------


void __fastcall TFormMain::Button18Click(TObject *Sender)
{
    char A1[20];
    if(FileExists("Data\\SetClass.CMD"))DeleteFile("Data\\SetClass.CMD");

    AnsiString FileName=GetCurrentDir()+AnsiString("\\Data\\JFConfig.ini");
    GetPrivateProfileString("PABX","Password","HELP",A1,18, FileName.c_str());

    AnsiString str;
    Memo3->Lines->Clear();
    str="@o\r\n"+AnsiString(A1).Trim()+";@n";
    Memo3->Lines->Add(str);

    int rec,j,i=0;
    rec=ModuleRecord->Table3->RecNo;

    ModuleRecord->Table3->First();
    ModuleRecord->Table3->Next();
    while (!ModuleRecord->Table3->Eof)
    {
        j=ModuleRecord->Table3->FieldByName("ClsA")->AsInteger;
        str=ModuleRecord->Table3->FieldByName("Num")->AsString.Trim();
        if(str.Length()>5)str=str.SubString(str.Length()-4,5);//经验也
        //普通用户、受控功能无效,有结余--升
        if(((j&0x8000)==0x0)&&((j&0x4000)==0x0)&&
            (ModuleRecord->Table3->FieldByName("Jy")->AsFloat>0))
        {
            str="excac:dir="+str+",cat="+AnsiString(j&0x3fff)+";";
            Memo3->Lines->Add(str);
            i++;
        }
        //特殊用户、受控功能无效--升
        else if(((j&0x8000)==0x0)&&((j&0x4000)!=0x0))
        {
            str="excac:dir="+str+",cat="+AnsiString(j&0x3fff)+";";
            Memo3->Lines->Add(str);
            i++;
        }
        //普通用户、受控功能有效,无结余--降
        else if(((j&0x8000)!=0x0)&&((j&0x4000)==0x0)&&
                (ModuleRecord->Table3->FieldByName("jy")->AsFloat<=0))
        {
            str="excac:dir="+str+",cat="+AnsiString(j&0x3ff8)+";";
            Memo3->Lines->Add(str);
            i++;
        }
        ModuleRecord->Table3->Next();
    }
    ModuleRecord->Table3->First();
    ModuleRecord->Table3->MoveBy(rec-1);
    if(i>0)
        Memo3->Lines->SaveToFile("Data\\SetClass.cmd");
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button19Click(TObject *Sender)
{
    char A1[30];
    AnsiString FileName=GetCurrentDir()+AnsiString("\\Data\\JFConfig.ini");
    GetPrivateProfileString("PABX","Program","",A1,30, FileName.c_str());

    if(FileExists("Data\\SetClass.Log"))DeleteFile("Data\\SetClass.Log");
    if(!FileExists("Data\\SetClass.CMD"))return;
    AnsiString str=AnsiString(A1)+" TR:Data\\SetClass.CMD,LO:Data\\SetClass.LOG";
    WinExec(str.c_str(),SW_SHOW);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button20Click(TObject *Sender)
{
    if(!FileExists("Data\\SetClass.Log"))return;
    Memo4->Lines->LoadFromFile("Data\\SetClass.log");

    int rec,j,i;
    rec=ModuleRecord->Table3->RecNo;

    ModuleRecord->Table3->First();
    ModuleRecord->Table3->Next();

    i=0;
    int c1,c2,c3,cls;
    AnsiString no2p;
    AnsiString str;
    bool executed;
    for(;;)
    {
        for(;i<Memo4->Lines->Count;i++)
        {
            executed=false;
            str=Memo4->Lines->Strings[i];
            c1=str.AnsiPos("excac:dir=");
            if(c1!=0)
            {
                c2=str.AnsiPos(",cat=");
                if(c2!=0)
                {
                    c3=str.AnsiPos(";");
                    if(c3!=0)
                    {
                        no2p=str.SubString(c1+10,c2-c1-10);
                        cls=str.SubString(c2+5,c3-c2-5).ToInt();
                        c1=Memo4->Lines->Strings[i+1].AnsiPos("EXECUTED");
                        if(c1==1)
                        {
                            executed=true;
                            i+=2;
                            break;
                        }
                    }
                }
            }
        }
        if(!executed)break;
        while(!ModuleRecord->Table3->Eof)
        {
            str=ModuleRecord->Table3->FieldByName("Num")->AsString.Trim();
            if(str.Length()>5)str=str.SubString(str.Length()-4,5);//经验也
            if(no2p==str)
            {
                if(!(ModuleRecord->DataSource3->State == dsEdit)&&
                    !(ModuleRecord->DataSource3->State == dsInsert))
                ModuleRecord->Table3->Edit();

                ModuleRecord->Table3->FieldByName("ClsB")->AsInteger=cls;
                if(ModuleRecord->Table3->FieldByName("ClsA")->AsInteger==cls)
                    ModuleRecord->Table3->FieldByName("ClsA")->AsInteger=(cls|0x8000);
                else
                    ModuleRecord->Table3->FieldByName("ClsA")->AsInteger&=0x7fff;
                ModuleRecord->Table3->Next();
                break;
            }
            ModuleRecord->Table3->Next();
        }
        if(ModuleRecord->Table3->Eof)break;
    }
    ModuleRecord->Table3->First();
    ModuleRecord->Table3->MoveBy(rec-1);
}
//---------------------------------------------------------------------------

void __fastcall TFormMain::Button21Click(TObject *Sender)
{
    Button18Click(this);
    Button19Click(this);
    Button20Click(this);
}
//---------------------------------------------------------------------------


void __fastcall TFormMain::CheckBox4Click(TObject *Sender)
{
    ComboBox1->Enabled=CheckBox4->Checked;
    ComboBox1Change(this);
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ControlTimer()
{
    unsigned short h,hour,min,sec,msec;
    Now().DecodeTime(&hour,&min,&sec,&msec);
    if(hour==NextTime)
    {
        ComboBox1Change(this);
        Button21Click(this);
    }
}
//---------------------------------------------------------------------------
void __fastcall TFormMain::ComboBox1Change(TObject *Sender)
{
    unsigned short h,hour,min,sec,msec;
    AnsiString str=ComboBox1->Text.SubString(1,ComboBox1->Text.Length()-4);
    h=4;
    if(!str.IsEmpty())
        h=str.ToInt();
    Now().DecodeTime(&hour,&min,&sec,&msec);
    h=((hour/h)+1)*h;
    NextTime=(h%24);
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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