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

📄 pohstop.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PohStop.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "ListBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmPohStop *frmPohStop;
//---------------------------------------------------------------------------
__fastcall TfrmPohStop::TfrmPohStop(TComponent* Owner)
    : TListBaseForm(Owner,euSdPoh,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::FillHeadObjToGrid()
{
   AnsiString ItemStr;
   try
   {
    StartWaitForm("正在获取数据...");

    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if(comServer->RecordCount>0)
    {
        sgPohCheck->RowCount=1;
        for(int i=0;i<comServer->RecordCount;i++)
        {
            comServer->LocateByIndex(i);
            ItemStr="\t"+ AnsiString(" ")+
                    "\t"+ GetHeadValue(fiPohCode)+
                    "\t"+ GetHeadValue(fiPohDate)+
                    "\t"+ GetHeadValue(fiPohSupply)+
                    "\t"+ GetHeadValue(fiPohCurrency)+
                    "\t"+ GetHeadValue(fiPohAmt)+
                    "\t"+ GetHeadValue(fiPohBuyer)+
                    "\t"+ GetHeadValue(fiPohContract)+
                    "\t"+ GetHeadValue(fiPohSugDate);
            sgPohCheck->AddItem(ItemStr);
        }
    }
    else
    {
       sgPohCheck->RowCount=1;
       sgPodCheck->RowCount=1;
    }
   }
   __finally
   {
    EndWaitForm();
   }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::GetWhereStrToSQL()
{
     WhereStr="PohCheck=1 and PohCancel=0 and PohStop=0 and PohClose=0 and ";

     if(Trim(sePohCodeF->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohCode>='"+Trim(sePohCodeF->Text)+"' and ";
     if(Trim(sePohCodeT->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohCode<='"+Trim(sePohCodeT->Text)+"' and ";
     if(Trim(dePohDateF->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohDate>='"+FormatDateTime("yyyy-mm-dd",dePohDateF->Date)+"' and ";
     if(Trim(dePohDateT->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohDate<='"+FormatDateTime("yyyy-mm-dd",dePohDateT->Date)+"' and ";
     if(Trim(scPohBuyerCode->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohBuyer like '"+Trim(scPohBuyerCode->ItemData[cbItem2])+"' and ";
     if(Trim(scPohSupplyCode->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "PohSupply like '"+Trim(scPohSupplyCode->ItemData[cbItem2])+"' and ";

     if (WhereStr.Length() > 5)
        WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
     else
        WhereStr="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::InitEditControl()
{
    sgPohCheck->RowCount=1;
    sgPodCheck->RowCount=1;
    btnStop->Enabled=false;
    sePohCodeF->Text="";
    sePohCodeT->Text="";
    dePohDateF->Text="";
    dePohDateT->Text=dePohDateT->InitDate;
    scPohBuyerCode->Text="";
    scPohSupplyCode->Text="";
    sbBar->Panels->Items[1]->Text="操作员:"+g_sdUserCode;
    sbBar->Panels->Items[2]->Text=g_sdCompanyName;
    sbBar->Panels->Items[3]->Text=g_sdCurDate;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPohStop::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmPohStop::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------

void __fastcall  TfrmPohStop::ChangeToBrowseState(bool agree)
{
    return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPohStop::AddDetailObjToGrid(AnsiString s_Code)
{
    AnsiString ItemStr;
    sgPodCheck->RowCount=1;
    comServer->LocateByKey(WideString(s_Code));
    if(comServer->RecordCount>0)
    {
      for (int i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          ItemStr="\t"+GetDetailValue(fiPodCode)+
                  "\t"+GetDetailValue(fiPodLine)+
                  "\t"+GetDetailValue(fiPodGoods)+
                  "\t"+GetDetailValue(fiPodUnit)+
                  "\t"+GetDetailValue(fiPodReqDate)+
                  "\t"+GetDetailValue(fiPodQty)+
                  "\t"+GetDetailValue(fiPodDept)+
                  "\t"+GetDetailValue(fiPodLoc)+
                  "\t"+GetDetailValue(fiPodSo);
          sgPodCheck->AddItem(ItemStr,i+1);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::DelDetailObjFromGrid(AnsiString s_Code)
{
    AnsiString m;
    for(int i=sgPodCheck->RowCount;i>0;i--)
    {
        m = Trim(sgPodCheck->Cells[1][i]);
        if(m==s_Code)
           sgPodCheck->RemoveItem(i);
    }

/*
    AnsiString m;
    bool Founded;
    for(int i=1;i<sgPodCheck->RowCount;i++)
    {
        m = Trim(sgPodCheck->Cells[1][i]);
        if(m==s_Code)
        {
           Founded=true;
           sgPodCheck->RemoveItem(i);
           while(Founded)
           {
              m = Trim(sgPodCheck->Cells[1][i]);
              if(m == s_Code)
              {
                sgPodCheck->RemoveItem(i);
                Founded=true;
              }
              else
                Founded=false;
           }
           break;
        }
    }
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmPohStop::btnClearClick(TObject *Sender)
{
    InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::btnQueryClick(TObject *Sender)
{
    GetWhereStrToSQL();
    FillHeadObjToGrid();
}
//---------------------------------------------------------------------------

void __fastcall TfrmPohStop::FormShow(TObject *Sender)
{
    FillComboBox(scPohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
    FillComboBox(scPohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
    InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohStop::BitExitClick(TObject *Sender)
{
    frmPohStop->Close();
}
//---------------------------------------------------------------------------


void __fastcall TfrmPohStop::btnStopClick(TObject *Sender)
{
    for(int i=sgPohCheck->RowCount-1; i>0;i--)
    {
      if(sgPohCheck->Cells[1][i]=="√")
      {
         comServer->LocateByKey(WideString(sgPohCheck->Cells[2][i]));
//         if(!comServer->Eof)
//            comServer->Stop(1);
         DelDetailObjFromGrid(sgPohCheck->Cells[2][i]);
         sgPohCheck->Cells[1][i]="";
         sgPohCheck->RemoveItem(i);
      }
    }
    sgPodCheck->RowCount=1;
    btnStop->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TfrmPohStop::sgPohCheckSelectCell(TObject *Sender,
      int ACol, int ARow, bool &CanSelect)
{
 if(sgPohCheck->RowCount > 1 && ARow > 0)
 {
   AddDetailObjToGrid(sgPohCheck->Cells[2][ARow]);
 }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPohStop::sgPohCheckDblClick(TObject *Sender)
{
    int ARow=sgPohCheck->Row;
    if(ARow>0)
    {
      if(sgPohCheck->Cells[1][ARow]==" ")
      {
         btnStop->Enabled=true;
         sgPohCheck->Cells[1][ARow]="√";
//         AddDetailObjToGrid(sgPohCheck->Cells[2][ARow]);
      }
      else
      {
         sgPohCheck->Cells[1][ARow]=" ";
//         DelDetailObjFromGrid(sgPohCheck->Cells[2][ARow]);
         //找到有没有需要审核的
         for (int i=1;i<sgPohCheck->RowCount;i++)
         {
            if(sgPohCheck->Cells[1][i]=="√")
            {
               btnStop->Enabled=true;
               break;
            }
            else
               btnStop->Enabled=false;
         }
      }
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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