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

📄 scraph.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
       {
          AddHeadRecord();
       }
}
//---------------------------------------------------------------------------

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

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

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

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

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

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

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

void __fastcall TfrmScraph::sgScraphDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgScraph->Row;
    if (iRow == 0)
    {
       return;
    }
    sgScraph->Visible=false;
    fpScrapDetail->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::ChangeToBrowseState(bool Browse)
{
     sgScraph->Visible=true;
     fpScrapDetail->Visible=false;
     if(Browse==false)
      sgScraph->SetFocus();

}
//---------------------------------------------------------------------------
void __fastcall TfrmScraph::btnOKClick(TObject *Sender)
{
  try
  {
    if (CurrentState==caAddDetail||CurrentState==caAddBill)
    {
       if(DetailState==caAddDetail)
         comServer->AddItem();
//       comServer->CurItemStatus;
       SendDataToComObject(2);
       comServer->AddToObject();
       ClearControl(2,false);
       seScrapdGoods->SetFocus();
    }
    else
      ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraph::btnCancelClick(TObject *Sender)
{
     CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraph::seScrapdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]";
  SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods,sdLg where ";
  SqlStr+=" LgGoodsCode=goodscode and lgstate=1 ";
  SqlStr+=" and LgLocCode = '"+scScrapdLoc->ItemData[1]+"' order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seScrapdGoods->Text=p->ColData[1];
    SetDetail(seScrapdGoods->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::seScrapdGoodsExit(TObject *Sender)
{
 SetDetail(Trim(seScrapdGoods->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmScraph::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdFc:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScraphFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
    break;
   }
   case euSdLoc:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScrapdLoc,"select locname memo,loccode from sdloc order by loccode","memo","LocCode");
    break;
   }
   case euSdPosType:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScraphPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    break;
   }
   case euSdDept:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScraphDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by DeptCode","memo","DeptCode");
    break;
   }
   case euSdKeeper:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScraphKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
    break;
   case euSdUnit:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScrapdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    break;
   }
   case euSdBatch:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScrapdBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
    break;
   }
   case euSdSr:
   {
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scScrapdSr,"select srdesc memo,srcode from sdsr order by SrCode","memo","SrCode");
    break;
   }
   default:
    break;
  }
}
//---------------------------------------------------------------------------


void __fastcall TfrmScraph::SetDetail(AnsiString gc)
{
  int IsFound=g_sdRsGoods->LocateByKey(WideString(gc));
  if(IsFound != 0) //输入无效编码
  {
   seScrapdGoods->Text=pv_GoodsCode;
   return;
  }
  seScrapdGoods->Text=GetGoodsValue("GoodsCode");
  pv_GoodsCode=GetGoodsValue("GoodsCode");
  labScrapdGoodsName->Caption=GetGoodsValue("GoodsName");
  scScrapdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
  if(GetGoodsValue("GoodsTrackSo")=="0")
  {//该物料不跟踪订单,则锁定销售单号和行号
   seScrapdSod->Enabled=false;
   seScrapdSodLine->Enabled=false;
   seScrapdSod->Text="";
   seScrapdSodLine->Text="";
  }
  else
  {
   seScrapdSod->Enabled=true;
   seScrapdSodLine->Enabled=true;
  }
  if(GetGoodsValue("GoodsBatch")=="0")
  {//该物料不采用批次管理,则锁定批号
   scScrapdBatch->Enabled=false;
   scScrapdBatch->ItemIndex=-1;
  }
  else
  {
   scScrapdBatch->Enabled=true;
  }
}
void __fastcall TfrmScraph::seScrapdSodButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="005[订单号][订单行号][客户名称][物料编码][物料名称]select sohcode,sodline,ClientName,sodgoods,goodsname from sdsoh,sdclient,sdsod,sdgoods";
  SqlStr+=" where sohcheck=1 and sohclient=clientcode  and sohcode=sodcode and sodgoods=goodscode and sodgoods='"+seScrapdGoods->Text+"' order by sohcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"订单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seScrapdSod->Text=p->ColData[1];
    seScrapdSodLine->Text=p->ColData[2];
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::scScrapdLocChange(TObject *Sender)
{
 seScrapdGoods->Text="";
}
//---------------------------------------------------------------------------

void __fastcall TfrmScraph::seScraphCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seScraphCode->Text != GetHeadValue(fiScraphCode))
    {
      comServer->LocateByKey(WideString(seScraphCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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