void CEMWeekSynthesisReport::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CExcel xls; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp, szWhere; int nCol = 0, nRow = 0; int nTotal[12], nTemp = 0; szSQL = GetQueryString(); int nCount = rs.ExecSQL(szSQL); if (nCount <= 0) { ShowMessage(150, MB_ICONSTOP); return; } xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 30); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(2, 10); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 10); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 10); xls.SetColumnWidth(7, 10); xls.SetColumnWidth(8, 10); xls.SetColumnWidth(9, 10); xls.SetColumnWidth(10, 10); xls.SetColumnWidth(11, 13); CellFormat df(&xls), hf(&xls), nf(&xls); df.SetItalic(true); df.SetCellStyle(FMT_TEXT | FMT_CENTER); hf.SetBold(true); hf.SetCellStyle(FMT_TEXT | FMT_CENTER); nf.SetCellStyle(FMT_NUMBER1); //Header xls.SetCellMergedColumns(nCol, nRow, 3); xls.SetCellMergedColumns(nCol, nRow + 1, 3); xls.SetCellMergedColumns(nCol, nRow + 2, 11); xls.SetCellMergedColumns(nCol, nRow + 3, 11); xls.SetCellText(nCol, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); TranslateString(_T("Weekly Synthesis Report"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(nCol, nRow + 2, tmpStr, FMT_TEXT | FMT_CENTER, true, 12); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, &df); //Column Header CStringArray arrCol; arrCol.Add(_T("Ph\xF2ng")); arrCol.Add(_T("Qu\xE2n")); arrCol.Add(_T("\x42HYT Qu\xE2n")); arrCol.Add(_T("\x42\x1EA1n")); arrCol.Add(_T("Tr\x1EBB < \x36t")); arrCol.Add(_T("\x43h\xEDnh s\xE1\x63h")); arrCol.Add(_T("\x44\xE2n")); arrCol.Add(_T("\x42HYT kh\xE1\x63")); arrCol.Add(_T("\x42H TNSQ")); arrCol.Add(_T("\x42H Qu\xE2n \x111\x1ED9i")); arrCol.Add(_T("BHYT Qu\xE2n nh\xE2n")); arrCol.Add(_T("BHYT(N\x1EE3 th\x1EBB)")); arrCol.Add(_T("T\x1ED5ng \x63\x1ED9ng")); nRow = 4; for (int i = 0; i < arrCol.GetCount(); i++) { xls.SetCellText(nCol+i, nRow, arrCol.GetAt(i), FMT_TEXT | FMT_CENTER, true, 10); } for (int i = 0; i< 12; i++) { nTotal[i] = 0; } nRow = 5; while (!rs.IsEOF()){ rs.GetValue(_T("roomid"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, nTemp); tmpStr.Format(_T("%d"), nTemp); xls.SetCellText(nCol+i+1, nRow, tmpStr, &nf); nTotal[i] += nTemp; } nRow++; rs.MoveNext(); } TranslateString(_T("Total"), tmpStr); xls.SetCellText(nCol, nRow, tmpStr, FMT_TEXT | FMT_CENTER, true); for (int i = 0; i<12; i++) { tmpStr.Format(_T("%d"), nTotal[i]); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } szWhere.Format(_T(" AND hcr_admitdate BETWEEN cast_string2timestamp('%s') AND cast_string2timestamp('%s')"), m_szFromDate, m_szToDate); if (pMF->GetModuleID() == _T("EM")) szWhere.AppendFormat(_T(" AND hd_enddept = '%s'"), pMF->GetCurrentDepartmentID()); szSQL.Format(_T(" SELECT sum(c1) as c1,") \ _T(" sum(c2) as c2,") \ _T(" sum(c3) as c3,") \ _T(" sum(c4) as c4,") \ _T(" sum(c5) as c5,") \ _T(" sum(c6) as c6,") \ _T(" sum(c7) as c7,") \ _T(" sum(c8) as c8,") \ _T(" sum(c9) as c9,") \ _T(" sum(c10) as c10, ") \ _T(" sum(c11) as c11, ") \ _T(" sum(c12) as c12 ") \ _T(" FROM") \ _T(" (") \ _T(" SELECT") \ _T(" case when hd_object=1 then 1 else 0 end as c1,") \ _T(" case when hd_object=2 then 1 else 0 end as c2,") \ _T(" case when hd_object=8 then 1 else 0 end as c3,") \ _T(" case when hd_object in(6, 9) then 1 else 0 end as c4,") \ _T(" case when hd_object=3 then 1 else 0 end as c5,") \ _T(" case when hd_object=7 then 1 else 0 end as c6,") \ _T(" case when hd_object=4 then 1 else 0 end as c7,") \ _T(" case when hd_object=5 then 1 else 0 end as c8,") \ _T(" case when hd_object=10 then 1 else 0 end as c9,") \ _T(" case when hd_object=11 then 1 else 0 end as c10,") \ _T(" case when hd_object=12 then 1 else 0 end as c11,") \ _T(" 1 as c12 ") \ _T(" FROM hms_doc") \ _T(" LEFT JOIN hms_exam ON (he_docno = hd_docno AND hd_doctor = he_doctor)") \ _T(" LEFT JOIN hms_clinical_record ON(hcr_docno=hd_docno)") \ _T(" WHERE hcr_numinward > 0 %s") \ _T(" ) tbl"), szWhere); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); if (!rs.IsEOF()){ nRow++; xls.SetCellText(nCol, nRow, _T("V\xE0o vi\x1EC7n"), FMT_TEXT | FMT_CENTER, true); for (int i = 0; i< 12; i++) { szTemp.Format(_T("c%d"), i+1); rs.GetValue(szTemp, tmpStr); xls.SetCellText(nCol+i+1, nRow, tmpStr, FMT_NUMBER1, true); } } else { ShowMessage(150, MB_ICONSTOP); return; } xls.Save(_T("Exports\\Bao Cao Tong Hop Tuan C1_1.xls")); }
//Bao cao tong hop su dung dich vu ky thuat theo quu ( mau 21/BHYT) void CHMSInsuraceRepor21aDialog::PrintTonghopsudungdichvukythuatBHYT() { CHMSMainFrame *pMF = (CHMSMainFrame *)AfxGetMainWnd(); UpdateData(true); CReport rpt; CRecord rs(&pMF->m_db); CString tmpStr, szSQL, szDate, szMoney; if(!rpt.Init(_T("Reports/HMS/HF_THONGKETONGHOPDICHVUKYTHUATTHEOQUY.RPT")) ) { return; } StringUpper(pMF->m_CompanyInfo.sc_pname, tmpStr); rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), tmpStr); StringUpper(pMF->m_CompanyInfo.sc_name, tmpStr); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), tmpStr); rpt.GetReportHeader()->SetValue(_T("ObjectGroup"), _T("")); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd, ddmmyyyy), CDate::Convert(m_szToDate, yyyymmdd,ddmmyyyy)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); //Page Header //Report Detail int nIndex = 1; CString szOldLine, szNewLine,szAmount; CReportSection* rptDetail; long double grpCost=0, ttlCost=0, totalCost=0; double cost=0; //nID = 1-PhiKB //nID = 2-Xet nghiem //nID = 3-CDHA //nID = 4-TDCN //nID = 5-PTTT //nID = 6-VTTH //nID = 7-Ky thuat cao CStringArray arrFeeGrp, arrTitle; arrFeeGrp.Add(_T("Test"));arrTitle.Add(_T("A")); arrFeeGrp.Add(_T("Diagnostic image"));arrTitle.Add(_T("B")); arrFeeGrp.Add(_T("Visiting the function rolls"));arrTitle.Add(_T("C")); arrFeeGrp.Add(_T("Surgery - procedures"));arrTitle.Add(_T("D")); arrFeeGrp.Add(_T("Consumables"));arrTitle.Add(_T("E")); arrFeeGrp.Add(_T("High-tech services"));arrTitle.Add(_T("F")); //if (m_bInPatient != 1) //{ // /*Phi kham benh //-----------------------------------------------------------------------------------------------------------------------------*/ // szSQL.Format(_T(" select hfl_name as examname,hfl_unit as unit, ") \ // _T(" sum(soluong) as soluong, ") \ // _T(" insprice,sum(soluong * insprice) as suminsprice") \ // _T(" from (") \ // _T(" select he_docno,he_examtype,hfe_invoiceno as invoiceno, ") \ // _T(" sum(1) as soluong,hfe_insprice as insprice") \ // _T(" from hms_exam ") \ // _T(" left join hms_doc on(hd_docno=he_docno) ") \ // _T(" where hd_object in('1','2') and he_payment ='P'") \ // _T(" group by he_docno,he_examtype,insprice, invoiceno") \ // _T(" ) as tb1 ") \ // _T(" left join hms_fee_invoice on(hfi_docno = he_docno and hfi_type ='P' and invoiceno = hfi_invoiceno) ") \ // _T(" left join hms_fee_list on (hfl_feeid=he_examtype)") \ // _T(" where insprice > 0 and date(hfi_recvdate) between '%s' and '%s' and hfl_inspaid ='Y'") \ // _T(" group by examname,unit, insprice,examname,hfl_unit ") \ // _T(" order by examname;"),m_szFromDate,m_szToDate); // // rs.ExecSQL(szSQL); // if (!rs.IsEOF()) // { // grpCost=ttlCost=cost=ttlCost=0; // nIndex=1; // rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetFaceSize(12); // rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetBold(true); // rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetItalic(false); // rpt.GetGroupHeader(0)->GetItem(_T("Group"))->SetFaceSize(12); // rpt.GetGroupHeader(0)->GetItem(_T("Group"))->SetBold(true); // rpt.GetGroupHeader(0)->GetItem(_T("Group"))->SetItalic(false); // rptDetail = rpt.AddDetail(rpt.GetGroupHeader(0)); // TranslateString(_T("Nh\xF3m ph\xED kh\xE1m \x62\x1EC7nh"), tmpStr); // rptDetail->SetValue(_T("GroupName"),tmpStr ); // rptDetail->SetValue(_T("Group"),_T("E") ); // // while(!rs.IsEOF()) // { // rptDetail = rpt.AddDetail(); // tmpStr.Format(_T("%d"), nIndex++); // rptDetail->SetValue(_T("1"), tmpStr); // rs.GetValue(_T("examname"), tmpStr); // rptDetail->SetValue(_T("2"), tmpStr); // rs.GetValue(_T("soluong"), tmpStr); // rptDetail->SetValue(_T("3"), tmpStr); // rs.GetValue(_T("insprice"), cost); // FormatCurrency(cost, tmpStr); // rptDetail->SetValue(_T("4"), tmpStr); // rs.GetValue(_T("suminsprice"), cost); // grpCost += cost; // FormatCurrency(cost, tmpStr); // rptDetail->SetValue(_T("5"), tmpStr); // // rs.MoveNext(); // } // ttlCost += grpCost; // // // if(ttlCost > 0){ // CString szField, szAmount; // TranslateString(_T("Total Amount"), szAmount); // rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); // rptDetail->SetValue(_T("TotalGroup"), szAmount + _T("(E)")); // FormatCurrency(ttlCost, tmpStr); // rptDetail->SetValue(_T("s5"), tmpStr); // totalCost+=ttlCost; // } // } //} grpCost=ttlCost=cost=ttlCost=0; nIndex=1; int j = 0, nCount = 0, nTemp = 0; BeginWaitCursor(); for (int i = 0; i < arrFeeGrp.GetCount(); i++) { grpCost=ttlCost=cost=ttlCost=0; nIndex=1; j = i+2; szSQL = GetQueryString(j); nCount = rs.ExecSQL(szSQL); if(!rs.IsEOF()) { rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetFaceSize(12); rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetBold(true); rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetItalic(false); rptDetail = rpt.AddDetail(rpt.GetGroupHeader(0)); TranslateString(arrFeeGrp.GetAt(i), tmpStr); rptDetail->SetValue(_T("GroupName"), tmpStr); rptDetail->SetValue(_T("Group"), arrTitle.GetAt(i)); while(!rs.IsEOF()) { rs.GetValue(_T("groupname"), szNewLine); if(szNewLine != szOldLine && !szNewLine.IsEmpty()){ if(grpCost > 0) { TranslateString(_T("Total Child Group"), tmpStr); rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), tmpStr); FormatCurrency(grpCost, tmpStr); rptDetail->SetValue(_T("s5"), tmpStr); ttlCost += grpCost; nIndex=1; grpCost = 0; } rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetFaceSize(10); rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetBold(true); rpt.GetGroupHeader(0)->GetItem(_T("GroupName"))->SetItalic(true); rptDetail = rpt.AddDetail(rpt.GetGroupHeader(0)); rptDetail->SetValue(_T("GroupName"),szNewLine ); szOldLine = szNewLine; } rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%d"), nIndex++); rptDetail->SetValue(_T("1"), tmpStr); rs.GetValue(_T("pcmsname"), tmpStr); rptDetail->SetValue(_T("2"), tmpStr); rs.GetValue(_T("soluong"), tmpStr); rptDetail->SetValue(_T("3"), tmpStr); rs.GetValue(_T("insprice"), cost); FormatCurrency(cost, tmpStr); rptDetail->SetValue(_T("4"), tmpStr); rs.GetValue(_T("suminsprice"), cost); grpCost += cost; FormatCurrency(cost, tmpStr); rptDetail->SetValue(_T("5"), tmpStr); rs.MoveNext(); } if(grpCost > 0){ TranslateString(_T("Total Child Group"), tmpStr); rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), tmpStr); FormatCurrency(grpCost, tmpStr); rptDetail->SetValue(_T("s5"), tmpStr); ttlCost += grpCost; } if(ttlCost > 0){ TranslateString(_T("Total Parent Group"), szAmount); rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), szAmount + _T("(") + arrTitle.GetAt(i) + _T(")")); FormatCurrency(ttlCost, tmpStr); rptDetail->SetValue(_T("S5"), tmpStr); totalCost+=ttlCost; } nTemp += nCount; } } if (nTemp == 0) { ShowMessageBox(_T("No Data."), MB_ICONSTOP); return; } if(totalCost > 0){ TranslateString(_T("Total Amount"), szAmount); rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), szAmount + _T("(A+B+C+D+E+F)")); FormatCurrency(totalCost, tmpStr); rptDetail->SetValue(_T("s5"), tmpStr); } tmpStr = pMF->GetSysDateTime(); szDate.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), tmpStr.Mid(8, 2), tmpStr.Mid(5, 2), tmpStr.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), szDate); MoneyToString(szMoney, tmpStr); rpt.GetReportFooter()->SetValue(_T("SumInWord"), tmpStr); EndWaitCursor(); rpt.PrintPreview(); }
/*------------------------------------------------------------------------------------------------------------------------------ Export To Excell Bao cao tong hop nhap xuat ton kho ------------------------------------------------------------------------------------------------------------------------------*/ void rptDonthuoctonghop::OnExportToXLS(){ CMainFrame_E10 *pMF = (CMainFrame_E10 *) AfxGetMainWnd(); CString tmpStr,szSQL, szWhere, szTemp; CString szType, szTypeName; for (int i=0 ; i<= m_wndType.GetCount(); i++) { if(m_wndType.GetCheck(i)) { m_wndType.SetCurSel(i); if(!szType.IsEmpty()) { szType += _T(","); szTypeName +=_T(", "); } szType.AppendFormat(_T("'%s'"), m_wndType.GetCurrent(0)); szTypeName.AppendFormat(_T("%s"), m_wndType.GetCurrent(1)); } } if(!szType.IsEmpty()) szWhere.AppendFormat(_T(" and mp_producttype in(%s)"), szType); else szTypeName.Format(_T("T\x1EA5t \x63\x1EA3 lo\x1EA1i thu\x1ED1\x63")); if(!m_szGroupKey.IsEmpty()) { szWhere.AppendFormat(_T(" and substr(mp_product_class_id, 1, %d)= '%s' "), m_szGroupKey.GetLength(), m_szGroupKey); } if(str2int(m_szSourceKey) > 0) { szWhere.AppendFormat(_T(" and mpi_resource_id=%d "), str2int(m_szSourceKey)); } if (!m_szStockKey.IsEmpty()) szWhere.AppendFormat(_T(" and expstockid = %d"), ToInt(m_szStockKey)); szSQL.Format(_T(" SELECT ") \ _T(" mp_name as name, ") \ _T(" mpc_name as genericname, ") \ _T(" get_uomname(mp_uom_id) as unit, ") \ _T(" mpi_taxprice as price, ") \ _T(" sum(expqty) as qty,") \ _T(" sum(expqty*mpi_taxprice) as amount") \ _T(" FROM mev") \ _T(" LEFT JOIN m_product_item ON(mpi_product_item_id=sitemid)") \ _T(" LEFT JOIN m_product ON(mpi_product_id=mp_product_id)") \ _T(" LEFT JOIN m_product_class ON(mpc_product_class_id=mp_product_class_id) ") \ _T(" WHERE sitemid > 0 AND iotype = 'PPO' and expdate between cast_string2timestamp('%s') and cast_string2timestamp('%s') %s ") \ _T(" GROUP BY mp_name,mpc_name,mp_uom_id,mpi_taxprice") \ _T(" ORDER BY name,unit"), m_szFromDate, m_szToDate, szWhere); CReportSection* rptDetail=NULL; CRecord rs(&pMF->m_db); double cost = 0; int nItem = 1; rs.ExecSQL(szSQL); if(rs.IsEOF()){ ShowMessage(150, MB_ICONSTOP); return ; } CExcel xls; xls.CreateSheet(1); xls.SetWorksheet(0); CellFormat df(&xls), cf(&xls), hf(&xls); df.SetItalic(true); df.SetCellStyle(FMT_TEXT | FMT_CENTER); hf.SetBold(true); hf.SetCellStyle(FMT_TEXT | FMT_CENTER); cf.SetFontName(_T("Segoe UI")); xls.SetColumnWidth(0, 5); xls.SetColumnWidth(1, 35); xls.SetColumnWidth(2, 35); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 10); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 15); xls.SetCellMergedColumns(0, 0, 2); xls.SetCellMergedColumns(0, 1, 2); xls.SetCellText(0, 0, pMF->m_szHealthService, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(0, 1, pMF->m_szHospitalName, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellMergedColumns(0, 2, 7); TranslateString(_T("General Prescription"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(0, 2, tmpStr,FMT_TEXT | FMT_CENTER, true, 12); xls.SetCellMergedColumns(0, 3, 7); tmpStr.Format(_T("T\x1EEB ngày %s \x111\x1EBFn ngày %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmm, ddmmyyyy|hhmm), CDateTime::Convert(m_szToDate, yyyymmdd|hhmm, ddmmyyyy|hhmm)); xls.SetCellText(0, 3, tmpStr, &df); int nRow = 3; if (!m_szStockKey.IsEmpty()) { nRow++; tmpStr.Format(_T("T\x1EEB kho: %s"), m_wndStock.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szTypeKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Lo\x1EA1i: %s"), m_wndType.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szGroupKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Nhóm: %s"), m_wndGroup.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } if(!m_szSourceKey.IsEmpty()) { nRow++; tmpStr.Format(_T("Ngu\x1ED3n: %s"), m_wndSource.GetCurrent(1)); xls.SetCellMergedColumns(0, nRow, 7); xls.SetCellText(0, nRow, tmpStr, &cf); } nRow++; xls.SetCellText(0, nRow, _T("STT"), &hf); xls.SetCellText(1, nRow, _T("Tên thu\x1ED1\x63/ HL"), &hf); xls.SetCellText(2, nRow, _T("T\xEAn ho\x1EA1t \x63h\x1EA5t"), &hf); xls.SetCellText(3, nRow, _T("\x110\x1A1n v\x1ECB"), &hf); xls.SetCellText(4, nRow, _T("\x110\x1A1n giá"), &hf); xls.SetCellText(5, nRow, _T("S\x1ED1 l\x1B0\x1EE3ng"), &hf); xls.SetCellText(6, nRow, _T("Th\xE0nh ti\x1EC1n"), &hf); double Amount=0.0, ttCost =0.0; while(!rs.IsEOF()) { //rs.GetValue(_T("expinvoice"), szNewLine); //if(szNewLine != szOldLine && !szNewLine.IsEmpty()) //{ // nRow++; // CString szField, szAmount; // xls.SetCellText(1, nRow, szNewLine, FMT_TEXT,true); // rs.GetValue(_T("iotype"), tmpStr); // xls.SetCellText(2,nRow,pMF->GetSelectionString(_T("pms_export_type"), tmpStr),FMT_TEXT,true); // rs.GetValue(_T("expdate"), tmpStr); // xls.SetCellText(3, nRow, CDate::Convert(tmpStr,yyyymmdd,ddmmyyyy), FMT_DATE,true); // rs.GetValue(_T("deptid"), tmpStr); // xls.SetCellText(4,nRow,tmpStr,FMT_TEXT, true); // if (grpCost >0) // { // tmpStr.Format(_T("%.2f"), grpCost); // xls.SetCellText(6,nRow-nItem,tmpStr,FMT_NUMBER1,true); // ttCost += grpCost; // } // szOldLine = szNewLine; // nItem=1; // grpCost= 0; //} nRow ++; tmpStr.Format(_T("%d"), nItem++); xls.SetCellText(0,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("name"), tmpStr); xls.SetCellText(1,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("genericname"), tmpStr); xls.SetCellText(2,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("unit"), tmpStr); xls.SetCellText(3,nRow,tmpStr, FMT_TEXT); rs.GetValue(_T("price"), tmpStr); xls.SetCellText(4,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("qty"), tmpStr); xls.SetCellText(5,nRow,tmpStr, FMT_NUMBER1); rs.GetValue(_T("amount"), Amount); ttCost +=Amount; tmpStr.Format(_T("%.2f"), Amount); xls.SetCellText(6,nRow,tmpStr, FMT_NUMBER1); rs.MoveNext(); } //if (grpCost >0) //{ nRow++; // tmpStr.Format(_T("%.2f"), grpCost); // xls.SetCellText(6,nRow-nItem,tmpStr,FMT_NUMBER1,true); // ttCost += grpCost; //} if (ttCost >0) { nRow++; xls.SetCellText(1,nRow,_T("T\x1ED5ng ti\x1EC1n:"), FMT_TEXT,true); tmpStr.Format(_T("%.2f"), ttCost); xls.SetCellText(6,nRow,tmpStr,FMT_NUMBER1,true); } xls.Save(_T("Exports\\Don Thuoc Tong Hop.XLS")); }
void RMPrintReceptionReceipt(CString szDept, long nDocumentNo, int nReceptIdx, CString szPrintHema){ CHMSMainFrame *pMF = (CHMSMainFrame *)AfxGetMainWnd(); static CReport rpt; CString szSQL, tmpStr; CRecord rs(&pMF->m_db); if(!rpt.Init(_T("Reports/HMS/HR_EXAMINATIONSHEET.RPT")) ) return; szSQL.Format(_T(" SELECT hd_patientno as patientno, ") \ _T(" hd_docno as docno,") \ _T(" trim(hp_surname||' '||hp_midname||' '||hp_firstname) as pname,") \ _T(" hp_birthdate as birthdate,") \ _T(" hms_getage(date(hd_admitdate), hp_birthdate) as age,") \ _T(" hp_sex as sexid,") \ _T(" sys_sel_getname('sys_sex', hp_sex) as sex,") \ _T(" hp_occupation as occupationid,") \ _T(" sys_sel_getname('sys_occupation', cast(hp_occupation as text)) as occupation,") \ _T(" hp_dtladdr as detailaddress,") \ _T(" hp_provid as provid,") \ _T(" (select distinct sp_name from sys_prov where sp_id=hp_provid) as provill,") \ _T(" hp_distid as distid,") \ _T(" (select distinct sd_name from sys_dist where sd_provid=hp_provid and sd_id=hp_distid) as district,") \ _T(" hp_villid as villid,") \ _T(" (select distinct sv_name from sys_vill where sv_provid=hp_provid and sv_distid=hp_distid and sv_id=hp_villid) as village,") \ _T(" hp_workplaceid as workplaceid,") \ _T(" hp_workplace as workplace,") \ _T(" hd_object as objectid,") \ _T(" (SELECT distinct ho_desc FROM hms_object WHERE ho_id=hd_object) as objectname,") \ _T(" hd_cardno as cardno,") \ _T(" hd_cardidx as cardidx,") \ _T(" hc_regdate as regdate,") \ _T(" hc_expdate as expdate,") \ _T(" (SELECT distinct hfl_name FROM hms_fee_list WHERE hfl_feeid=he_examtype) as examtype,") \ _T(" (SELECT distinct hrl_name FROM hms_roomlist WHERE hrl_deptid=he_deptid AND hrl_id=he_roomid) as roomname, ") \ _T(" he_receptno as receptno, ") \ _T(" hfe_unitprice as amount, ") \ _T(" hd_transplace as transplace, ") \ _T(" hd_transdiagn as transdiagn, ") _T(" hd_xobject as xobject, ") \ _T(" hd_xcardno as xcardno, ") \ _T(" hd_xissuedate as xissuedate ") \ _T(" FROM hms_patient") \ _T(" LEFT JOIN hms_doc ON(hd_patientno=hp_patientno)") \ _T(" LEFT JOIN hms_card ON(hc_patientno=hd_patientno and hc_cardno=hd_cardno and hc_idx=hd_cardidx) ") \ _T(" LEFT JOIN hms_exam ON(he_docno=hd_docno)") \ _T(" WHERE trim(he_deptid)='%s' AND he_docno=%ld AND he_receptidx=%d"), szDept, nDocumentNo, nReceptIdx); //_fmsg(_T("%s"), szSQL); int ret = rs.ExecSQL(szSQL); if(rs.IsEOF()) return; //Report Header rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), pMF->m_CompanyInfo.sc_name); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), pMF->m_CompanyInfo.sc_pname); tmpStr = pMF->GetSysDateTime(); CString printDate; printDate.Format(rpt.GetReportHeader()->GetValue(_T("PrintDate")),tmpStr.Mid(11, 5), tmpStr.Mid(8, 2), tmpStr.Mid(5, 2), tmpStr.Left(4)); rpt.GetReportHeader()->SetValue(_T("PrintDate"), printDate); rpt.GetReportHeader()->SetValue(_T("PatientNo"), rs.GetValue(_T("patientno"))); rpt.GetReportHeader()->SetValue(_T("DocumentNo"), rs.GetValue(_T("docno"))); StringUpper(rs.GetValue(_T("pname")), tmpStr); rpt.GetReportHeader()->SetValue(_T("PatientName"), tmpStr); tmpStr.Empty(); rpt.GetReportHeader()->SetValue(_T("Age"), rs.GetValue(_T("age"))); rpt.GetReportHeader()->SetValue(_T("Sex"), rs.GetValue(_T("sex"))); rpt.GetReportHeader()->SetValue(_T("Occupation"), rs.GetValue(_T("occupation"))); tmpStr.Format(_T("%s - %s - %s"), rs.GetValue(_T("village")), rs.GetValue(_T("district")), rs.GetValue(_T("provill"))); rpt.GetReportHeader()->SetValue(_T("Address"), tmpStr); rs.GetValue(_T("detailaddress"), tmpStr); rpt.GetReportHeader()->SetValue(_T("DetailAddress"), tmpStr); tmpStr.Empty(); rpt.GetReportHeader()->SetValue(_T("WorkPlace"), rs.GetValue(_T("workplace"))); rpt.GetReportHeader()->SetValue(_T("ExamRoom"), rs.GetValue(_T("roomname"))); rpt.GetReportHeader()->SetValue(_T("SheetNo"), rs.GetValue(_T("receptno"))); rpt.GetReportHeader()->SetValue(_T("ExamType"), rs.GetValue(_T("examtype"))); rpt.GetReportHeader()->SetValue(_T("Money"), rs.GetValue(_T("amount"))); rpt.GetReportHeader()->SetValue(_T("ObjectName"), rs.GetValue(_T("objectname"))); rs.GetValue(_T("cardno"), tmpStr); rpt.GetReportHeader()->SetValue(_T("CardNo"), tmpStr); rs.GetValue(_T("xobject"), tmpStr); if(szPrintHema == _T("Y") && tmpStr == _T("H")){ rpt.GetReportHeader()->SetValue(_T("Hema"), _T("HEMA")); } rpt.GetReportHeader()->SetValue(_T("RegDate"), CDate::Convert(rs.GetValue(_T("regdate")))); rpt.GetReportHeader()->SetValue(_T("ExpDate"), CDate::Convert(rs.GetValue(_T("expdate")))); rpt.GetReportHeader()->SetValue(_T("TransferHospital"), rs.GetValue(_T("transplace"))); rpt.GetReportHeader()->SetValue(_T("TransferDiagnosis"), rs.GetValue(_T("transdiagn"))); tmpStr.Empty(); rpt.GetReportHeader()->SetValue(_T("Relason"), tmpStr); rs.GetValue(_T("xcardno"), tmpStr); rpt.GetReportHeader()->SetValue(_T("xcardno"), tmpStr); rs.GetValue(_T("xissuedate"), tmpStr); rpt.GetReportHeader()->SetValue(_T("xissuedate"), CDate::Convert(tmpStr)); //Page Header //Report Detail CReportSection* rptDetail = rpt.GetDetail(0); //Page Footer //Report Footer rpt.Print();; }
void CTMOperationFosteringList::OnExportSelect(){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szMoneyInWord, szTemp; int nIdx = 1, nRow = 0; double nAmount = 0, nTotalAmount = 0; CStringArray arrCol; szSQL = GetQueryString(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { AfxMessageBox(_T("No Data.")); return; } CExcel xls; xls.CreateSheet(1); xls.SetWorksheet(0); //Header xls.SetColumnWidth(0, 5); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(3, 20); xls.SetColumnWidth(4, 20); xls.SetColumnWidth(5, 20); xls.SetColumnWidth(6, 30); xls.SetColumnWidth(7, 10); xls.SetColumnWidth(8, 15); xls.SetColumnWidth(9, 15); xls.SetColumnWidth(10, 15); xls.SetColumnWidth(11, 15); xls.SetCellMergedColumns(0, 0, 3); xls.SetCellMergedColumns(0, 1, 3); xls.SetCellMergedColumns(0, 2, 3); xls.SetCellMergedColumns(0, 3, 11); xls.SetCellMergedColumns(0, 4, 11); xls.SetCellText(0, 0, pMF->m_CompanyInfo.sc_pname, 4098, true); xls.SetCellText(0, 1, pMF->m_CompanyInfo.sc_name, 4098, true); xls.SetCellText(0, 2, pMF->GetCurrentDepartmentName(), 4098, true); TranslateString(_T("Operation Fostering List"), szTemp); StringUpper(szTemp, tmpStr); xls.SetCellText(0, 3, tmpStr, 4098, true, 12); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), m_szFromDate, m_szToDate); xls.SetCellText(0, 4, tmpStr, 4098, true); arrCol.Add(_T("STT")); arrCol.Add(_T("S\x1ED1 h\x1ED3 s\x1A1")); arrCol.Add(_T("S\x1ED1 BA")); arrCol.Add(_T("H\x1ECD v\xE0 t\xEAn")); arrCol.Add(_T("N\x103m sinh")); arrCol.Add(_T("Th\x1EBB/Qu\xE2n h\xE0m")); arrCol.Add(_T("\x44\x61nh m\x1EE5\x63 PTTT")); arrCol.Add(_T("T\xEAn PTTT")); arrCol.Add(_T("Ph\xE2n lo\x1EA1i PT, TT")); //arrCol.Add(_T("K\xEDp th\x1EF1\x63 hi\x1EC7n")); arrCol.Add(_T("\x43h\xEDnh")); arrCol.Add(_T("Ph\x1EE5")); arrCol.Add(_T("Gi\xFAp vi\x1EC7\x63")); arrCol.Add(_T("S\x1ED1 l\x1B0\x1EE3ng")); arrCol.Add(_T("S\x1ED1 ti\x1EC1n")); for (int i = 0; i < arrCol.GetCount(); i++) xls.SetCellText(i, 5, arrCol.GetAt(i), 4098, true); //Detail nRow = 6; while (!rs.IsEOF()) { xls.SetCellText(0, nRow, int2str(nIdx++), FMT_TEXT | FMT_RIGHT); xls.SetCellText(1, nRow, rs.GetValue(_T("doc_no")), 4098); xls.SetCellText(2, nRow, rs.GetValue(_T("record_no")), 4098); xls.SetCellText(3, nRow, rs.GetValue(_T("patient_name")), FMT_TEXT); xls.SetCellText(4, nRow, rs.GetValue(_T("yob")), 4098); xls.SetCellText(5, nRow, rs.GetValue(_T("extra_info")), FMT_TEXT); xls.SetCellText(6, nRow, rs.GetValue(_T("operation_name1")), FMT_TEXT); xls.SetCellText(7, nRow, rs.GetValue(_T("operation_name")), FMT_TEXT); xls.SetCellText(8, nRow, rs.GetValue(_T("operation_type")), 4098); xls.SetCellText(9, nRow, rs.GetValue(_T("practitioner")), FMT_TEXT); xls.SetCellText(10, nRow, rs.GetValue(_T("assistant")), FMT_TEXT); xls.SetCellText(11, nRow, rs.GetValue(_T("anethetist")), FMT_TEXT); xls.SetCellText(12, nRow, rs.GetValue(_T("quantity")), FMT_NUMBER1); rs.GetValue(_T("amount"), nAmount); nTotalAmount += nAmount; xls.SetCellText(13, nRow, double2str(nAmount), FMT_NUMBER1); nRow++; rs.MoveNext(); } if (nTotalAmount > 0) { xls.SetCellMergedColumns(0, nRow, 13); xls.SetCellText(0, nRow, _T("\x43\x1ED9ng"), 4098, true); xls.SetCellText(13, nRow, double2str(nTotalAmount), FMT_NUMBER1); nRow++; MoneyToString(double2str(nTotalAmount), szMoneyInWord); tmpStr.Format(_T("S\x1ED1 ti\x1EC1n \x62\x1EB1ng \x63h\x1EEF: %s"), szMoneyInWord); xls.SetCellMergedColumns(0, nRow, 13); xls.SetCellText(0, nRow, tmpStr, FMT_TEXT, true); } xls.Save(_T("Exports\\Danh sach de nghi boi duong PTTT.xls")); }
/*void CFMTempSendPatientListByDay::OnStaffAddNew(){ CMainFrame *pMF = (CMainFrame*) AfxGetMainWnd(); } */ void CFMTempSendPatientListByDay::OnPrintSelect(){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(TRUE); CReport rpt; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp; CString szSysDate; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessageBox(_T("No Data"), MB_OK | MB_ICONERROR); return; } if (!rpt.Init(_T("Reports/HMS/HF_DANHSACHBENHNHANTAMGUI_1.RPT"))) return; StringUpper(pMF->m_CompanyInfo.sc_pname, tmpStr); rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), tmpStr); StringUpper(pMF->m_CompanyInfo.sc_name, tmpStr); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), tmpStr); rpt.GetReportHeader()->SetValue(_T("Department"), pMF->GetCurrentDepartmentName()); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd | hhmm, ddmmyyyy | hhmm), CDateTime::Convert(m_szToDate, yyyymmdd | hhmm, ddmmyyyy | hhmm)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); CReportSection *rptDetail; CString szOldLine, szNewLine; CString szObjectNames; long double nGroupTotal = 0, nTotal = 0; double nCost; int nIndex = 1; szObjectNames.Empty(); CStringArray strArr; bool bCheckServ = false, bCheckIns = false; strArr.Add(_T("\x64\x1ECB\x63h v\x1EE5")); strArr.Add(_T("\x42\x110 - \x43S - \x42H")); while (!rs.IsEOF()) { rs.GetValue(_T("receiptdate"), tmpStr); szNewLine = CDate::Convert(tmpStr, yyyymmdd, ddmmyyyy); if (!szNewLine.IsEmpty() && szNewLine != szOldLine) { if (nGroupTotal > 0) { rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), _T("\x43\x1ED9ng ng\xE0y :")); FormatCurrency(nGroupTotal, tmpStr); rptDetail->SetValue(_T("TotalAmount"), tmpStr); nTotal += nGroupTotal; nGroupTotal = 0; } szOldLine = szNewLine; } rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%d"), nIndex++); rptDetail->SetValue(_T("1"), tmpStr); rs.GetValue(_T("pname"), tmpStr); rptDetail->SetValue(_T("2"), tmpStr); rs.GetValue(_T("docno"), tmpStr); rptDetail->SetValue(_T("3"), tmpStr); rs.GetValue(_T("recordno"), tmpStr); rptDetail->SetValue(_T("4"), tmpStr); rs.GetValue(_T("dept"), tmpStr); rptDetail->SetValue(_T("5"), tmpStr); if (nGroupTotal == 0) { rs.GetValue(_T("receiptdate"), tmpStr); rptDetail->SetValue(_T("6"), CDate::Convert(tmpStr, yyyymmdd, ddmmyyyy)); } rs.GetValue(_T("deposit"), nCost); nGroupTotal += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("7"), tmpStr); rs.MoveNext(); } if (nGroupTotal > 0) { rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); rptDetail->SetValue(_T("TotalGroup"), _T("\x43\x1ED9ng kho\x61")); FormatCurrency(nGroupTotal, tmpStr); rptDetail->SetValue(_T("TotalAmount"), tmpStr); nTotal += nGroupTotal; nGroupTotal = 0; } if (nTotal > 0) { FormatCurrency(nTotal, tmpStr); rpt.GetReportFooter()->SetValue(_T("Total"), tmpStr + _T(" \x111\x1ED3ng")); CString szMoney; tmpStr.Replace(_T("."), _T("")); MoneyToString(tmpStr, szMoney); rpt.GetReportFooter()->SetValue(_T("SumInWords"), szMoney + _T(" \x111\x1ED3ng")); } szSysDate = pMF->GetSysDate(); tmpStr.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), szSysDate.Right(2), szSysDate.Mid(5, 2), szSysDate.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), tmpStr); EndWaitCursor(); rpt.PrintPreview(); }
// Intended to be a mad fast parser. It's not THAT fast currently, there's still // things to optimize, but meh. int RequestHeader::ParseHttpHeader(const char *buffer) { if (first_header_) { // Step 1: Method first_header_ = false; if (!memcmp(buffer, "GET ", 4)) { method = GET; buffer += 4; } else if (!memcmp(buffer, "HEAD ", 5)) { method = HEAD; buffer += 5; } else if (!memcmp(buffer, "POST ", 5)) { method = POST; buffer += 5; } else { method = UNSUPPORTED; status = 501; return -1; } SkipSpace(&buffer); // Step 2: Resource, params (what's after the ?, if any) const char *endptr = strchr(buffer, ' '); const char *q_ptr = strchr(buffer, '?'); int resource_name_len; if (q_ptr) resource_name_len = q_ptr - buffer; else resource_name_len = endptr - buffer; if (!resource_name_len) { status = 400; return -1; } resource = new char[resource_name_len + 1]; memcpy(resource, buffer, resource_name_len); resource[resource_name_len] = '\0'; if (q_ptr) { int param_length = endptr - q_ptr - 1; params = new char[param_length + 1]; memcpy(params, q_ptr + 1, param_length); params[param_length] = '\0'; } if (strstr(buffer, "HTTP/")) type = FULL; else type = SIMPLE; return 0; } // We have a real header to parse. const char *colon = strchr(buffer, ':'); if (!colon) { status = 400; return -1; } // The header is formatted as key: value. int key_len = colon - buffer; char *key = new char[key_len + 1]; strncpy(key, buffer, key_len); key[key_len] = 0; StringUpper(key, key_len); // Go to after the colon to get the value. buffer = colon + 1; SkipSpace(&buffer); int value_len = (int)strlen(buffer); if (!strcmp(key, "USER-AGENT")) { user_agent = new char[value_len + 1]; memcpy(user_agent, buffer, value_len + 1); ILOG("user-agent: %s", user_agent); } else if (!strcmp(key, "REFERER")) { referer = new char[value_len + 1]; memcpy(referer, buffer, value_len + 1); } else if (!strcmp(key, "CONTENT-LENGTH")) { content_length = atoi(buffer); ILOG("Content-Length: %i", (int)content_length); } delete [] key; return 0; }
/*void CFMDischargeDepositUnpaidReport::OnClerkAddNew(){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); } */ void CFMDischargeDepositUnpaidReport::OnPrintSelect() { CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CReport rpt; CReportSection *rptDetail; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp, szSysDate, szOldLine, szNewLine, szObjectNames; bool bCheckServ = false, bCheckIns = false; long double nGroupTotal[10]; long double nTotal[10]; double nCost; int nIndex = 1; CStringArray strArr; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessageBox(_T("No Data"), MB_OK | MB_ICONERROR); return; } if (!rpt.Init(_T("Reports/HMS/HF_DANHSACHBENHNHANTAMGUIDARAVIENCHUATHANHTOAN.RPT"))) return; rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), pMF->m_CompanyInfo.sc_pname); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), pMF->m_CompanyInfo.sc_name); rpt.GetReportHeader()->SetValue(_T("Department"), pMF->GetCurrentDepartmentName()); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmm, ddmmyyyy|hhmm), CDateTime::Convert(m_szToDate, yyyymmdd|hhmm, ddmmyyyy|hhmm)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); for (int i = 0; i < 10; i++) { nGroupTotal[i] = 0; nTotal[i] = 0; } szObjectNames.Empty(); strArr.Add(_T("\x64\x1ECB\x63h v\x1EE5")); strArr.Add(_T("\x42\x110 - \x43S - \x42H")); for (int i = 0; i < m_wndObjectList.GetItemCount(); i++) { if (m_wndObjectList.GetCheck(i)) { tmpStr = m_wndObjectList.GetItemText(i, 2); if (tmpStr == _T("S")) bCheckServ = true; else bCheckIns = true; } } if (bCheckServ || bCheckIns) { if (bCheckServ) szObjectNames.AppendFormat(_T("%s"), strArr[0]); if (bCheckIns) { if (!szObjectNames.IsEmpty()) szObjectNames += _T(", "); szObjectNames.AppendFormat(_T("%s"), strArr[1]); } TranslateString(_T("Object"), szTemp); tmpStr.Format(_T("%s %s"), szTemp, szObjectNames); rpt.GetReportHeader()->SetValue(_T("Object"), tmpStr); } if (!bCheckIns && !bCheckServ) rpt.GetReportHeader()->SetValue(_T("Object"), _T("T\x1EA5t \x63\x1EA3 \x63\xE1\x63 \x111\x1ED1i t\x1B0\x1EE3ng")); while (!rs.IsEOF()) { rs.GetValue(_T("dept"), szNewLine); if (!szNewLine.IsEmpty() && szNewLine != szOldLine) { if (nGroupTotal[4] > 0) { rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); //TranslateString(_T("\x43\x1ED9ng kho\x61"), tmpStr); rptDetail->SetValue(_T("TotalGroup"), _T("\x43\x1ED9ng kho\x61")); for (int i = 4; i < 10; i++) { FormatCurrency(nGroupTotal[i], tmpStr); szTemp.Format(_T("s%d"), i+1); rptDetail->SetValue(szTemp, tmpStr); nTotal[i] += nGroupTotal[i]; nGroupTotal[i] = 0; } } /*rptDetail = rpt.AddDetail(rpt.GetGroupHeader(1)); rs.GetValue(_T("objname"), tmpStr); rptDetail->SetValue(_T("GroupName"), tmpStr); rs.GetValue(_T("objid"), szObject);*/ szOldLine = szNewLine; } rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%d"), nIndex++); rptDetail->SetValue(_T("1"), tmpStr); rs.GetValue(_T("pname"), tmpStr); rptDetail->SetValue(_T("2"), tmpStr); rs.GetValue(_T("recordno"), tmpStr); rptDetail->SetValue(_T("3"), tmpStr); if (nGroupTotal[4] == 0) { rs.GetValue(_T("dept"), tmpStr); rptDetail->SetValue(_T("4"), tmpStr); } rs.GetValue(_T("deposit"), nCost); nGroupTotal[4] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("5"), tmpStr); rs.GetValue(_T("polamt"), nCost); nGroupTotal[5] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("6"), tmpStr); rs.GetValue(_T("discountamt"), nCost); nGroupTotal[6] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("7"), tmpStr); rs.GetValue(_T("feeamt"), nCost); nGroupTotal[7] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("8"), tmpStr); rs.GetValue(_T("income"), nCost); nGroupTotal[8] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("9"), tmpStr); rs.GetValue(_T("outlay"), nCost); nGroupTotal[9] += nCost; FormatCurrency(nCost, tmpStr); rptDetail->SetValue(_T("10"), tmpStr); rs.MoveNext(); } if (nGroupTotal[4] > 0) { rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); //TranslateString(_T("\x43\x1ED9ng kho\x61"), tmpStr); rptDetail->SetValue(_T("TotalGroup"), _T("\x43\x1ED9ng kho\x61")); for (int i = 4; i < 10; i++) { FormatCurrency(nGroupTotal[i], tmpStr); szTemp.Format(_T("s%d"), i+1); rptDetail->SetValue(szTemp, tmpStr); nTotal[i] += nGroupTotal[i]; nGroupTotal[i] = 0; } } if (nTotal[4] > 0) { rptDetail = rpt.AddDetail(rpt.GetGroupFooter(1)); //TranslateString(_T("T\x1ED5ng \x63\x1ED9ng"), tmpStr); rptDetail->SetValue(_T("TotalGroup"), _T("T\x1ED5ng \x63\x1ED9ng")); for (int i = 4; i < 10; i++) { FormatCurrency(nTotal[i], tmpStr); szTemp.Format(_T("s%d"), i+1); rptDetail->SetValue(szTemp, tmpStr); } } if (!m_szClerkKey.IsEmpty()) { tmpStr = m_wndClerk.GetCurrent(1); StringUpper(tmpStr, szTemp); rpt.GetReportFooter()->SetValue(_T("ReceiverBy"), szTemp); } szSysDate = pMF->GetSysDate(); tmpStr.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), szSysDate.Right(2), szSysDate.Mid(5, 2), szSysDate.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), tmpStr); EndWaitCursor(); rpt.PrintPreview(); }
void CEMMonthlyDrugIncome::OnPrintSelect(){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); CReport rpt; CString tmpStr, szSQL, szWhere; CRecord rs(&pMF->m_db); if(!rpt.Init(_T("Reports/HMS/HE_THONGKEBENHNHANCAPTUONG.RPT")) ) return ; BeginWaitCursor(); UpdateData(true); szSQL = GetQueryString(); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); StringUpper(pMF->m_CompanyInfo.sc_name, tmpStr); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), tmpStr); StringUpper(pMF->m_CompanyInfo.sc_pname, tmpStr); rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), tmpStr); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); rs.GetValue(_T("tenkhoa"), tmpStr); rpt.GetReportHeader()->SetValue(_T("Department"), tmpStr); int nIndex = 1; CReportSection* rptDetail; int c1 = 0; rs.GetValue(_T("hd_object"), tmpStr); if(tmpStr == _T("1")) { if(!tmpStr.IsEmpty()) c1++; } rpt.GetReportHeader()->SetValue(_T("quan"), tmpStr); while(!rs.IsEOF()) { rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%ld"), nIndex ++); rptDetail->SetValue(_T("0"), tmpStr); rs.GetValue(_T("docno"),tmpStr); rptDetail->SetValue(_T("1"), tmpStr); rs.GetValue(_T("tenBN"),tmpStr); rptDetail->SetValue(_T("2"), tmpStr); rs.GetValue(_T("tencapbac"), tmpStr); rptDetail->SetValue(_T("3"), tmpStr); rs.GetValue(_T("chucvu"), tmpStr); rptDetail->SetValue(_T("4"), tmpStr); rs.GetValue(_T("donvi"), tmpStr); rptDetail->SetValue(_T("5"), tmpStr); rs.GetValue(_T("tendoituong"), tmpStr); rptDetail->SetValue(_T("6"), tmpStr); rs.GetValue(_T("icd10"), tmpStr); rptDetail->SetValue(_T("7"), tmpStr); rs.GetValue(_T("benhchinh"), tmpStr); rptDetail->SetValue(_T("8"), tmpStr); rs.MoveNext(); } CString szDate; tmpStr = pMF->GetSysDate(); szDate.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), tmpStr.Mid(8, 2), tmpStr.Mid(5, 2), tmpStr.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), szDate); EndWaitCursor(); rpt.PrintPreview(); }
void CFMGeneralInsuranceOutlayList::OnPrintSelect(){ CMainFrame_E10 *pMF = (CMainFrame_E10*) AfxGetMainWnd(); UpdateData(TRUE); CReport rpt; CRecord rs(&pMF->m_db); CString szSQL, tmpStr, szTemp; CString szSysDate; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessageBox(_T("No Data"), MB_OK | MB_ICONERROR); return; } if (!rpt.Init(_T("Reports/HMS/HF_BANGKETHCHIBH.RPT"))) return; StringUpper(pMF->m_szHealthService, tmpStr); rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), tmpStr); StringUpper(pMF->m_szHospitalName, tmpStr); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), tmpStr); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd | hhmm, ddmmyyyy | hhmm), CDateTime::Convert(m_szToDate, yyyymmdd | hhmm, ddmmyyyy | hhmm)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); CReportSection *rptDetail; CString szOldLine, szNewLine; CStringArray arrField; long double nTotal[13]; double nCost; int nIndex = 1; for (int i = 0; i < 13; i++) { nTotal[i] = 0; } arrField.Add(_T("deposit_extraction")); arrField.Add(_T("food_fee")); arrField.Add(_T("")); arrField.Add(_T("ins_payment_amount")); arrField.Add(_T("pol_payment_amount")); arrField.Add(_T("total_amount")); arrField.Add(_T("remaining_amount")); arrField.Add(_T("return_amount")); arrField.Add(_T("salary_amount")); arrField.Add(_T("stamp_train_amount")); arrField.Add(_T("holiday_amount")); arrField.Add(_T("other_amount")); arrField.Add(_T("total_payment_amount")); while (!rs.IsEOF()) { rptDetail = rpt.AddDetail(); rs.GetValue(_T("hfe_date"), tmpStr); rptDetail->SetValue(_T("1"), CDate::Convert(tmpStr, yyyymmdd, ddmmyyyy)); for (int j = 0; j < 13; j++) { rs.GetValue(arrField.GetAt(j), nCost); nTotal[j] += nCost; FormatCurrency(nCost, tmpStr); szTemp.Format(_T("%d"), j+2); rptDetail->SetValue(szTemp, tmpStr); } rs.MoveNext(); } if (nTotal[5] > 0) { for (int i = 0; i < 13; i++) { FormatCurrency(nTotal[i], tmpStr); szTemp.Format(_T("s%d"), i + 2); rpt.GetReportFooter()->SetValue(szTemp, tmpStr); } } szSysDate = pMF->GetSysDate(); tmpStr.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), szSysDate.Right(2), szSysDate.Mid(5, 2), szSysDate.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), tmpStr); EndWaitCursor(); rpt.PrintPreview(); }