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

📄 srethcancel.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "SrethCancel.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSrethCancel *frmSrethCancel;
//---------------------------------------------------------------------------
__fastcall TfrmSrethCancel::TfrmSrethCancel(TComponent* Owner)
        :TListBaseForm(Owner,euSdSreth,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCancel::InitEditControl()
{
 FillComboBox(scSrethSaler,"Select userCode,UserName from sdUser where UserCode in (select SalerCode from SdSaler)","UserName","UserCode");
 FillComboBox(scSrethClient,"Select ClientCode,ClientName from sdClient where ClientCancel=0","ClientName","ClientCode");

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

void __fastcall TfrmSrethCancel::ClearControl()
{
           seSrethCodeF->Text            ="";
           seSrethCodeT->Text            ="";
           deSrethDateF->Text            ="";
           deSrethDateT->Text            ="";
           scSrethClient->ItemIndex      =-1;
           scSrethSaler->ItemIndex      =-1;

           SrethGrid->RowCount=1;
           SretdGrid->RowCount=1;
           btnCancel->Enabled=false;
}
//---------------------------------------------------------------------------

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

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

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

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

void __fastcall TfrmSrethCancel::FillDetailGridWithData()
{
      int i;
      AnsiString ItemStr;
      SretdGrid->RowCount=1;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);

          ItemStr="\t"+GetDetailValue(fiSretdLine)+"\t"+GetDetailValue(fiSretdSogCode)+"\t"+
                   GetDetailValue(fiSretdSogdLine)+"\t"+
                    GetDetailValue(fiSretdGoods)+"\t"+GetDetailValue(fiSretdUnit)+"\t"+
                    GetDetailValue(fiSretdQty);

          SretdGrid->AddItem(ItemStr);
      }
}
void __fastcall TfrmSrethCancel::FillHeadGridWithData()
{
      int i;
      AnsiString HeadStr;
      SrethGrid->RowCount=1;
      for (i=0;i<comServer->RecordCount;i++)
      {
          comServer->LocateByIndex(i);
          HeadStr="\t"+AnsiString("  ")+"\t"+GetHeadValue(fiSrethCode)+"\t"+
                       GetHeadValue(fiSrethClient)+"\t"+GetHeadValue(fiSrethDate)+"\t"+
                       GetHeadValue(fiSrethCurrency)+"\t"+GetHeadValue(fiSrethRr);
          SrethGrid->AddItem(HeadStr);
      }

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

AnsiString __fastcall TfrmSrethCancel::GetHeadValue(int Index)
{
        WideString S;
        S = ReadFieldValue(comServer,Index);
        return S;
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmSrethCancel::GetDetailValue(int Index)
{
        WideString S;
        S = ReadItemValue(comServer,Index);
        return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethCancel::SetHeadValue(int Index,AnsiString Value)
{
       WriteFieldValue(comServer,Index,WideString(Value));
}

//---------------------------------------------------------------------------

void __fastcall TfrmSrethCancel::SetDetailValue(int Index,AnsiString Value)
{
       WriteItemValue(comServer,Index,WideString(Value));
}
//---------------------------------------------------------------------------



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

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSrethCancel::GetWhereSQLString()
{
     AnsiString WhereStr;
     WhereStr="SrethCancel=0 and SrethCheck=0";
     WhereStr=WhereStr+" and SrethClient in(select ClientCode from sdClient where ClientCancel=0)";     
     if(!seSrethCodeF->Text.IsEmpty())
        WhereStr=WhereStr+" and SrethCode>='"+Trim(seSrethCodeF->Text)+"'";
     if(!seSrethCodeT->Text.IsEmpty())
        WhereStr=WhereStr+" and SrethCode<='"+Trim(seSrethCodeT->Text)+"'";
//     if(!scSrethSaler->Text.IsEmpty())
//        WhereStr=WhereStr+" and SrethSaler='"+Trim(scSrethSaler->ItemData[1])+"'";
     if(!deSrethDateF->Text.IsEmpty())
        WhereStr=WhereStr+" and SrethDate>='"+FormatDateTime("YYYY-MM-DD",deSrethDateF->Date)+"'";
     if(!deSrethDateT->Text.IsEmpty())
        WhereStr=WhereStr+" and SrethDate<='"+FormatDateTime("YYYY-MM-DD",deSrethDateT->Date)+"'";
     if(!scSrethClient->Text.IsEmpty())
        WhereStr=WhereStr+" and SrethClient='"+Trim(scSrethClient->ItemData[1])+"'";
   return(WhereStr);
}


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

void __fastcall TfrmSrethCancel::btnQueryClick(TObject *Sender)
{
 SrethGrid->RowCount=1;
 SretdGrid->RowCount=1;
 btnCancel->Enabled=false;

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



void __fastcall TfrmSrethCancel::SrethGridClick(TObject *Sender)
{
   if(SrethGrid->Row>0)
   {
     comServer->LocateByKey(WideString(SrethGrid->TextMatrix[SrethGrid->Row][2]));
     if(SrethGrid->Col == 1)
     {
      if(SrethGrid->TextMatrix[SrethGrid->Row][1]=="ㄨ")
        {
           SrethGrid->TextMatrix[SrethGrid->Row][1]="";
         }
        else
         {
           SrethGrid->TextMatrix[SrethGrid->Row][1]="ㄨ";
         }
      }
     FillDetailGridWithData();
    }
}
//---------------------------------------------------------------------------

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


void __fastcall TfrmSrethCancel::btnQuiteClick(TObject *Sender)
{
 Close();
}
//---------------------------------------------------------------------------

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

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

⌨️ 快捷键说明

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