Медицина » Дипломная работа на тему гастриты

 

Дипломная работа на тему - страница 13

Автор: prOff 17.11.2014, 22:35

/ test2Dlg. H : header file - Дипломная работа на тему

(m_hIcon);

}

void COptim::OnPaint()

{

if (IsIconic())

{

CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);

// Center icon in client rectangle

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon

dc.DrawIcon(x, y, m_hIcon);

}

else

{

CPropertyPage::OnPaint();

/обнови пожалуйста список/

}

}

void COptim::OnSysCommand(UINT nID, LPARAM lParam)

{

CPropertyPage::OnSysCommand(nID, lParam);

}

double COptim::calc(double vls, CString formula)

{

int lb,rb; //left_bracket, right_bracket

CString flag_br = ""; //если занята обрабатывается формула из скобок

CString res,m,a,sub;

int mul,add,oper,end,beg;

CString first,second;

formula.TrimLeft('=');

while(formula != "") {

oper = 0;

if(flag_br == "") {

lb = formula.ReverseFind('(');

if(lb != -1) {

rb = formula.Find(')',lb);

if(formula[lb+1] == '-') {

formula.SetAt(lb,'"');

formula.Delete(lb+1);

formula.SetAt(rb,'"');

continue;

}

else {

flag_br = formula;

formula = formula.Mid(lb+1,rb-lb-1);

flag_br.Delete(lb,rb-lb+1);

}

}

}

m = "/";

mul = formula.FindOneOf(m);

a = "+-";

add = formula.FindOneOf(a);

if(mul != -1) oper = mul;

else if(add != -1) {

oper = add;

}

if(oper) {

sub = formula.Left(oper);

sub.MakeReverse();

end = sub.FindOneOf("/+-");

end == -1?end = sub.GetLength():end;

first = sub.Mid(0,end);

first.MakeReverse();

if(first[0] == '"') {

first.Trim('"');

first.Insert(0,'-');

}

beg = oper - end;

sub = formula.Mid(oper+1);

end = sub.FindOneOf("/+-");

end == -1?end = sub.GetLength():end;

second = sub.Mid(0,end);

if(second[0] == '"') {

second.Trim('"');

second.Insert(0,'-');

}

end += oper;

}else {

first = formula;

beg=0;

end=formula.GetLength();

second = "";

}

if(first[0] == '$') {

sub = first.Right(first.GetLength()-1);

first.Format("%.2f",vls[atoi(sub)-1]);

}

if(second != "" && second[0] == '$') {

sub = second.Right(second.GetLength()-1);

second.Format("%.2f",vls[atoi(sub)-1]);

}

//получаем значение из справочника

if(first[0] == '%') {

CString temp = first.TrimLeft('%');

Crates loc = new Crates(pattern);

ASSERT(loc);

CString strSQL;

strSQL.Format("SELECT FROM rates WHERE (name = '%s');",temp);

loc->Open(Crates::dynaset,(LPCTSTR) strSQL);

temp = loc->m_value;

loc->Close();

delete loc;

if(temp.FindOneOf("%")!=-1) {

temp.TrimRight('%');

first.Format("%.2f",atof(temp)/100.0);

}else first = temp;

}

if(second != "" && second[0] == '%') {

CString temp = second.TrimLeft('%');

Crates loc = new Crates(pattern);

ASSERT(loc);

CString strSQL;

strSQL.Format("SELECT FROM rates WHERE (name = '%s');",temp);

loc->Open(Crates::dynaset,(LPCTSTR) strSQL);

temp = loc->m_value;

loc->Close();

delete loc;

if(temp.FindOneOf("%")!=-1) {

temp.TrimRight('%');

second.Format("%.2f",atof(temp)/100.0);

}else second = temp;

}

if(!oper) return atof(first);

if(atof(second) == 0.0 && formula[oper] == '/') return -9999.9;

switch(formula[oper]) {

case '+': res.Format("%.2f",atof(first)+atof(second));break;

case '-': res.Format("%.2f",atof(first)-atof(second));break;

case '/': res.Format("%.2f",atof(first)/atof(second));break;

case '': res.Format("%.2f",atof(first)atof(second));break;

}

formula.Delete(beg,end-beg+1);

mul = add = -1;

if(formula == "") {

if(flag_br !="") {

formula = flag_br;

if(atof(res)<0) {

res.Delete(0);

res.Insert(0,'"');

res += '"';

}

formula.Insert(lb,res);

flag_br = "";

continue;

}

else return atof(res);

}

if(atof(res)<0) {

res.Delete(0);

res.Insert(0,'"');

res += '"';

}

formula.Insert(beg,res);

}

return 0.0;

}

double COptim::get_basic_data(CString formula, Ctransact rec)

{

int cnt = 0;

rec->MoveFirst();

while(!rec->IsEOF()) {

cnt++;

rec->MoveNext();

}

double in = new double [cnt];

rec->MoveFirst();

for(int x=0;x

in[x] = atof(rec->m_sum);

rec->MoveNext();

}

return calc(in,formula);

}

void COptim::OnCbnSetfocusCombo2()

{

CString top;

int count = 0;

if(bk) {

if(bk->IsOpen()) bk->Close();

delete bk;

bk = NULL;

}

bk = new Cbook(base);

bk->Open(Cbook::dynaset);

bk->MoveFirst();

int cur_pos = cb_top.GetCurSel();

cb_top.ResetContent();

//заполнение верхнего комбобокса значениями пока таблица не закончится

while(!bk->IsEOF()) {

top.Format("%d.%s (№%d)",++count,(LPCSTR)bk->m_name,bk->m_num);

cb_top.AddString((LPCTSTR)top);

bk->MoveNext();

}

cb_top.SetCurSel(cur_pos);

//установка комбобокса на первую строку

bk->Close();

delete bk;

bk = NULL;

}

//Pages.h

#pragma once

#include

#include "Operations.h"

#include "DataRowset.h"

#include "book.h"

#include "transact.h"

#include "rates.h"

#include "afxwin.h"

// CPages dialog

class CPages : public CPropertyPage

{

DECLARE_DYNAMIC(CPages)

public:

CPages();

virtual CPages();

// Dialog Data

enum { IDD = IDD_PAGES };

protected:

virtual void DoDataExchange(CDataExchange pDX); // DDX/DDV support

protected:

HICON m_hIcon;

// Generated message map functions

// virtual BOOL OnInitDialog();

afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

afx_msg void OnPaint();

afx_msg HCURSOR OnQueryDragIcon();

DECLARE_MESSAGE_MAP()

private:

CDatabase work;

COperations ops;

CDataRowset prov;

CDatabase book;

public:

afx_msg void OnDestroy();

CComboBox cm_operations;

afx_msg void OnCbnSelchangeCombo1();

afx_msg void OnCbnSetfocusCombo1();

CStatic var1;

CEdit var2;

CStatic var3;

CEdit var4;

CStatic var5;

CEdit var6;

CStatic var7;

CEdit var8;

private:

int m_active;

CWnd wndw[8];

int choice;

public:

afx_msg void OnBnClickedButton1();

private:

Cbook rwset_book;

Ctransact rwset_trsact;

public:

double calc(double vls, CString formula);

virtual BOOL OnInitDialog();

};

// Pages.cpp : implementation file

//

#include "stdafx.h"

#include "taxa.h"

#include "Pages.h"

#include ".\pages.h"

// CPages dialog

IMPLEMENT_DYNAMIC(CPages, CPropertyPage)

CPages::CPages()

: CPropertyPage(CPages::IDD)

, m_active(0)

, rwset_book(NULL)

, rwset_trsact(NULL)

, ops(NULL)

{

}

CPages::CPages()

{

}

void CPages::DoDataExchange(CDataExchange pDX)

{

CPropertyPage::DoDataExchange(pDX);

DDX_Control(pDX, IDC_COMBO1, cm_operations);

DDX_Control(pDX, IDC_STATIC_1, var1);

DDX_Control(pDX, IDC_EDIT1, var2);

DDX_Control(pDX, IDC_STATIC_2, var3);

DDX_Control(pDX, IDC_EDIT2, var4);

DDX_Control(pDX, IDC_STATIC_3, var5);

DDX_Control(pDX, IDC_EDIT3, var6);

DDX_Control(pDX, IDC_STATIC_4, var7);

DDX_Control(pDX, IDC_EDIT4, var8);

}

BEGIN_MESSAGE_MAP(CPages, CPropertyPage)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

//}}AFX_MSG_MAP

ON_WM_DESTROY()

ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)

ON_CBN_SETFOCUS(IDC_COMBO1, OnCbnSetfocusCombo1)

ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)

END_MESSAGE_MAP()

// CPages message handlers

BOOL CPages::OnInitDialog()

{

CPropertyPage::OnInitDialog();

// TODO: Add extra initialization here

//Заполняем массив элементов управления (для удобства управления)

wndw[0] =(CWnd) &var1;

wndw[1] =(CWnd) &var2;

wndw[2] =(CWnd) &var3;

wndw[3] =(CWnd) &var4;

wndw[4] =(CWnd) &var5;

wndw[5] =(CWnd) &var6;

wndw[6] =(CWnd) &var7;

wndw[7] =(CWnd) &var8;

//Создаем переменные Баз Данных и открываем их(БД)

work = new CDatabase();

book = new CDatabase();

try{

book->Open("book",NULL,NULL,"ODBC;",NULL);

work->Open("template",FALSE,FALSE,_T("ODBC;"),FALSE);

}catch(...){

SendMessage(WM_CLOSE);

return FALSE;

}

//Заполняем верхнее поле в форме информацией о возможных типах операций

ops = new COperations(work);

ops->Open(CRecordset::snapshot);

ops->MoveFirst();

while(!ops->IsEOF()) {

cm_operations.AddString(ops->get_op());

ops->MoveNext();

}

cm_operations.SetCurSel(0); //и показываем в верхнем поле первый элемент

return TRUE; // return TRUE unless you set the focus to a control

// EXCEPTION: OCX Property Pages should return FALSE

}

void CPages::OnSysCommand(UINT nID, LPARAM lParam)

{

CDialog::OnSysCommand(nID, lParam);

}

void CPages::OnPaint()

{

if (IsIconic())

{

CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0);

// Center icon in client rectangle

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon

dc.DrawIcon(x, y, m_hIcon);

}

else

{

CPropertyPage::OnPaint();

}

}

HCURSOR CPages::OnQueryDragIcon()

{

return static_cast

Источник: http://lib.podelise.ru/docs/1597/index-5192-1.html...


Теги к новости - Дипломная работа на тему гастриты

Раздел: Профилактика - Дипломная работа на тему гастриты