// outsourcing2.cpp : implementation file
//
#include "stdafx.h"
#include "ylgl.h"
#include "outsourcing2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// outsourcing2
outsourcing2::outsourcing2(CWnd* pParent /*=NULL*/)
	: CDialog(outsourcing2::IDD)
{
	//{{AFX_DATA_INIT(outsourcing2)
	m_year = atoi(g_date.Mid(0, 4));
	m_month = atoi(g_date.Mid(5, 2));
	m_day = atoi(g_date.Mid(8, 2));
	m_radio1 = 0;
	m_bInit = 0;
	m_timestmap = 0;
	m_radio2 = 0;
	//}}AFX_DATA_INIT
}

void outsourcing2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(outsourcing2)
	DDX_Control(pDX, IDC_COMBObranch, m_combobranch);
	DDX_Control(pDX, IDC_COMBOren, m_comboren);
	DDX_Control(pDX, IDC_COMBOsplb2, m_combosplb2);
	DDX_Control(pDX, IDC_COMBOsp, m_combosp);
	DDX_Control(pDX, IDC_COMBOsplb, m_combosplb);
	DDX_Control(pDX, IDC_SPIN3, m_spinday);
	DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
	DDX_Control(pDX, IDC_SPIN1, m_spinyear);
	DDX_Control(pDX, IDC_LIST2, m_List1);
	DDX_Control(pDX, IDC_STATIC1, m_static1);
	DDX_Text(pDX, IDC_EDITyear, m_year);
	DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
	DDX_Text(pDX, IDC_EDITmonth, m_month);
	DDV_MinMaxUInt(pDX, m_month, 1, 12);
	DDX_Text(pDX, IDC_EDITday, m_day);
	DDV_MinMaxUInt(pDX, m_day, 1, 31);
	DDX_Radio(pDX, IDC_RADIO3, m_radio1);
	DDX_Radio(pDX, IDC_RADIO24, m_radio2);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(outsourcing2, CDialog)
	//{{AFX_MSG_MAP(outsourcing2)
	ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
	ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
	ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
	ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_EN_CHANGE(IDC_EDITmoney2, OnChangeEDITmoney2)
	ON_CBN_SELCHANGE(IDC_COMBOsplb, OnSelchangeCOMBOsplb)
	ON_CBN_SELCHANGE(IDC_COMBOsp, OnSelchangeCOMBOsp)
	ON_BN_CLICKED(IDC_BUTprint, OnBUTprint)
	ON_BN_CLICKED(IDC_RADIO24, OnRadio24)
	ON_BN_CLICKED(IDC_RADIO25, OnRadio25)
	ON_CBN_SELCHANGE(IDC_COMBOsplb2, OnSelchangeCOMBOsplb2)
	ON_BN_CLICKED(IDC_RADIO26, OnRadio26)
	ON_CBN_SELCHANGE(IDC_COMBOren, OnSelchangeCOMBOren)
	ON_CBN_CLOSEUP(IDC_COMBOren, OnCloseupCOMBOren)
	ON_CBN_SELCHANGE(IDC_COMBObranch, OnSelchangeCOMBObranch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// outsourcing2 diagnostics

#ifdef _DEBUG
void outsourcing2::AssertValid() const
{
	CDialog::AssertValid();
}

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

/////////////////////////////////////////////////////////////////////////////
// outsourcing2 message handlers
extern BOOL CALLBACK EnumChildProc2(HWND hwnd, LPARAM lParam);

BOOL outsourcing2::OnInitDialog()
{
	CDialog::OnInitDialog();
	if (g_bAllBranch)
	{
		GetDlgItem(IDC_STATIC3)->ShowWindow(SW_SHOW);
		GetDlgItem(IDC_COMBObranch)->ShowWindow(SW_SHOW);

		//	m_combobranch.AddString ("");
		for (int i = 0; i < g_brancharray.GetSize(); i++)
		{
			m_combobranch.AddString(g_brancharray.ElementAt(i).ElementAt(0));
		}
	}

	CRect rc2;
	GetWindowRect(rc2);
	::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
	g_WidthScale2 = (float)g_rc.Width() / (float)rc2.Width(); // new/Old
	g_HeightScale2 = (float)g_rc.Height() / (float)rc2.Height();
	EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc2, 0);
	GetDlgItem(IDC_STATIC22)->ShowWindow(m_radio2 == 0);
	GetDlgItem(IDC_COMBOsplb2)->ShowWindow(m_radio2 == 0);

	GetDlgItem(IDC_STATIC20)->ShowWindow(m_radio2);
	GetDlgItem(IDC_STATIC21)->ShowWindow(m_radio2);
	GetDlgItem(IDC_COMBOsplb)->ShowWindow(m_radio2);
	GetDlgItem(IDC_COMBOsp)->ShowWindow(m_radio2);

	m_combosplb.GetWindowRect(rc2);
	ScreenToClient(rc2);
	rc2.bottom += 200;
	m_combosplb.MoveWindow(rc2);
	m_combosp.GetWindowRect(rc2);
	ScreenToClient(rc2);
	rc2.bottom += 200;
	m_combosp.MoveWindow(rc2);

	m_static1.SetFont(&g_titlefont);
#ifdef CHILD_VERSION
#ifdef LKAY_VERSION
	m_List1.SetHeadings("������,100;�ҳ�����,100;��������,100;��Ʒ����,100;����,100;P��,100;����,100;��������,100;�Ƿ񷢳�,100;��������,100;�Ƿ����,100;�������,100;���ʦ,100" );
#else
	m_List1.SetHeadings("������,100;�ҳ�����,100;��������,100;��Ʒ����,100;����,100;��������,100;�Ƿ񷢳�,100;��������,100;�Ƿ����,100;�������,100;���ʦ,100");
#endif
#else
	m_List1.SetHeadings("������,100;�б�����,100;Ů������,100;��Ʒ����,100;����,100;��������,100;�Ƿ񷢳�,100;��������,100;�Ƿ����,100;�������,100;���ʦ,100" );
#endif

	m_List1.m_bSortSupport = 0;
	m_List1.LoadColumnInfo(178);
	m_spinyear.SetRange(1900, 3000);
	m_spinmonth.SetRange(1, 12);
	m_spinday.SetRange(1, 31);
	m_comboren.RefDroppedWidth();
	m_bInit = 1;

	CArray<CStringArray, CStringArray>m_List3array;
	g_sendhead.bsql = 0;
	g_sendhead.code[0] = 2;
	g_sendhead.code[1] = 4;
	g_sendhead.code[2] = 9;
	g_sendhead.tabcount = 3;
	g_pMainWnd->ProcessChatMessageRequest2(1);
	if (g_bSendOK == 0)
	{
		CDialog::OnOK();
		return 0;
	}
	DataToArray(&g_List1array, &m_List2array, &m_List3array);
	m_combosplb.ResetContent();
	m_combosplb.AddString("ȫ��");
	for (int i = 0; i < g_List1array.GetSize(); i++)
		m_combosplb.AddString(g_List1array.ElementAt(i).ElementAt(0));


	m_combosplb2.ResetContent(); m_combosplb2.AddString("ȫ��");
	for (i = 0; i < m_List3array.GetSize(); i++)
	{
		m_combosplb2.AddString(m_List3array.ElementAt(i).ElementAt(1));
	}
	m_combosplb2.SetCurSel(0);


	DateChange();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void outsourcing2::FillGrid()
{
	UpdateData();
	if (m_radio2 == 0)
	{
		FillGrid2();
		return;
	}
	if (m_radio2 == 2)
	{
		FillGrid3();
		return;
	}

	m_List1.DeleteAllItems2();
	int ii = 0;
	m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
	int count = 0;
	int sum1 = 0;
	float sum2 = 0;

	CString str;
	CString splb = "ȫ��";
	CString sp = "ȫ��";
	int pos = m_combosplb.GetCurSel();
	if (pos != -1)
	{
		m_combosplb.GetLBText(pos, splb);
	}
	pos = m_combosp.GetCurSel();
	if (pos != -1)
	{
		m_combosp.GetLBText(pos, sp);
	}
	if (splb == "ȫ��")
	{
		for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
		{
			m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
			sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
		}
	}
	else
	{
		if (sp != "ȫ��")
		{
			for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
			{
				if (sp != m_List1array.ElementAt(ii).ElementAt(3))continue;
				m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
				if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
				{
					int aa = ii;
					while (aa)
					{
						if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
						aa--;
					}
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
				}
				sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			}
		}
		else
		{
			CStringArray cursparray;
			for (int aa = 0; aa < m_combosp.GetCount(); aa++)
			{
				m_combosp.GetLBText(aa, str);
				cursparray.Add(str);
			}


			for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
			{

				BOOL bFind = 0;
				for (int aa = 0; aa < cursparray.GetSize(); aa++)
				{
					if (cursparray.ElementAt(aa) == m_List1array.ElementAt(ii).ElementAt(3))
					{
						bFind = 1; break;
					}
				}
				if (bFind == 0)continue;


				m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
				if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
				{
					int aa = ii;
					while (aa)
					{
						if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
						aa--;
					}
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
					m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
				}
				sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			}
		}
	}

	m_List1.m_arLabels.SetSize(count, 1);

	for (int aa = 0; aa < count; aa++)
	{
#ifdef LKAY_VERSION
		m_List1.m_arLabels.ElementAt (aa).InsertAt (7, GetPriceFromName(m_List1.m_arLabels.ElementAt (aa).ElementAt (3)));
		sum2+=atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (4))*atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (7));
#else
		m_List1.m_arLabels.ElementAt(aa).InsertAt(5, GetPriceFromName(m_List1.m_arLabels.ElementAt(aa).ElementAt(3)));
		sum2 += atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(4))*atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(5));
#endif
	}

	ii = count;
	m_List1.m_LabelCount = ii;
	m_List1.SetItemCountEx(ii);

	str.Format("��Ŀ:%d", ii);
	SetDlgItemText(IDC_STATIC2, str);

	str.Format("%d", sum1);
	SetDlgItemText(IDC_EDITmoney1, str);

	str.Format("%0.5f", sum2);
	SetDlgItemText(IDC_EDITmoney3, str);
}

void outsourcing2::OnBUTclose()
{
	CDialog::OnCancel();
}

void outsourcing2::OnChangeEDITyear()
{
	DateChange();
}

void outsourcing2::OnChangeEDITmonth()
{
	DateChange();
}

void outsourcing2::OnChangeEDITday()
{

}

void outsourcing2::DateChange()
{
	if (m_bInit == 0)return;
	m_spinyear.EnableWindow(0);
	m_spinmonth.EnableWindow(0);
	m_spinday.EnableWindow(0);
	UpdateData();

	if (m_branch != "")
	{
		g_pMainWnd->OnDisconnect();
		g_branchip = GetIP(m_branch);
		g_pMainWnd->OnDisconnect();
		g_branchname = m_branch;
		g_bBranchModify = 1;
	}
	
	int i;
	int g_nYearposTemp = g_nYearpos;
	BOOL bLastYear = 0;
	BOOL bThisYear = 0;
#if JEFF_TEST_ON	// 2015��ʼ���ÿ�������;
	int g_nYearposPre = -1;
	if (m_year >= 2014 && m_year <= atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
	{
		g_nYearpos = -1;
		bThisYear = 1;
		if (m_year == 2014)
		{
			g_nYearposPre = GetYearPos(m_year - 1);
		}
	}
	else if (m_year <= 2013 && g_hisyeararray.GetSize())
	{
		g_nYearpos = GetYearPos(m_year);
		if (g_nYearpos != -1)
			g_nYearposPre = GetYearPos(m_year - 1);
		bLastYear = 1;
	}
#else
	if (m_year == atoi(g_date.Left(4)) && g_hisyeararray.GetSize())
		bThisYear = 1;
	else if (m_year <= atoi(g_date.Left(4)) - 1 && g_hisyeararray.GetSize())
		bLastYear = 1;
	g_nYearpos = GetYearPos(m_year);
	int g_nYearposPre = GetYearPos(m_year - 1);
#endif

	g_sendhead.bsql = 0;
	g_sendhead.code[0] = 148;
	g_sendhead.tabcount = 1;
	CString sql, strdate, strdate2;
	strdate.Format("%04d-%02d-%02d", m_year, m_month, 1);
	strdate2.Format("%04d-%02d-%02d", m_year, m_month, 31);
	m_static1.SetWindowText(strdate.Left(7) + "��������");
	if (m_radio1 == 0)
		sql.Format("[date1]>='" + strdate + "' and [date1]<='" + strdate2 + "';");
	else
		sql.Format("[date3]>='" + strdate + "' and [date3]<='" + strdate2 + "' and [status1]='OK';");
	g_pMainWnd->ProcessChatMessageRequest2(sql);
	if (g_bSendOK == 0)
	{
		m_spinyear.EnableWindow(1);
		m_spinmonth.EnableWindow(1);
		m_spinday.EnableWindow(1);
		g_nYearpos = g_nYearposTemp;
		return;
	}
	DataToArray(&m_List1array);
	if (bLastYear)//�����ȥ��, ��ӽ���IJ���
	{
		g_nYearpos = -1;//����
		g_sendhead.bsql = 0;
		g_sendhead.code[0] = 148;
		g_sendhead.tabcount = 1;
		g_pMainWnd->ProcessChatMessageRequest2(sql);
		if (g_bSendOK == 0)
		{
			m_spinyear.EnableWindow(1);
			m_spinmonth.EnableWindow(1);
			m_spinday.EnableWindow(1);
			g_nYearpos = g_nYearposTemp;
			return;
		}
		CArray<CStringArray, CStringArray>ThisYearList1array;
		DataToArray(&ThisYearList1array);
		int oldsize = m_List1array.GetSize();
		m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
		for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
		{
			m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
		}
	}
	if (g_nYearposPre != -1)//����ǽ���, ���ȥ��IJ���
	{
		g_nYearpos = g_nYearposPre;//ȥ��
		g_sendhead.bsql = 0;
		g_sendhead.code[0] = 148;
		g_sendhead.tabcount = 1;
		g_pMainWnd->ProcessChatMessageRequest2(sql);
		if (g_bSendOK == 0)
		{
			m_spinyear.EnableWindow(1);
			m_spinmonth.EnableWindow(1);
			m_spinday.EnableWindow(1);
			g_nYearpos = g_nYearposTemp;
			return;
		}
		CArray<CStringArray, CStringArray>ThisYearList1array;
		DataToArray(&ThisYearList1array);
		int oldsize = m_List1array.GetSize();
		m_List1array.SetSize(oldsize + ThisYearList1array.GetSize());
		for (i = oldsize; i < oldsize + ThisYearList1array.GetSize(); i++)
		{
			m_List1array.ElementAt(i).Copy(ThisYearList1array.ElementAt(i - oldsize));
		}
	}
	g_nYearpos = g_nYearposTemp;



	FillGrid();
	m_spinyear.EnableWindow(1);
	m_spinmonth.EnableWindow(1);
	m_spinday.EnableWindow(1);
}

void outsourcing2::OnRadio3()
{
	// TODO: Add your control notification handler code here
	UpdateData();
	DateChange();
}

void outsourcing2::OnRadio4()
{
	// TODO: Add your control notification handler code here
	UpdateData();
	DateChange();
}

void outsourcing2::OnChangeEDITmoney2()
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO: Add your control notification handler code here

}

void outsourcing2::OnSelchangeCOMBOsplb()
{
	// TODO: Add your control notification handler code here
	int pos = m_combosplb.GetCurSel();
	if (pos == -1)return;
	CString str;
	m_combosplb.GetLBText(pos, str);
	m_combosp.ResetContent();
	m_combosp.AddString("ȫ��");
	for (int ii = 0; ii < m_List2array.GetSize(); ii++)
	{
		if (m_List2array.ElementAt(ii).ElementAt(6) == str)
		{
			m_combosp.AddString(m_List2array.ElementAt(ii).ElementAt(1));
		}
	}
	m_combosp.SetCurSel(0);
	FillGrid();
}

void outsourcing2::OnSelchangeCOMBOsp()
{
	// TODO: Add your control notification handler code here
	FillGrid();
}

CString outsourcing2::GetPriceFromName(CString name)
{
	for (int ii = 0; ii < m_List2array.GetSize(); ii++)
	{
		if (m_List2array.ElementAt(ii).ElementAt(1) == name)
		{
			return m_List2array.ElementAt(ii).ElementAt(5);
		}
	}
	return "0";
}

void outsourcing2::OnBUTprint()
{
	// TODO: Add your control notification handler code here
	UpdateData();
	CString str;
	str.Format("c:\\%d%02d��������.xls", m_year, m_month);
	ListToXLS(&m_List1, str, 0);
}

void outsourcing2::OnRadio24()
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDlgItem(IDC_STATIC22)->ShowWindow(m_radio2 == 0);
	GetDlgItem(IDC_COMBOsplb2)->ShowWindow(m_radio2 == 0);

	GetDlgItem(IDC_STATIC28)->ShowWindow(m_radio2 == 2);
	GetDlgItem(IDC_COMBOren)->ShowWindow(m_radio2 == 2);

	GetDlgItem(IDC_STATIC20)->ShowWindow(m_radio2 == 1);
	GetDlgItem(IDC_STATIC21)->ShowWindow(m_radio2 == 1);
	GetDlgItem(IDC_COMBOsplb)->ShowWindow(m_radio2 == 1);
	GetDlgItem(IDC_COMBOsp)->ShowWindow(m_radio2 == 1);
	FillGrid();
}

void outsourcing2::OnRadio25()
{
	// TODO: Add your control notification handler code here
	OnRadio24();
}

void outsourcing2::FillGrid2()
{
	m_List1.DeleteAllItems2();
	int ii = 0;
	m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
	int count = 0;
	CString str;
	CString splb = "ȫ��";
	int sum1 = 0;
	float sum2 = 0;


	int pos = m_combosplb2.GetCurSel();
	if (pos != -1)
	{
		m_combosplb2.GetLBText(pos, splb);
	}


	if (splb == "ȫ��")
	{
		for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
		{
			m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
			sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
			{
				int aa = ii;
				while (aa)
				{
					if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
					aa--;
				}
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
			}
		}
	}
	else
	{
		for (ii = 0; ii < m_List1array.GetSize(); ii++)
		{
#ifdef LKAY_VERSION
			if(m_List1array.ElementAt (ii).ElementAt (7).GetLength ()<4)continue;
			if(m_List1array.ElementAt (ii).ElementAt (7).Right (m_List1array.ElementAt (ii).ElementAt (7).GetLength ()-4)!=splb)continue;
#else
			if (m_List1array.ElementAt(ii).ElementAt(5).GetLength() < 4)continue;
			if (m_List1array.ElementAt(ii).ElementAt(5).Right(m_List1array.ElementAt(ii).ElementAt(5).GetLength() - 4) != splb)continue;
#endif



			m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
			sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
			{
				int aa = ii;
				while (aa)
				{
					if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
					aa--;
				}
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
			}
		}
	}

	m_List1.m_arLabels.SetSize(count, 1);

	for (int aa = 0; aa < count; aa++)
	{
#ifdef LKAY_VERSION
		m_List1.m_arLabels.ElementAt (aa).InsertAt (7, GetPriceFromName(m_List1.m_arLabels.ElementAt (aa).ElementAt (3)));
		sum2+=atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (4))*atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (7));
#else
		m_List1.m_arLabels.ElementAt(aa).InsertAt(5, GetPriceFromName(m_List1.m_arLabels.ElementAt(aa).ElementAt(3)));
		sum2 += atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(4))*atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(5));
#endif
	}


	ii = count;
	m_List1.m_LabelCount = ii;
	m_List1.SetItemCountEx(ii);



	str.Format("��Ŀ:%d", ii);
	SetDlgItemText(IDC_STATIC2, str);

	str.Format("%d", sum1);
	SetDlgItemText(IDC_EDITmoney1, str);

	str.Format("%0.5f", sum2);
	SetDlgItemText(IDC_EDITmoney3, str);

}

void outsourcing2::OnSelchangeCOMBOsplb2()
{
	// TODO: Add your control notification handler code here
	FillGrid();
}

void outsourcing2::OnRadio26()
{
	// TODO: Add your control notification handler code here
	OnRadio24();
}

void outsourcing2::OnSelchangeCOMBOren()
{
	// TODO: Add your control notification handler code here
	FillGrid();
}

void outsourcing2::FillGrid3()
{
	m_List1.DeleteAllItems2();
	int ii = 0;
	m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
	int count = 0;
	CString str;
	CString splb = "ȫ��";
	int sum1 = 0;
	float sum2 = 0;
	int pos = m_comboren.GetCurSel();
	if (pos != -1)
	{
		m_comboren.GetLBText(pos, splb);
	}
	splb.TrimRight();

	if (splb == "ȫ��" || splb == "")
	{
		for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
		{
			m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
			sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
			{
				int aa = ii;
				while (aa)
				{
					if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
					aa--;
				}
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
			}
		}
	}
	else
	{
		for (ii = 0; ii < m_List1array.GetSize(); ii++)
		{


#ifdef LKAY_VERSION
			if(m_List1array.ElementAt (ii).ElementAt (11)!=splb)continue;
#else
			if (m_List1array.ElementAt(ii).ElementAt(9) != splb)continue;
#endif


			m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
			sum1 += atoi(m_List1array.ElementAt(ii).ElementAt(4));
			if (m_List1.m_arLabels.ElementAt(count - 1).ElementAt(0) == "")
			{
				int aa = ii;
				while (aa)
				{
					if (m_List1array.ElementAt(aa).ElementAt(0) != "")break;
					aa--;
				}
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(0, m_List1array.ElementAt(aa).ElementAt(0));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(1, m_List1array.ElementAt(aa).ElementAt(1));
				m_List1.m_arLabels.ElementAt(count - 1).SetAt(2, m_List1array.ElementAt(aa).ElementAt(2));
			}
		}
	}

	m_List1.m_arLabels.SetSize(count, 1);

	for (int aa = 0; aa < count; aa++)
	{
#ifdef LKAY_VERSION
		m_List1.m_arLabels.ElementAt (aa).InsertAt (7, GetPriceFromName(m_List1.m_arLabels.ElementAt (aa).ElementAt (3)));
		sum2+=atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (4))*atof(m_List1.m_arLabels.ElementAt (aa).ElementAt (7));
#else
		m_List1.m_arLabels.ElementAt(aa).InsertAt(5, GetPriceFromName(m_List1.m_arLabels.ElementAt(aa).ElementAt(3)));
		sum2 += atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(4))*atof(m_List1.m_arLabels.ElementAt(aa).ElementAt(5));
#endif
	}


	ii = count;
	m_List1.m_LabelCount = ii;
	m_List1.SetItemCountEx(ii);



	str.Format("��Ŀ:%d", ii);
	SetDlgItemText(IDC_STATIC2, str);

	str.Format("%d", sum1);
	SetDlgItemText(IDC_EDITmoney1, str);

	str.Format("%0.5f", sum2);
	SetDlgItemText(IDC_EDITmoney3, str);

}

void outsourcing2::OnCloseupCOMBOren()
{
	// TODO: Add your control notification handler code here
	FillGrid();
}

void outsourcing2::OnSelchangeCOMBObranch()
{
	// TODO: Add your control notification handler code here
	int pos = m_combobranch.GetCurSel();
	if (pos == -1)return;
	m_combobranch.GetLBText(pos, m_branch);
	DateChange();



	CArray<CStringArray, CStringArray>m_List3array;
	g_sendhead.bsql = 0;
	g_sendhead.code[0] = 2;
	g_sendhead.code[1] = 4;
	g_sendhead.code[2] = 9;
	g_sendhead.tabcount = 3;
	g_pMainWnd->ProcessChatMessageRequest2(1);
	if (g_bSendOK == 0)
	{
		return;
	}
	DataToArray(&g_List1array, &m_List2array, &m_List3array);
	m_combosplb.ResetContent();
	m_combosplb.AddString("ȫ��");
	for (int i = 0; i < g_List1array.GetSize(); i++)
		m_combosplb.AddString(g_List1array.ElementAt(i).ElementAt(0));


	m_combosplb2.ResetContent(); m_combosplb2.AddString("ȫ��");
	for (i = 0; i < m_List3array.GetSize(); i++)
	{
		m_combosplb2.AddString(m_List3array.ElementAt(i).ElementAt(1));
	}
	m_combosplb2.SetCurSel(0);
}