sohcancel.cpp

来自「科思ERP部分源码及控件」· C++ 代码 · 共 260 行

CPP
260
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SohCancel.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSohCancel *frmSohCancel;
//---------------------------------------------------------------------------
__fastcall TfrmSohCancel::TfrmSohCancel(TComponent* Owner,HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        :TListBaseForm(Owner, chWnd, MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSohCancel::InitEditControl()
{
 FillComboBox(Handle,scSohSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
 FillComboBox(Handle,scSohClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::ClearControl()
{
           seSohCodeF->Text            ="";
           seSohCodeT->Text            ="";
           deSohDateF->Text            ="";
           deSohDateT->Text            ="";
           scSohClient->ItemIndex      =-1;
           scSohSaler->ItemIndex       =-1;

           SohGrid->RowCount=1;
           SodGrid->RowCount=1;
           btnCancel->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::WaitUserInput(int Section)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSohCancel::DisplayBill()
{
        FillHeadGridWithData();
        comServer->MoveFirst();
        FillDetailGridWithData();
}
void __fastcall TfrmSohCancel::ChangeToBrowseState(bool Browse)
{
    ClearControl();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::GetBill(AnsiString WhereStr)
{
    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if (comServer->RecordCount!=0)      //Found it
       {
         DisplayBill();
         btnCancel->Enabled=true;
       }
       else
        ShowMessageWindow("在数据库中没有查到记录,请重新输入条件",mwsInformation);
   RecodCount->Caption="查询单据数为:"+IntToStr(comServer->RecordCount);        
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::FillDetailGridWithData()
{
      int i;
      AnsiString ItemStr;
      SodGrid->RowCount=1;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          ItemStr="\t"+GetDetailValue("SodLine")+"\t"+
                    GetDetailValue("SodGoods")+"\t"+GetDetailValue("SodGoodsName")+"\t"+GetDetailValue("SodGoodsSpec")+"\t"+
                    GetDetailValue("SodUnit")+"\t"+
                    GetDetailValue("SodPrice")+"\t"+GetDetailValue("SodDisc")+"\t"+
                    GetDetailValue("SodQty")+"\t"+GetDetailValue("SodRecDate");
          SodGrid->AddItem(ItemStr);
      }
}
void __fastcall TfrmSohCancel::FillHeadGridWithData()
{
      int i;
      AnsiString HeadStr;
      SohGrid->RowCount=1;
      for (i=0;i<comServer->RecordCount;i++)
      {
          comServer->LocateByIndex(i);
          HeadStr="\t"+AnsiString("  ")+"\t"+GetHeadValue("SohCode")+"\t"+GetHeadValue("SohContract")+"\t"+
                       GetHeadValue("SohClient")+"\t"+GetHeadValue("SohDate")+"\t"+
                       GetHeadValue("SohCurrency")+"\t"+GetHeadValue("SohSettleMode")+"\t"+
                       GetHeadValue("SohSaler");
          SohGrid->AddItem(HeadStr);
      }

}
//---------------------------------------------------------------------------
    // Fix 2003-01-09 [Fengji]
//AnsiString __fastcall TfrmSohCancel::GetHeadValue(int Index)
//{
//        WideString S;
//        S = ReadFieldValue(comServer,Index);
//        return S;
//}
////---------------------------------------------------------------------------
//
//AnsiString __fastcall TfrmSohCancel::GetDetailValue(int Index)
//{
//        WideString S;
//        S = ReadItemValue(comServer,Index);
//        return S;
//}
////---------------------------------------------------------------------------
//void __fastcall TfrmSohCancel::SetHeadValue(int Index,AnsiString Value)
//{
//       WriteFieldValue(comServer,Index,WideString(Value));
//}
//
////---------------------------------------------------------------------------
//
//void __fastcall TfrmSohCancel::SetDetailValue(int Index,AnsiString Value)
//{
//       WriteItemValue(comServer,Index,WideString(Value));
//}
////---------------------------------------------------------------------------
//


void __fastcall TfrmSohCancel::FormShow(TObject *Sender)
{
//       InitEditControl();
       ClearControl();
       ChangeToBrowseState(true);

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSohCancel::GetWhereSQLString()
{
     AnsiString WhereStr;
     WhereStr="SohCancel=0 and SohClose=0 and SohCheck=0";
     WhereStr=WhereStr+" and SohClient in(select ClientCode from sdClient where ClientCancel=0)";
     if(!seSohCodeF->Text.IsEmpty())
        WhereStr=WhereStr+" and SohCode>='"+Trim(seSohCodeF->Text)+"'";
     if(!seSohCodeT->Text.IsEmpty())
        WhereStr=WhereStr+" and SohCode<='"+Trim(seSohCodeT->Text)+"'";
     if(!scSohSaler->Text.IsEmpty())
        WhereStr=WhereStr+" and SohSaler='"+Trim(scSohSaler->ItemData[1])+"'";
     if(!deSohDateF->Text.IsEmpty())
        WhereStr=WhereStr+" and SohDate>='"+FormatDateTime("YYYY-MM-DD",deSohDateF->Date)+"'";
     if(!deSohDateT->Text.IsEmpty())
        WhereStr=WhereStr+" and SohDate<='"+FormatDateTime("YYYY-MM-DD",deSohDateT->Date)+"'";
     if(!scSohClient->Text.IsEmpty())
        WhereStr=WhereStr+" and SohClient='"+Trim(scSohClient->ItemData[1])+"'";
   return(WhereStr);
}


void __fastcall TfrmSohCancel::btnClearClick(TObject *Sender)
{
       ClearControl();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::btnQueryClick(TObject *Sender)
{
           SohGrid->RowCount=1;
           SodGrid->RowCount=1;
           btnCancel->Enabled=false;

  AnsiString WhereStr=GetWhereSQLString();
  GetBill(WhereStr);
}
//---------------------------------------------------------------------------



void __fastcall TfrmSohCancel::SohGridClick(TObject *Sender)
{
   if(SohGrid->Row>0)
   {
    comServer->LocateByKey(WideString(SohGrid->TextMatrix[SohGrid->Row][2]));
     if(MC == 1)
     {
      if(SohGrid->TextMatrix[SohGrid->Row][1]=="ㄨ")
        {
           SohGrid->TextMatrix[SohGrid->Row][1]="";
         }
        else
         {
           SohGrid->TextMatrix[SohGrid->Row][1]="ㄨ";
         }
       }
      FillDetailGridWithData();       
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::btnCancelClick(TObject *Sender)
{
  for(int i=1; i<SohGrid->RowCount;i++)
  {
   if(SohGrid->TextMatrix[i][1]=="ㄨ")
   {
      comServer->LocateByKey(WideString(SohGrid->TextMatrix[i][2]));
     try
     {
       comServer->Revoke(1);
     }
     catch(Exception &e)
     {
      throw Exception(e.Message);
     }
   }
 }
  ClearControl();
  btnQueryClick(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::btnQuitClick(TObject *Sender)
{
   Close();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSohCancel::SohGridMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   int Column,Row;
   SohGrid->MouseToCell(X,Y,Column,Row);
   MC = Column;
   if(Column==1&&Row>0)
      SohGrid->Cursor=crHandPoint;
   else
      SohGrid->Cursor=crDefault;

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

⌨️ 快捷键说明

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