📄 stocklist.cpp
字号:
case 1:
sumRow->Item["PlaceName"]= S"合計";
break;
case 2:
sumRow->Item["PlaceName"]= S"sum";
break;
default: break;
}
if (flgunit==true){
sumRow->Item["Lot"]=Convert::ToString(sumTotalPlan);
}else{
sumRow->Item["Lot"]=Convert::ToString(sumTotalPlandouble);
}
////// dTableTmp->Rows->Add(sumRow);
///end
///add a sum row to the end
dTableTmp->Rows->Add(sumRow);
dViewTmp = new DataView(dTableTmp);
dViewTmp->AllowDelete = false;
dViewTmp->AllowNew = false;
dataGrid1->DataSource = dViewTmp;
//comboBox1->Text=S"All";
}
///
void FAP::StockList::selectProcess(){
DataTable *dTmp1;
dTmp1 = dtblGetProcessPro(infStockList,dbStockList);
DataRow* newRow1;
newRow1 = dTmp1->NewRow();
newRow1->Item[S"PROCESS_NO"] =S"All";
// Add row to Employee table.
dTmp1->Rows->Add(newRow1);
//dataGrid1->DataSource = dTmp1;
comboBox1->DataSource = dTmp1;
//strProductCode=(this->txtProCode->Text);
//MessageBox::Show(Convert::ToString(dTmp1->Rows->Item[0]->Item[S"PRODUCT_NO"]));
comboBox1->DisplayMember = S"PROCESS_NO";
comboBox1->Text=S"All";
}
DataTable * FAP::StockList::dtblGetProcessPro(infClass *infTmp,
DBBase * dBTMP)
{
//String * strSQL;
DataTable *dtblTmp;
DataSet * dsetTmp;
/*OleDbDataReader *dReadTmp;*/
String * strSQL;
strSQL=S"";
strSQL = String::Concat(strSQL,"select distinct a.process_no as PROCESS_NO from cost_mst a, stock_data b where b.stock_pos = a.store_no and b.product_code = '");
//设置
//搜索
if (iflag==1){
strSQL = String::Concat(strSQL,txtProCode->Text->Trim());
}
if (iflag==2||iflag==3){
strSQL = String::Concat(strSQL,strChoosen);
}
//
strSQL = String::Concat(strSQL,"' and trim(b.lot) is not null");
dBTMP->blnCnnOpen();
dsetTmp = dBTMP->dSetSQL_Select(strSQL,S"TMP",0);
dBTMP->blnCnnClose();
try
{
dtblTmp = dsetTmp->Tables->Item[S"TMP"];
}
catch (...) {
return NULL;
}
return dtblTmp;
}
void FAP::StockList::doSelectProcess(){
String * strCheck;
strCheck=comboBox1->Text;
if (iflag==2||iflag==3){
FillDBGrid2(strChoosen,strCheck);
FillDBGrid1();
comboBox2->SelectedIndex=0;
}
if (selectFlag==1){
if ( ( strCheck->CompareTo(S"All") )==0){
FillDBGrid(strChoosen);
FillDBGrid1();
comboBox2->SelectedIndex=0;
}else{
FillDBGrid2(strChoosen,strCheck);
FillDBGrid1();
comboBox2->SelectedIndex=0;
}
}
if (((strCheck->CompareTo(S"All"))==0)&&(iflag!=1)){
FillDBGrid(strChoosen);
FillDBGrid1();
comboBox2->SelectedIndex=0;
}
}
////////////////////////////////////////////////////////////////////////////////
void FAP::StockList::FillDBGrid2(String *strProCode,String * strCheck){
String *strSQL ;
DataSet * dSetTmp ;
DataTable *dTableTmp;
DataView *dViewTmp;
String *saLang[]= {S"C",S"J",S"E"};
strSQL = S"select distinct a.Name_";
strSQL = String::Concat(strSQL,saLang[infStockList->intLang]);
strSQL = String::Concat(strSQL,S" as PlaceName ,(case b.stock_type when 0 then ' ' when 1 then ' ' when 2 then '▲' end) as StockType, ");
strSQL = String::Concat(strSQL,S" (case b.lot when '-1000000' then '-1' else b.lot end) as Lot,");
if (flgunit==true){
strSQL = String::Concat(strSQL,S"floor(b.stock_qty) as PlanNum,'' as ExistNum,b.stock_pos as Stock_Code from cost_mst a, stock_data b");
}else{
strSQL = String::Concat(strSQL,S"b.stock_qty as PlanNum,'' as ExistNum,b.stock_pos as Stock_Code from cost_mst a, stock_data b");
}
strSQL = String::Concat(strSQL,S" where b.stock_pos = a.store_no and b.product_code = '",strProCode,S"' and a.process_no='");
strSQL = String::Concat(strSQL,strCheck);
strSQL = String::Concat(strSQL,S"' and trim(b.lot) is not null");
strSQL = String::Concat(strSQL,S" and b.stock_qty<> 0 order by StockType");
if (!dbStockList->blnCnnOpen())
{
return;
}
try
{
dSetTmp = dbStockList->dSetSQL_Select(strSQL,S"StockList",0);
dTableTmp = dSetTmp->Tables->Item[S"StockList"];
}
catch (...) {
return;
}
sumTotalPlan=0;
sumTotalPlandouble=0.000;
IEnumerator* tempRow = dTableTmp->Rows->GetEnumerator();
tempRow->Reset();
while (tempRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(tempRow->Current);
if (flgunit==true)
{
sumTotalPlan =sumTotalPlan+Convert::ToInt32(dRowTmp->Item[S"PlanNum"]);
}
else{
sumTotalPlandouble =sumTotalPlandouble+Convert::ToDouble(dRowTmp->Item[S"PlanNum"]);
}
}
dViewTmp = new DataView(dTableTmp);
dViewTmp->AllowDelete = false;
dViewTmp->AllowNew = false;
dGridStockList->DataSource = dViewTmp;
}
void FAP::StockList::setUnit(String * productCode)
{
String * sSQL=S"";
OleDbDataReader * reader;
String * unitString;
sSQL=String::Concat(sSQL,S"select unit from parts_mst where product_code='");
sSQL=String::Concat(sSQL,productCode);
sSQL=String::Concat(sSQL,"'");
dbStockList->blnCnnOpen();
reader=dbStockList->dReadSQL_Select(sSQL);
while (reader->Read())
{
unitString=reader->GetString(0);
break;
}
if ((unitString->CompareTo(S"PC"))==0)
{
flgunit=true;
}else{flgunit=false;}
dbStockList->blnCnnClose();
}
void FAP::StockList::doStockTypeSelect()
{
String * strProductCode;
String * strProcess;
String * strStockType;
int iStockType=0;
strProductCode=txtProCode->Text;
strProcess=comboBox1->Text;
//strStockType=comboBox2->Text;
//检测为空
if ((strProductCode->Trim()->CompareTo (S""))==0)
{
return;
}
if ((strProcess->Trim()->CompareTo (S""))==0)
{
return;
}
//if ((strStockType->Trim()->CompareTo (S""))==0)
//{
// return;
//}
//iStockType=comboBox2->SelectedIndex;
if (comboBox2->SelectedIndex==2){iStockType=2;}
if (comboBox2->SelectedIndex==1){iStockType=1;}
if (comboBox2->SelectedIndex==0){iStockType=3;}
//转换
strStockType=Convert::ToString(iStockType);
/***********************************
*开始执行数据库操作
***********************************/
////String * strSQL=S"";
////strSQL=String::Concat(strSQL,S"");
////strSQL=String::Concat(strSQL,);
////
String *strSQL ;
DataSet * dSetTmp ;
DataTable *dTableTmp;
DataView *dViewTmp;
String *saLang[]= {S"C",S"J",S"E"};
strSQL = S"select distinct a.Name_";
strSQL = String::Concat(strSQL,saLang[infStockList->intLang]);
strSQL = String::Concat(strSQL,S" as PlaceName ,");
strSQL = String::Concat(strSQL,S"(case b.stock_type when 0 then ' ' when 1 then ' ' when 2 then '▲' end) as StockType, ");
strSQL = String::Concat(strSQL,S" (case b.lot when '-1000000' then '-1' else b.lot end) as Lot,");
if (flgunit==true){
strSQL = String::Concat(strSQL,S"floor(b.stock_qty) as PlanNum,'' as ExistNum,b.stock_pos as Stock_Code from cost_mst a, stock_data b");
}else{
strSQL = String::Concat(strSQL,S"b.stock_qty as PlanNum,'' as ExistNum,b.stock_pos as Stock_Code from cost_mst a, stock_data b");
}
strSQL = String::Concat(strSQL,S" where b.stock_pos = a.store_no and b.product_code = '",strProductCode);
//按照工序名称来选择
if ((strProcess->CompareTo (S"All"))==0){
//不操作
}else{
strSQL = String::Concat(strSQL,S"' and a.process_no='");
strSQL = String::Concat(strSQL,strProcess);
}
//
strSQL = String::Concat(strSQL,S"' and trim(b.lot) is not null");
//按照库存类型来选择
if ((strStockType->CompareTo(S"3"))==0)
{
//不操作
}
else
{
strSQL = String::Concat(strSQL,S" and b.stock_type=");
strSQL = String::Concat(strSQL,strStockType);
}
strSQL = String::Concat(strSQL,S" and b.stock_qty<> 0 order by StockType");
if (!dbStockList->blnCnnOpen())
{
return;
}
try
{
dSetTmp = dbStockList->dSetSQL_Select(strSQL,S"StockList",0);
dTableTmp = dSetTmp->Tables->Item[S"StockList"];
}
catch (...) {
return;
}
sumTotalPlan=0;
sumTotalPlandouble=0.000;
IEnumerator* tempRow = dTableTmp->Rows->GetEnumerator();
tempRow->Reset();
while (tempRow->MoveNext())
{
DataRow *dRowTmp = __try_cast<DataRow*>(tempRow->Current);
if (flgunit==true)
{
sumTotalPlan =sumTotalPlan+Convert::ToInt32(dRowTmp->Item[S"PlanNum"]);
}
else{
sumTotalPlandouble =sumTotalPlandouble+Convert::ToDouble(dRowTmp->Item[S"PlanNum"]);
}
}
dViewTmp = new DataView(dTableTmp);
dViewTmp->AllowDelete = false;
dViewTmp->AllowNew = false;
dGridStockList->DataSource = dViewTmp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -