//--------------------------------------------------------------------------- #include #pragma hdrstop #include "PolicySave.h" #include "PolicyUnit.h" #include "UtilityUnit.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- __fastcall TPolicySaveForm::TPolicySaveForm(TComponent* Owner, int type, String name) : TForm(Owner) { m_iType = type; m_name = name; m_sType = type==TYPE_P_BET ? "打法" : "注码"; } //--------------------------------------------------------------------------- void __fastcall TPolicySaveForm::FormCreate(TObject *Sender) { m_leName->Text = m_name; m_leName->EditLabel->Caption = m_sType + "名称:"; } //--------------------------------------------------------------------------- void __fastcall TPolicySaveForm::OnOkClick(TObject *Sender) { vector& aPolicies = m_iType==TYPE_P_BET ? g_aBetPolicies : g_aChipPolicies; // bool bRepeat = false; int type = -1; m_iPolicy = -1; for(int i=0; iname == m_leName->Text){ m_iPolicy = i; type = aPolicies[i]->type; break; } } if(m_iPolicy>=0){ if(type<2){ String msg = "该名称的" + m_sType + "为系统内置,不可覆盖,请修改名称"; MessageBox(Handle, msg.c_str(), L"保存", MB_ICONERROR | MB_OK); return; } else if(IsPolicyInUse(m_iType, m_iPolicy)){ String msg = "该名称的" + m_sType + "正在使用中,不可覆盖,请修改名称"; MessageBox(Handle, msg.c_str(), L"保存", MB_ICONERROR | MB_OK); return; } else{ vector coms = PolicyInCombo(aPolicies[m_iPolicy]->id); if(!coms.empty()){ String msg = "该名称的" + m_sType + "被组合方案使用,不可覆盖,请修改名称"; MessageBox(Handle, msg.c_str(), L"保存", MB_ICONERROR | MB_OK); return; } String msg = "该名称的" + m_sType + "已存在,是否覆盖?"; int mrRet = MessageBox(Handle, msg.c_str(), L"保存", MB_ICONQUESTION | MB_OKCANCEL); if(mrRet==mrCancel) return; } } m_name = m_leName->Text; ModalResult = mrOk; } //---------------------------------------------------------------------------