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

📄 pohcancel.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PohCancel.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"

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

    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if(comServer->RecordCount>0)
    {
        sgPohCancel->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(fiPohTaxCode)+
                    "\t"+ GetHeadValue(fiPohBuyer)+
                    "\t"+ GetHeadValue(fiPohContract)+
                    "\t"+ GetHeadValue(fiPohSugDate);
            sgPohCancel->AddItem(ItemStr);
        }
    }
    else
    {
       sgPohCancel->RowCount=1;
       sgPodCancel->RowCount=1;
    }
   }
   __finally
   {
    EndWaitForm();
   }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::GetWhereStrToSQL()
{
     WhereStr="PohCheck=0 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 TfrmPohCancel::InitEditControl()
{
    sgPohCancel->RowCount=1;
    sgPodCancel->RowCount=1;
    btnCancel->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 TfrmPohCancel::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmPohCancel::AddDetailObjToGrid(AnsiString s_Code)
{
    AnsiString ItemStr;
    sgPodCancel->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);
          sgPodCancel->AddItem(ItemStr,i+1);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::DelDetailObjFromGrid(AnsiString s_Code)
{
    AnsiString m;
    for(int i=sgPodCancel->RowCount;i>0;i--)
    {
        m = Trim(sgPodCancel->Cells[1][i]);
        if(m==s_Code)
           sgPodCancel->RemoveItem(i);
    }

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

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

void __fastcall TfrmPohCancel::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 TfrmPohCancel::BitExitClick(TObject *Sender)
{
    frmPohCancel->Close();
}
//---------------------------------------------------------------------------


void __fastcall TfrmPohCancel::btnCancelClick(TObject *Sender)
{
    for(int i=sgPohCancel->RowCount; i>0;i--)
    {
      if(sgPohCancel->Cells[1][i]=="√")
      {
         comServer->LocateByKey(WideString(sgPohCancel->Cells[2][i]));
         if(!comServer->Eof)
         {
            comServer->Revoke(1);
         }
         DelDetailObjFromGrid(sgPohCancel->Cells[2][i]);
         sgPohCancel->Cells[1][i]="";
         sgPohCancel->RemoveItem(i);
      }
    }
    sgPodCancel->RowCount=1;
    btnCancel->Enabled=false;
}
//---------------------------------------------------------------------------

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

}
//---------------------------------------------------------------------------

void __fastcall TfrmPohCancel::sgPohCancelDblClick(TObject *Sender)
{
    int ARow=sgPohCancel->Row;
    if(ARow>0)
    {
      if(sgPohCancel->Cells[1][ARow]==" ")
      {
         btnCancel->Enabled=true;
         sgPohCancel->Cells[1][ARow]="√";
//         AddDetailObjToGrid(sgPohCancel->Cells[2][ARow]);
      }
      else
      {
         sgPohCancel->Cells[1][ARow]=" ";
//         DelDetailObjFromGrid(sgPohCancel->Cells[2][ARow]);
         //找到有没有需要审核的
         for (int i=1;i<sgPohCancel->RowCount;i++)
         {
            if(sgPohCancel->Cells[1][i]=="√")
            {
               btnCancel->Enabled=true;
               break;
            }
            else
               btnCancel->Enabled=false;
         }
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPohCancel::HavingRight()
{
 TComResultSet *RsTemp;
 AnsiString sSQL;
 sSQL=" select buyercode from sdbuyer where buyerCancel=1 and buyercode='"
     +g_sdUserCode+"'";
 RsTemp=NewResultSet();
 RsTemp->Open(sSQL,"");
 if(RsTemp->RecordCount <= 0)
 {
  RsTemp->Close();
  throw Exception("当前用户没有取消/反取消权限");
 }
 else
  RsTemp->Close();
 delete RsTemp; 
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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