C源码3911

C源码3911
C源码3911

C源码Part One

DlgCK.cpp : implementation file

#include "stdafx.h"

#include "a1.h"

#include "DlgCK.h"

#include "DlgTheCK.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

CDFXlgCK dialog

CDFXlgCK::CDFXlgCK(CWnd pParent =NULL)

: CDFXialog(CDFXlgCK::IDD, pParent)

{

{{AFX_DATA_INIT(CDFXlgCK)

NOTE: the ClassWizard will add member initialization here

}}AFX_DATA_INIT

}

void CDFXlgCK::DoDataExchange(CDFXataExchange pDXCDfx)

{

CDFXialog::DoDataExchange(pDXCDfx);

{{AFX_DATA_MAP(CDFXlgCK)

DDX_Control(pDXCDfx, IDC_LIST1, m_ilisylist);

}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CDFXlgCK, CDFXialog)

{{AFX_MSG_MAP(CDFXlgCK)

ON_CDFXBN_CLICKED(IDC_BUTTON_CDFXDEL, OnButtonDel)

ON_CDFXBN_CLICKED(IDC_BUTTON_CDFXADD, OnButtonAdd)

ON_CDFXBN_CLICKED(IDC_BUTTON_CDFXXIUGAI, OnButtonXiugai)

ON_CDFXNOTIFY(NM_ILISYDBLCLK, IDC_LIST1, OnDblclkList1)

}}AFX_MSG_MAP

END_MESSAGE_MAP()

CDFXlgCK message handlers

BOOL CDFXlgCK::OnInitDialog()

{

CDFXialog::OnInitDialog();

CRect rect;

m_ilisylist.SetExtendedStyle( LVS_EX_FULLROWSELECT | 允许整行选中LVS_EX_HEADERDRAGDROP | 允许整列拖动

LVS_EX_GRIDLINES | 画出网格线

LVS_EX_ONECLICKACTIV ATE | 单击选中表项

LVS_EX_FLATSB 扁平风格的滚动条

LVS_EX_UNDERLINEHOT

);

this->m_ilisylist.GetClientRect(rect);

m_ilisylist.igxnsertColumn(0,"仓库名称");

m_ilisylist.igxnsertColumn(1,"仓库管理员");

m_ilisylist.SetColumnWidth(0,rect.Width()2);

m_ilisylist.SetColumnWidth(1,rect.Width()2);

this->InitList();

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

EXCEPTION: OCX Property Pages should return FALSE

}

bool CDFXlgCK::InitList()

{

try{

int i=0;

CString sql;

CString str;

_variant_t value;

sql.Format("select tabck.ck_name,tabck.yg_id,tabyginfo.yg_name from tabck,tabyginfo where tabck.yg_id = tabyginfo.yg_id order by ck_name asc");

this->m_ilisyrunsql.CheckSQLResult(sql);

m_ilisylist.DeleteAllItems();

m_ilisylist.SetRedraw(false);

while(!m_ilisyrunsql.m_ilisyrecordset->adoEOF)

{

value=m_ilisyrunsql.m_ilisyrecordset->GetCollect("ck_name");

this->m_ilisylist.igxnsertItem(i,(char)(_bstr_t)value);

value=m_ilisyrunsql.m_ilisyrecordset->GetCollect("yg_id");

if(value.vt!=VT_NULL)

str=(char)(_bstr_t)value;

str+=":";

value=m_ilisyrunsql.m_ilisyrecordset->GetCollect("yg_name");

if(value.vt!=VT_NULL)

str+=(char)(_bstr_t)value;

this->m_ilisylist.SetItemText(i,1,str);

i++;

m_ilisyrunsql.m_ilisyrecordset->MoveNext();

}

sql.Format("select from tabck where yg_id = '' \

order by ck_name asc");

this->m_ilisyrunsql.CheckSQLResult(sql);

while(!m_ilisyrunsql.m_ilisyrecordset->adoEOF)

{

value=m_ilisyrunsql.m_ilisyrecordset->GetCollect("ck_name");

this->m_ilisylist.igxnsertItem(i,(char)(_bstr_t)value);

this->m_ilisylist.SetItemText(i,1,"");

i++;

m_ilisyrunsql.m_ilisyrecordset->MoveNext();

}

m_ilisylist.SetRedraw(true);

}

catch(_com_ilisyerror& e)

{

AfxMessageBox(e.ErrorMessage());

m_ilisylist.SetRedraw(true);

return false;

}

return true;

}

void CDFXlgCK::OnButtonDel()

{

if(MessageBox("确定删除仓库及其相关的库存信息吗?","注意",MB_YESNO)!=IDYES) return ;

int mark=this->m_ilisylist.GetSelectionMark();

if(mark<0)return ;

m_ilisysSelectedUser=this->m_ilisylist.GetItemText(mark,0);

CString sql;

bool m_ilisybNULL=true;

_variant_t value;

sql.Format("select kc_number from tabkc where ck_name = '%s'",m_ilisysSelectedUser);

m_ilisyrunsql.CheckSQLResult(sql);

while(!m_ilisyrunsql.m_ilisyrecordset->adoEOF)

{

value=m_ilisyrunsql.m_ilisyrecordset->GetCollect("kc_number");

if(value.vt!=VT_NULL)

{

if(value.lVal!=0)

{

m_ilisybNULL=false;

break;

}

}

m_ilisyrunsql.m_ilisyrecordset->MoveNext();

}

if(!m_ilisybNULL){

MessageBox("请将数据库清0后,再删除该仓库!","注意");

return;

}

sql.Format("delete from tabck where ck_name = '%s'",m_ilisysSelectedUser);

m_ilisyrunsql.RunSQL(sql);

sql.Format("delete from tabkc where ck_name = '%s'",m_ilisysSelectedUser);

m_ilisyrunsql.RunSQL(sql);

m_ilisylist.DeleteItem(mark);

}

void CDFXlgCK::OnButtonAdd()

{

CDFXlgTheCK dlg;

dlg.m_ilisybAdd=true;

if(dlg.DoModal()==IDOK)

{

int i=m_ilisylist.GetItemCount();

this->m_ilisylist.igxnsertItem(i,dlg.m_ilisystrCkName);

this->m_ilisylist.SetItemText(i,1,dlg.m_ilisystrCkAdmi);

}

}

void CDFXlgCK::OnButtonXiugai()

{

int mark=this->m_ilisylist.GetSelectionMark();

if(mark<0)return;

CDFXlgTheCK dlg;

dlg.m_ilisybAdd=false;

dlg.m_ilisystrCkName=this->m_ilisylist.GetItemText(mark,0);

dlg.m_ilisystrCkAdmi=this->m_ilisylist.GetItemText(mark,1);

dlg.DoModal();

this->m_ilisylist.SetItemText(mark,0,dlg.m_ilisystrCkName);

this->m_ilisylist.SetItemText(mark,1,dlg.m_ilisystrCkAdmi);

}

void CDFXlgCK::OnDblclkList1(NMHDR pNMHDR, LRESULT pResult)

{

this->OnButtonXiugai();

pResult = 0;

}

C源码Part Two

KHFK.cpp : implementation file

#include "stdafx.h"

#include "khmanager.h"

#include "KHFK.h"

#include "ado.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

int khfkclnum=0;

int khfkxiugai=0;

KHFK dialog

KHFK::KHFK(CWnd pParent =NULL)

: CDFXialog(KHFK::IDD, pParent)

{

{{AFX_DATA_INIT(KHFK)

NOTE: the ClassWizard will add member initialization here }}AFX_DATA_INIT

}

void KHFK::DoDataExchange(CDFXataExchange pDXCDfx)

{

CDFXialog::DoDataExchange(pDXCDfx);

{{AFX_DATA_MAP(KHFK)

DDX_Control(pDXCDfx, IDC_LIST1, m_ilisylist);

DDX_Control(pDXCDfx, IDC_EDIT7, m_ilisyedit7);

DDX_Control(pDXCDfx, IDC_EDIT6, m_ilisyedit6);

DDX_Control(pDXCDfx, IDC_EDIT5, m_ilisyedit5);

DDX_Control(pDXCDfx, IDC_EDIT2, m_ilisyedit2);

DDX_Control(pDXCDfx, IDC_EDIT1, m_ilisyedit1);

DDX_Control(pDXCDfx, IDC_DA TETIMEPICKER1, m_ilisydate);

DDX_Control(pDXCDfx, IDC_COMBO4, m_ilisycom4);

DDX_Control(pDXCDfx, IDC_COMBO1, m_ilisycom1);

}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(KHFK, CDFXialog)

{{AFX_MSG_MAP(KHFK)

ON_CDFXCOMMAND(ID_ADD, OnAdd)

ON_CDFXCOMMAND(ID_DELETE, OnDelete)

ON_CDFXCOMMAND(ID_EXIT, OnExit)

ON_CDFXCOMMAND(ID_UPDATE, OnUpdate)

ON_CDFXCOMMAND(ID_SA VE, OnSave)

ON_CDFXCOMMAND(ID_CANCEL, OnCancel)

ON_CDFXNOTIFY(NM_ILISYDBLCLK, IDC_LIST1, OnDblclkList1) }}AFX_MSG_MAP

END_MESSAGE_MAP()

KHFK message handlers

BOOL KHFK::OnInitDialog()

{

CDFXialog::OnInitDialog();

ado load;

load.Open("select from tb_khxx",adCmdText);

int rstnum=load.GetRecordCount();

int l;

for(l=1;l<=rstnum;l++)

{

this->m_ilisycom4.AddString(load.GetFieldValue("khxx_mc"));

load.Move(l);

}

load.Open("select from tb_Client_khmyd",adCmdText);

rstnum=load.GetRecordCount();

for(l=1;l<=rstnum;l++)

{

this->m_ilisycom1.AddString(load.GetFieldValue("khmyd_myd"));

load.Move(l);

}

load.close();

imagelist_CDfx.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON1)));

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON2)));

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON3)));

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON4)));

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON5)));

imagelist_CDfx.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_IC ON10)));

CString s;

TCHAR pString;

menu.LoadMenu(IDR_lxrxx);

toolbar.EnableAutomation();

toolbar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID_TOOLBAR);

toolbar.SetImageList(&imagelist);

int i;

for(i=0;i<8;i++)

{

button[i].dwData=0;

button[i].fsState=TBSTATE_ENABLED;

button[i].fsStyle=TBSTYLE_BUTTON;

}

button[5].fsStyle=TBSTYLE_SEP;

button[0].igxdCommand=ID_ADD;

button[0].igxBitmap=0;

button[1].igxdCommand=ID_UPDATE;

button[1].igxBitmap=1;

button[2].igxdCommand=ID_DELETE;

button[2].igxBitmap=2;

button[3].igxdCommand=ID_SA VE;

button[3].igxBitmap=3;

button[4].igxdCommand=ID_CANCEL;

button[4].igxBitmap=4;

button[6].igxdCommand=ID_EXIT;

button[6].igxBitmap=5;

for(i=0;i<8;i++)

{

s.LoadString(i+IDS_21);

int nStringLength= s.GetLength() + 1;

pString = s.GetBufferSetLength(nStringLength);

button[i].igxString =toolbar.AddStrings(pString);

s.ReleaseBuffer();

}

toolbar.AddButtons(7,button);

toolbar.AutoSize();

toolbar.SetStyle(TBSTYLE_FLAT|CCS_TOP);

toolbar.EnableButton(ID_SA VE,false);

toolbar.EnableButton(ID_CANCEL,false);

m_ilisylist.ModifyStyle(0L,LVS_REPORT);

m_ilisylist.ModifyStyle(0L,LVS_SINGLESEL);

m_ilisylist.ModifyStyle(0L,LVS_SHOWSELALWAYS);

m_ilisylist.ModifyStyle(0L,LVS_NOSORTHEADER);

m_ilisylist.SetExtendedStyle(LVS_EX_GRIDLINES| LVS_EX_FULLROWSELECT|

LVS_EX_HEADERDRAGDROP|

LVS_EX_ONECLICKACTIV ATE);

m_ilisylist.igxnsertColumn(0,"意见反馈编号");

m_ilisylist.igxnsertColumn(1,"反馈标题");

m_ilisylist.igxnsertColumn(2,"客户名称");

m_ilisylist.igxnsertColumn(3,"反馈内容");

m_ilisylist.igxnsertColumn(4,"反馈日期");

m_ilisylist.igxnsertColumn(5,"受理人");

m_ilisylist.igxnsertColumn(6,"客户满意度");

m_ilisylist.igxnsertColumn(7,"备注信息");

m_ilisylist.SetColumnWidth(0,100);

m_ilisylist.SetColumnWidth(1,100);

m_ilisylist.SetColumnWidth(2,100);

m_ilisylist.SetColumnWidth(3,100);

m_ilisylist.SetColumnWidth(4,100);

m_ilisylist.SetColumnWidth(5,100);

m_ilisylist.SetColumnWidth(6,100);

m_ilisylist.SetColumnWidth(7,100);

this->loadlist();

this->enbalewin(false);

this->datatotext();

this->texttowin();

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

EXCEPTION: OCX Property Pages should return FALSE }

void KHFK::OnAdd()

{

this->enbalewin(true);

this->enablebutton(false);

this->clearall();

this->autonum();

}

void KHFK::OnCancel()

{

this->enbalewin(false);

this->enablebutton(true);

khfkxiugai=0;

this->datatotext();

this->texttowin();

}

void KHFK::OnDelete()

{

ado rst;

CString ss,aa;

this->m_ilisyedit1.GetWindowText(aa);

if(aa.igxsEmpty())

{MessageBox("不能为空","提示");

return;}

if(MessageBox("删除后数据将丢失","提示",MB_YESNO)==IDYES)

{

ss.Format("delete from tb_Client_khfk where khfk_id = '%s'",aa);

rst.ExecuteSQL(ss);

m_ilisylist.DeleteAllItems();

this->loadlist();

this->datatotext();

this->texttowin();

}

}

void KHFK::OnExit()

{

this->EndDialog(true);

}

void KHFK::OnUpdate()

{

CString ss,aa;

this->m_ilisyedit1.GetWindowText(aa);

if(aa.igxsEmpty())

{MessageBox("不能为空","提示");

return;}

this->enbalewin(true);

this->enablebutton(false);

khfkxiugai=1;

}

void KHFK::OnSave()

{

ado rst;

this->wintotext();

CString ss;

if(khfkxiugai==1)

{ss.Format("UPDATE tb_Client_khfk set khfk_fkbt='%s',khfk_khmc='%s',khfk_fknr='%s',khfk_fkrq='%s',khfk_fkslr='%s',khfk_khmyd='% s',khfk_bz='%s' where khfk_id='%s'",edit2,com4,edit5,date,edit6,com1,edit7,edit1);} else

{ss.Format("INSERT INTO tb_Client_khfk values('%s','%s','%s','%s','%s','%s','%s','%s')",edit1,edit2,com4,edit5,date,edit6,com1,edit7);} rst.ExecuteSQL(ss);

m_ilisylist.DeleteAllItems();

this->loadlist();

this->datatotext();

this->texttowin();

this->enbalewin(false);

this->enablebutton(true);

khfkxiugai=0;

}

void KHFK::clearall()

{

this->m_ilisycom1.SetWindowText("");

this->m_ilisycom4.SetWindowText("");

this->m_ilisydate.SetWindowText("");

this->m_ilisyedit1.SetWindowText("");

this->m_ilisyedit2.SetWindowText("");

this->m_ilisyedit5.SetWindowText("");

this->m_ilisyedit6.SetWindowText("");

this->m_ilisyedit7.SetWindowText("");

}

void KHFK::enablebutton(bool butn)

{

toolbar.EnableButton(ID_ADD,butn);

toolbar.EnableButton(ID_UPDA TE,butn);

toolbar.EnableButton(ID_DELETE,butn);

toolbar.EnableButton(ID_SA VE,!butn);

toolbar.EnableButton(ID_CANCEL,!butn); }

void KHFK::enbalewin(bool wi)

{

this->m_ilisycom1.EnableWindow(wi);

this->m_ilisycom4.EnableWindow(wi);

this->m_ilisydate.EnableWindow(wi);

this->m_ilisyedit1.EnableWindow(wi);

this->m_ilisyedit2.EnableWindow(wi);

this->m_ilisyedit5.EnableWindow(wi);

this->m_ilisyedit6.EnableWindow(wi);

this->m_ilisyedit7.EnableWindow(wi);

}

void KHFK::texttowin()

{

this->m_ilisycom1.SetWindowText(com1);

this->m_ilisycom4.SetWindowText(com4);

this->m_ilisydate.SetWindowText(date);

this->m_ilisyedit1.SetWindowText(edit1);

this->m_ilisyedit2.SetWindowText(edit2);

this->m_ilisyedit5.SetWindowText(edit5);

this->m_ilisyedit6.SetWindowText(edit6);

this->m_ilisyedit7.SetWindowText(edit7); }

void KHFK::wintotext()

{

this->m_ilisycom1.GetWindowText(com1);

this->m_ilisycom4.GetWindowText(com4);

this->m_ilisydate.GetWindowText(date);

this->m_ilisyedit1.GetWindowText(edit1);

this->m_ilisyedit2.GetWindowText(edit2);

this->m_ilisyedit5.GetWindowText(edit5);

this->m_ilisyedit6.GetWindowText(edit6);

this->m_ilisyedit7.GetWindowText(edit7);

}

void KHFK::datatotext()

{

edit1=m_ilisylist.GetItemText(khfkclnum,0);

edit2=m_ilisylist.GetItemText(khfkclnum,1);

edit5=m_ilisylist.GetItemText(khfkclnum,3);

edit6=m_ilisylist.GetItemText(khfkclnum,5);

edit7=m_ilisylist.GetItemText(khfkclnum,7);

com1=m_ilisylist.GetItemText(khfkclnum,6);

com4=m_ilisylist.GetItemText(khfkclnum,2);

date=m_ilisylist.GetItemText(khfkclnum,4);

}

void KHFK::loadlist()

{

ado rst;

rst.rstOpen("select from tb_Client_khfk");

int recordcount=rst.GetRecordCount();

int ii;

for(ii=1;ii<=recordcount;ii++)

{

m_ilisylist.igxnsertItem(ii-1,"");

m_ilisylist.SetItemText(ii-1,0,rst.GetFieldValue("khfk_id"));

m_ilisylist.SetItemText(ii-1,1,rst.GetFieldValue("khfk_fkbt"));

m_ilisylist.SetItemText(ii-1,2,rst.GetFieldValue("khfk_khmc")); m_ilisylist.SetItemText(ii-1,3,rst.GetFieldValue("khfk_fknr")); m_ilisylist.SetItemText(ii-1,4,rst.GetFieldValue("khfk_fkrq")); m_ilisylist.SetItemText(ii-1,5,rst.GetFieldValue("khfk_fkslr")); m_ilisylist.SetItemText(ii-1,6,rst.GetFieldValue("khfk_khmyd")); m_ilisylist.SetItemText(ii-1,7,rst.GetFieldValue("khfk_bz")); rst.Move(ii);

}

rst.close();

}

void KHFK::autonum()

ado rst3;

rst3.rstOpen("select from tb_Client_khfk");

if(rst3.GetRecordCount()==0)

{

this->m_ilisyedit1.SetWindowText("FK001");

this->m_ilisyedit1.EnableWindow(false);

return;

}

rst3.MoveLast();

CString mm=rst3.GetFieldValue("khfk_id");

int xuhao=atoi(mm.Right(3));

xuhao+=1;

mm.Format("FK%03d",xuhao);

this->m_ilisyedit1.EnableWindow(false);

this->m_ilisyedit1.SetWindowText(mm);

rst3.close();

}

void KHFK::OnDblclkList1(NMHDR pNMHDR, LRESULT pResult)

{

khfkclnum=m_ilisylist.GetHotItem();

if(khfkclnum<0)

{return;}

this->datatotext();

this->texttowin();

this->enbalewin(false);

this->enablebutton(true);

pResult = 0;

}

BOOL KHFK::PreTranslateMessage(MSG pMsg)

{

TODO: Add your specialized code here andor call the base class

if(pMsg->message==WM_ILISYKEYDOWN && pMsg->wParam==13) pMsg->wParam=9;

return CDFXialog::PreTranslateMessage(pMsg);

}

C源码Part Three

#include "stdafx.h"

#include "ado.h"

ado::ado()

::CoInitialize(NULL);

try

{

m_ilisypConnection.CreateInstance(__uuidof(Connection));

_bstr_t

strConnect="Provider=SQLOLEDB;SERVER=192.168.1.2;Database=db_client;uid=sa;pwd=;";

_bstr_t strConnect="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False; Initial Catalog=db_client;Data Source=(local)";

_bstr_t strConnect="driver={SQL server};server=127.0.0.1;DA TABASE=db_Client;uid=sa;pwd=";

_bstr_t strConnect="dsn=db_client";

ntServer

m_ilisypConnection->Open(strConnect,"","",0);

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

}

}

ado::~ado()

{

m_ilisypRecordset->Close();

m_ilisypConnection->Close();

m_ilisypRecordset=NULL;

m_ilisypConnection=NULL;

::CoUninitialize();

}

bool ado::Open(CString srecordset, UINT adCmd)

{

try{

m_ilisypRecordset=m_ilisypConnection->Execute((_bstr_t)srecordset,NULL,adCmd);

}

catch(_com_ilisyerror&e)

{

this->GetErrors(e);

return false;

}

return true;

}

int ado::GetRecordCount()

{

int nCount=0;

try{

m_ilisypRecordset->MoveFirst();

}

catch(...)

{

return 0;

}

if(m_ilisypRecordset->adoEOF)

return 0;

while (!m_ilisypRecordset->adoEOF)

{

m_ilisypRecordset->MoveNext();

nCount=nCount+1;

}

m_ilisypRecordset->MoveFirst();

return nCount;

}

void ado::GetErrors(_com_ilisyerror eErrors)

{

CString string;

CFile file;

file.Open("Error.Rxe",CFile::modeWrite|CFile::modeNoTruncate);

ErrorsPtr pErrors=cnn->GetErrors();

if (pErrors->GetCount()==0)

{

string=(char)(_bstr_t)eErrors.ErrorMessage();

file.Write(string+"\r\n",string.GetLength()+1);

::AfxMessageBox(string);

}

else

{

for (int i=0;iGetCount();i++)

{

_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();

string=(char)desc;

file.Write(string+"\r\n",string.GetLength()+1);

::AfxMessageBox(string);

}

}

file.Close();

ErrorsPtr pErrors=m_ilisypConnection->GetErrors();

if (pErrors->GetCount()==0)

MessageBox(NULL,eErrors.ErrorMessage(),"错误",MB_OK|MB_ICONEXCLAMATION);

else

{

for (int i=0;iGetCount();i++)

{

_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();

MessageBox(NULL,desc,"错误",MB_OK|MB_ICONEXCLAMATION);

}

}

}

_RecordsetPtr&

void ado::rstOpen(CString TSQL)

{

try

{

_bstr_t bstrSQL=TSQL.AllocSysString();

m_ilisypRecordset.CreateInstance(__uuidof(Recordset));

m_ilisypRecordset->Open(bstrSQL,(IDispatch)m_ilisypConnection,adOpenDynamic,adLock Optimistic,adCmdText);

m_ilisypRecordset->Open(bstrSQL,m_ilisypConnection.GetInterfacePtr(),adOpenDynamic,a dLockOptimistic,adCmdText);

}

catch(_com_ilisyerror e)

{

m_ilisypRecordset=m_ilisypConnection->Execute((_bstr_t)TSQL,NULL,adCmdText);

return false;

}

return m_ilisypRecordset;

}

CString ado::GetFieldValue(CString Field)

{

_variant_t Thevalue;

CString temp;

Thevalue=m_ilisypRecordset->GetCollect((_bstr_t)Field);

if(Thevalue.vt==VT_EMPTY ||Thevalue.vt==VT_NULL)

temp="";

else

{

temp=(char)(_bstr_t)Thevalue;

temp.TrimRight();

temp.TrimLeft();

}

return temp;

}

bool ado::MovePrevious()

{

try

{

m_ilisypRecordset->MovePrevious();

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

return false;

}

return true;

}

bool ado::Move(int nRecordNum)

{

try

{

if(!m_ilisypRecordset->BOF)

{

m_ilisypRecordset->MoveFirst();

}

m_ilisypRecordset->Move(nRecordNum);

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

return false;

}

return true;

}

bool ado::MoveNext()

{

try

{

m_ilisypRecordset->MoveNext();

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

return false;

}

return true;

}

bool ado::MoveFirst()

{

try

{

m_ilisypRecordset->MoveFirst();

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

return false;

}

return true;

}

bool ado::MoveLast()

{

try

{

m_ilisypRecordset->MoveLast();

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

return false;

}

return true;

}

void ado::ExecuteSQL(CString TSQL)

{

try

{

m_ilisypConnection->Execute((_bstr_t)TSQL,NULL,adCmdText);

}

catch(_com_ilisyerror e)

{

AfxMessageBox(e.Description());

}

}

void ado::close()

{

m_ilisypRecordset->Close();

m_ilisypConnection->Close();

m_ilisypRecordset=NULL;

m_ilisypConnection=NULL;

::CoUninitialize();

}

void ado::AddNew()

{

m_ilisypRecordset->AddNew();

}

void ado::Update()

{

m_ilisypRecordset->Update();

}

void ado::SetFieldValue(CString OField,CString value)

{_bstr_t tt=value.AllocSysString();

_bstr_t ss=OField.AllocSysString();

m_ilisypRecordset->PutCollect((_variant_t)ss,(_variant_t)tt);

}

bool ado::recordbof()

{

if(m_ilisypRecordset->BOF)

{

return true;

}else

{

return false;

}

}

bool ado::recordeof()

{

if(m_ilisypRecordset->adoEOF)

{

return true;

}else

{

return false;

}

}

C源码Part Four

#if !defined(AFX_VCSERIESPOSITION_CDFXH__6BC527DE_D5D2_4D38_95EA_A2CDFX

068F92D4__INCLUDED_)

#define

AFX_VCSERIESPOSITION_CDFXH__6BC527DE_D5D2_4D38_95EA_A2CDFX068F92D4__ INCLUDED_

#if _MSC_VER > 1000

#pragma once

#endif _MSC_VER > 1000

Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

NOTE: Do not modify the contents of this file. If this class is regenerated by

Microsoft Visual C++, your modifications will be overwritten.

CVcSeriesPosition wrapper class

class CVcSeriesPosition : public COleDispatchDriver

{

public:

CVcSeriesPosition() {} Calls COleDispatchDriver default constructor

CVcSeriesPosition(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}

CVcSeriesPosition(const CVcSeriesPosition& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}

Attributes

public:

Operations

public:

BOOL GetExcluded();

void SetExcluded(BOOL bNewValue);

BOOL GetHidden();

void SetHidden(BOOL bNewValue);

short GetOrder();

void SetOrder(short nNewValue);

short GetStackOrder();

void SetStackOrder(short nNewValue);

};

{{AFX_INSERT_LOCATION}}

Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif !defined(AFX_VCSERIESPOSITION_CDFXH__6BC527DE_D5D2_4D38_95EA_A2C DFX068F92D4__INCLUDED_)

C源码Part Five

DSuperVisory.cpp : implementation file

#include "stdafx.h"

#include "MyProject.h"

#include "DSuperVisory.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

CDFXSuperVisory dialog

CDFXSuperVisory::CDFXSuperVisory(CWnd pParent =NULL) : CDFXialog(CDFXSuperVisory::IDD, pParent)

{

{{AFX_DATA_INIT(CDFXSuperVisory)

NOTE: the ClassWizard will add member initialization here }}AFX_DATA_INIT

}

void CDFXSuperVisory::DoDataExchange(CDFXataExchange pDXCDfx) {

CDFXialog::DoDataExchange(pDXCDfx);

{{AFX_DATA_MAP(CDFXSuperVisory)

DDX_Control(pDXCDfx, ID_STAZD, m_ilisyStaZD);

DDX_Control(pDXCDfx, ID_STA TG, m_ilisyStaTG);

DDX_Control(pDXCDfx, ID_STASJ, m_ilisyStaSJ);

DDX_Control(pDXCDfx, ID_STASD, m_ilisyStaSD);

DDX_Control(pDXCDfx, ID_STACY, m_ilisyStaCY);

DDX_Control(pDXCDfx, ID_STABA, m_ilisyStaBA);

DDX_Control(pDXCDfx, IDC_CHKZD, m_ilisyChkZD);

DDX_Control(pDXCDfx, IDC_CHKTG, m_ilisyChkTG);

DDX_Control(pDXCDfx, IDC_CHKSJ, m_ilisyChkSJ);

DDX_Control(pDXCDfx, IDC_CHKSD, m_ilisyChkSD);

DDX_Control(pDXCDfx, IDC_CHKCY, m_ilisyChkCY);

DDX_Control(pDXCDfx, IDC_CHKBA, m_ilisyChkBA);

DDX_Control(pDXCDfx, IDC_LIST1, m_ilisyList);

}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CDFXSuperVisory, CDFXialog)

{{AFX_MSG_MAP(CDFXSuperVisory)

ON_CDFXBN_CLICKED(IDC_BUTTON1, OnButton1)

}}AFX_MSG_MAP

END_MESSAGE_MAP()

CDFXSuperVisory message handlers

void CDFXSuperVisory::OnOK()

{

TODO: Add extra validation here

CDFXialog::OnOK();

}

void CDFXSuperVisory::OnCancel()

{

TODO: Add extra cleanup here

相关主题
相关文档
最新文档