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

📄 calendarinput.cpp

📁 这是一个工厂的生产线的仓库管理.有计划,实绩,库存等
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		oDR_Date->ItemArray  = DataArrayCal;
		oDR_Team1->ItemArray = DataArrayT_1;
		oDR_Team2->ItemArray = DataArrayT_2;
		oDR_Team3->ItemArray = DataArrayT_3;
	}
	dataGridCal->Refresh();
}

bool CalendarInput::GetGridData(int iYear, int iMonth)
{
	String* sSQL = S"";
	DateTime dtDay;
	int iCnt;

	dtDay = DateTime(iYear, iMonth, 1);
	//CheckData
	sSQL = S"";
	sSQL = String::Concat(sSQL,	S"select"																		);
	sSQL = String::Concat(sSQL,	S"	count (*) as CALENDER_CNT "													);
	sSQL = String::Concat(sSQL,	S"from"																			);
	sSQL = String::Concat(sSQL,	S"	WORK_CALENDER "																);
	sSQL = String::Concat(sSQL,	S"where"																		);
	sSQL = String::Concat(sSQL, S"	FACTORY_CODE = '", sFactory, S"' and"										);
	sSQL = String::Concat(sSQL, S"	PROCESS_NO   = '", sSelProcess, S"' and"									);
	sSQL = String::Concat(sSQL, S"	WORK_YMD >=			   to_date('", dtDay.ToString(L"yyyy/MM/dd"), S"','yyyy-mm-dd') and"	);
	sSQL = String::Concat(sSQL, S"	WORK_YMD <  add_months(to_date('", dtDay.ToString(L"yyyy/MM/dd"), S"','yyyy-mm-dd'), 1) ");
	
	iCnt = oDB->intSQL_Select(sSQL);
	if(iCnt <= 0){
		if(MakeNewCalender(iYear, iMonth) == false){
			return false;
		}
	}

	String * strDayOff[]={S"休",S"休",S"DayOff"};
	
	//GetGridData
	sSQL = S"";
	sSQL = String::Concat(sSQL, S"select"																			);
	sSQL = String::Concat(sSQL, S"	WORK_YMD,"																		);
	sSQL = String::Concat(sSQL, S"	decode(DAY_SHIFT, 1, 'A', decode(NIGHT_SHIFT, 1, 'B','");
		sSQL = String::Concat(sSQL,strDayOff[iLanguage],S"')) as TEAM1,");
	sSQL = String::Concat(sSQL, S"	decode(DAY_SHIFT, 2, 'A', decode(NIGHT_SHIFT, 2, 'B','");
		sSQL = String::Concat(sSQL,strDayOff[iLanguage],S"')) as TEAM2,");
	sSQL = String::Concat(sSQL, S"	decode(DAY_SHIFT, 3, 'A', decode(NIGHT_SHIFT, 3, 'B','");
		sSQL = String::Concat(sSQL,strDayOff[iLanguage],S"')) as TEAM3 ");
	sSQL = String::Concat(sSQL, S"from"																				);
	sSQL = String::Concat(sSQL, S"	WORK_CALENDER "																	);
	sSQL = String::Concat(sSQL, S"where"																			);
	sSQL = String::Concat(sSQL, S"	FACTORY_CODE = '", sFactory, S"' and"											);
	sSQL = String::Concat(sSQL, S"	PROCESS_NO   = '", sSelProcess, S"' and"										);
	sSQL = String::Concat(sSQL, S"	WORK_YMD >=			   to_date('", dtDay.ToString(L"yyyy/MM/dd"), S"','YYYY-MM-DD') and"		);
	sSQL = String::Concat(sSQL, S"	WORK_YMD <  add_months(to_date('", dtDay.ToString(L"yyyy/MM/dd"), S"','YYYY-MM-DD'), 1) "	);
	sSQL = String::Concat(sSQL, S"order by"																			);
	sSQL = String::Concat(sSQL, S"	WORK_YMD"																		);

	oDataSet = oDB->dSetSQL_Select(sSQL, S"GridData", 0);
	return true;
}

void CalendarInput::WriteGridData(void)
{
	String* sSQL;
	int ix, iy;
	DateTime	dtDay;
	Object*		DataArrayCal[] = new Object*[8];
	Object*		DataArrayT_1[] = new Object*[8];
	Object*		DataArrayT_2[] = new Object*[8];
	Object*		DataArrayT_3[] = new Object*[8];
	bool	bFlg = true;

	oDB->blnBeginTrans();

	for(iy = 0; iy < 24; iy += 4){
		//24
		DataArrayCal = oGridTable->get_Rows()->get_Item(iy+0)->get_ItemArray();
		DataArrayT_1 = oGridTable->get_Rows()->get_Item(iy+1)->get_ItemArray();
		DataArrayT_2 = oGridTable->get_Rows()->get_Item(iy+2)->get_ItemArray();
		DataArrayT_3 = oGridTable->get_Rows()->get_Item(iy+3)->get_ItemArray();
		for(ix = 1; ix <= 7; ix++){
			if(String::Compare(DataArrayCal[ix]->ToString(), S" ") != 0){
				dtDay = DateTime(iSelYear, iSelMonth, Convert::ToInt32(DataArrayCal[ix]));
				sSQL = S"";
				sSQL = String::Concat(sSQL, S"update"														);
				sSQL = String::Concat(sSQL, S"	WORK_CALENDER "												);
				sSQL = String::Concat(sSQL, S"set"															);
				sSQL = String::Concat(sSQL, S"	DAY_SHIFT = ("												);
				sSQL = String::Concat(sSQL, S"		select decode('A',"									);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_1[ix]->ToString(), "',1,"			);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_2[ix]->ToString(), "',2,"			);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_3[ix]->ToString(), "',3)"			);
				sSQL = String::Concat(sSQL, S"		from dual"												);
				sSQL = String::Concat(sSQL, S"		),"														);
				sSQL = String::Concat(sSQL, S"	NIGHT_SHIFT = ("											);
				sSQL = String::Concat(sSQL, S"		select decode('B',"									);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_1[ix]->ToString(), "',1,"			);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_2[ix]->ToString(), "',2,"			);
				sSQL = String::Concat(sSQL, S"			'", DataArrayT_3[ix]->ToString(), "',3)"			);
				sSQL = String::Concat(sSQL, S"		from dual"												);
				sSQL = String::Concat(sSQL, S"		),"														);
				sSQL = String::Concat(sSQL, S"	UPDATE_YMD = sysdate "										);
				sSQL = String::Concat(sSQL, S"where"														);
				sSQL = String::Concat(sSQL, S"	FACTORY_CODE = '", sFactory,    S"' and"					);
				sSQL = String::Concat(sSQL, S"	PROCESS_NO = '",   sSelProcess, S"' and"					);
				sSQL = String::Concat(sSQL, S"	WORK_YMD = to_date('", dtDay.ToString(L"yyyy/MM/dd"),"','yyyy-mm-dd')"	);

				bFlg = bFlg && oDB->blnSQL_Execute(sSQL);
			}
		}
	}
	//Commit
	if(bFlg == true){
		oDB->blnCommit();
	} else {
		oDB->blnRollBack();
	}
}

bool CalendarInput::MakeNewCalender(int iYear, int iMonth)
{
	String* sSQL = S"";
	
	sSQL = String::Concat(sSQL, S"insert into"																				);
	sSQL = String::Concat(sSQL, S"	WORK_CALENDER "																			);
	sSQL = String::Concat(sSQL, S"select distinct"																			);
	sSQL = String::Concat(sSQL, S"	CST.FACTORY_CODE,"																		);
	sSQL = String::Concat(sSQL, S"	CST.LINE_CODE,"																			);
	sSQL = String::Concat(sSQL, S"	CST.PROCESS_NO,"																		);
	sSQL = String::Concat(sSQL, S"	add_months(CAL.BASE_DAY, 12*", (iYear-1).ToString(), S"+", (iMonth-1).ToString(), S"),"	);
	sSQL = String::Concat(sSQL, S"	'',"																					);
	sSQL = String::Concat(sSQL, S"	'',"																					);
	sSQL = String::Concat(sSQL, S"	sysdate "																				);
	sSQL = String::Concat(sSQL, S"from"																						);
	sSQL = String::Concat(sSQL, S"	("																						);
	sSQL = String::Concat(sSQL, S"		select"																				);
	sSQL = String::Concat(sSQL, S"			to_date('0001/01/' || to_char(DAY.DAY,'09'), 'yyyy/mm/dd') as BASE_DAY"			);
	sSQL = String::Concat(sSQL, S"		from"																				);
	sSQL = String::Concat(sSQL, S"			("																				);
	sSQL = String::Concat(sSQL, S"				select  1 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  2 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  3 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  4 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  5 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  6 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  7 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  8 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select  9 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 10 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 11 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 12 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 13 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 14 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 15 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 16 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 17 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 18 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 19 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 20 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 21 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 22 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 23 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 24 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 25 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 26 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 27 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 28 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 29 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 30 as DAY from DUAL union all"										);
	sSQL = String::Concat(sSQL, S"				select 31 as DAY from DUAL"													);
	sSQL = String::Concat(sSQL, S"			) DAY"																			);
	sSQL = String::Concat(sSQL, S"	) CAL,"																					);
	sSQL = String::Concat(sSQL, S"	COST_MST CST "																			);
	sSQL = String::Concat(sSQL, S"where"																					);
	sSQL = String::Concat(sSQL, S"	CST.FACTORY_CODE = '", sFactory, S"' and"												);
	sSQL = String::Concat(sSQL, S"	CST.PROCESS_NO = '",   sSelProcess, S"'"												);

	oDB->blnBeginTrans();

	if(oDB->blnSQL_Execute(sSQL)) {
		try{
			oDB->blnCommit();
			return true;
		}
		catch (...) {
			oDB->blnRollBack();
			return false;
		}
	}
	return false;
}

void CalendarInput::EditCalender(void)
{
	DataGridCell oCell;
	int iRow, iCol;
	int iWeek;
	int i;
	Object*		DataArrayCal[] = new Object*[8];
	Object*		DataArrayT_1[] = new Object*[8];
	Object*		DataArrayT_2[] = new Object*[8];
	Object*		DataArrayT_3[] = new Object*[8];

	oCell = dataGridCal->CurrentCell;
	iRow = oCell.RowNumber;
	iCol = oCell.ColumnNumber;
	iWeek = iRow / 4;

	if(iCol == 0){
		return;
	}

	DataArrayCal = oGridTable->get_Rows()->get_Item(iWeek * 4 + 0)->get_ItemArray();
	DataArrayT_1 = oGridTable->get_Rows()->get_Item(iWeek * 4 + 1)->get_ItemArray();
	DataArrayT_2 = oGridTable->get_Rows()->get_Item(iWeek * 4 + 2)->get_ItemArray();
	DataArrayT_3 = oGridTable->get_Rows()->get_Item(iWeek * 4 + 3)->get_ItemArray();
String * ostrDayOff[]={S"休",S"休",S"DayOff"};
	for(i= 0; i < 4; i++){
		switch(i){
			case 1:
				if(String::Compare(DataArrayT_1[iCol]->ToString(), sSelShift) == 0){
					DataArrayT_1[iCol] = ostrDayOff[iLanguage];//S"DayOff";
				}
				if(iRow % 4 == 1){
					DataArrayT_1[iCol] = sSelShift;
				}
				break;
			case 2:
				if(String::Compare(DataArrayT_2[iCol]->ToString(), sSelShift) == 0){
					DataArrayT_2[iCol] =  ostrDayOff[iLanguage];//S"DayOff";
				}
				if(iRow % 4 == 2){
					DataArrayT_2[iCol] = sSelShift;
				}
				break;
			case 3:
				if(String::Compare(DataArrayT_3[iCol]->ToString(), sSelShift) == 0){
					DataArrayT_3[iCol] =  ostrDayOff[iLanguage];//S"DayOff";
				}
				if(iRow % 4 == 3){
					DataArrayT_3[iCol] = sSelShift;
				}
				break;
			default:
				if(String::Compare(DataArrayCal[iCol]->ToString(), S" ") == 0 || (iRow % 4) == 0){
					i = 4;   //Exit Roop
				}
		}
	}

	oGridTable->get_Rows()->get_Item(iWeek * 4 + 1)->ItemArray = DataArrayT_1;
	oGridTable->get_Rows()->get_Item(iWeek * 4 + 2)->ItemArray = DataArrayT_2;
	oGridTable->get_Rows()->get_Item(iWeek * 4 + 3)->ItemArray = DataArrayT_3;
	dataGridCal->Refresh();
}

void ColorDataGridTextBoxColumn::Paint(Graphics *g, Rectangle bounds, CurrencyManager *source, int rowNum, Brush *backBrush, Brush *foreBrush, bool alignToRight)
{
	String*	sBuf;
	String * oostrDayOff[]={S"休",S"休",S"DayOff"};
	int ointlang;//=oInf->::iLanguage;
	String * cultureInfo=Convert::ToString(Thread::CurrentThread->CurrentUICulture);
	if (String::Compare(cultureInfo, S"zh-CHS") == 0){ointlang=0;}
	if (String::Compare(cultureInfo, S"ja") == 0){ointlang=1;}
	if (String::Compare(cultureInfo, S"en") == 0){ointlang=2;}


	Object* cellValue = this->GetColumnValueAtRow(source, rowNum);
	if(cellValue != NULL){
		sBuf = dynamic_cast<String*>(cellValue);
		if(String::Compare(sBuf, "A") == 0){
			foreBrush = new SolidBrush(System::Drawing::Color::Black);
			backBrush = new SolidBrush(System::Drawing::Color::PaleGoldenrod);
		}
		if(String::Compare(sBuf, "B") == 0){
			foreBrush = new SolidBrush(System::Drawing::Color::White);
			backBrush = new SolidBrush(System::Drawing::Color::CornflowerBlue);
		}
		if(String::Compare(sBuf, oostrDayOff[ointlang]) == 0){
			foreBrush = new SolidBrush(System::Drawing::Color::Black);
			backBrush = new SolidBrush(System::Drawing::Color::LightSalmon);
		}
	}
	System::Windows::Forms::DataGridTextBoxColumn::Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}

⌨️ 快捷键说明

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