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

📄 prethcheck.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "PrethCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPrethCheck *frmPrethCheck;
//---------------------------------------------------------------------------
__fastcall TfrmPrethCheck::TfrmPrethCheck(TComponent* Owner)
    : TListBaseForm(Owner,euSdPreth,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::ChangeToBrowseState(bool Browse)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::FillHeadObjToGrid()
{
   AnsiString ItemStr;
   try
   {
    StartWaitForm("正在获取数据...");

    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if(comServer->RecordCount>0)
    {
        for(int i=0;i<comServer->RecordCount;i++)
        {
            comServer->LocateByIndex(i);
            ItemStr="\t\t"+ GetHeadValue(fiPrethCode)
                    + "\t"+ GetHeadValue(fiPrethDate)
                    + "\t"+ GetHeadValue(fiPrethSupply)
                    + "\t"+ GetHeadValue(fiPrethCurrency)
                    + "\t"+ GetHeadValue(fiPrethTaxCode);
            sgPrethCheck->AddItem(ItemStr);
        }
    }
    else
    {
        ShowMessage("没有满足条件并且可以审核的单据");
    }
   }
   __finally
   {
    EndWaitForm();
   }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::GetWhereStrToSQL()
{
     WhereStr="PrethCheck=0 and PrethCancel=0";
//        WhereStr = "1=1 "; // for debugging

     if(!(Trim(sePrethCodeF->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethCode>='"+Trim(sePrethCodeF->Text)+"'";
     if(!(Trim(sePrethCodeT->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethCode<='"+Trim(sePrethCodeT->Text)+"'";
     if(!(Trim(dePrethDateF->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethDate>='"+FormatDateTime("yyyy-mm-dd",dePrethDateF->Text)+"'";
     if(!(Trim(dePrethDateT->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethDate<='"+FormatDateTime("yyyy-mm-dd",dePrethDateT->Text)+"'";
     if(!(Trim(scPrethSupplyCode->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethSupply='"+Trim(scPrethSupplyCode->ItemData[cbItem2])+"'";
     if(!(Trim(scPrethCurrency->Text)).IsEmpty())
        WhereStr=WhereStr+ " and PrethCurrency='"+Trim(scPrethCurrency->Text)+"'";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::InitEditControl()
{
    FillComboBox(scPrethSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
    FillComboBox(scPrethCurrency,"select CurrencyCode from sdCurrency order By CurrencyCode","CurrencyCode");

    sgPrethCheck->RowCount=1;
    sgPretdCheck->RowCount=1;
    btnCheck->Enabled=false;
    sePrethCodeF->Text="";
    sePrethCodeT->Text="";
    dePrethDateF->Text="";
    dePrethDateT->Text=dePrethDateT->InitDate;
    scPrethCurrency->Text="";
    scPrethSupplyCode->Text="";

    sbBar->Panels->Items[1]->Text="操作员:"+g_sdUserCode;
    sbBar->Panels->Items[2]->Text=g_sdCompanyName;
    sbBar->Panels->Items[3]->Text=g_sdCurDate;

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrethCheck::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPrethCheck::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::AddDetailObjToGrid(AnsiString s_Code)
{
    AnsiString ItemStr;
    sgPretdCheck->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(fiPretdCode)
                  +"\t"+GetDetailValue(fiPretdLine)
                  +"\t"+GetDetailValue(fiPretdPrecCode)
                  +"\t"+GetDetailValue(fiPretdPrecdLine)
                  +"\t"+GetDetailValue(fiPretdGoods)
                  +"\t"+GetDetailValue(fiPretdUnit)
                  +"\t"+GetDetailValue(fiPretdQty)
                  +"\t"+GetDetailValue(fiPretdLoc)
                  +"\t"+GetDetailValue(fiPretdBatch);
          sgPretdCheck->AddItem(ItemStr,i+1);
      }
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPrethCheck::btnClearClick(TObject *Sender)
{
    InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::btnQueryClick(TObject *Sender)
{
    sgPrethCheck->RowCount=1;
    sgPretdCheck->RowCount=1;
    HavingRight();
    GetWhereStrToSQL();
    FillHeadObjToGrid();
}
//---------------------------------------------------------------------------

void __fastcall TfrmPrethCheck::FormShow(TObject *Sender)
{
    InitEditControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::BitExitClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------


void __fastcall TfrmPrethCheck::btnCheckClick(TObject *Sender)
{
    for(int i=sgPrethCheck->RowCount-1; i>0; i--)
    {
      if(sgPrethCheck->Cells[1][i]=="√")
      {
         comServer->LocateByKey(WideString(sgPrethCheck->Cells[2][i]));
         if(!comServer->Eof)
         {
            comServer->Check(1);
         }
         sgPrethCheck->RemoveItem(i);
      }
    }
    sgPretdCheck->RowCount=1;
    btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------



void __fastcall TfrmPrethCheck::sgPrethCheckDblClick(TObject *Sender)
{
    int i;
    i = sgPrethCheck->Row;
    if(i > 0)
    {
      if(sgPrethCheck->Cells[1][i]!="√")
      {
         btnCheck->Enabled=true;
         sgPrethCheck->Cells[1][i]="√";
      }
      else
      {
         sgPrethCheck->Cells[1][i]="";
         //找到有没有需要审核的
         for (int i=1;i<sgPrethCheck->RowCount;i++)
         {
            if(sgPrethCheck->Cells[1][i]=="√")
            {
               btnCheck->Enabled=true;
               break;
            }
            else
               btnCheck->Enabled=false;
         }
      }
    }

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

void __fastcall TfrmPrethCheck::sgPrethCheckSelectCell(TObject *Sender,
      int ACol, int ARow, bool &CanSelect)
{
 if(sgPrethCheck->RowCount>1 && ARow > 0)
 {
   AddDetailObjToGrid(sgPrethCheck->Cells[2][ARow]);
 }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPrethCheck::HavingRight()
{
 TComResultSet *RsTemp;
 AnsiString sSQL;
 sSQL=" select buyercode from sdbuyer where buyercheck=1 and buyercode='"
     +g_sdUserCode+"'";
 RsTemp=NewResultSet();
 RsTemp->Open(WideString(sSQL),WideString(""));
 if(RsTemp->RecordCount <= 0)
 {
  RsTemp->Close();
  throw Exception("当前用户没有审核/反审核权限");
 }
 else
  RsTemp->Close();
 delete RsTemp;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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