C++开发源码研读(391)

?C++开发源码研读(391)
C++ Source Part One
ListKCPD1.cpp: implementation of the CListKCPD class.
#include "stdafx.h"
#include "a1.h"
#include "ListKCPD1.h"
#include "myfunction.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
ConstructionDestruction
CListKCPD::CListKCPD()
{
m_pstrlistKc=new CStringList[4];
for(int i=0;i<100;i++)
{
m_iTheItemState[i]=0;
m_iKcSelected[i]=-1;
}
this->InitValuesFromDB();
}
CListKCPD::~CListKCPD()
{
delete [] m_pstrlistKc;
}
void CListKCPD::OnNewEditChange(const int& item,const int& subitem)
{
TRACE("void CListXSDJ::OnNewEditChange()\n");
if(this->m_bSetValue) return ;
ASSERT(this->m_poplist!=NULL);
CString str;
m_edit.GetWindowText(str);
CString str_sl=this->GetItemText(item,3);
if(!m_poplist->IsWindowVisible())
m_poplist->ShowListPop();
switch(subitem)
{
case 0:
{
str.MakeUpper();
CString id=this->GetItemText(item,1);
int sl=0;
sl=atoi(str_sl);
if(sl&&str!=this->m_sSetFocus)
{
this->SetItemText(item,3,"");
if(m_iKcSelected[item]>=0)
this->CancelTheItem(item);
}
this->m_iTheItemState[item]=NOCK;
this->m_iKcSelected[item]=-1;
this->m_poplist->RefreshListCtrlView(1,id,0,str);
break;
}
case 1:
{
str.MakeUpper();
CString ck_name=this->GetItemText(item,0);
int sl=0;
sl=atoi(str_sl);
if(sl&&str!=this->m_sSetFocus)
{
this->SetItemText(item,3,"");
if(m_iKcSelected[item]>=0)
this->CancelTheItem(item);
}
this->m_iTheItemState[item]=NOID;
m_iKcSelected[item]=-1;
this->m_poplist->RefreshListCtrlView(0,ck_name,1,str);
break;
}
case 2:
{
CString ck_name=this->GetItemText(item,0);
int sl=0;
sl=atoi(str_sl);
if(sl&&str!=this->m_sSetFocus)
{
this->SetItemText(item,3,"");
if(m_iKcSelected[item]>=0)
this->CancelTheItem(item);
}
this->m_iTheItemState[item]=NONAME;
m_iKcSelected[item]=-1;
this->m_poplist->RefreshListCtrlView(0,ck_name,2,str);
break;
}
case 3:
{
CString ck_name=this->GetItemText(item,0);
CString id=this->GetItemText(item,1);
this->m_pstrlistKc[3].SetAt(this->m_pstrlistKc[3].FindIndex(FindKc(item)),str);
this->m_poplist->RefreshListCtrlView(0,ck_name,1,id);
break;
}
}
}
void CListKCPD::OnEditSetFocus(const int& item, const int& subitem)
{
CString str;
m_edit.m_dSetFocusValue=0;
m_edit.GetWindowText(str);
this->m_sSetFocus=str;
m_edit.GetWindowRect(&this->m_rectWindow);
str.MakeUpper();
switch(subitem)
{
case 0:
{
CString id=this->GetItemText(item,1);
this->m_poplist->ShowWindow(SW_HIDE);
ASSERT(this->m_poplist!=NULL);
this->m_poplist->SetShowPosition(this->m_rectWindow,&m_edit);
this->m_poplist->RefreshListCtrlView(1,id,0,str);
if(!m_poplist->IsWindowVisible())
m_poplist->ShowListPop();
break;
}
case 1:
{
this->m_po

plist->ShowWindow(SW_HIDE);
ASSERT(this->m_poplist!=NULL);
this->m_poplist->SetShowPosition(this->m_rectWindow,&m_edit);
CString ck_name=this->GetItemText(item,0);
this->m_poplist->RefreshListCtrlView(0,ck_name,1,str);
if(!m_poplist->IsWindowVisible())
m_poplist->ShowListPop();
break;

}
case 2:
{
this->m_poplist->ShowWindow(SW_HIDE);
ASSERT(this->m_poplist!=NULL);
this->m_poplist->SetShowPosition(this->m_rectWindow,&m_edit);
CString ck_name=this->GetItemText(item,0);
this->m_poplist->RefreshListCtrlView(0,ck_name,2,str);
if(!m_poplist->IsWindowVisible())
m_poplist->ShowListPop();
break;
}
case 3:
{
if(this->CheckKc(item)&&(IsSelected(item)!=-1))
{
this->m_poplist->ShowWindow(SW_HIDE);
CString ck_name=this->GetItemText(item,0);
CString id=this->GetItemText(item,1);
this->m_poplist->SetShowPosition(this->m_rectWindow,&m_edit);
this->m_poplist->RefreshListCtrlView(0,ck_name,1,id);
m_poplist->ShowListPop();
this->m_edit.m_dSetFocusValue=atoi(str);
}
else
{
m_edit.ShowWindow(SW_HIDE);
this->m_iEditedIndex=-1;
this->SetNextItemFocus();
MessageBox("请确定有此库存信息!并且该记录唯一!","错误");
}
break;
}
}
}
bool CListKCPD::OnEditReturn(const int& item, const int& subitem)
{
CString str;
m_edit.GetWindowText(str);
switch(subitem)
{
case 0:
case 1:
case 2:
{
if(this->m_poplist->IsWindowVisible()&&this->m_poplist->GetSelectedMark()>=0)
{
this->SetValueUnChange(m_poplist->GetListCtrlSel(subitem));
this->SetItemText(m_nItem,0,this->m_poplist->GetListCtrlSel(0));
this->SetItemText(m_nItem,1,this->m_poplist->GetListCtrlSel(1));
this->SetItemText(m_nItem,2,this->m_poplist->GetListCtrlSel(2));
this->SetItemText(m_nItem,3,this->m_poplist->GetListCtrlSel(3));
m_iTheItemState[item]=NOWRONG;
m_iTheItemState[item]=NONE;
m_iTheItemState[item]&=NOCK;
m_iTheItemState[item]|=YPTRUE;
}
else
SetValueUnChange("");
break;
}
case 4:
{
break;
}
}
return CBaseList::OnEditReturn(item,subitem);
}
void CListKCPD::OnEditKillFocus(const int& item, const int& subitem)
{
CString str;
m_edit.GetWindowText(str);
switch(subitem)
{
case 3:
{
this->m_pstrlistKc[3].SetAt(
this->m_pstrlistKc[3].FindIndex(FindKc(item)),str);
this->m_poplist->SelectStringList(4,m_pstrlistKc);
break;
}
}
CBaseList::OnEditKillFocus(item,subitem);
}
bool CListKCPD::InitValuesFromDB()
{
LRunSql m_runsql;
CString sql;
_variant_t value;
m_pstrlistKc[0].AddTail("仓库名称");
m_pstrlistKc[1].AddTail("药品编号");
m_pstrlistKc[2].AddTail("药品名称");
m_pstrlistKc[3].AddTail("库存数量");
m_strlistNo.AddTail("");
sql.Format("select tabkc.yp_id,tabkc.ck_name,tabkc.kc_number,\
tabypinfo.yp_name from tabkc,tabypinfo \
where tabkc.yp_id = tabyp

info.yp_id");
m_runsql.CheckSQLResult(sql);
while(!m_runsql.m_recordset->adoEOF)
{
value=m_runsql.m_recordset->GetCollect("ck_name");
if(value.vt!=VT_NULL)
m_pstrlistKc[0].AddTail((char)(_bstr_t)value);
value=m_runsql.m_recordset->GetCollect("yp_id");
if(value.vt!=VT_NULL)
m_pstrlistKc[1].AddTail((char)(_bstr_t)value);
value=m_runsql.m_recordset->GetCollect("yp_name");
if(value.vt!=VT_NULL)
m_pstrlistKc[2].AddTail((char)(_bstr_t)value);
value=m_runsql.m_recordset->GetCollect("kc_number");
if(value.vt!=VT_NULL)
m_pstrlistKc[3].AddTail((char)(_bstr_t)value);
m_strlistNo.AddTail((char)(_bstr_t)value);
m_runsql.m_recordset->MoveNext();
}
this->m_poplist->SelectStringList(4,this->m_pstrlistKc);
return true;
}
bool CListKCPD::Create(DWORD dwStyle, const RECT &rect, CWnd pParentWnd, UINT nID)
{
bool b=CBaseList::Create(dwStyle,rect,pParentWnd,nID);
m_poplist->SelectStringList(4,this->m_pstrlistKc);
return b;
}
void CListKCPD::OnEditUDNPMessage(const int& item, const int& subitem, UINT key)
{
switch(subitem)
{
case 0:
case 1:
case 2:
{
this->m_poplist->SendTheUDNPMessage(key);
break;
}
}
}
int CListKCPD::CheckKc(const int& item)
{
if(m_iKcSelected[item]=FindKc(item)>=0)
{
m_iTheItemState[item]=NOWRONG;
}
else
{
TRACE("CKFALSE");
m_iTheItemState[item]=0;
}
return m_iTheItemState[item];
}
int CListKCPD::FindKc(const int& item)
{ int n=this->GetItemCount();
if(item<-1||item>=n)return -1;
CString ck_name=this->GetItemText(item,0);
CString yp_id=this->GetItemText(item,1);
CString yp_name=this->GetItemText(item,2);

bool result=false;
POSITION pos=NULL;int i;
for( pos = this->m_pstrlistKc[0].GetHeadPosition(),i=0; pos != NULL; i++)
{
if(ck_name== m_pstrlistKc[0].GetNext( pos ))
if(this->m_pstrlistKc[1].GetAt(this->m_pstrlistKc[1].FindIndex(i))==yp_id)
if(this->m_pstrlistKc[2].GetAt(this->m_pstrlistKc[2].FindIndex(i))==yp_name)
{
return i;
}
}
return -1;
}
void CListKCPD::OnESC(const int& item, const int& subitem)
{
CString str;
str.Format("%d",m_edit.m_dSetFocusValue);
switch(this->m_nSubItem)
{
case 3:
this->m_pstrlistKc[3].SetAt(
this->m_pstrlistKc[3].FindIndex(
this->m_iKcSelected[this->m_nItem])
,str);
this->m_poplist->SelectStringList(4,m_pstrlistKc);
break;
}
CBaseList::OnESC(item,subitem);
}
int CListKCPD::IsSelected(const int& item)if selected return -1, else return index;
{
int index=this->FindKc(item);
if(index<0)return m_iKcSelected[item]=-1;
int n=this->GetItemCount();
for(int i=0;i{
if(i==item) continue;
if(m_iKcSelected[i]==-1)
if(!CheckKc(i)) continue;
if(this->m_iKcSelected[i]==index)
return m_iKcSelected[item]=-1;
}
return m_iKcSelected[item]=index;
}
void CListKCPD::PreOnEditChar(const int& item, const int& subitem, UINT &key)
{
switch(subitem)
{

case 3:
if((key>=0x30&&key<=0x39)||key==0x08)
{
;
}
else
{
key=VK_CONTROL;
}
break;
}
}
bool CListKCPD::CheckAll()
{
int n=GetItemCount();
for(int i=0;i{
if(GetItemText(i,0)==""&&GetItemText(i,1)=="")
{
DeleteItem(i);
continue;
}
long number=0;
if(!this->CheckTheItem(i))
{
return false;
}
if(this->IsSelected(i)==-1)
{
MessageBox("数据不唯一,请确认数据唯一","注意!");
this->m_nItem=i;
m_iEditedIndex=-1;
PostMessage(SETNEXTITEMPHFOCUS,0,0);
return false;
}
}
return true;
}
bool CListKCPD::CheckTheItem(const int& item)
{
if(!this->CheckKc(item))
{
this->m_nItem=item;
this->m_iEditedIndex=-1;
MessageBox("请输入完整登记信息","注意");
this->PostMessage(SETNEXTITEMPHFOCUS,0,0);
return false;
}
CString str=this->GetItemText(item,3);
if(str=="")
{
TRACE("SL false"); this->m_nItem=item;
this->m_iEditedIndex=2;
MessageBox("若确实要清空该药品库存,请添0","注意");
this->PostMessage(SETNEXTITEMPHFOCUS,0,0);
return false;
}
return true;
}
bool CListKCPD::DeleteSelected()
{ if(this->m_poplist->IsWindowVisible())
this->m_poplist->ShowWindow(SW_HIDE);
if(this->m_edit.IsWindowVisible())
m_edit.ShowWindow(SW_HIDE);
LVITEM item=new LVITEM;
int number=this->GetSelectedCount();
for(int i=this->GetItemCount()-1;i>=0;i--)
{
this->m_nItem=i;
item->iItem=i;
item->mask=LVIF_STATE ;
item->stateMask=LVIS_SELECTED ;
GetItem(item);
if(item->state==LVIS_SELECTED)
{
DeleteItem(i);
if(m_iKcSelected[i]==-1)continue;
m_pstrlistKc[3].SetAt(m_pstrlistKc[3].FindIndex(m_iKcSelected[i]),m_strlistNo.GetAt(m_strlistNo.FindIndex(m_iKcSelected[i])));
this->m_poplist->SelectStringList(4,this->m_pstrlistKc);
this->m_iTheItemState[i]=NONE;
this->m_iKcSelected[i]=-1;
}
}
if(GetItemCount()==0)
InsertItem(0,"");
this->m_nItem=0;
Invalidate();
return true;
}
bool CListKCPD::CancelTheItem(const int &item)
{
m_pstrlistKc[3].SetAt(
m_pstrlistKc[3].FindIndex(m_iKcSelected[item]),
m_strlistNo.GetAt(m_strlistNo.FindIndex(m_iKcSelected[item]))
);
this->m_poplist->SelectStringList(4,this->m_pstrlistKc);
this->m_iTheItemState[item]=NONE;
this->m_iKcSelected[item]=-1;
this->SetItemText(item,3,"");
return true;
}

C++ Source 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)
: CDialog(KHFK::IDD, pParent)
{
{{AFX_DATA_INIT(KHFK)
NOTE: the ClassWizard will add member initialization here
}}AFX_DATA_INIT
}
void KHFK::DoDataExchange(CDataExchange pDX)
{
CDialog::DoDataExchange(pDX);
{{AFX_DATA_MAP(KHFK)
DDX_Control(pDX, ID

C_LIST1, m_list);
DDX_Control(pDX, IDC_EDIT7, m_edit7);
DDX_Control(pDX, IDC_EDIT6, m_edit6);
DDX_Control(pDX, IDC_EDIT5, m_edit5);
DDX_Control(pDX, IDC_EDIT2, m_edit2);
DDX_Control(pDX, IDC_EDIT1, m_edit1);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_date);
DDX_Control(pDX, IDC_COMBO4, m_com4);
DDX_Control(pDX, IDC_COMBO1, m_com1);
}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(KHFK, CDialog)
{{AFX_MSG_MAP(KHFK)
ON_COMMAND(ID_ADD, OnAdd)
ON_COMMAND(ID_DELETE, OnDelete)
ON_COMMAND(ID_EXIT, OnExit)
ON_COMMAND(ID_UPDATE, OnUpdate)
ON_COMMAND(ID_SAVE, OnSave)
ON_COMMAND(ID_CANCEL, OnCancel)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
}}AFX_MSG_MAP
END_MESSAGE_MAP()
KHFK message handlers
BOOL KHFK::OnInitDialog()
{
CDialog::OnInitDialog();
ado load;
load.Open("select from tb_khxx",adCmdText);
int rstnum=load.GetRecordCount();
int l;
for(l=1;l<=rstnum;l++)
{
this->m_com4.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_com1.AddString(load.GetFieldValue("khmyd_myd"));
load.Move(l);
}
load.close();

imagelist.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON2)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON3)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON4)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON5)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON10)));

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].idCommand=ID_ADD;
button[0].iBitmap=0;
button[1].idCommand=ID_UPDATE;
button[1].iBitmap=1;
button[2].idCommand=ID_DELETE;
button[2].iBitmap=2;
button[3].idCommand=ID_SAVE;
button[3].iBitmap=3;
button[4].idCommand=ID_CANCEL;
button[4].iBitmap=4;
button[6].idCommand=ID_EXIT;
button[6].iBitmap=5;
for(i=0;i<8;i++)
{
s.LoadString(i+IDS_21);
int nStringLength= s.GetLength() + 1;
pString = s.GetBufferSetLength(nStringLength);

button[i].iString =toolbar.AddStrings(pString);
s.ReleaseBuffer();
}
toolbar.AddButtons(7,button);
toolbar.AutoSize();
toolbar.SetStyle(TBSTYLE_FLAT|CCS_TOP);
toolbar.EnableButton(ID_SAVE,false);
toolbar.EnableButton(ID_CANCEL,false);
m_list.ModifyStyle(0L,LVS_REPORT);
m_list.ModifyStyle(0L,LVS_SINGLESEL);
m_list.ModifyStyle(0L,LVS_SHOWSELALWAYS);
m_list.ModifyStyle(0L,LVS_NOSORTHEADER);
m

_list.SetExtendedStyle(LVS_EX_GRIDLINES|
LVS_EX_FULLROWSELECT|
LVS_EX_HEADERDRAGDROP|
LVS_EX_ONECLICKACTIVATE);
m_list.InsertColumn(0,"意见反馈编号");
m_list.InsertColumn(1,"反馈标题");
m_list.InsertColumn(2,"客户名称");
m_list.InsertColumn(3,"反馈内容");
m_list.InsertColumn(4,"反馈日期");
m_list.InsertColumn(5,"受理人");
m_list.InsertColumn(6,"客户满意度");
m_list.InsertColumn(7,"备注信息");
m_list.SetColumnWidth(0,100);
m_list.SetColumnWidth(1,100);
m_list.SetColumnWidth(2,100);
m_list.SetColumnWidth(3,100);
m_list.SetColumnWidth(4,100);
m_list.SetColumnWidth(5,100);
m_list.SetColumnWidth(6,100);
m_list.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_edit1.GetWindowText(aa);
if(aa.IsEmpty())
{MessageBox("不能为空","提示");
return;}
if(MessageBox("删除后数据将丢失","提示",MB_YESNO)==IDYES)
{
ss.Format("delete from tb_Client_khfk where khfk_id = '%s'",aa);
rst.ExecuteSQL(ss);
m_list.DeleteAllItems();
this->loadlist();
this->datatotext();
this->texttowin();
}

}
void KHFK::OnExit()
{
this->EndDialog(true);

}
void KHFK::OnUpdate()
{
CString ss,aa;
this->m_edit1.GetWindowText(aa);
if(aa.IsEmpty())
{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_list.DeleteAllItems();
this->loadlist();
this->datatotext();
this->texttowin();
this->enbalewin(false);
this->enablebutton(true);
khfkxiugai=0;

}
void KHFK::clearall()
{
this->m_com1.SetWindowText("");
this->m_com4.SetWindowText("");
this->m_date.SetWindowText("");
this->m_edit1.SetWindowText("");
this->m_edit2.SetWindowText("");
this->m_edit5.SetWindowText("");
this->m_edit6.SetWindowText("");
this->m_edit7.SetWindowText("");
}
void KHFK::enablebutton(bool butn)
{
toolbar.EnableButton(ID_ADD,butn);
toolbar.EnableButton(ID_UPDATE,butn);
toolbar.EnableButton(ID_DELETE,but

n);
toolbar.EnableButton(ID_SAVE,!butn);
toolbar.EnableButton(ID_CANCEL,!butn);
}
void KHFK::enbalewin(bool wi)
{
this->m_com1.EnableWindow(wi);
this->m_com4.EnableWindow(wi);
this->m_date.EnableWindow(wi);
this->m_edit1.EnableWindow(wi);
this->m_edit2.EnableWindow(wi);
this->m_edit5.EnableWindow(wi);
this->m_edit6.EnableWindow(wi);
this->m_edit7.EnableWindow(wi);
}
void KHFK::texttowin()
{
this->m_com1.SetWindowText(com1);
this->m_com4.SetWindowText(com4);
this->m_date.SetWindowText(date);
this->m_edit1.SetWindowText(edit1);
this->m_edit2.SetWindowText(edit2);
this->m_edit5.SetWindowText(edit5);
this->m_edit6.SetWindowText(edit6);
this->m_edit7.SetWindowText(edit7);
}
void KHFK::wintotext()
{
this->m_com1.GetWindowText(com1);
this->m_com4.GetWindowText(com4);
this->m_date.GetWindowText(date);
this->m_edit1.GetWindowText(edit1);
this->m_edit2.GetWindowText(edit2);
this->m_edit5.GetWindowText(edit5);
this->m_edit6.GetWindowText(edit6);
this->m_edit7.GetWindowText(edit7);
}
void KHFK::datatotext()
{
edit1=m_list.GetItemText(khfkclnum,0);
edit2=m_list.GetItemText(khfkclnum,1);
edit5=m_list.GetItemText(khfkclnum,3);
edit6=m_list.GetItemText(khfkclnum,5);
edit7=m_list.GetItemText(khfkclnum,7);
com1=m_list.GetItemText(khfkclnum,6);
com4=m_list.GetItemText(khfkclnum,2);
date=m_list.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_list.InsertItem(ii-1,"");
m_list.SetItemText(ii-1,0,rst.GetFieldValue("khfk_id"));
m_list.SetItemText(ii-1,1,rst.GetFieldValue("khfk_fkbt"));
m_list.SetItemText(ii-1,2,rst.GetFieldValue("khfk_khmc"));
m_list.SetItemText(ii-1,3,rst.GetFieldValue("khfk_fknr"));
m_list.SetItemText(ii-1,4,rst.GetFieldValue("khfk_fkrq"));
m_list.SetItemText(ii-1,5,rst.GetFieldValue("khfk_fkslr"));
m_list.SetItemText(ii-1,6,rst.GetFieldValue("khfk_khmyd"));
m_list.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_edit1.SetWindowText("FK001");
this->m_edit1.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_edit1.EnableWindow(false);

this->m_edit1.SetWindowText(mm);
rst3.close();
}
void KHFK::OnDblclkList1(NMHDR pNMHDR, LRESULT pResult)
{
khfkclnum=m_list.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_KEYDOWN && pMsg->wParam==13)
pMsg->wParam=9;
return CDialo

g::PreTranslateMessage(pMsg);
}

C++ Source Part Three
#include "myfunction.h"
#include "ListCtrlPop.h"
#include "WhiteFrame.h"
#include "WhiteRect.h"
#include "LineEdit.h"
#if !defined(AFX_DLGXSJZ_H__23A6FEAB_3058_4154_BFD6_C41E011E7988__INCLUDED_)
#define AFX_DLGXSJZ_H__23A6FEAB_3058_4154_BFD6_C41E011E7988__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif _MSC_VER > 1000
DlgXSJZ.h : header file
CDlgXSJZ dialog
class CDlgXSJZ : public CDialog
{
Construction
public:
virtual ~CDlgXSJZ();
void SetUnChangeValue(CString str);
bool GetRKTHINFO();
bool GetRKINFO();
bool GetXSTHINFO();
bool InitPH();
bool InitJZ();
bool GetXSINFO();
CString ChanShengPh();
bool CheckAll();
void SetTheFocus();
CDlgXSJZ(int state,CWnd pParent = NULL); standard constructor
Dialog Data
{{AFX_DATA(CDlgXSJZ)
enum { IDD = IDD_DIALOG_XSJZ };
CButton m_btnOk;
CEdit m_editIsJq;
CEdit m_editSy;
CDateTimeCtrl m_tcRq;
CComboBox m_comboJsr;
CComboBox m_comboSkfs;
CLineEdit m_editBz;
CLineEdit m_editPh;
CLineEdit m_editSkJe;
CLineEdit m_editWs;
CLineEdit m_editSs;
CLineEdit m_editYs;
CLineEdit m_editKhName;
CLineEdit m_editKhId;
CLineEdit m_editJsfs;
CLineEdit m_editXsPh;
}}AFX_DATA
double m_dss;
double m_dws;
double m_dys;
CString m_strXs_ph;
LRunSql m_runsql;
double m_dYsfk;
double m_dSsfk;
double m_dWsfk;
double m_dSFk_BC; 本次之后
double m_dLeft;
bool is_jq;
bool m_bSetUnChangeValue;
CString m_strPhKeyField;
CString m_strJzKeyField;
CString m_strTablePh;
CString m_strTableJz;
CString m_strsf;
CWhiteFrame m_wfXsJz;
CWhiteRect m_wrXsPh;
CWhiteRect m_wrResult;
CWhiteFrame m_wstrXsPhTitle;
CString m_strPhTitle;
CString m_strdataPhTitle;
CWhiteFrame m_wstrXsPh;
CString m_strPh;
CString m_strdataPh;
CWhiteFrame m_wstrKhId;
CString m_strId;
CString m_strdataId;
CWhiteFrame m_wstrKhName;
CString m_strName;
CString m_strdataName;
CWhiteFrame m_wstrJsfs;
CString m_strJsfs;
CString m_strdataJsfs;
CWhiteFrame m_wstrYs;
CString m_strYsf;
CString m_strdataYsf;
CWhiteFrame m_wstrSs;
CString m_strSsf;
CString m_strdataSsf;
CWhiteFrame m_wstrWs;
CString m_strWsf;
CString m_strdataWsf;
CWhiteFrame m_wstrSkTitle;
CString m_strJzTitle;
CWhiteFrame m_wstrSkJe;
CString m_strJzSFkJe;
CWhiteFrame m_wstrPh;
CString m_strJzPh;
CWhiteFrame m_wstrRq;
CString m_strJzRq;
CWhiteFrame m_wstrJsr;
CString m_strJzJsr;
CWhiteFrame m_wstrSkfs;
CString m_strJzSFkfs;
CWhiteFrame m_wstrBz;
CString m_strJzBz;
enum{XSJZ=0,XSTHJZ=1,RKJZ=2,RKTHJZ=3};
int m_iState;
CLineEdit m_wstrXsPh;
CLineEdit m_wstrKhId;
CLineEdit m_wstrKhName;
CLineEdit m_wstrJsfs;
CLineEdit m_wstrYs;
CLineEdit m_wstrSs;
CLineEdit m_wstrWs;
Overrides

ClassWizard generated virtual function overrides
{{AFX_VIRTUAL(CDlgXSJZ)
public:
virtual BOOL PreTranslateMessage(MSG pMsg);
protected:
virtual void DoDataExchange(CDataExchange pDX); DDXDDV support
}}AFX_VIRTUAL
Implementation
protected:
Generated message map functions
{{AFX_MSG(CDlgXSJZ)
virtual void OnOK();
virtual BOOL OnInitDialog();
afx_msg void OnChangeEdit8();
afx_msg void OnButton1();
virtual void OnCancel();
}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
{{AFX_INSERT_LOCATION}}
Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif !defined(AFX_DLGXSJZ_H__23A6FEAB_3058_4154_BFD6_C41E011E7988__INCLUDED_)

C++ Source Part Four
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.
#include "stdafx.h"
#include "vclabel.h"
Dispatch interfaces referenced by this interface
#include "VcBackdrop.h"
#include "vcfont.h"
#include "vctextlayout.h"
#include "Font.h"
CVcLabel properties
CVcLabel operations
CVcBackdrop CVcLabel::GetBackdrop()
{
LPDISPATCH pDispatch;
InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void)&pDispatch, NULL);
return CVcBackdrop(pDispatch);
}
CString CVcLabel::GetFormat()
{
CString result;
InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_BSTR, (void)&result, NULL);
return result;
}
void CVcLabel::SetFormat(LPCTSTR lpszNewValue)
{
static BYTE parms[] =
VTS_BSTR;
InvokeHelper(0x2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
lpszNewValue);
}
CVcFont CVcLabel::GetVtFont()
{
LPDISPATCH pDispatch;
InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void)&pDispatch, NULL);
return CVcFont(pDispatch);
}
BOOL CVcLabel::GetAuto()
{
BOOL result;
InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_BOOL, (void)&result, NULL);
return result;
}
void CVcLabel::SetAuto(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
BOOL CVcLabel::GetStanding()
{
BOOL result;
InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BOOL, (void)&result, NULL);
return result;
}
void CVcLabel::SetStanding(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
CVcTextLayout CVcLabel::GetTextLayout()
{
LPDISPATCH pDispatch;
InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void)&pDispatch, NULL);
return CVcTextLayout(pDispatch);
}
short CVcLabel::GetFormatLength()
{
short result;
InvokeHelper(0x7, DISPATCH_PROPERTYGET, VT_I2, (void)&result, NULL);
return result;
}
void CVcLabel::SetRefFont(LPDISPATCH newValue)
{
static BYTE parms[] =
VTS_DISPATCH;
InvokeHelper(0x8, DISPATCH_PROPERTYPUTREF, VT_EMPTY, NULL, parms,
newValue);
}
COleFont CVcLabel::GetFont

()
{
LPDISPATCH pDispatch;
InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void)&pDispatch, NULL);
return COleFont(pDispatch);
}

C++ Source Part Five
DlgXSTHINFO.cpp : implementation file
#include "stdafx.h"
#include "a1.h"
#include "DlgXSTHINFO.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CDlgXSTHINFO dialog
CDlgXSTHINFO::CDlgXSTHINFO(int field_number,int state,CWnd pParent =NULL)
: CDialog(CDlgXSTHINFO::IDD, pParent)
{
{{AFX_DATA_INIT(CDlgXSTHINFO)
NOTE: the ClassWizard will add member initialization here
}}AFX_DATA_INIT
m_tabXsth=new CTabXSTH(field_number,state);
}
void CDlgXSTHINFO::DoDataExchange(CDataExchange pDX)
{
CDialog::DoDataExchange(pDX);
{{AFX_DATA_MAP(CDlgXSTHINFO)
NOTE: the ClassWizard will add DDX and DDV calls here
}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgXSTHINFO, CDialog)
{{AFX_MSG_MAP(CDlgXSTHINFO)
}}AFX_MSG_MAP
END_MESSAGE_MAP()
CDlgXSTHINFO message handlers
void CDlgXSTHINFO::OnOK()
{
TODO: Add extra validation here
this->m_tabXsth->m_edits[0].GetWindowText(ph);
int i=m_tabXsth->m_list->GetSelectionMark();
if(this->m_tabXsth->m_dataXs.m_iState!=RK)
{
this->m_strdataPh= m_tabXsth->m_list->GetItemText(i,0);
this->m_strdataId= m_tabXsth->m_list->GetItemText(i,2);
this->m_strdataName=m_tabXsth->m_list->GetItemText(i,3);
this->m_strdataYsf= m_tabXsth->m_list->GetItemText(i,4);
this->m_strdataSsf= m_tabXsth->m_list->GetItemText(i,5);
this->m_strdataWsf= m_tabXsth->m_list->GetItemText(i,6);
this->m_strdataJsfs=m_tabXsth->m_list->GetItemText(i,12);
jq= m_tabXsth->m_list->GetItemText(i,13);
}
else
{
this->m_strdataPh= m_tabXsth->m_list->GetItemText(i,0);
this->m_strdataId= m_tabXsth->m_list->GetItemText(i,1);
this->m_strdataName=m_tabXsth->m_list->GetItemText(i,2);
this->m_strdataYsf= m_tabXsth->m_list->GetItemText(i,3);
this->m_strdataSsf= m_tabXsth->m_list->GetItemText(i,4);
this->m_strdataWsf= m_tabXsth->m_list->GetItemText(i,5);
this->m_strdataJsfs=m_tabXsth->m_list->GetItemText(i,11);
jq= m_tabXsth->m_list->GetItemText(i,12);

}
CDialog::OnOK();
}
BOOL CDlgXSTHINFO::OnInitDialog()
{
CDialog::OnInitDialog();

TODO: Add extra initialization here
CRect rect;
this->GetClientRect(rect);
rect.top=20;
rect.bottom-=60;
CString str;
this->m_tabXsth->Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP,rect,this,ID_TABCTRL_YAOPIN);
switch(m_tabXsth->m_dataXs.m_iState)
{
case RK:
str="入库查询";
break;
case RKTH:str="入库退货查询";
break;
case XSTH:str="销售退货查询";
break;

}
this->SetWindowText(str);
return TRUE; return TRUE unless you set the focus to a control
EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDlgXSTHINFO::DestroyWindow()
{
return CDialog::DestroyWindow();
}
CDlgXSTHINFO::~CDlgXSTHINFO()
{
delete this->m_tabXsth;
m_tabXsth=NULL;
}


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