📄 calendarinput.cpp
字号:
#include "StdAfx.h"
#include "CalendarInput.h"
using namespace System::Globalization;
using namespace System::Threading;
using namespace FAP;
void CalendarInput::InitDisp(void)
{
DateTime dtNow;
String* sSQL = S"";
String* saLangName[] = {S"NAME_C",S"NAME_J",S"NAME_E"};
//Initialize Year ComboBox
dtNow = DateTime::Now;
comboBoxYear->Items->Add(String::Format("{0}", __box(dtNow.Year-1)));
comboBoxYear->Items->Add(String::Format("{0}", __box(dtNow.Year )));
comboBoxYear->Items->Add(String::Format("{0}", __box(dtNow.Year+1)));
//Initialize Process ComboBox
sSQL = String::Concat(sSQL, S"select" );
sSQL = String::Concat(sSQL, S" PROCESS_NO," );
sSQL = String::Concat(sSQL, S" PROCESS_NO || ' ' || NAME_J as NAME_J," );
sSQL = String::Concat(sSQL, S" PROCESS_NO || ' ' || NAME_C as NAME_C," );
sSQL = String::Concat(sSQL, S" PROCESS_NO || ' ' || NAME_E as NAME_E " );
sSQL = String::Concat(sSQL, S"from" );
sSQL = String::Concat(sSQL, S" COST_MST " );
sSQL = String::Concat(sSQL, S"where" );
sSQL = String::Concat(sSQL, S" FACTORY_CODE = '", sFactory ,"' and" );
sSQL = String::Concat(sSQL, S" PROCESS_NO is not null and PROCESS_NO<>'MA00' " );
sSQL = String::Concat(sSQL, S"order by" );
sSQL = String::Concat(sSQL, S" PROCESS_NO" );
oDataSet = oDB->dSetSQL_Select(sSQL, S"COST_MST", 0);
comboBoxProcess->DataSource = oDataSet->Tables->Item[S"COST_MST"];
comboBoxProcess->ValueMember = S"PROCESS_NO";
comboBoxProcess->DisplayMember = saLangName[iLanguage];
//Select Default
comboBoxYear->SelectedIndex = 1;
comboBoxMonth->SelectedIndex = dtNow.Month -1;
comboBoxProcess->SelectedIndex = 0;
}
void CalendarInput::InitGrid(void)
{
ColorDataGridTextBoxColumn *oRowHeader;
ColorDataGridTextBoxColumn *oSunday;
ColorDataGridTextBoxColumn *oMonday;
ColorDataGridTextBoxColumn *oTuesday;
ColorDataGridTextBoxColumn *oWednesday;
ColorDataGridTextBoxColumn *oThursday;
ColorDataGridTextBoxColumn *oFriday;
ColorDataGridTextBoxColumn *oSaturday;
DataView *oDataView;
oGridTable = new DataTable(S"GridData");
oGridSet = new DataSet();
oDataSet = new DataSet();
oTableStyle = new DataGridTableStyle();
oGridTable->Columns->Add(new DataColumn(S"Header", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Sunday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Monday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Tuesday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Wednesday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Thursday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Friday", __typeof(System::String)));
oGridTable->Columns->Add(new DataColumn(S"Saturday", __typeof(System::String)));
oGridSet->Tables->Add(oGridTable);
oDataView = oGridTable->DefaultView;
oDataView->AllowNew = false;
dataGridCal->DataSource = oGridTable;
oTableStyle->MappingName = S"GridData";
oTableStyle->AllowSorting = false;
//Header
oRowHeader = new ColorDataGridTextBoxColumn();
oRowHeader->MappingName = S"Header";
/////设置班次
if (iLanguage==0){
oRowHeader->HeaderText = S"班";
}
if (iLanguage==1){
oRowHeader->HeaderText = S"班";
}
if (iLanguage==2){
oRowHeader->HeaderText = S"Team";
}
//oRowHeader->HeaderText = S" ";
oRowHeader->Alignment = HorizontalAlignment::Center;
oRowHeader->Width = 69;
oRowHeader->ReadOnly = true;
//Sunday
oSunday = new ColorDataGridTextBoxColumn();
oSunday->MappingName = S"Sunday";
oSunday->HeaderText = oInf->saG_WeekSun[iLanguage];
oSunday->Alignment = HorizontalAlignment::Center;
oSunday->Width = 92;
//Monday
oMonday = new ColorDataGridTextBoxColumn();
oMonday->MappingName = S"Monday";
oMonday->HeaderText = oInf->saG_WeekMon[iLanguage];
oMonday->Alignment = HorizontalAlignment::Center;
oMonday->Width = 92;
//Tuesday
oTuesday = new ColorDataGridTextBoxColumn();
oTuesday->MappingName = S"Tuesday";
oTuesday->HeaderText = oInf->saG_WeekTue[iLanguage];
oTuesday->Alignment = HorizontalAlignment::Center;
oTuesday->Width = 92;
//Wednesday
oWednesday = new ColorDataGridTextBoxColumn();
oWednesday->MappingName = S"Wednesday";
oWednesday->HeaderText = oInf->saG_WeekWed[iLanguage];
oWednesday->Alignment = HorizontalAlignment::Center;
oWednesday->Width = 92;
//Thursday
oThursday = new ColorDataGridTextBoxColumn();
oThursday->MappingName = S"Thursday";
oThursday->HeaderText = oInf->saG_WeekThu[iLanguage];
oThursday->Alignment = HorizontalAlignment::Center;
oThursday->Width = 92;
//Friday
oFriday = new ColorDataGridTextBoxColumn();
oFriday->MappingName = S"Friday";
oFriday->HeaderText = oInf->saG_WeekFri[iLanguage];
oFriday->Alignment = HorizontalAlignment::Center;
oFriday->Width = 92;
//Saturday
oSaturday = new ColorDataGridTextBoxColumn();
oSaturday->MappingName = S"Saturday";
oSaturday->HeaderText = oInf->saG_WeekSat[iLanguage];
oSaturday->Alignment = HorizontalAlignment::Center;
oSaturday->Width = 92;
oTableStyle->GridColumnStyles->Add(oRowHeader);
oTableStyle->GridColumnStyles->Add(oSunday);
oTableStyle->GridColumnStyles->Add(oMonday);
oTableStyle->GridColumnStyles->Add(oTuesday);
oTableStyle->GridColumnStyles->Add(oWednesday);
oTableStyle->GridColumnStyles->Add(oThursday);
oTableStyle->GridColumnStyles->Add(oFriday);
oTableStyle->GridColumnStyles->Add(oSaturday);
oTableStyle->RowHeadersVisible = false;
dataGridCal->TableStyles->Add(oTableStyle);
oGridRow = oGridTable->NewRow(); //1-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //1-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //1-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //1-Team3
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //2-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //2-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //2-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //2-Team3
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //3-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //3-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //3-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //3-Team3
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //4-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //4-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //4-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //4-Team3
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //5-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //5-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //5-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //5-Team3
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //6-Day
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //6-Team1
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //6-Team2
oGridTable->Rows->Add(oGridRow);
oGridRow = oGridTable->NewRow(); //6-Team3
oGridTable->Rows->Add(oGridRow);
SetGridCalender();
}
void CalendarInput::SetGridCalender(void)
{
int iDay = 1;
int iDayMax;
int iStartWeek;
int ix,iy;
DateTime dtCalDay;
DataRow* oDR_Date;
DataRow* oDR_Team1;
DataRow* oDR_Team2;
DataRow* oDR_Team3;
Object* DataArrayCal[] = new Object*[8];
Object* DataArrayT_1[] = new Object*[8];
Object* DataArrayT_2[] = new Object*[8];
Object* DataArrayT_3[] = new Object*[8];
int iMaxDay[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int iMaxDay1[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
iSelYear = Convert::ToInt32(comboBoxYear->Text);
iSelMonth = comboBoxMonth->SelectedIndex + 1;
sSelProcess = comboBoxProcess->SelectedValue->ToString();
dtCalDay = DateTime(iSelYear, iSelMonth, iDay);
iStartWeek = dtCalDay.get_DayOfWeek();
//iDayMax = iMaxDay[comboBoxMonth->SelectedIndex] + (((iSelYear - 2000) % 4) == 0);
if(((iSelYear - 2000) % 4)==0){
iDayMax = iMaxDay1[comboBoxMonth->SelectedIndex];
}
else
{
iDayMax=iMaxDay[comboBoxMonth->SelectedIndex];
}
//GetGridData
if(GetGridData(iSelYear, iSelMonth) == false){
return;
}
//SetGrid
for(iy = 0; iy < 24; iy += 4){//24
oDR_Date = oGridTable->get_Rows()->get_Item(iy);
oDR_Team1 = oGridTable->get_Rows()->get_Item(iy+1);
oDR_Team2 = oGridTable->get_Rows()->get_Item(iy+2);
oDR_Team3 = oGridTable->get_Rows()->get_Item(iy+3);
DataArrayCal[0] = S" ";
//设置语言0中文,1日文,2英文
if (iLanguage==0){
DataArrayT_1[0] = S"1班";
DataArrayT_2[0] = S"2班";
DataArrayT_3[0] = S"3班";
}
if (iLanguage==1){
DataArrayT_1[0] = S"1班";
DataArrayT_2[0] = S"2班";
DataArrayT_3[0] = S"3班";
}
if (iLanguage==2){
DataArrayT_1[0] = S"Team1";
DataArrayT_2[0] = S"Team2";
DataArrayT_3[0] = S"Team3";
}
for(ix = 1; ix <= 7; ix++){
//if((ix + iy*7) < (iDay + iStartWeek - 1) || iDay > iDayMax){
if((ix + iy*7) < (iDay + iStartWeek) || iDay >( iDayMax)){
DataArrayCal[ix] = S" ";
DataArrayT_1[ix] = S" ";
DataArrayT_2[ix] = S" ";
DataArrayT_3[ix] = S" ";
} else{
//DataArrayCal[ix] = String::Format("{0}", __box(iDay));
//DataArrayT_1[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM1")->ToString();
//DataArrayT_2[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM2")->ToString();
//DataArrayT_3[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM3")->ToString();
//iDay++;
DataArrayCal[ix] = String::Format("{0}", __box(iDay));
DataArrayT_1[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM1")->ToString();
DataArrayT_2[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM2")->ToString();
DataArrayT_3[ix] = oDataSet->Tables->Item["GridData"]->Rows->get_Item(iDay -1)->get_Item(S"TEAM3")->ToString();
iDay++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -