qcsd.cpp

来自「速达开源ERP系统」· C++ 代码 · 共 200 行

CPP
200
字号
//--------------------------------------------------------------------------
#include <vcl.h>
#include "Qcsd.h"
#include "Qcsh.h"
//--------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma link "StdBaseForm"
#pragma resource "*.dfm"

TfrmQcsd  *frmQcsd;
//-----------------------------------------------------
__fastcall TfrmQcsd::TfrmQcsd(TComponent* Owner)
        : TStdBaseForm(Owner)
{
}
__fastcall TfrmQcsd::TfrmQcsd(TComponent* Owner,TComServer *FComServer)
        : TStdBaseForm(Owner)
{
    comServer = FComServer;
}
//-----------------------------------------
void __fastcall TfrmQcsd::MiddleForm()
{
     Left =(Screen->Width  - Width ) / 2;
     Top  =(Screen->Height - Height) / 2;
}
AnsiString __fastcall TfrmQcsd::GetHeadValue(int Index)
{
    return this->comServer->FieldValue[Index];
}
//-----------------------------------------------------
void __fastcall TfrmQcsd::btnOKClick(TObject *Sender)
{
    double dDQty,dCQty,dYQty,dNQty;
    if(sgQcsd->RowCount>1)
    {
       int j;
       j=comServer->ItemCount-1;
       if(j>=0)
       {
          comServer->LocateItemByIndex(j);
          j=StrToInt(this->comServer->ItemValue[fiQcsdLine]);

          j=j+1;
       }
       else
          j=1;
       for(int i=1;i<sgQcsd->RowCount;i++)
       {
           if(sgQcsd->Cells[1][i]=="√")
           {
               try
               {
                dDQty=StrToFloat(sgQcsd->Cells[5][i]); //送检数量
                dCQty=StrToFloat(sgQcsd->Cells[6][i]); //实检数量
                dYQty=StrToFloat(sgQcsd->Cells[8][i]); //合格数量
                if(dCQty > dDQty)
                {
                 ::MessageBox(Handle,"实检数量不能超过送检数量","错误提示",MB_OK|MB_ICONSTOP);
                 continue;
                }
                if(dYQty > dCQty)
                {
                 ::MessageBox(Handle,"合格数量不能超过实检数量","错误提示",MB_OK|MB_ICONSTOP);
                 continue;
                }
               }
               catch(...)
               {
                 if(::MessageBox(Handle,"数量填写错误,选择'确定'继续执行,选择'取消'中断执行","错误提示",MB_OKCANCEL|MB_ICONSTOP)==IDOK)
                  continue;
                 else
                  return;
               }
               comServer->AddItem();
               this->comServer->ItemValue[fiQcsdLine] = IntToStr(j);            //请购单行号
               this->comServer->ItemValue[fiQcsdCode] = frmQcsh->seQcshCode->Text;
               this->comServer->ItemValue[fiQcsdFLine] = sgQcsd->Cells[2][i];
               this->comServer->ItemValue[fiQcsdGoods] = sgQcsd->Cells[3][i];
               this->comServer->ItemValue[fiQcsdTrd] = sgQcsd->Cells[7][i];
               this->comServer->ItemValue[fiQcsdDQty] = sgQcsd->Cells[5][i];
               this->comServer->ItemValue[fiQcsdCQty] = sgQcsd->Cells[6][i];
               this->comServer->ItemValue[fiQcsdYQty] = sgQcsd->Cells[8][i];
               dNQty=dCQty-dYQty;
               this->comServer->ItemValue[fiQcsdNQty] = FloatToStr(dNQty);
               this->comServer->ItemValue[fiQcsdMode] = "1";
               this->comServer->ItemValue[fiQcsdState] = "1";
               this->comServer->ItemValue[fiQcsdDesc] = "";
               comServer->AddToObject();
               j=j+1;
           }
       }
    }
}
//------------------------------------------------
void __fastcall TfrmQcsd::btnCancelClick(TObject *Sender)
{
    Close();
}
//-----------------------------------------------------
void __fastcall TfrmQcsd::FormShow(TObject *Sender)
{
    MiddleForm();
    InitControlGroup();
}
//-------------------------------------------------------
void __fastcall TfrmQcsd::InitControlGroup()
{
    sgQcsd->RowCount = 1;
    seQcshType->Text= this->comServer->FieldValue[fiQcshType];
    seQcshDocCode->Text=this->comServer->FieldValue[fiQcshDocCode];
    FillTrd();
    FillGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcsd::FillGridWithData()
{
    AnsiString  ItemStr,s_SQL;
    if(frmQcsh->scQcshType->ItemData[1] == "1") //采购收获质检
    {
        s_SQL="select PrecdLine Line,PrecdGoods Goods,GoodsName,PrecdQty Qty from sdPrecd,sdGoods ";
        s_SQL+=" where PrecdGoods=GoodsCode and PrecdCode='"+seQcshDocCode->Text+"' order by PrecdLine";
    }else if(frmQcsh->scQcshType->ItemData[1] == "2")  //完成品质检
    {
        s_SQL = "select WepdLine Line,WepdGoods Goods,GoodsName,WepdCQty Qty from sdWepd,sdGoods ";
        s_SQL +=" where WepdGoods=GoodsCode and WepdCode='"+seQcshDocCode->Text+"' order by WepdLine";
    }else if(frmQcsh->scQcshType->ItemData[1] == "3")
    {
    }
    sgQcsd->RowCount=1;
    TComResultSet * RsRpod;
    RsRpod=NewResultSet();
    RsRpod->Open(s_SQL,"");
    AnsiString Qty;
    while( RsRpod->Eof == 0)
    {
     Qty = RsRpod->FieldByName("Qty");
     ItemStr = "\t"+AnsiString(" ") +
               "\t"+RsRpod->FieldByName("Line")+
               "\t"+RsRpod->FieldByName("Goods")+
               "\t"+RsRpod->FieldByName("GoodsName")+
               "\t"+RsRpod->FieldByName("Qty")+
               "\t"+RsRpod->FieldByName("Qty")+
               "\t"+""+
               "\t"+RsRpod->FieldByName("Qty");

     sgQcsd->AddItem(ItemStr);
     RsRpod->MoveNext();
    }
    delete RsRpod;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcsd::SetDetailValue(int Index,AnsiString Value)
{
    this->comServer->ItemValue[Index] = Value;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmQcsd::GetDetailValue(int Index)
{
     return this->comServer->ItemValue[Index];
}
//---------------------------------------------------------------------------

void __fastcall TfrmQcsd::sgQcsdDblClick(TObject *Sender)
{
    int ARow=sgQcsd->Row;
    if (ARow >0)
    {
      if (sgQcsd->Cells[1][ARow] == "√")
          sgQcsd->Cells[1][ARow] =  " ";
      else
          sgQcsd->Cells[1][ARow] =  "√";
    }
}
void __fastcall TfrmQcsd::FillTrd()
{
    TComResultSet * RsTrd;
    AnsiString s_SQL;
    int Index=0;
    s_SQL = "select TrdCode from sdTrd";
    RsTrd=NewResultSet();
    RsTrd->Open(s_SQL,"");
    sgQcsd->Columns->Items[7]->ClearListItem();
    while( RsTrd->Eof == 0)
    {
        sgQcsd->Columns->Items[7]->AddListItem(
                   RsTrd->FieldByName("TrdCode"), Index);
        Index++;
        RsTrd->MoveNext();
    }
    RsTrd->Close();
    delete RsTrd;
}

⌨️ 快捷键说明

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