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

📄 gpch.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    return ItemStr;
}

//---------------------------------------------------------------------------
void __fastcall TfrmGpch::RefreshGridData(int mAction)
{
    int i;
    AnsiString ItemStr;
    switch(mAction)
    {
       case 0: // Append
         ItemStr=GetDataToGrid();
         sgGpch->AddItem(ItemStr);
         break;
       case 1: // Modify
         i=sgGpch->Row;
         ItemStr=GetDataToGrid();
         sgGpch->ChangeItem(ItemStr,i);
         break;
       case 2: // Delete
         sgGpch->RemoveItem(sgGpch->Row);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::FillGridWithData()
{
    int i;
    AnsiString ItemStr;

    sgGpch->RowCount=1;
    if(comServer->RecordCount > 0)
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0); // Append
      }
}
//---------------------------------------------------------------------------


void __fastcall TfrmGpch::DisplayBill()
{
      if(comServer->RecordCount==0)
         return;
      GetDataFromComObject(1);  // Head
      FillGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::GetBill(AnsiString BillID)
{
    int iRow;
    iRow=comServer->Find("GpchCode='"+BillID+"'");
    if (iRow>0)      //FIND THIS BILL
    {
       DisplayBill();
    }
    else
       if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
       {
          AddHeadRecord();
       }
}
//---------------------------------------------------------------------------

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

AnsiString __fastcall TfrmGpch::GetDetailValue(int Index)
{
    AnsiString S;
    S = ReadItemValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmGpch::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgGpch,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgGpch,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::FormShow(TObject *Sender)
{
//    InitEditControl();
    ClearControl(1,false); // Head
    ClearControl(2,false); // Detail
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::sgGpchSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow > 0)
    {
     comServer->LocateItemByKey(sgGpch->TextMatrix[ARow][1]);
    }
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);    // Detail
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::sgGpchDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgGpch->Row;
    if (iRow == 0)
    {
       return;
    }
    sgGpch->Visible=false;
    fpGpcdDetail->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::ChangeToBrowseState(bool Browse)
{
     sgGpch->Visible=true;
     fpGpcdDetail->Visible=false;
     if(Browse==false)
      sgGpch->SetFocus();

}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::btnOKClick(TObject *Sender)
{
  try
  {
    if (CurrentState==caAddDetail||CurrentState==caAddBill)
    {
       if(DetailState==caAddDetail)
         comServer->AddItem();
       SendDataToComObject(2);
       comServer->AddToObject();
       ClearControl(2,false);
       seGpcdGoods->SetFocus();
    }
    else
      ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::btnCancelClick(TObject *Sender)
{
     CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::seGpcdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[物料编码][物料名称][计量单位]";
  SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode from sdgoods where ";
  SqlStr+=" Goodscancel=0 ";
  SqlStr+=" order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seGpcdGoods->Text=p->ColData[1];
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::SetValueGridFromRsGoods()
{
 scGpcdOPlan->LocateKey(GetGoodsValue("GoodsPlanType"));
 scGpcdNPlan->LocateKey(GetGoodsValue("GoodsPlanType"));

 sgdValue->Cells[1][1]=GetGoodsValue("GoodsSafeQty");
 sgdValue->Cells[1][2]=GetGoodsValue("GoodsSafeQty");
 sgdValue->Cells[2][1]=GetGoodsValue("GoodsRopQty");
 sgdValue->Cells[2][2]=GetGoodsValue("GoodsRopQty");
 sgdValue->Cells[3][1]=GetGoodsValue("GoodsEoq");
 sgdValue->Cells[3][2]=GetGoodsValue("GoodsEoq");
 sgdValue->Cells[4][1]=GetGoodsValue("GoodsEoi");
 sgdValue->Cells[4][2]=GetGoodsValue("GoodsEoi");
 sgdValue->Cells[5][1]=GetGoodsValue("GoodsMaxQty");
 sgdValue->Cells[5][2]=GetGoodsValue("GoodsMaxQty");
 sgdValue->Cells[6][1]=GetGoodsValue("GoodsOoq");
 sgdValue->Cells[6][2]=GetGoodsValue("GoodsOoq");
 sgdValue->Cells[7][1]=GetGoodsValue("GoodsWasteRate");
 sgdValue->Cells[7][2]=GetGoodsValue("GoodsWasteRate");
 sgdValue->Cells[8][1]=GetGoodsValue("GoodsMinPack");
 sgdValue->Cells[8][2]=GetGoodsValue("GoodsMinPack");
 sgdValue->Cells[9][1]=GetGoodsValue("GoodsPaot");
 sgdValue->Cells[9][2]=GetGoodsValue("GoodsPaot");
 sgdValue->Cells[10][1]=GetGoodsValue("GoodsPtof");
 sgdValue->Cells[10][2]=GetGoodsValue("GoodsPtof");
 sgdValue->Cells[11][1]=GetGoodsValue("GoodsMinQty");
 sgdValue->Cells[11][2]=GetGoodsValue("GoodsMinQty");
 sgdValue->Cells[12][1]=GetGoodsValue("GoodsOverDays");
 sgdValue->Cells[12][2]=GetGoodsValue("GoodsOverDays");
 sgdValue->Cells[13][1]=GetGoodsValue("GoodsIdleDays");
 sgdValue->Cells[13][2]=GetGoodsValue("GoodsIdleDays");
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::seGpcdGoodsExit(TObject *Sender)
{
 if(Trim(seGpcdGoods->Text)!="")
 {
  int GoodsFound;
  GoodsFound=g_sdRsGoods->LocateByKey(WideString(Trim(seGpcdGoods->Text)));
  if(GoodsFound != 0) //物料编码不存在
  {
   seGpcdGoods->Text="";
   return;
  }
  seGpcdGoods->Text=GetGoodsValue("GoodsCode");
  SetValueGridFromRsGoods();
 }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdGccr:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scGpcdGccr,"select GccrName memo,GccrCode from sdGccr order by GccrCode","memo","GccrCode");
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGpch::sgdValueKeyPress(TObject *Sender, char &Key)
{
 if((Key<'0' || Key>'9')&&Key!='.'&&Key!='\b'&&Key!='\r')
  Abort();
}
//---------------------------------------------------------------------------

void __fastcall TfrmGpch::seGpchCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seGpchCode->Text != GetHeadValue(fiGpchCode))
    {
      comServer->LocateByKey(WideString(seGpchCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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