📄 projectmanageview.cpp
字号:
// ProjectManageView.cpp : CProjectManageView 类的实现
//
#include "stdafx.h"
#include "ProjectManage.h"
#include "ProjectManageDoc.h"
#include "ProjectManageView.h"
#include "User.h"
#include "ADODB.h"
#include "CSpreadSheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CProjectManageView
IMPLEMENT_DYNCREATE(CProjectManageView, cdxCSizingFormView)
BEGIN_MESSAGE_MAP(CProjectManageView, cdxCSizingFormView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
ON_NOTIFY(NM_CLICK, IDC_LIST1, &CProjectManageView::OnNMClickList1)
END_MESSAGE_MAP()
// CProjectManageView 构造/析构
CProjectManageView::CProjectManageView()
:cdxCSizingFormView(CProjectManageView::IDD)
{
// TODO: 在此处添加构造代码
this->m_pDocTemplate=NULL;
CProjectManageApp* pApp= (CProjectManageApp*)AfxGetApp();
pApp->StoreMyView(this);
}
CProjectManageView::~CProjectManageView()
{
}
BOOL CProjectManageView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
cs.style |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
return cdxCSizingFormView::PreCreateWindow(cs);
}
// CProjectManageView 绘制
void CProjectManageView::OnDraw(CDC* /*pDC*/)
{
CProjectManageDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
CTabCtrl* tab=(CTabCtrl*)this->GetDlgItem(IDC_TAB1);
CRect rect;
this->GetClientRect(&rect);
//tab->MoveWindow(&rect);
// TODO: 在此处为本机数据添加绘制代码
}
// CProjectManageView 打印
BOOL CProjectManageView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CProjectManageView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加额外的打印前进行的初始化过程
}
void CProjectManageView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加打印后进行的清除过程
}
// CProjectManageView 诊断
#ifdef _DEBUG
void CProjectManageView::AssertValid() const
{
cdxCSizingFormView::AssertValid();
}
void CProjectManageView::Dump(CDumpContext& dc) const
{
cdxCSizingFormView::Dump(dc);
}
CProjectManageDoc* CProjectManageView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CProjectManageDoc)));
return (CProjectManageDoc*)m_pDocument;
}
#endif //_DEBUG
// CProjectManageView 消息处理程序
void CProjectManageView::OnInitialUpdate()
{
cdxCSizingFormView::OnInitialUpdate(m_wndPlaceholder,fdAll);
AddSzControl(m_Box,mdResize,mdResize);
AddSzControlEx(m_BasicInfoTabPage,0,100,0,100);
AddSzControlEx(m_oListmateriel,0,100,0,100);
GetParentFrame()->RecalcLayout();
ReorganizeControls();
ResizeParentToFit();
InitListHead();
// TODO: 在此添加专用代码和/或调用基类
}
void CProjectManageView::InitListHead()
{
for(int delcolumn=100;delcolumn>=0;delcolumn--)
m_oListmateriel.DeleteColumn(delcolumn);
////设置list对话框的列
DWORD dwStyle;
RECT rect;
LV_COLUMN lvc;
dwStyle = m_oListmateriel.GetStyle();
dwStyle |= LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT|LVS_SHOWSELALWAYS ;
m_oListmateriel.SetExtendedStyle(dwStyle);
m_oListmateriel.GetClientRect(&rect);
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;
lvc.fmt=LVCFMT_LEFT;
lvc.iSubItem = 0;
lvc.pszText = _T("编号");
lvc.cx = 50;
m_oListmateriel.InsertColumn(1,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("项目名称");
lvc.cx = 80;
m_oListmateriel.InsertColumn(2,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("区域");
lvc.cx = 80;
m_oListmateriel.InsertColumn(3,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("客户");
lvc.cx = 100;
m_oListmateriel.InsertColumn(4,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("日期");
lvc.cx = 90;
m_oListmateriel.InsertColumn(5,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("参与人员");
lvc.cx = 150;
m_oListmateriel.InsertColumn(6,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("日期");
lvc.cx = 0;
m_oListmateriel.InsertColumn(7,&lvc);
lvc.iSubItem = 7;
lvc.pszText = _T("售后代维原因");
lvc.cx = 150;
m_oListmateriel.InsertColumn(8,&lvc);
lvc.iSubItem = 8;
lvc.pszText = _T("售后代维内容");
lvc.cx = 120;
m_oListmateriel.InsertColumn(9,&lvc);
lvc.iSubItem = 9;
lvc.pszText = _T("结果");
lvc.cx = 60;
m_oListmateriel.InsertColumn(10,&lvc);
lvc.iSubItem = 10;
lvc.pszText = _T("备注");
lvc.cx = 150;
m_oListmateriel.InsertColumn(11,&lvc);
m_BasicInfoTabPage.AddPage("基本信息", &m_oBaseInfodlg, IDD_BASICINFOFRM);
m_BasicInfoTabPage.AddPage("人力成本",&m_oStuffList,IDD_USER_COST);
m_BasicInfoTabPage.AddPage("车辆成本",&m_oCarList,IDD_CAR_COST);
m_BasicInfoTabPage.AddPage("用料统计",&m_oSutffList,IDD_STUFF_LIST);
m_BasicInfoTabPage.Show();
LoadListViewData();
//m_ItemTabPage.Show();
}
void CProjectManageView::DoDataExchange(CDataExchange* pDX)
{
// TODO: 在此添加专用代码和/或调用基类
cdxCSizingFormView::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PLACEHOLDER, m_wndPlaceholder);
DDX_Control(pDX, IDC_LIST1, m_oListmateriel);
DDX_Control(pDX, IDC_TAB1, m_BasicInfoTabPage);
DDX_Control(pDX, IDC_BOX, m_Box);
}
void CProjectManageView::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
CString ProjectName,ProjID,ProjDesc,UserType,RegionName,SalesDate,cDataTime,SalesPerson,ServiceReson,ServiceConcent,ServiceResult;
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if(pNMListView->iItem != -1)
{
CString strtemp,value,mValue,proviceName,AreaName;
strtemp.Format("单击的是第%d行第%d列",
pNMListView->iItem, pNMListView->iSubItem);
RegionName=m_oListmateriel.GetItemText(pNMListView->iItem, 2);
ProjectName=m_oListmateriel.GetItemText(pNMListView->iItem, 1);
ProjID=m_oListmateriel.GetItemText(pNMListView->iItem, 0);
UserType=m_oListmateriel.GetItemText(pNMListView->iItem, 3);
ProjDesc=m_oListmateriel.GetItemText(pNMListView->iItem, 10);
SalesDate=m_oListmateriel.GetItemText(pNMListView->iItem, 4);
cDataTime=m_oListmateriel.GetItemText(pNMListView->iItem, 6);
SalesPerson=m_oListmateriel.GetItemText(pNMListView->iItem, 5);
ServiceReson=m_oListmateriel.GetItemText(pNMListView->iItem, 7);
ServiceConcent=m_oListmateriel.GetItemText(pNMListView->iItem, 8);
ServiceResult=m_oListmateriel.GetItemText(pNMListView->iItem, 9);
this->m_Storage.OpenSql("ProjectTab","mod_id","where ProjectID="+ProjID+"");
this->m_Storage.GetFieldValue(0,value);
this->m_Storage.OpenSql("RegionTree","mod_parent","where mod_id="+value+"");
this->m_Storage.GetFieldValue(0,mValue);
this->m_Storage.OpenSql("RegionTree","mod_name,mod_parent","where mod_id="+mValue+"");
this->m_Storage.GetFieldValue(0,AreaName);
this->m_Storage.GetFieldValue(1,mValue);
this->m_Storage.OpenSql("RegionTree","mod_name","where mod_id="+mValue+"");
this->m_Storage.GetFieldValue(0,proviceName);
CComboBox* modBox=(CComboBox*)m_oBaseInfodlg.GetDlgItem(IDC_COMBO3);
modBox->SetWindowTextA(value);
CComboBox* poriceBox=(CComboBox*)m_oBaseInfodlg.GetDlgItem(IDC_COMBO2);
poriceBox->SetWindowTextA(proviceName);
CComboBox* AreaBox=(CComboBox*)m_oBaseInfodlg.GetDlgItem(IDC_COMBO5);
AreaBox->SetWindowTextA(AreaName);
CComboBox* RegionBox=(CComboBox*)m_oBaseInfodlg.GetDlgItem(IDC_COMBO4);
RegionBox->SetWindowTextA(RegionName);
CEdit * mProjName=(CEdit*)m_oBaseInfodlg.GetDlgItem(IDC_EDIT1);
mProjName->SetWindowTextA(ProjectName);
//CEdit * mPID=(CEdit*)m_oBaseInfodlg.GetDlgItem(IDC_EDIT2);
//mPID->SetWindowTextA(ProjID);
CComboBox* mProjID=(CComboBox*)m_oBaseInfodlg.GetDlgItem(IDC_COMBO1);
mProjID->SetWindowTextA(UserType);
/*CEdit* txtSalesDate=(CEdit*)m_oBaseInfodlg.GetDlgItem(IDC_DATETIMEPICKER1);
txtSalesDate->SetWindowTextA(SalesDate);*/
COleDateTime dt;
dt.ParseDateTime(SalesDate);
CDateTimeCtrl* txtSalesDate=(CDateTimeCtrl*)m_oBaseInfodlg.GetDlgItem(IDC_DATETIMEPICKER1);
txtSalesDate->SetTime(dt);
///**CEdit* txtDataTime=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_DATETIMEPICKER2);
//txtDataTime->SetWindowTextA(cDataTime);*/
COleDateTime dtt;
dtt.ParseDateTime(cDataTime);
CDateTimeCtrl* txtDataTime=(CDateTimeCtrl*) m_oBaseInfodlg.GetDlgItem(IDC_DATETIMEPICKER2);
txtDataTime->SetTime(dtt);
CEdit* txtSalesPerson=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT3);
txtSalesPerson->SetWindowTextA(SalesPerson);
CEdit* txtServiceReson=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT4);
txtServiceReson->SetWindowTextA(ServiceReson);
CEdit* txtServiceConcent=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT5);
txtServiceConcent->SetWindowTextA(ServiceConcent);
CEdit* txtServiceResult=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT6);
txtServiceResult->SetWindowTextA(ServiceResult);
CEdit* txtServiceDesc=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT7);
txtServiceDesc->SetWindowTextA(ProjDesc);
CEdit* txtPIDbox=(CEdit*) m_oBaseInfodlg.GetDlgItem(IDC_EDIT2);
txtPIDbox->SetWindowTextA(ProjID);
theApp.ProjID=ProjID;
theApp.ProjName=ProjectName;
m_oStuffList.LoadDataView();
m_oCarList.LoadDataView();
m_oSutffList.LoadDataView();
}
*pResult = 0;
}
void CProjectManageView::LoadData(CString sSql)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -