⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slabsearchformview.cpp

📁 开发环境为VC++ 的数据库管理系统
💻 CPP
字号:
// SlabSearchFormView.cpp : implementation file
//

#include "stdafx.h"
#include "mestang.h"
#include "SlabSearchFormView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSlabSearchFormView

IMPLEMENT_DYNCREATE(CSlabSearchFormView, CFormView)

CSlabSearchFormView::CSlabSearchFormView()
	: CFormView(CSlabSearchFormView::IDD)
{
	//{{AFX_DATA_INIT(CSlabSearchFormView)
	m_date_input = 0;
	m_castid = _T("");
	m_slab_h = 220;
	m_slab_l = 3300;
	m_slab_w = 2000;
	//}}AFX_DATA_INIT
}

CSlabSearchFormView::~CSlabSearchFormView()
{
}

void CSlabSearchFormView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSlabSearchFormView)
	DDX_Control(pDX, IDC_RELATE, m_relate);
	DDX_Control(pDX, IDC_CONDICTION2, m_condiction2);
	DDX_Control(pDX, IDC_LIST_SLAB_TOTAL, m_list_slab_total);
	DDX_Control(pDX, IDC_STEEL_CODE, m_steel_code);
	DDX_Control(pDX, IDC_STATUS, m_status);
	DDX_Control(pDX, IDC_SHIFT, m_shift);
	DDX_Control(pDX, IDC_LIST_SLAB_SEARCH, m_list_slab_search);
	DDX_Control(pDX, IDC_CONDICTION, m_condiction);
	DDX_DateTimeCtrl(pDX, IDC_DATE_INPUT, m_date_input);
	DDX_Text(pDX, IDC_EDIT_FurCode, m_castid);
	DDX_Text(pDX, IDC_EDIT_Slab_H, m_slab_h);
	DDX_Text(pDX, IDC_EDIT_Slab_L, m_slab_l);
	DDX_Text(pDX, IDC_EDIT_Slab_W, m_slab_w);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSlabSearchFormView, CFormView)
	//{{AFX_MSG_MAP(CSlabSearchFormView)
	ON_WM_DESTROY()
	ON_BN_CLICKED(ID_SEARCH_CONDICTION, OnSearchCondiction)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSlabSearchFormView diagnostics

#ifdef _DEBUG
void CSlabSearchFormView::AssertValid() const
{
	CFormView::AssertValid();
}

void CSlabSearchFormView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSlabSearchFormView message handlers

void CSlabSearchFormView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	m_shift.SetCurSel(1);
	m_status.SetCurSel(1);
	m_condiction.SetCurSel(6);
	m_condiction2.SetCurSel(6);
	m_relate.SetCurSel(0);
	if (theApp.cn.is_opened==false)
	{
		theApp.open_mes();
	}
	else
	{
	}
	
	CString temp_code;
	steel_code_count=0;
	resultset &rs_steelcode = *(theApp.cn).select("select STEEL_CODE from  STEEL_GRADE");

	for(;!rs_steelcode.eod();++rs_steelcode)
	{
		temp_code=result_CString(rs_steelcode,"STEEL_CODE");
        int j=m_steel_code.FindStringExact(0,temp_code);
		if(j==-1)
		m_steel_code.AddString(temp_code);
		steel_code_count++;
	}
	rs_steelcode.release();	
	m_steel_code.SetCurSel(0);

	int code_count=0;
	CString str_shift,si;
	m_shift.SetCurSel(0);
	m_steel_code.SetCurSel(1);
	theApp.cn.close();
	

	//设置LIST_SLAB_SEARCH的框架大小
	m_list_slab_search.SetWindowPos(NULL,0,0,1242,280,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
	m_list_slab_search.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_INFOTIP | LVS_EDITLABELS);
	m_list_slab_search.SetBkColor(RGB(224,255,255));
	m_list_slab_search.SetTextBkColor(RGB(230 ,230 ,250));
	m_list_slab_search.SetTextColor(RGB(85 ,26 ,139 ));
	//设置列表框LIST_SLAB_SEARCH标题名字
	int k=0;
	m_list_slab_search.InsertColumn(k++,"炉号",LVCFMT_CENTER,100);
	m_list_slab_search.InsertColumn(k++,"入库数(块)",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"已挂料数(块)",LVCFMT_CENTER,100);	
	m_list_slab_search.InsertColumn(k++,"库存数(块)",LVCFMT_CENTER,100);		
	m_list_slab_search.InsertColumn(k++,"板坯类型",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"钢种",LVCFMT_CENTER,60);
	m_list_slab_search.InsertColumn(k++,"板坯厚度(mm)",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"板坯宽度(mm)",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"板坯长度(mm)",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"班次",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"操作者",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"入库日期",LVCFMT_CENTER,140);		
	m_list_slab_search.InsertColumn(k++,"C",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"Si",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"Mn",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"P",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"S",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"Nb",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"V",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"Ti",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"Al",LVCFMT_CENTER,60);	
	m_list_slab_search.InsertColumn(k++,"Cu",LVCFMT_CENTER,80);
    m_list_slab_search.InsertColumn(k++,"Ni",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"元素1",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"元素1含量",LVCFMT_CENTER,80);	
	m_list_slab_search.InsertColumn(k++,"元素2",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"元素2含量",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"元素3",LVCFMT_CENTER,80);
	m_list_slab_search.InsertColumn(k++,"元素3含量",LVCFMT_CENTER,80);
	//设置LIST_SLAB_TOTAL的框架大小
	m_list_slab_total.SetWindowPos(NULL,0,0,1242,250,SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE);
	m_list_slab_total.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_INFOTIP | LVS_EDITLABELS);
	m_list_slab_total.SetBkColor(RGB(224,255,255));
	m_list_slab_total.SetTextBkColor(RGB(230 ,230 ,250));
	m_list_slab_total.SetTextColor(RGB(85 ,26 ,139 ));
	//设置列表框LIST_SLAB_TOTAL标题名字
	m_list_slab_total.InsertColumn(0,"钢种",LVCFMT_CENTER,200);
	m_list_slab_total.InsertColumn(1,"板坯类型",LVCFMT_CENTER,200);
	m_list_slab_total.InsertColumn(2,"板坯厚度(mm)",LVCFMT_CENTER,200);	
	m_list_slab_total.InsertColumn(3,"板坯宽度(mm)",LVCFMT_CENTER,200);
	m_list_slab_total.InsertColumn(4,"板坯长度(mm)",LVCFMT_CENTER,200);
	m_list_slab_total.InsertColumn(5,"数量",LVCFMT_CENTER,200);
	//设置列表框控件字体
	CFont m_ListFont;
    m_ListFont.CreateFont(16,0,0,0,FW_NORMAL, 0,0,0,DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Times New Roman");
    m_list_slab_search.SetFont(&m_ListFont);
    m_list_slab_total.SetFont(&m_ListFont);	

	m_date_input = CTime::GetCurrentTime();
	UpdateData(false);
}

void CSlabSearchFormView::OnDestroy() 
{
	CFormView::OnDestroy();
	
	// TODO: Add your message handler code here
	
}

void CSlabSearchFormView::OnSearchCondiction() 
{
	// TODO: Add your control notification handler code here
	m_list_slab_search.DeleteAllItems();
	UpdateData(TRUE);
	int condiction_no = m_condiction.GetCurSel();
	CString cond_furcode;
	CString cond_steel_code;
	CString cond_shift;
	CString cond_input_data;
	CString cond_status;
	CString cond_oper_name;
	CString si;
	CString cond_slab_h,cond_slab_w,cond_slab_l;
	switch(condiction_no)
	{
		case 0:
			{//shift
			m_shift.GetLBText(m_shift.GetCurSel(),cond_shift);
			si.Format("'%s'",cond_shift);
			theApp.open_mes();	
			resultset &rs_slab_search0 = *(theApp.cn).select ("select * from  CAST_INF where SHIFT="+si+"order by STEEL_TYPE,MATERIAL_THICK DESC,MATERIAL_WIDE DESC,MATERIAL_LENGTH DESC,INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search0);
			theApp.cn.close();
			break;
			}
		case 1:
			{// chi cun
			cond_slab_h.Format("%d",m_slab_h);
			cond_slab_w.Format("%d",m_slab_w);
			cond_slab_l.Format("%d",m_slab_l);
			theApp.open_mes();	
			resultset &rs_slab_search2 = *(theApp.cn).select ("select * from  CAST_INF where MATERIAL_THICK ="+cond_slab_h+"and MATERIAL_WIDE ="+cond_slab_w+"and MATERIAL_LENGTH ="+cond_slab_l+"order by STEEL_TYPE, INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search2);
			theApp.cn.close();
			break;
			}
		case 2:
			{//steel code
			m_steel_code.GetLBText(m_steel_code.GetCurSel(),cond_steel_code);
			si.Format("'%s'",cond_steel_code);
			theApp.open_mes();	
			resultset &rs_slab_search3 = *(theApp.cn).select ("select * from  CAST_INF where STEEL_TYPE="+si+"order by MATERIAL_THICK DESC,MATERIAL_WIDE DESC,MATERIAL_LENGTH DESC,INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search3);
			theApp.cn.close();
			break;
			}
		case 3:
			{//lengzhuang or zhigong
			m_status.GetLBText(m_status.GetCurSel(),cond_status);
			si.Format("'%s'",cond_status);
			theApp.open_mes();	
			resultset &rs_slab_search4 = *(theApp.cn).select ("select * from  CAST_INF where DHCR="+si+"order by STEEL_TYPE,MATERIAL_THICK DESC,MATERIAL_WIDE DESC,MATERIAL_LENGTH DESC,INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search4);
			theApp.cn.close();
			break;
			}
		case 4:
			{//furcode
			m_castid.TrimRight();
			m_castid.TrimLeft();
			si.Format("'%s'",m_castid);
			theApp.open_mes();	
			resultset &rs_slab_search5 = *(theApp.cn).select ("select * from  CAST_INF where CAST_ID="+si);
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search5);
			theApp.cn.close();
			break;
			}
		case 5:
			{//all
			theApp.open_mes();	
			resultset &rs_slab_search5 = *(theApp.cn).select ("select * from  CAST_INF order by STEEL_TYPE,MATERIAL_THICK DESC,MATERIAL_WIDE DESC,MATERIAL_LENGTH DESC,INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search5);
			theApp.cn.close();
			break;
			}
		case 6:
			{//order by input data
			cond_input_data = m_date_input.Format("'%Y-%m-%d'");
			cond_input_data.TrimLeft();
			cond_input_data.TrimRight();
			theApp.open_mes();	
			resultset &rs_slab_search6 = *(theApp.cn).select ("select * from  CAST_INF where INPUT_DATE="+cond_input_data+"order by STEEL_TYPE,DHCR");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search6);
			theApp.cn.close();
			break;
			}
		default:
			{//all
			theApp.open_mes();	
			resultset &rs_slab_search_all = *(theApp.cn).select ("select * from  CAST_INF order by STEEL_TYPE,MATERIAL_THICK DESC,MATERIAL_WIDE DESC,MATERIAL_LENGTH DESC,INPUT_DATE DESC");
			SlabInfo_List_Update(m_list_slab_search,rs_slab_search_all);
			theApp.cn.close();
			break;
			}
	}
	m_list_slab_total.DeleteAllItems();
	theApp.open_mes();	
	resultset	&rs_steel= *(theApp.cn).select ("select * from  CAST_INF_STATISTIC2 ");
	SlabTotal_STEEL(m_list_slab_total,rs_steel);
	resultset	&rs_dhcr = *(theApp.cn).select ("select * from  CAST_INF_STATISTIC1 ");
	SlabTotal_DUCR(m_list_slab_total,rs_dhcr);
	theApp.cn.close();

}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -