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

📄 mainfrm.cpp

📁 醫院管理 還不錯 醫院管理 還不錯 醫院管理 還不錯
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                            " (%s,'%s','%s',%s,%s,%s)";

        AnsiString strExec;
        if (pDlg->edtVaccinationNum->Text == "")
        {
            pDlg->edtVaccinationNum->Text = "0";
        }

        if (pDlg->edtVaccinationPrice->Text == "")
        {
            pDlg->edtVaccinationPrice->Text = "0";
        }
        strExec.sprintf(strFmt.c_str(),
                        strMedicalId,
                        pDlg->cboVaccinationDrug->Text.c_str(),

                        pDlg->cboVaccinationUnit->Text.c_str(),
                        pDlg->edtVaccinationPrice->Text.c_str(),
                        pDlg->edtVaccinationNum->Text.c_str(),

                        gLogonInf.m_strOptId.c_str());

        qryEx->SQL->Clear();
#ifdef _DEBUG

        ShowMessage(strExec);
#endif

        qryEx->SQL->Add(strExec);
        qryEx->ExecSQL();
    }

    if (pDlg->chkSickLeave->Checked)
    {
        qryEx->SQL->Clear();
        qryEx->SQL->Add("delete from SickLeave where MedicalId=" + strMedicalId);

        AnsiString strFmt = "insert into SickLeave "
                            "(MedicalId,DayNum,OptId) values"
                            " (%s,%s,%s)";

        AnsiString strExec;

        if (pDlg->edtSickLeaveNum->Text == "")
        {
            pDlg->edtSickLeaveNum->Text = "0";
        }

        strExec.sprintf(strFmt.c_str(),
                        strMedicalId,
                        pDlg->edtSickLeaveNum->Text.c_str(),
                        gLogonInf.m_strOptId.c_str());

        qryEx->SQL->Clear();
#ifdef _DEBUG

        ShowMessage(strExec);
#endif

        qryEx->SQL->Add(strExec);
        qryEx->ExecSQL();
    }
    //qryEx->ExecSQL();
    delete pDlg;

    dmMain->qryMedical->Close();
    dmMain->qryMedical->Open();

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

#if 0

void __fastcall TfrmMain::miAddExamClick(TObject *Sender)
{
    if (dmMain->qryClientInfo->RecordCount < 1)
        return;

    TfrmExam * pDlg = new TfrmExam(this);

    pDlg->Caption = "新建";

    pDlg->dtpExamDate->Date = Now();
    pDlg->dtpExamTime->Time = Now();
    TADOQuery * qryEx = dmMain->qrySQLPlus;

    int nEmployeeId = dmMain->qryClientInfo->FieldByName("Id")->Value;

    if (pDlg->ShowModal() == mrOk)
    {
        qryEx->Close();
        qryEx->SQL->Clear();
        qryEx->Prepared = true;

        qryEx->SQL->Add("insert into Exam "
                        "(EmployeeId,ExamKind,ExamDate,ExamTime,ExamResult,ExamOpinon,ExamRemark, OptId)"
                        " values ("
                        + IntToStr(nEmployeeId) + ","
                        + IntToStr(pDlg->rdoExamKind->ItemIndex) + ",'"
                        + DateToStr(pDlg->dtpExamDate->Date) + "','"
                        + TimeToStr(pDlg->dtpExamTime->Time) + "',"
                        + IntToStr(pDlg->rdoExamResult->ItemIndex) + ",'"
                        + pDlg->mmoOpinon->Text + "','"
                        +  pDlg->mmoRemark->Text + "',"
                        + gLogonInf.m_strOptId + ")");


        qryEx->ExecSQL();
        qryEx->Prepared = false;
        dmMain->qryExam->Close();
        dmMain->qryExam->Open();

    }
    delete pDlg;
}
#endif
//---------------------------------------------------------------------------







void __fastcall TfrmMain::btnMedicalAddClick(TObject *Sender)
{
    if (pcRecord->ActivePageIndex == 0)
    {
        miAddMedicalClick(miAddMedical);
    }
    else
    {
        miAddExamClick(miAddExam);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmMain::btnMedicalRemoveClick(TObject *Sender)
{
    if (pcRecord->ActivePageIndex == 0)
    {
        miDeleMedicalClick(miDeleMedical);
    }
    else
    {
        miDeleExamClick(miDeleExam);
    }

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


void __fastcall TfrmMain::miDeleMedicalClick(TObject *Sender)
{
    if (dmMain->qryMedical->RecordCount < 1)
    {
        return;
    }
    AnsiString strConfirm;
    strConfirm.sprintf("真的删除%s的就诊记录吗?", dmMain->qryClientInfo->FieldByName("Name")->AsString);
    if (IDNO == Msg(Handle, strConfirm.c_str(), "提示", MB_YESNO | MB_ICONQUESTION))
    {
        return;
    }

    AnsiString strDelId = dmMain->qryMedical->FieldByName("Id")->AsString;

    dmMain->qrySQLPlus->Close();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from Medical where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from Drug where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from Injection where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from SickLeave where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from Oxygen where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qrySQLPlus->SQL->Clear();
    dmMain->qrySQLPlus->SQL->Add("delete from Vaccination where id=" + strDelId);
    dmMain->qrySQLPlus->ExecSQL();

    dmMain->qryMedical->Close();
    dmMain->qryMedical->Open();

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






void __fastcall TfrmMain::ExamAfterOpen(TDataSet * DataSet)
{
    AnsiString strDataInfo;
    strDataInfo.sprintf("体检记录 %d ", dmMain->qryExam->RecordCount    );
    stsMain->Panels->Items[4]->Text = strDataInfo;
}

void __fastcall TfrmMain::MedicalAfterOpen(TDataSet * DataSet)
{
    AnsiString strDataInfo;
    strDataInfo.sprintf("就诊记录 %d ", dmMain->qryMedical->RecordCount   );
    stsMain->Panels->Items[5]->Text = strDataInfo;
}

void __fastcall TfrmMain::EmployeeAfterOpen(TDataSet * DataSet)
{
    AnsiString strDataInfo;
    strDataInfo.sprintf("检索到员工 %d 个 当前 %s", dmMain->qryClientInfo->RecordCount,
                        dmMain->qryClientInfo->FieldByName("Name")->AsString.c_str());
    stsMain->Panels->Items[3]->Text = strDataInfo;
}
void __fastcall TfrmMain::btnSearchClick(TObject *Sender)
{
    TADOQuery * qryOpen = dmMain->qryClientInfo;

    qryOpen->Close();

    qryOpen->SQL->Clear();

    AnsiString strValue = edtValue->Text;

    qryOpen->SQL->Add("select Id,Name,(iif(Sex=0,'男','女')) as Sex,"
                      "Birth,PlaceOfBirth,MaritalStatus,Profession,Department,"
                      "SuprName,EmployeeNo,Height,Weight,Zip,Addr,Tele,EmergencyName,"
                      "EmergencyTele, Remark from EmployeeInf");


    if (strValue != "")
    {
        if (cboCondition->ItemIndex == 0)
        {

            //if (strValue != "")
            //{
            qryOpen->SQL->Add("where Name like '%" \
                              + strValue + "%'");
            // }
        }
        else if (cboCondition->ItemIndex == 1)
        {
            qryOpen->SQL->Add(" where Id = "
                              "(select EmployeeId from Medical where Format(MedicalDate, 'YYYY-MM-DD') like '%"
                              + strValue + "%')");

        }
        else if (cboCondition->ItemIndex == 2)
        {
            qryOpen->SQL->Add(" where Id = "
                              "(select EmployeeId from Exam where Format(ExamDate, 'YYYY-MM-DD') like '%"
                              + strValue + "%')");

        }
        m_bSearch = true;

    }
#if _DEBUG
    ShowMessage(qryOpen->SQL->Text);
#endif

    try
    {
        qryOpen->Open();
    }
    catch (Exception & e)
    {}

    DisplayDetail();
}
//---------------------------------------------------------------------------

void __fastcall TfrmMain::edtValueKeyPress(TObject *Sender, char &Key)
{
    if (Key == 0xd)
    {
        btnSearchClick(btnSearch);
    }
}
//---------------------------------------------------------------------------







void __fastcall TfrmMain::grdClientInfCellClick(TColumn *Column)
{
    DisplayDetail();
}
//---------------------------------------------------------------------------


void TfrmMain::DisplayDetail()
{
    AnsiString strCurrClientId;
    if (!dmMain->qryClientInfo->Active || dmMain->qryClientInfo->RecordCount < 1)
    {
        strCurrClientId = "-1 and False";
    }
    else
    {
        strCurrClientId =  dmMain->qryClientInfo->FieldByName("Id")->AsString ;
    }
    dmMain->qryExam->Close();
    dmMain->qryExam->SQL->Clear();

    int nIndex = cboCondition->ItemIndex;

    dmMain->qryExam->SQL->Add("select Id,EmployeeId,ExamDate, ExamTime,"
                              "Switch(ExamKind=0,'入职体检',ExamKind=1,'职业健康检查',ExamKind=2,'应急检查',ExamKind=3,'离岗前检查') as Kind,"
                              "Switch(ExamResult=0,'正常',ExamResult=1,'异常',ExamResult=2,'其他') as Result,"
                              "ExamRemark,ExamOpinon,OptId from Exam");

    if (m_bSearch && nIndex == 2)
    {
        dmMain->qryExam->SQL->Add(" where Format(ExamDate,'YYYY-MM-DD') like '%" + edtValue->Text + "%'");
    }
    else
    {

        dmMain->qryExam->SQL->Add(" where EmployeeId="        +   strCurrClientId);
    }
#if _DEBUG
    ShowMessage(dmMain->qryExam->SQL->Text);
#endif

    dmMain->qryExam->Open();

    dmMain->qryMedical->Close();
    dmMain->qryMedical->SQL->Clear();
    dmMain->qryMedical->SQL->Add("select Id,Format(MedicalDate,'YYYY-MM-DD') as MedicalDate,Complaint,CheckUp,CheckResult,"
                                 "iif(IsDrug=1,'是','否') as IsDrug,"
                                 "iif(IsInjection=1,'是','否') as IsInjection,"
                                 "iif(IsOxygen=1,'是','否') as IsOxygen,"
                                 "iif(IsPregnancy=1,'是','否') as IsPregnancy,"
                                 "iif(IsEkg=1,'是','否') as IsEkg,"
                                 "iif(IsSplint=1,'是','否') as IsSplint,"
                                 "iif(IsVaccination=1,'是','否') as IsVaccination,"
                                 "iif(IsWound=1,'是','否') as IsWound,"
                                 "iif(IsReferral=1,'是','否') as IsReferral,"
                                 "iif(IsSickLeave=1,'是','否') as IsSickLeave,"

                                 "Remark,HealthEdu,OptDate,OptId,EmployeeId "
                                 "from Medical ");
    if (m_bSearch && nIndex == 1)
    {
        dmMain->qryMedical->SQL->Add(" where Format(MedicalDate, 'YYYY-MM-DD') like '%" + edtValue->Text + "%'");
    }
    else
    {
        dmMain->qryMedical->SQL->Add("where EmployeeId="   +       strCurrClientId);
    }
#if _DEBUG

    ShowMessage(dmMain->qryMedical->SQL->Text);
#endif

    dmMain->qryMedical->Open();
    
}
void __fastcall TfrmMain::grdClientInfKeyUp(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if (Key == VK_UP || Key == VK_DOWN)
    {
        DisplayDetail();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmMain::grdClientInfDblClick(TObject *Sender)
{
    ModiEmployeeInf();
    
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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