📄 dutydetail.cpp
字号:
//****** begin **************************//
//changed and noted by dongzhaoliang in 2006/5
//****** end **************************//
#include "stdafx.h"
#include "DutyDetail.h"
using namespace FAP;
using namespace System::Collections;
void DutyDetail::begin(void){
arrayStringInputDataJustify= new String __gc *[3];
switch(iLanguage){
case 0:
arrayStringInputDataJustify[0]=S"确定登录数据?";
arrayStringInputDataJustify[1]=S"表格未填入数字!!";
arrayStringInputDataJustify[2]=S"登录成功!";
break;
case 1:
arrayStringInputDataJustify[0]=S"データを登録して宜しいでしょうか?";
arrayStringInputDataJustify[1]=S"数字を表に記入してください!!";
arrayStringInputDataJustify[2]=S"登録に成功しました!";
break;
case 2:
arrayStringInputDataJustify[0]=S"Really Input Data?";
arrayStringInputDataJustify[1]=S"Haven't Input Digit Into Form!!";
arrayStringInputDataJustify[2]=S"Input Success!!";
break;
default:
arrayStringInputDataJustify[0]=S"确定登录数据?";
arrayStringInputDataJustify[1]=S"表格未填入数字!!";
arrayStringInputDataJustify[2]=S"登录成功!";
break;
}
}
void DutyDetail::InitProcess(int intLang){
String *strSQL;
DataSet *dsetDetail;
DataTable *dtblTmp;
String * sa_Lang[]= {S"C",S"J",S"E"};
//strSQL = S" select distinct process_no as AA, name_";
//
//strSQL = String::Concat(strSQL,sa_Lang[intLang]);
//strSQL = String::Concat(strSQL,S" as BB from cost_mst where process_no >= 'MA01'");
//dbDutyDetail->blnCnnOpen();
//dsetDetail = dbDutyDetail->dSetSQL_Select(strSQL,S"DetailProcess",0);
//dtblTmp = dsetDetail->Tables->Item[S"DetailProcess"];
//cboProcess->DataSource = dtblTmp;
//cboProcess->DisplayMember = S"BB";
//cboProcess->ValueMember = S"AA" ;processNumber
strSQL = S"";
strSQL = String::Concat(strSQL,S"select distinct process_no as PROCESS_NO, name_",sa_Lang[intLang],S" as processName " );
strSQL = String::Concat(strSQL,S" from cost_mst " );
strSQL = String::Concat(strSQL,S" where process_no != 'MA00' " );
strSQL = String::Concat(strSQL,S" order by PROCESS_NO DESC " );
dbDutyDetail->blnCnnOpen();
dsetDetail = dbDutyDetail->dSetSQL_Select(strSQL,S"DetailProcess",0);
dtblTmp = dsetDetail->Tables->Item[S"DetailProcess"];
cboProcess->DataSource = dtblTmp;
cboProcess->DisplayMember = S"processName";
cboProcess->ValueMember = S"PROCESS_NO";
dbDutyDetail->blnCnnClose();
}
double DutyDetail::dblCntCost(){
DataGridCell dCellManNumber;
DataGridCell dCellCost;
double dblManNumber;
double dblReturn = 0;
dCellManNumber.ColumnNumber = 1; //point to second column
dCellCost.ColumnNumber = 2; //point to third column
for (int i = 0;i< __try_cast<DataView *>(dataGrid1->DataSource)->Count;i++) { //read the datagrid's data row by row
dCellManNumber.RowNumber = i;
dCellCost.RowNumber = i;
if (dataGrid1->Item[dCellManNumber]->ToString()->CompareTo(S"") != 0) { //to justify whether the data is not empty
try
{
dblManNumber = Single::Parse(dataGrid1->Item[dCellManNumber]->ToString());
}
catch (...) {
MessageBox::Show(S"请输入数字!");
dataGrid1->Select(i);
return 0;
}
dblReturn += dblManNumber * (Single::Parse(dataGrid1->Item[dCellCost]->ToString()));
}
}
return dblReturn;
}
bool DutyDetail::blnUpdDB(double dblTotal,DateTime dteTmp,String *strTeam,String *strProcess){
String *strUpt;
String *strIst;
int intCnt;
DataGridCell dCellManNumber;
DataGridCell dCellRank;
dCellManNumber.ColumnNumber = 1;
dCellRank.ColumnNumber = 0;
for (int i = 0;i<__try_cast<DataView *>(dataGrid1->DataSource)->Count;i++)
{
dCellManNumber.RowNumber = i;
dCellRank.RowNumber = i;
if (dataGrid1->Item[dCellManNumber]->ToString()->Trim()->CompareTo(S"")==0) {
continue;
}
/* strUpt = S"update labor_cost set total_number = total_number + ";
strUpt = String::Concat(strUpt,dataGrid1->Item[dCellTmp]->ToString());
strUpt = String::Concat(strUpt,S" where work_ymd = to_date('",dteTmp.ToString(S"yyyy-MM-dd"),S"','yyyy-MM-dd')");
strUpt = String::Concat(strUpt,S" and rank = '",dataGrid1->Item[dCellRank]->ToString(),S"'");
strUpt = String::Concat(strUpt,S" and process_no = '",strProcess,S"'");
strUpt = String::Concat(strUpt,S" and team = ",strTeam);*/
strUpt = S" ";
strUpt = String::Concat(strUpt,S"update labor_cost" );
strUpt = String::Concat(strUpt,S" set total_number = total_number + ",dataGrid1->Item[dCellManNumber]->ToString() );
strUpt = String::Concat(strUpt,S" where work_ymd = to_date('",dteTmp.ToString(S"yyyy-MM-dd"),S"','yyyy-MM-dd')");
strUpt = String::Concat(strUpt,S" and rank = '",dataGrid1->Item[dCellRank]->ToString(),S"'" );
strUpt = String::Concat(strUpt,S" and process_no = '",strProcess,S"'" );
strUpt = String::Concat(strUpt,S" and team = ",strTeam );
if (!dbDutyDetail->blnSQL_Execute(strUpt,&intCnt)){ //intCnt is for Executes a SQL statement against the Connection and returns the number of rows affected.
return false;
}
if (intCnt == 0) { //if no row exit in the current labor_cost table ,insert one
strIst =S"";
strIst =String::Concat(strIst,S"insert into labor_cost ");
strIst =String::Concat(strIst,S" (WORK_YMD, PROCESS_NO, TEAM, RANK, TOTAL_NUMBER) ");;
//(to_date('2006-05-24', 'yyyy-MM-dd'), 'NF02', 1, 'H6', 2)
strIst = String::Concat(strIst,S"values ");
strIst = String::Concat(strIst,S" (to_date('",dteTmp.ToString(S"yyyy-MM-dd"),S"','yyyy-MM-dd') ,");
strIst = String::Concat(strIst,S" '",strProcess,S"',");
strIst = String::Concat(strIst, strTeam,S",");
strIst = String::Concat(strIst,S" '",dataGrid1->Item[dCellRank]->ToString(),S"',");
strIst = String::Concat(strIst, dataGrid1->Item[dCellManNumber]->ToString());
strIst = String::Concat(strIst,S" )");
if (!dbDutyDetail->blnSQL_Execute(strIst)) {
return false;
}
}
}
return true;
}
void DutyDetail::InitGrid(int intLang){
DataSet *dsetTmp;
DataTable *dTblTmp;
DataView *dViewTmp;
String *strSQL;
DataGridTextBoxColumn *oColRank;// = new DataGridColumnStyle();
DataGridTextBoxColumn *oColTest;// = new DataGridColumnStyle();
DataGridTextBoxColumn *oColCost;// = new DataGridColumnStyle();
DataGridTableStyle *oTableStyle;
oTableStyle = new DataGridTableStyle();
oTableStyle->MappingName = S"DD";
//col rank
oColRank = new DataGridTextBoxColumn();
oColRank->Alignment = HorizontalAlignment::Center;
oColRank->MappingName = S"rank";
oColRank->HeaderText = infDutyDetail->sa_Rank[intLang];
oColRank->Width = 120;
oColRank->ReadOnly = true;
oColRank->NullText = S"";
//col number
oColTest = new DataGridTextBoxColumn();
oColTest->Alignment = HorizontalAlignment::Center;
oColTest->MappingName = S"peopleNumber";
oColTest->HeaderText = infDutyDetail->sa_Number[intLang];
oColTest->NullText = S"";
oColTest->Width = 120;
oColTest->ReadOnly = false;
//col cost
oColCost = new DataGridTextBoxColumn(); //for calculating not for display
oColCost->MappingName = S"cost";
oColCost->Width = 0;
oTableStyle->GridColumnStyles->Add(oColRank);
oTableStyle->GridColumnStyles->Add(oColTest);
oTableStyle->GridColumnStyles->Add(oColCost);
dataGrid1->TableStyles->Add(oTableStyle);
/*strSQL = S" select rank,null as test,cost from labor_cost_rank order by SUBSTR(rank,1,2) desc ,SUBSTR(rank,3) desc";*/
strSQL = S"";
/*strSQL = String::Concat(strSQL,S"select rank, null as test, cost " );*/
strSQL = String::Concat(strSQL,S"select rank, null as peopleNumber, cost " );
strSQL = String::Concat(strSQL,S" from labor_cost_rank " );
strSQL = String::Concat(strSQL,S" order by SUBSTR(rank, 1, 2) desc, SUBSTR(rank, 3) desc " );
dbDutyDetail->blnCnnOpen();
dsetTmp = dbDutyDetail->dSetSQL_Select(strSQL,S"DD",0);
dTblTmp = dsetTmp->Tables->Item[S"DD"];
dbDutyDetail->blnCnnClose();
dViewTmp = new DataView(dTblTmp);
dViewTmp->AllowNew= false ;
dViewTmp->AllowDelete = false ;
dataGrid1->DataSource = dViewTmp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -