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

📄 gosh.cpp

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

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


void __fastcall TfrmGosh::GenrateBill()
{
    int TempCount;
    if(scGoshType->ItemIndex==3)
      throw Exception("出库类型为<其它出库>时没有生成功能!");
    TempCount = comServer->ItemCount;
    StartWaitForm("正在启动生成界面");
    TfrmGosd *p=new TfrmGosd(this);
    try
    {
      p->GetComObject(comServer);
      EndWaitForm();
      p->ShowModal();
      if (TempCount < comServer->ItemCount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    }
    __finally
    {
      delete p;
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGosh::seGosdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="006[物料编码][物料名称][计量单位][多计量单位][批次管理][订单管理]";
  SqlStr+=" select GoodsCode,GoodsName,GoodsUnitCode,GoodsMUnit,GoodsBatch,GoodsTrackSo from sdgoods where goodscancel=0 and ";
  if(scGoshType->ItemIndex==0)
    SqlStr+=" goodsSale=1 and goodsstate=2 order by goodscode";
  else if(scGoshType->ItemIndex==1)
    SqlStr+=" goodsfrom=1 and goodsstate=2 order by goodscode";
  else if(scGoshType->ItemIndex==2)
    SqlStr+=" goodsstate=2 order by goodscode";
  else if(scGoshType->ItemIndex==3)
    SqlStr+=" goodsstate=2 order by goodscode";

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


void __fastcall TfrmGosh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdFc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scGoshFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
    }
    break;
   case euSdPosType:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scGoshPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    }
    break;
   case euSdKeeper:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scGoshKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scGosdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(seGosdLoc,"select locname memo,loccode from sdloc where LocType=1 order by LocCode","memo","LocCode");
    }
    break;
   case euSdBatch:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scGosdBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------



void __fastcall TfrmGosh::scGoshTypeChange(TObject *Sender)
{
  if(scGoshType->ItemIndex==3 )
    tbGenDetail->Enabled=false;
  else
    tbGenDetail->Enabled=true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGosh::BackDisp()
{
  double dQty,dPrice,dAmt;
  if(seGosdQty->Text != "" && seGosdPrice->Text != "")
  {
   dQty=StrToFloat(seGosdQty->Text);
   dPrice=StrToFloat(seGosdPrice->Text);
   dAmt=dQty*dPrice;
   seGosdAmt->Text=DataCarry(dAmt,2,0);
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGosh::seGosdQtyExit(TObject *Sender)
{
  BackDisp();
}
//---------------------------------------------------------------------------

void __fastcall TfrmGosh::SetDetail(AnsiString gc)
{
    int IsFound=g_sdRsGoods->LocateByKey(WideString(gc));
    if(IsFound != 0) //输入无效编码
    {
     seGosdGoods->Text=pv_GoodsCode;
     return;
    }
    seGosdGoods->Text=GetGoodsValue("GoodsCode");
    pv_GoodsCode=GetGoodsValue("GoodsCode");
    labGosdGoodsName->Caption=GetGoodsValue("GoodsName");
    scGosdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
    if(GetGoodsValue("GoodsTrackSo")=="0")
    {//该物料不跟踪订单,则锁定销售单号和行号
      seGosdSod->Enabled=false;
      seGosdSodLine->Enabled=false;
    }
    else
    {
      seGosdSod->Enabled=true;
      seGosdSodLine->Enabled=true;
    }
    if(GetGoodsValue("GoodsBatch")=="0")
    {//该物料不采用批次管理,则锁定批号
      scGosdBatch->Enabled=false;
    }
    else
    {
      scGosdBatch->Enabled=true;
    }
}
void __fastcall TfrmGosh::seGosdGoodsExit(TObject *Sender)
{
 if(Trim(seGosdGoods->Text) != "")
   SetDetail(Trim(seGosdGoods->Text));
}
//---------------------------------------------------------------------------

void __fastcall TfrmGosh::seGosdLocButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc,sdLg where LocCode=lgLocCode and lgState=1 and ";
  SqlStr+=" LocType=1 and lggoodscode='"+seGosdGoods->Text+"' order by LocCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"出库货位查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seGosdLoc->LocateKey(p->ColData[1]);
//    seGosdLoc->Text= seGosdLoc->ItemData[0];
  }
  delete p;
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmGosh::seGoshCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seGoshCode->Text != GetHeadValue(fiGoshCode))
    {
      comServer->LocateByKey(WideString(seGoshCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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