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

📄 vw_mrp_column.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  {
    pResultSet->Open(strSQL,"");
 //清空私有变量
    zx_Num=0;
    zx_ColNum=0;
    zx_ColPer=0;
    jh_Num=0;
    jh_ColNum=0;
    jh_ColPer=0;
    xq_Num=0;
    xq_ColNum=0;
    xq_ColPer=0;
    PeriodType=0;
    DayNum=0;
    pResultSet->MoveFirst();
    while(!pResultSet->Eof)
    {
      strItem=pResultSet->FieldByName("parameteritem");
      strValue=pResultSet->FieldByName("parametervalue");
      switch(StrToInt(strItem))
      {
        case 2:
          zx_Num=StrToInt(strValue);
          break;
        case 5:
          zx_ColNum=StrToInt(strValue);
          break;
        case 6:
          zx_ColPer=StrToInt(strValue);
          break;
        case 3:
          jh_Num=StrToInt(strValue);
          break;
        case 7:
          jh_ColNum=StrToInt(strValue);
          break;
        case 8:
          jh_ColPer=StrToInt(strValue);
          break;
        case 4:
          xq_Num=StrToInt(strValue);
          break;
        case 9:
          xq_ColNum=StrToInt(strValue);
          break;
        case 10:
          xq_ColPer=StrToInt(strValue);
          break;
        case 11:
          PeriodType=StrToInt(strValue);
          break;
        default:
          break;
      }
      pResultSet->MoveNext();
    }
    pResultSet->Close();
  }
  __finally
  {
    delete pResultSet;
  }
  switch(PeriodType)
  {
  //周期类型 1-天,2-周,3-旬,4-半月,5-月,6-季,7-半年,8-年
  //周期类型间隔天数 天-1,周-7,旬-10,半月-15,月-30,季-90,半年-183,年-366
    case 1:
      DayNum=1;
      break;
    case 2:
      DayNum=7;
      break;
    case 3:
      DayNum=10;
      break;
    case 4:
      DayNum=15;
      break;
    case 5:
      DayNum=30;
      break;
    case 6:
      DayNum=90;
      break;
    case 7:
      DayNum=183;
      break;
    case 8:
      DayNum=366;
      break;
    default:
      tbMainBar->Enabled=false;
      throw Exception("计划周期参数错误");
  }
}
//-------------------------------------------------
void __fastcall TfrmVW_Mrp_column::PMInfPopup(TObject *Sender)
{
 int ARow,i;
 AnsiString tmp;
 ARow=sgMrp->Row;
 if(ARow < 1)
  return;
 tmp=sgMrp->Cells[9][ARow];
 if(sgMrp->Cells[0][ARow] == " ")
 {
  for(i=ARow;i>0;i--)
   if(sgMrp->Cells[0][i] != " ")
    break;
  if(i>0)
   ARow=i;
 }
 PMI1->Caption="物料编码<"+sgMrp->Cells[0][ARow]+">";
 PMI2->Caption="物料名称<"+sgMrp->Cells[1][ARow]+">";
 PMI3->Caption="批量<"+sgMrp->Cells[2][ARow]+">";
 PMI4->Caption="提前期<"+sgMrp->Cells[3][ARow]+">";
 PMI5->Caption="当前库存<"+sgMrp->Cells[4][ARow]+">";
 PMI6->Caption="安全库存<"+sgMrp->Cells[5][ARow]+">";
 PMI7->Caption="已分配量<"+sgMrp->Cells[6][ARow]+">";
 PMI8->Caption="低层码<"+sgMrp->Cells[7][ARow]+">";
 PMI9->Caption="需求来源<"+sgMrp->Cells[8][ARow]+">";
 PMI10->Caption="需求类型<"+tmp+">";
}
//---------------------------------------------------
AnsiString __fastcall TfrmVW_Mrp_column::GetQueryStrColumn()
{
  AnsiString l_SQLcolumn="",l_column;
  if(CB_Gross->Checked)
  {
   l_column="1";
  }
  if(CB_Poh->Checked)
  {
   if (l_column.IsEmpty())
     l_column="2";
   else
     l_column=l_column +",2";
   }
   if(CB_Macc->Checked)
   {
   if (l_column.IsEmpty())
     l_column="3";
   else
     l_column=l_column +",3" ;
   }
    if(CB_Clean->Checked)
   {
    if (l_column.IsEmpty())
       l_column="4";
    else
       l_column=l_column +",4";
   }
    if(CB_Soh->Checked)
   {
    if (l_column.IsEmpty())
        l_column="5";
    else
        l_column=l_column +",5" ;
    }
    if(CB_Take->Checked)
    {
     if (l_column.IsEmpty())
        l_column="6" ;
     else
        l_column=l_column +",6" ;
    }
    if (!l_column.IsEmpty())
        l_SQLcolumn =" and mrpdType in ("+l_column+")";
    if(rb_Poh->Checked)
        l_SQLcolumn+="  and mrpfrom =1 " ;
    if(rb_Wo->Checked)
        l_SQLcolumn+="  and mrpfrom =2 " ;
    if(rb_Wx->Checked)
        l_SQLcolumn+="  and mrpfrom =3 " ;
    return  l_SQLcolumn;
   }
//---------------------------------------------------------------------------
void __fastcall TfrmVW_Mrp_column::FillGridWithData_Type()
{
  TComResultSet *RsQuery;
  AnsiString ItemStr,sSql;
  AnsiString Tempstr,Tempstr1,Tempstr2;
  AnsiString sRDate;
   AnsiString l_TypeDate;
  double iQty;
   AnsiString  m_SQL;
    AnsiString l;
    l="mrpdgoods;mrpdrdate;mrpdtype;" ;
   RsQueryQty=new  TComResultSet(Handle,g_ClientHandle);
   RsQueryQty->Open("select * from sdmrpd ",l);

  //获取查询语句
  sSql=GetQueryStr()+" order by MrpGoods,MrpdRDate,MrpdType";
  if(sSql=="")
    return;
  try
  {
    sgMrp->RowCount=1;
    RsQuery=new  TComResultSet(Handle,g_ClientHandle);
    RsQuery->Open(sSql,"");
    FillterColumData();
    RsQuery->MoveFirst();
    Tempstr1="";
    Tempstr2="";
    sgMrp->ScrollBars=ssNone; //取消滚动条,防止屏幕滚动
    while( RsQuery->Eof == 0)
    {
      Tempstr=     RsQuery->FieldByName("MrpGoods");
      l_TypeDate=  RsQuery->FieldByName("MrpdRDate");
      if(Tempstr!=Tempstr1) //不同物料
      {
        Tempstr1=Tempstr;
        Tempstr2=l_TypeDate;
        ItemStr=    RsQuery->FieldByName("MrpGoods")+
            "\t"+RsQuery->FieldByName("GoodsName")+
            "\t"+RsQuery->FieldByName("MrpEoq")+
            "\t"+RsQuery->FieldByName("MrpLt")+
            "\t"+RsQuery->FieldByName("MrpCiq")+
            "\t"+RsQuery->FieldByName("MrpSiq")+
            "\t"+RsQuery->FieldByName("MrpDiq")+
            "\t"+RsQuery->FieldByName("MrpLlc")+
            "\t"+DataConvert("MrpFrom",RsQuery->FieldByName("MrpFrom"))+
            "\t"+AnsiString(l_TypeDate);
            ItemStr= ItemStr+"\t"+TitleColumn(Tempstr,l_TypeDate);
        sgMrp->AddItem(ItemStr);
      }
      else    //相同物料
       {
        if(l_TypeDate!=Tempstr2) //相同物料,不同需求
        {
          Tempstr2=l_TypeDate;
          ItemStr=   AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(" ")+
            "\t"+AnsiString(l_TypeDate);
           ItemStr= ItemStr+"\t"+TitleColumn(Tempstr,l_TypeDate);
           sgMrp->AddItem(ItemStr);
        }
      }
      RsQuery->MoveNext();
    }
    RsQuery->Close();
    sgMrp->ScrollBars=ssBoth;//设置滚动条
  }
  __finally
  {
    delete RsQuery;
    delete RsQueryQty;
  }
  if(sgMrp->RowCount>1)
  {
    sgMrp->Row=1;
    sgMrp->Col=1;
  }
}
//------------------------------------------------
AnsiString __fastcall TfrmVW_Mrp_column::TitleColumn(AnsiString f_goods,AnsiString f_date)
 {

 //RsQueryQty=new  TComResultSet(Handle,g_ClientHandle);
 AnsiString l_str="";
// AnsiString  ItemStr="",m_SQL;
 AnsiString ll,l_qty;
// AnsiString l_sqlgross,l_sqlpoh,l_sqlmacc,l_sqlclean,l_sqlSoh,l_sqlTake;
 //m_SQL="select mrpdqty from sdmrpd where mrpdgoods ='"+ f_goods+"' and mrpdrdate = '"+f_date+"'" ;

   if(CB_Gross->Checked)
   {
     RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"1"+"\t");
     l_str= AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
   }
   if(CB_Poh->Checked)
   {
     RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"2"+"\t");
     l_qty=  AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
     if (l_str.IsEmpty())
        l_str= l_qty;
     else
        l_str= l_str+"\t"+l_qty;
     }
   if(CB_Macc->Checked)
   {
     RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"3"+"\t");
     l_qty=  AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
     if (l_str.IsEmpty())
        l_str= l_qty;
     else
        l_str= l_str+"\t"+l_qty;
    }
    if(CB_Clean->Checked)
   {
      RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"4"+"\t");
     l_qty=  AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
     if (l_str.IsEmpty())
        l_str= l_qty;
     else
        l_str= l_str+"\t"+l_qty;
    }
    if(CB_Soh->Checked)
   {

      RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"5"+"\t");
     l_qty=  AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
     if (l_str.IsEmpty())
        l_str= l_qty;
     else
        l_str= l_str+"\t"+l_qty;
    }
     if(CB_Take->Checked)
   {

      RsQueryQty->LocateByKey(f_goods+"\t"+f_date+"\t"+"6"+"\t");
     l_qty=  AnsiString(RsQueryQty->FieldByName("mrpdQTY"));
     if (l_str.IsEmpty())
        l_str= l_qty;
     else
        l_str= l_str+"\t"+l_qty;
    }
   return l_str;
 }
//---------------------------------------------------------------------------
 void __fastcall TfrmVW_Mrp_column::FillterColumData()
{
 int l_column=0,l_Tcolumn;
 sgMrp->Cells[0][0]="物料编码";
 sgMrp->Cells[1][0]="物料名称";
 sgMrp->Cells[2][0]="批量";
 sgMrp->Cells[3][0]="提前期";
 sgMrp->Cells[4][0]="当前库存";
 sgMrp->Cells[5][0]="安全库存";
 sgMrp->Cells[6][0]="已分配量";
 sgMrp->Cells[7][0]="低层码";
 sgMrp->Cells[8][0]="来源";
 sgMrp->Cells[9][0]="需求日期";
  sgMrp->ColCount= 16;
   l_Tcolumn = 9;
   if(CB_Gross->Checked)
   {
      l_column++;
      sgMrp->Columns->Items[l_Tcolumn+1]->TitleString ="毛需求";
   }
   if(CB_Poh->Checked)
   {
     l_column++ ;
     sgMrp->Columns->Items[l_Tcolumn+l_column]->TitleString ="计划入库";
     }
   if(CB_Macc->Checked)
   {
     l_column++;
     sgMrp->Columns->Items[l_Tcolumn+l_column]->TitleString ="计划库存";
    }
    if(CB_Clean->Checked)
   {
     l_column++;
     sgMrp->Columns->Items[l_Tcolumn+l_column]->TitleString ="净需求";
    }
    if(CB_Soh->Checked)
   {
     l_column++;
     sgMrp->Columns->Items[l_Tcolumn+l_column]->TitleString ="计划订单";
    }
     if(CB_Take->Checked)
   {
     l_column++;
     sgMrp->Columns->Items[l_Tcolumn+l_column]->TitleString ="计划下达";
    }
    sgMrp->ColCount= l_Tcolumn+l_column+1;
}

⌨️ 快捷键说明

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