📄 admcolumndlg.cpp
字号:
// AdmColumnDlg.cpp : implementation file
//
#include "stdafx.h"
#include "tvnews.h"
#include "AdmColumnDlg.h"
#include "Column.h"
#include "ColumnInfDlg.h"
#include "Channel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdmColumnDlg dialog
CAdmColumnDlg::CAdmColumnDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAdmColumnDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAdmColumnDlg)
m_Channel = _T("");
//}}AFX_DATA_INIT
}
void CAdmColumnDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdmColumnDlg)
DDX_Control(pDX, IDC_COMBO1, m_cmbChannel);
DDX_Control(pDX, IDC_LIST1, m_ColList);
DDX_CBString(pDX, IDC_COMBO1, m_Channel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAdmColumnDlg, CDialog)
//{{AFX_MSG_MAP(CAdmColumnDlg)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_BN_CLICKED(IDC_BTNUPDATE_RINFO, OnBtnupdateEdt)
ON_BN_CLICKED(IDC_BTNUPDATE_RINFO2, OnBtnupdateIns)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_CBN_SELENDOK(IDC_COMBO1, OnSelendokCombo1)
ON_BN_CLICKED(IDC_BTNUPDATE_RINFO3, OnBtnupdateRinfo3)
ON_WM_SHOWWINDOW()
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdmColumnDlg message handlers
BOOL CAdmColumnDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ColList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_ColList.InsertColumn(0,_T("ID"));
m_ColList.SetColumnWidth(0,0);
m_ColList.InsertColumn(1,_T("栏目名称"));
m_ColList.SetColumnWidth(1,150);
m_ColList.InsertColumn(2,_T("频道名称"));
m_ColList.SetColumnWidth(2,150);
m_ColList.InsertColumn(3,_T("描述"));
m_ColList.SetColumnWidth(3,150);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAdmColumnDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
//-- Get the number of selected rows
int nSelRows = m_ColList.GetSelectedCount();
if(!nSelRows) //-- If there are no rows selected,jump out here
return;
//-- Get the position of the first selected row
POSITION pos =m_ColList.GetFirstSelectedItemPosition();
//-- Get the index of next selected row
int i = m_ColList.GetNextSelectedItem(pos);
if (i != -1) //-- Execute this loop as long as GetNextSelectedItem() returns -1
{
selectID= atoi(m_ColList.GetItemText(i, 0));
}
*pResult = 0;
return;
}
void CAdmColumnDlg::OnBtnupdateEdt()
{
// TODO: Add your control notification handler code here
if(m_ColList.GetSelectedCount()==0)
{
MessageBox("请选择要编辑的行!");
return;
}
CColumnInfDlg ColumnInfDlg;
ColumnInfDlg.Type=1;
ColumnInfDlg.iUID=selectID;
ColumnInfDlg.DoModal();
CColumn Column;
Column.ShowList(m_ColList," AND Columns.UID<>0 ");
}
void CAdmColumnDlg::OnBtnupdateIns()
{
// TODO: Add your control notification handler code here
CColumnInfDlg ColumnInfDlg;
ColumnInfDlg.Type=0;
ColumnInfDlg.DoModal();
CColumn Column;
Column.ShowList(m_ColList,"");
}
void CAdmColumnDlg::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
CChannel Channel;
UpdateData(true);
int number = m_cmbChannel.GetCurSel();
CString strName;
m_cmbChannel.GetLBText(number,strName);
int ID = Channel.GetIDByName(strName);
CString strSQL,strID;
if(ID==0)
strSQL="";
else
{
strID.Format("%d", ID);
strSQL= " AND ChannelID = " + strID ;
strSQL= strSQL + " AND Columns.UID<>0 ";
}
CColumn Column;
Column.ShowList(m_ColList,strSQL);
}
void CAdmColumnDlg::OnSelendokCombo1()
{
// TODO: Add your control notification handler code here
}
void CAdmColumnDlg::OnBtnupdateRinfo3()
{
// TODO: Add your control notification handler code here
if(m_ColList.GetSelectedCount()==0)
{
MessageBox("请选择要删除的行!");
return;
}
if(MessageBox("你确定要删除该栏目吗?","询问信息", MB_YESNO ) == IDYES)
{
CColumn Column;
long iFlg;
CString cMessage;
Column.sql_delete(selectID,iFlg,cMessage);
if(1==iFlg)
{
Column.ShowList(m_ColList," AND Columns.UID<>0 ");
}
else
{
MessageBox(cMessage);
}
}
}
void CAdmColumnDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
CChannel Channel;
CStringArray allChannels;
Channel.GetAllChannel(allChannels);
m_cmbChannel.ResetContent();
int i;
for(i=0;i<allChannels.GetSize();i++)
{
m_cmbChannel.AddString(_T(allChannels.GetAt(i)));
}
m_cmbChannel.SelectString(-1,"所有频道");
CColumn Column;
Column.ShowList(m_ColList," AND Columns.UID<>0 ");
}
void CAdmColumnDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nSelRows = m_ColList.GetSelectedCount();
if(!nSelRows) //-- If there are no rows selected,jump out here
return;
//-- Get the position of the first selected row
POSITION pos =m_ColList.GetFirstSelectedItemPosition();
//-- Get the index of next selected row
int i = m_ColList.GetNextSelectedItem(pos);
if (i != -1) //-- Execute this loop as long as GetNextSelectedItem() returns -1
{
selectID= atoi(m_ColList.GetItemText(i, 0));
}
CColumnInfDlg ColumnInfDlg;
ColumnInfDlg.Type=1;
ColumnInfDlg.iUID=selectID;
ColumnInfDlg.DoModal();
CColumn Column;
Column.ShowList(m_ColList," AND Columns.UID<>0 ");
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -