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

📄 alfh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    AnsiString S;
    S = ReadFieldValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAlfh::GetDetailValue(int Index)
{
    AnsiString S;
    S = ReadItemValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::FormCreate(TObject *Sender)
{
//    FormIniFile="D:\Test.Ini";
//    SetGridWidth(Name,sgAlfd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgAlfd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::sgAlfdSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow == 0)
    {
       return;
    }
    comServer->LocateItemByKey(WideString(sgAlfd->TextMatrix[ARow][1]));
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::sgAlfdDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgAlfd->Row;
    if (iRow == 0)
    {
       return;
    }
    sgAlfd->Visible=false;
    FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::ChangeToBrowseState(bool Browse)
{
    FloatPanel2->Visible=false;
    sgAlfd->Visible=true;
    if(Browse==false)
    {
      sgAlfd->SetFocus();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::btnOKClick(TObject *Sender)
{
  try
  {
    if (CurrentState==caAddDetail||CurrentState==caAddBill)
    {
       if(DetailState==caAddDetail)
          comServer->AddItem();
       SendDataToComObject(2);
       comServer->AddToObject();
       ClearControl(2,false);
       seAlfdGoods->SetFocus();
    }
    else
      ChangeToBrowseState();
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::seAlfdGoodsButtonClick(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 = '"+scAlfdOLoc->ItemData[1]+"'";
  SqlStr+=" and exists (select LGLOCCODE from sdlg where LGGOODSCODE = goodscode and lgstate=1 and  LGLOCCODE='"+scAlfdILoc->ItemData[1]+"')";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAlfdGoods->Text=p->ColData[1];
    SetDetail(seAlfdGoods->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::scAlfdUnitClick(TObject *Sender)
{
/*
 if(scAlfdUnit->ItemIndex > -1)
 {
  seAlfdConv->Text=scAlfdUnit->ItemData[2];
 }
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::seAlfdGoodsExit(TObject *Sender)
{
 SetDetail(Trim(seAlfdGoods->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdFc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scAlfhFmonth,"Select FcMonth from sdFc order by fcmonth","FcMonth");
    }
    break;
   case euSdDept:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scAlfhODept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by deptcode","memo","DeptCode");
     FillComboBox(scAlfhIDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by DeptCode","memo","DeptCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scAlfdOLoc,"select locname memo,loccode from sdloc order by loccode","memo","LocCode");
     FillComboBox(scAlfdILoc,"select locname memo,loccode from sdloc order by LocCode","memo","LocCode");
    }
    break;
   case euSdPosType:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scAlfhPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    break;
   case euSdKeeper:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scAlfhKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scAlfdUnit,"SELECT UnitName memo,UnitCode,UnitRate FROM sdUnit Order by UnitCode ","Memo","UnitCode","UnitRate");
    break;
   case euSdBatch:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scAlfdSBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
     FillComboBox(scAlfdDBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
    }
   default:
    break;
  }
}
//---------------------------------------------------------------------------


void __fastcall TfrmAlfh::SetDetail(AnsiString gc)
{
  int IsFound=g_sdRsGoods->LocateByKey(WideString(gc));
  if(IsFound != 0) //输入无效编码
  {
   seAlfdGoods->Text=pv_GoodsCode;
   return;
  }
  seAlfdGoods->Text = GetGoodsValue("GoodsCode");
  pv_GoodsCode=GetGoodsValue("GoodsCode");
  labAlfdGoodsName->Caption=GetGoodsValue("GoodsName");
  scAlfdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
/*
  if(GetGoodsValue("GoodsMUnit")=="0")
  {//该物料不使用多计量单位,则锁定单位和转换系数
   scAlfdUnit->Enabled=false;
   seAlfdConv->Enabled=false;
   seAlfdConv->Text="1";
  }
  else
  {
   scAlfdUnit->Enabled=true;
   seAlfdConv->Enabled=true;
  }
*/
  if(GetGoodsValue("GoodsTrackSo")=="0")
  {//该物料不跟踪订单,则锁定销售单号和行号
   seAlfdSSo->Enabled=false;
   seAlfdSSodLine->Enabled=false;
   seAlfdDSo->Enabled=false;
   seAlfdDSodLine->Enabled=false;
   seAlfdSSo->Text="";
   seAlfdDSo->Text="";
   seAlfdSSodLine->Text="";
   seAlfdDSodLine->Text="";
  }
  else
  {
   seAlfdSSo->Enabled=true;
   seAlfdSSodLine->Enabled=true;
   seAlfdDSo->Enabled=true;
   seAlfdDSodLine->Enabled=true;
  }
  if(GetGoodsValue("GoodsBatch")=="0")
  {//该物料不采用批次管理,则锁定批号
   scAlfdSBatch->Enabled=false;
   scAlfdDBatch->Enabled=false;
   scAlfdSBatch->ItemIndex=-1;
   scAlfdDBatch->ItemIndex=-1;
  }
  else
  {
   scAlfdSBatch->Enabled=true;
   scAlfdDBatch->Enabled=true;
  }
}

void __fastcall TfrmAlfh::seAlfdSSoButtonClick(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='"+seAlfdGoods->Text+"' order by sohcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"订单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAlfdSSo->Text=p->ColData[1];
    seAlfdSSodLine->Text=p->ColData[2];
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::seAlfdDSoButtonClick(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='"+seAlfdGoods->Text+"' order by sohcode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"订单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAlfdDSo->Text=p->ColData[1];
    seAlfdDSodLine->Text=p->ColData[2];
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::scAlfdOLocChange(TObject *Sender)
{
 seAlfdGoods->Text="";
}
//---------------------------------------------------------------------------

void __fastcall TfrmAlfh::seAlfhCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seAlfhCode->Text != GetHeadValue(fiAlfhCode))
    {
      comServer->LocateByKey(WideString(seAlfhCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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