📄 lxrxx.cpp
字号:
// lxrxx.cpp : implementation file
//
#include "stdafx.h"
#include "khmanager.h"
#include "lxrxx.h"
#include "ado.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
ado rst2;
int num=1;
int num2;
int sel=1;
int xiugai;
/////////////////////////////////////////////////////////////////////////////
// lxrxx dialog
lxrxx::lxrxx(CWnd* pParent /*=NULL*/)
: CDialog(lxrxx::IDD, pParent)
{
//{{AFX_DATA_INIT(lxrxx)
//}}AFX_DATA_INIT
}
void lxrxx::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(lxrxx)
DDX_Control(pDX, IDC_EDIT9, m_edit9);
DDX_Control(pDX, IDC_EDIT8, m_edit8);
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_EDIT4, m_edit4);
DDX_Control(pDX, IDC_EDIT3, m_edit3);
DDX_Control(pDX, IDC_EDIT2, m_edit2);
DDX_Control(pDX, IDC_EDIT1, m_edit1);
DDX_Control(pDX, IDC_DATETIMEPICKER2, m_date2);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_date1);
DDX_Control(pDX, IDC_COMBO2, m_com2);
DDX_Control(pDX, IDC_COMBO3, m_com3);
DDX_Control(pDX, IDC_COMBO1, m_com1);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_TAB1, m_tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(lxrxx, CDialog)
//{{AFX_MSG_MAP(lxrxx)
ON_COMMAND(ID_ADD, OnAdd)
ON_COMMAND(ID_DELETE, OnDelete)
ON_COMMAND(ID_EXIT, OnExit)
ON_COMMAND(ID_FIRST, OnFirst)
ON_COMMAND(ID_LAST, OnLast)
ON_COMMAND(ID_NEXT, OnNext)
ON_COMMAND(ID_SAVE, OnSave)
ON_COMMAND(ID_UP, OnUp)
ON_COMMAND(ID_UPDATE, OnUpdate)
ON_WM_PAINT()
ON_COMMAND(ID_CANCEL, OnCancel)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnSelchangeTab1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// lxrxx message handlers
void lxrxx::OnAdd()
{
m_tab.SetCurSel(0);
this->textshow();
this->enableall(true);
this->enbutton(false);
this->clearall();
this->numauto();
sel=0;
xiugai=0;
}
void lxrxx::OnCancel()
{
this->textshow();
this->datatotext();
this->texttowin();
this->enableall(false);
this->enbutton(true);
sel=1;
}
void lxrxx::OnDelete()
{
if(MessageBox("删除后数据将丢失","提示",MB_YESNO)==IDYES)
{
CString ss,aa;
this->m_edit1.GetWindowText(aa);
ss.Format("delete from tb_Client_lxrxx where lxrxx_id = '%s'",aa);
rst2.ExecuteSQL(ss);
m_list.DeleteAllItems();
this->loadf();
this->load2();
this->datatotext();
this->texttowin();
}
}
void lxrxx::OnExit()
{
CDialog::EndDialog(true);
}
void lxrxx::OnFirst()
{
m_tab.SetCurSel(0);
this->textshow();
rst2.MoveFirst();
this->datatotext();
this->texttowin();
num=1;
}
void lxrxx::OnLast()
{
m_tab.SetCurSel(0);
this->textshow();
rst2.MoveLast();
this->datatotext();
this->texttowin();
num=num2;
}
void lxrxx::OnNext()
{
if(num==num2)
{return;}
m_tab.SetCurSel(0);
this->textshow();
rst2.MoveNext();
this->datatotext();
this->texttowin();
num+=1;
}
void lxrxx::OnSave()
{
this->wintotext();
CString ss;
if(xiugai==1)
{ss.Format("UPDATE tb_Client_lxrxx set lxrxx_qymc='%s',lxrxx_xm='%s',lxrxx_xb='%s',lxrxx_nl='%s',lxrxx_zw='%s',lxrxx_bgdh='%s',lxrxx_Email='%s',lxrxx_csny='%s',lxrxx_sj='%s',lxrxx_grjj='%s',lxrxx_djrq='%s',lxrxx_xxdjr='%s',lxrxx_bz='%s' where lxrxx_id='%s'",com1,edit2,com2,edit3,com3,edit4,edit5,date1,edit6,edit7,date2,edit8,edit9,edit1);}
else
{ss.Format("INSERT INTO tb_Client_lxrxx values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",edit1,com1,edit2,com2,date1,edit3,com3,edit4,edit5,edit6,edit7,date2,edit8,edit9);}
rst2.ExecuteSQL(ss);
m_list.DeleteAllItems();
this->loadf();
this->load2();
this->datatotext();
this->texttowin();
this->enableall(false);
this->enbutton(true);
sel=1;
xiugai=0;
}
void lxrxx::OnUp()
{ if(num==1)
{return;}
m_tab.SetCurSel(0);
this->textshow();
rst2.MovePrevious();
this->datatotext();
this->texttowin();
num-=1;
}
void lxrxx::OnUpdate()
{
m_tab.SetCurSel(0);
this->textshow();
this->enableall(true);
this->enbutton(false);
sel=0;
xiugai=1;
}
BOOL lxrxx::OnInitDialog()
{
CDialog::OnInitDialog();
this->m_com2.AddString("男");
this->m_com2.AddString("女");
this->m_com3.AddString("董事长");
this->m_com3.AddString("总经理");
this->m_com3.AddString("销售主管");
this->m_com3.AddString("市场主管");
this->m_com3.AddString("宣传主管");
this->m_com3.AddString("总工程师");
this->m_com3.AddString("外联主管");
this->m_com3.AddString("人力资源主管");
this->m_com3.AddString("职员");
ado load;
load.Open("select * from tb_khxx",adCmdText);
int rstnum=load.GetRecordCount();
int l;
for(l=1;l<=rstnum;l++)
{
this->m_com1.AddString(load.GetFieldValue("khxx_mc"));
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_ICON6)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON7)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON8)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON9)));
imagelist.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON10)));
// int weith[2];
// weith[1]=150;
// weith[0]=500;
// weith[2]=200;
CString s;
TCHAR *pString;
CMenu menu;
menu.LoadMenu(IDR_lxrxx);
// this->SetMenu(&menu);
toolbar.EnableAutomation();
toolbar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,ID_TOOLBAR);
toolbar.SetImageList(&imagelist);
TBBUTTON button[12];
int i;
for(i=0;i<12;i++)
{
button[i].dwData=0;
button[i].fsState=TBSTATE_ENABLED;
button[i].fsStyle=TBSTYLE_BUTTON;
}
button[5].fsStyle=TBSTYLE_SEP;
button[10].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_FIRST;
button[6].iBitmap=5;
button[7].idCommand=ID_UP;
button[7].iBitmap=6;
button[8].idCommand=ID_NEXT;
button[8].iBitmap=7;
button[9].idCommand=ID_LAST;
button[9].iBitmap=8;
button[11].idCommand=ID_EXIT;
button[11].iBitmap=9;
for(i=0;i<12;i++)
{
s.LoadString(i+IDS_1);
int nStringLength= s.GetLength() + 1;
pString = s.GetBufferSetLength(nStringLength);
button[i].iString =toolbar.AddStrings(pString);
s.ReleaseBuffer();
}
toolbar.AddButtons(12,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);
m_list.InsertColumn(0,"联系人编号");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -