?? dsellquery.cpp
字號:
// DSellQuery.cpp : implementation file
//
#include "stdafx.h"
#include "qpglxt.h"
#include "DSellQuery.h"
#include "externDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CQpglxtApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDSellQuery dialog
CDSellQuery::CDSellQuery(CWnd* pParent /*=NULL*/)
: CDialog(CDSellQuery::IDD, pParent)
{
//{{AFX_DATA_INIT(CDSellQuery)
//}}AFX_DATA_INIT
}
void CDSellQuery::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDSellQuery)
DDX_Control(pDX, IDC_STAToolTextBottom, m_StaToolTextBottom);
DDX_Control(pDX, IDC_STAToolTextTop, m_StaToolTextTop);
DDX_Control(pDX, IDC_STAToolText, m_StaToolText);
DDX_Control(pDX, IDC_GRID2, m_Grid2);
DDX_Control(pDX, IDC_GRID1, m_Grid1);
DDX_Control(pDX, IDC_EDTCondition, m_EdtCondition);
DDX_Control(pDX, IDC_DATE2, m_Date2);
DDX_Control(pDX, IDC_DATE1, m_Date1);
DDX_Control(pDX, IDC_COMField, m_ComField);
DDX_Control(pDX, IDC_COMEmblem, m_ComEmblem);
DDX_Control(pDX, IDC_BUTQUERY, m_ButQuery);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDSellQuery, CDialog)
//{{AFX_MSG_MAP(CDSellQuery)
ON_BN_CLICKED(IDC_BUTQUERY, OnButquery)
ON_NOTIFY(NM_DBLCLK, IDC_GRID1, OnDblclkGrid1)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTPrint, OnBUTPrint)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDSellQuery message handlers
void CDSellQuery::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDSellQuery::OnButquery()
{
CString sField,sEmblem,sCondition,sSQL,sDate1,sDate2,cFieldType;
m_ComField.GetWindowText(sField);
m_ComEmblem.GetWindowText(sEmblem);
m_EdtCondition.GetWindowText(sCondition);
m_Date1.GetWindowText(sDate1);
m_Date2.GetWindowText(sDate2);
CString abc=m_ComField.m_CurrentFieldType;
if(m_ComField.m_CurrentFieldType=="字符型")
{
if(sEmblem=="LIKE")
sSQL.Format("SELECT * from %s WHERE %s %s '%s%%' AND 時間 BETWEEN #%s# AND #%s#",m_DataBaseName,sField,sEmblem,sCondition,sDate1,sDate2);
else
sSQL.Format("SELECT * from %s WHERE %s %s '%s' AND 時間 BETWEEN #%s# AND #%s#",m_DataBaseName,sField,sEmblem,sCondition,sDate1,sDate2);
}
if(m_ComField.m_CurrentFieldType=="數值型")
sSQL.Format("SELECT * from %s WHERE %s %s %s AND 時間 BETWEEN #%s# AND #%s#",m_DataBaseName,sField,sEmblem,sCondition,sDate1,sDate2);
if(m_ComField.m_CurrentFieldType=="日期型")
sSQL.Format("SELECT * from %s WHERE %s %s #%s# AND 時間 BETWEEN #%s# AND #%s#",m_DataBaseName,sField,sEmblem,sCondition,sDate1,sDate2);
rst.Open(sSQL,adCmdText);
m_Grid1.AddCellValue(rst);
}
void CDSellQuery::SetCaption(CString sCaption)
{
m_Caption=sCaption;
}
void CDSellQuery::SetDateBase(CString sDateBaseName)
{
m_DataBaseName=sDateBaseName;
}
BOOL CDSellQuery::OnInitDialog()
{
CDialog::OnInitDialog();
CString ToolText;
m_StaToolText.SetBkColor(RGB(92,92,92));
m_StaToolText.SetTextColor(RGB(255,255,255));
m_StaToolText.SetTextSize(12);
m_ComField.m_CurrentFieldType="文本";
ToolText.Format("用戶在右上方輸入查詢字段及查詢條件,單擊〖查詢〗按鈕,系統會將符合條件的概要%s信息顯示在綠色的表格中。用戶可以雙擊某條概要%s信息查詢對應的詳細%s信息。詳細%s信息顯示在粉色的表格中。",m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4),m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4),m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4),m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4));
m_StaToolText.SetWindowText(ToolText);
SetWindowText(m_Caption);
m_Grid1.ReadOnly(true);
m_Grid1.SetDataBase(m_DataBaseName,adCmdTable);
CString sWaterBook,sToolTextTop,sToolTextBottom;
sToolTextTop="概要"+m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"信息";
sToolTextBottom="詳細"+m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"信息";
this->m_StaToolTextTop.SetWindowText(sToolTextTop);
this->m_StaToolTextBottom.SetWindowText(sToolTextBottom);
sWaterBook=m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"明細查詢";
m_Grid1.SetBkColor(RGB(233,255,215));
m_Grid1.SetTextBkColor(RGB(233,255,215));
CString sSQL;
if(m_DataBaseName=="進貨查詢"|| m_DataBaseName=="銷售退貨查詢")
sSQL.Format("SELECT 票號,往來單位,倉庫,合計數量,合計金額,實付金額,未付金額,找零,經手人,操作員 FROM %s",m_DataBaseName);
else
sSQL.Format("SELECT 票號,往來單位,倉庫,合計數量,合計金額,實收金額,未收金額,找零,經手人,操作員 FROM %s",m_DataBaseName);
rst.Open(sSQL,adCmdText);
m_Grid2.ReadOnly(true);
m_Grid2.SetDataBase(sWaterBook,adCmdTable);
m_Grid2.SetBkColor(RGB(255,215,233));
m_Grid2.SetTextBkColor(RGB(255,215,233));
m_Grid2.DeleteAllItems();
m_ComField.SetFieldset(rst);
m_ComEmblem.SetCurSel(0);
m_ComField.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDSellQuery::OnDblclkGrid1(NMHDR* pNMHDR, LRESULT* pResult)
{
RxRecordset rRst;
CString sSQL,sText,TableName;
if(m_Grid1.GetHotItem()<0)
return;
m_HotItem=m_Grid1.GetHotItem();
TableName=m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"明細查詢";
sText=this->m_Grid1.GetItemText(m_Grid1.GetHotItem(),0);
sSQL.Format("SELECT* FROM %s WHERE 票號='%s'",TableName,sText);
rRst.Open(sSQL,adCmdText);
m_Grid2.AddCellValue(rRst);
*pResult = 0;
}
HBRUSH CDSellQuery::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CDSellQuery::OnBUTPrint()
{
CString sName,sDate,sCliect,sSumMoney,sBigMoney,sSumNumber,sID;
RxRecordset brst;
brst.Open("系統設置表");
sName=brst.GetFieldValue("公司名稱");
sName=sName+m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"單";
sDate=this->m_Grid1.GetItemText(m_HotItem,1);
sCliect=this->m_Grid1.GetItemText(m_HotItem,2);
sSumMoney=this->m_Grid1.GetItemText(m_HotItem,5);
sSumNumber=this->m_Grid1.GetItemText(m_HotItem,4);
sBigMoney=MoneyToChineseCode(sSumMoney);
sID=this->m_Grid1.GetItemText(m_HotItem,0);
m_ps.MainCaptionFontSize=400;
m_ps.DeckCaptionFontSize=180;
m_ps.MainCaption=sName;
m_ps.DeckCaptionNumber=3;
m_ps.DeckCaptions[0]=m_DataBaseName.Left(4)+"編號:"+sID;
m_ps.DeckCaptions[1]=m_DataBaseName.Mid(0,m_DataBaseName.GetLength()-4)+"日期:"+sDate;
m_ps.DeckCaptions[2]="往來單位:"+sCliect;
m_ps.Grid=&m_Grid2;
m_ps.TotalNumber=3;
m_ps.Totals[0]="合計金額(小寫):"+sSumMoney;
m_ps.Totals[2]="合計數量:"+sSumNumber;
m_ps.Totals[1]="合計金額(大寫):"+sBigMoney;
theApp.Print();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -