rpohcheck.cpp

来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 264 行

CPP
264
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#include "RpohCheck.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"

TfrmRpohCheck *frmRpohCheck;
//---------------------------------------------------------------------------
__fastcall TfrmRpohCheck::TfrmRpohCheck(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TListBaseForm(Owner,chWnd,MidCode,WhereStr)

{

}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCheck::FillHeadObjToGrid()
{
   AnsiString ItemStr;
   try
   {
    StartWaitForm("正在获取数据...");
    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    sgRpohCheck->RowCount=1;
    sgRpodCheck->RowCount=1;
    if(comServer->RecordCount>0)
    {
        for(int i=0;i<comServer->RecordCount;i++)
        {
            comServer->LocateByIndex(i);
            ItemStr="\t"+ AnsiString(" ")+
                    "\t"+ GetHeadValue("RpohCode")+
                    "\t"+ GetHeadValue("RpohDate")+
                    "\t"+ GetHeadValue("RpohSupplyCode")+
                    "\t"+ GetHeadValue("RpohCurrencyCode")+
                    "\t"+ GetHeadValue("RpohTaxCode")+
                    "\t"+ GetHeadValue("RpohBuyerCode")+
                    "\t"+ GetHeadValue("RpohPsite")+
                    "\t"+ GetHeadValue("RpohDeliver");
            sgRpohCheck->AddItem(ItemStr);
        }
    }
    else
    {
     ShowMessage("没有满足条件并且可以审核的单据");
    }
   }
   __finally
   {
    EndWaitForm();
   }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCheck::GetWhereStrToSQL()
{
     WhereStr="RpohCheck=0 and RpohCancel=0  and ";

     if(Trim(seRpohCodeF->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohCode>='"+Trim(seRpohCodeF->Text)+"' and ";
     if(Trim(seRpohCodeT->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohCode<='"+Trim(seRpohCodeT->Text)+"' and ";
     if(Trim(deRpohDateF->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohDate>='"+FormatDateTime("yyyy-mm-dd",deRpohDateF->Date)+"' and ";
     if(Trim(deRpohDateT->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohDate<='"+FormatDateTime("yyyy-mm-dd",deRpohDateT->Date)+"' and ";
     if(Trim(scRpohBuyerCode->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohBuyerCode = '"+Trim(scRpohBuyerCode->ItemData[cbItem2])+"' and ";
     if(Trim(scRpohSupplyCode->Text).IsEmpty()==false)
        WhereStr=WhereStr+ "RpohSupplyCode = '"+Trim(scRpohSupplyCode->ItemData[cbItem2])+"' and ";

     if (WhereStr.Length() > 5)
        WhereStr=WhereStr.SubString(1,WhereStr.Length()-5);
     else
        WhereStr="";
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCheck::InitEditControl()
{
    sgRpohCheck->RowCount=1;
    sgRpodCheck->RowCount=1;
    btnCheck->Enabled=false;
    seRpohCodeF->Text="";
    seRpohCodeT->Text="";
    deRpohDateF->Text="";
    deRpohDateT->Text=deRpohDateT->InitDate;
    scRpohBuyerCode->Text="";
    scRpohSupplyCode->Text="";
   // sbBar->Panels->Items[1]->Text="操作员:"+g_sdUserCode;
    //sbBar->Panels->Items[2]->Text=g_sdCompanyName;
    //sbBar->Panels->Items[3]->Text=g_sdCurDate;
//all this do in baseform
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmRpohCheck::AddDetailObjToGrid(AnsiString s_Code)
{
    AnsiString ItemStr;
    sgRpodCheck->RowCount=1;
    comServer->LocateByKey(WideString(s_Code));
    if(comServer->RecordCount>0)
    {
      for (int i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          l_Query->LocateByKey(GetDetailValue("RpodGoodsCode"));
          ItemStr="\t"+GetDetailValue("RpodCode")+
                  "\t"+GetDetailValue("RpodLine")+
                  "\t"+GetDetailValue("RpodGoodsCode")+
                  "\t"+l_Query->FieldByName("goodsname")+
                  "\t"+l_Query->FieldByName("goodsspec")+
                  "\t"+GetDetailValue("RpodUnitCode")+
                  "\t"+GetDetailValue("RpodConvRate")+
                  "\t"+GetDetailValue("RpodQty")+
                  "\t"+GetDetailValue("RpodPrice")+
                  "\t"+GetDetailValue("RpodAmt")+
                  "\t"+GetDetailValue("RpodReqDate");
          sgRpodCheck->AddItem(ItemStr,i+1);
      }
    }

}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCheck::DelDetailObjFromGrid(AnsiString s_Code)
{
    AnsiString m;
    for(int i=sgRpodCheck->RowCount;i>0;i--)
    {
        m = Trim(sgRpodCheck->Cells[1][i]);
        if(m==s_Code)
           sgRpodCheck->RemoveItem(i);
    }

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

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

    HavingRight();
    GetWhereStrToSQL();
    FillHeadObjToGrid();
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpohCheck::FormShow(TObject *Sender)
{
    l_Query->Close();
    l_Query->Open("select goodsname,goodscode,goodsspec from sdgoods","goodscode");
    FillComboBox(Handle,scRpohBuyerCode,"select BuyerCode,BuyerName from sdBuyer order By BuyerCode","BuyerName","BuyerCode");
    FillComboBox(Handle,scRpohSupplyCode,"select SupplyCode,SupplyName from sdSupply order By SupplyCode","SupplyName","SupplyCode");
    InitEditControl();

}
//---------------------------------------------------------------------------
void __fastcall TfrmRpohCheck::BitExitClick(TObject *Sender)
{
    frmRpohCheck->Close();
}
//---------------------------------------------------------------------------


void __fastcall TfrmRpohCheck::btnCheckClick(TObject *Sender)
{
    AnsiString sBillCode;
    for(int i=sgRpohCheck->RowCount-1; i>0;i--)
    {
      if(sgRpohCheck->Cells[1][i]=="√")
      {
         sBillCode=sgRpohCheck->Cells[2][i];
         comServer->LocateByKey(WideString(sBillCode));
         if(!comServer->Eof)
         {
          try
          {
           comServer->Edit();
           SetHeadValue("RpohCheck",1);
           SetHeadValue("RpohChecker",g_sdUserCode);
           SetHeadValue("RpohCheckDate",g_sdCurDate);
           comServer->Check(1);
          }
          catch(Exception &e)
          {
           throw Exception("审核请购单<"+sBillCode+">出现错误!\n"+e.Message);
          }
         }
         DelDetailObjFromGrid(sgRpohCheck->Cells[2][i]);
         sgRpohCheck->Cells[1][i]="";
         sgRpohCheck->RemoveItem(i);
      }
    }
    sgRpodCheck->RowCount=1;
    btnCheck->Enabled=false;

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


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

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


void __fastcall TfrmRpohCheck::sgRpohCheckClick(TObject *Sender)
{
if(sgRpohCheck->RowCount > 1 && sgRpohCheck->Row > 0)
 {
   AddDetailObjToGrid(sgRpohCheck->Cells[2][sgRpohCheck->Row]);
 }
}
//---------------------------------------------------------------------------





⌨️ 快捷键说明

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