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

📄 adjinvh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::FormCreate(TObject *Sender)
{
//    FormIniFile="D:\Test.Ini";
//    SetGridWidth(Name,sgAdjInvh,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmAdjInvh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgAdjInvh,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::FormShow(TObject *Sender)
{
//    InitEditControl();
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState(true);
    TGenBaseForm::MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::sgAdjInvhSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow > 0)
    {
       comServer->LocateItemByKey(WideString(sgAdjInvh->TextMatrix[ARow][1]));
    }
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::ChangeToBrowseState(bool agree)
{
    if(agree==true)
    {
      sgAdjInvh->Visible=true;
      FloatPanel2->Visible=false;
//      sgAdjInvh->Align=alClient;
//      FloatPanel2->Align=alNone;
    }
    else
    {
      sgAdjInvh->Visible=false;
      FloatPanel2->Visible=true;
//      sgAdjInvh->Align=alNone;
//      FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::btnOKClick(TObject *Sender)
{
  try
  {
    if ((CurrentState==caAddDetail)||(CurrentState==caAddBill))
    {
      if(DetailState==caAddDetail)
       comServer->AddItem();
      SendDataToComObject(2);
      comServer->AddToObject();
      ClearControl(2,false);
      if(seAdjInvdTsCode->Enabled)
        seAdjInvdTsCode->SetFocus();
      else
        seAdjInvdLoc->SetFocus();
    }
    else
      ChangeToBrowseState(true);
  }
  catch(Exception &e)
  {
   throw Exception(e.Message);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------


void __fastcall TfrmAdjInvh::GenrateBill()
{
    int TempCount;
    if(scAdjInvhType->ItemData[1] == "2")
      throw Exception("调整类型为<直接调整>时没有生成功能!");
    TempCount = comServer->ItemCount;
    StartWaitForm("正在启动生成界面");
    TfrmAdjInvd *p=new TfrmAdjInvd(this);
    try
    {
      p->GetComObject(comServer);
      EndWaitForm();
      p->ShowModal();
      if (TempCount < comServer->ItemCount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    }
    __finally
    {
      delete p;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::sgAdjInvhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgAdjInvh->Row;
    if (iRow == 0)
    {
       return;
    }
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmAdjInvh::seAdjInvdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[物料编码][物料名称][计量单位]";
  SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode from sdgoods,sdLg where goodscancel=0 and goodsstate=2 ";
  SqlStr+=" and GoodsCode=LgGoodsCode and LgState=1 and LgLocCode='"+seAdjInvdLoc->ItemData[1]+"' order by goodscode";

  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAdjInvdGoods->Text=p->ColData[1];
    labAdjInvdGoodsName->Caption=p->ColData[2];
    scAdjInvdUnit->LocateKey(p->ColData[3]);
  }
  delete p;
}
//---------------------------------------------------------------------------


void __fastcall TfrmAdjInvh::seAdjInvdGoodsExit(TObject *Sender)
{
  int IsFound=g_sdRsGoods->LocateByKey(WideString(seAdjInvdGoods->Text));
  if(IsFound != 0) //输入无效编码
  {
   seAdjInvdGoods->Text="";
   return;
  }
  seAdjInvdGoods->Text=GetGoodsValue("GoodsCode");
  labAdjInvdGoodsName->Caption=GetGoodsValue("GoodsName");
  scAdjInvdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
    case euSdFc:
      if(ShowUpdateMessage(MsgSrc,MsgType))
      {
        FillComboBox(scAdjInvhFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
      }
      break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scAdjInvdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(seAdjInvdLoc,"select locname memo,loccode from sdloc where LocType=1 order by LocCode","memo","LocCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmAdjInvh::scAdjInvhTypeChange(TObject *Sender)
{
  if(scAdjInvhType->ItemData[1] == "2")
    tbGenDetail->Enabled=false;
  else
    tbGenDetail->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::seAdjInvdLocButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc ";
  SqlStr+=" order by LocCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"调整货位查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAdjInvdLoc->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmAdjInvh::seAdjInvdTsCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="008[盘点单号][盘点行号][盘点货位][物料编码][物料名称][计量单位][盈/亏][差异数量]";
  SqlStr+=" select TshCode,TsdLine,TsdLoc,TsdGoods,GoodsName,GoodsUnitCode,Flg=(case TsdFlg when 1 then '盘盈' when -1 then '盘亏' else '盘平' end),TsdDQty ";
  SqlStr+=" from sdTsh,sdTsd,sdGoods ";
  SqlStr+=" where TshCode=TsdCode and TshCheck=1 and TsdGoods=GoodsCode and TsdDQty > 0 ";
  SqlStr+=" order by TshCode,TsdLine ";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"盘点单查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seAdjInvdTsCode->Text=p->ColData[1];
    seAdjInvdTsdLine->Text=p->ColData[2];
    seAdjInvdLoc->LocateKey(p->ColData[3]);
    seAdjInvdGoods->Text=p->ColData[4];
    labAdjInvdGoodsName->Caption=p->ColData[5];
    scAdjInvdUnit->LocateKey(p->ColData[6]);
    if(p->ColData[7] == "盘盈")
     seAdjInvdQty->Text=Trim(p->ColData[8]);
    else
     seAdjInvdQty->Text="-"+Trim(p->ColData[8]);
  }
  delete p;

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

void __fastcall TfrmAdjInvh::seAdjInvhCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal)
    {
      comServer->LocateByKey(WideString(seAdjInvhCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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