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

📄 tsh.cpp

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

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

void __fastcall TfrmTsh::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgTsd->RowCount=1;
    if(comServer->RecordCount > 0)
     for (i=0;i<comServer->ItemCount;i++)
     {
        comServer->LocateItemByIndex(i);
        RefreshGridData(0);
     }
}
//---------------------------------------------------------------------------

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

AnsiString __fastcall TfrmTsh::GetDetailValue(int Index)
{
    AnsiString S;
    S = ReadItemValue(comServer,Index);
    return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::FormCreate(TObject *Sender)
{
//    FormIniFile="D:\Test.Ini";
//    SetGridWidth(Name,sgTsd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgTsd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    TBillBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::sgTsdSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow == 0)
    {
       return;
    }
    comServer->LocateItemByKey(WideString(sgTsd->TextMatrix[ARow][1]));
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::sgTsdDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgTsd->Row;
    if (iRow == 0)
    {
       return;
    }
    sgTsd->Visible=false;
    FloatPanel2->Visible=true;
}
//---------------------------------------------------------------------------

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

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

void __fastcall TfrmTsh::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::BackDisp()
{
    seTsdAQty->Text=GetDetailValue(fiTsdAQty).ToDouble();
    seTsdAPrice->Text     =GetDetailValue(fiTsdAPrice);
    seTsdAAmt->Text     =GetDetailValue(fiTsdAAmt);
    seTsdTQty->Text     =GetDetailValue(fiTsdTQty);
    seTsdTPrice->Text     =GetDetailValue(fiTsdTPrice);
    seTsdTAmt->Text     =GetDetailValue(fiTsdTAmt);
    seTsdDQty->Text     =GetDetailValue(fiTsdDQty);
    seTsdIOQty->Text    =GetDetailValue(fiTsdIoQty);
    chkTsdFlg1->Checked =GetDetailValue(fiTsdFlg)=="1";  //盘盈
    chkTsdFlg2->Checked =GetDetailValue(fiTsdFlg)=="-1"; //盘亏
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::seTsdTQtyExit(TObject *Sender)
{
  if(!seTsdTQty->Text.IsEmpty())
    SetDetailValue(fiTsdTQty,seTsdTQty->Text);
  if(!seTsdTAmt->Text.IsEmpty())
    SetDetailValue(fiTsdTAmt,seTsdTAmt->Text);
  BackDisp();
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::seTsdGoodsButtonClick(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 = '"+scTsdLoc->ItemData[1]+"' order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seTsdGoods->Text=p->ColData[1];
    SetDetail(seTsdGoods->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------


void __fastcall TfrmTsh::seTsdGoodsExit(TObject *Sender)
{
 SetDetail(Trim(seTsdGoods->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdFc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTshFmonth,"Select FcMonth from sdFc order by fcmonth","FcMonth");
    }
    break;
   case euSdDept:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTshDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by deptcode","memo","DeptCode");
    }
    break;
   case euSdPosType:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTshPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
    }
    break;
   case euSdKeeper:
    if(ShowUpdateMessage(MsgSrc,MsgType))
     FillComboBox(scTshKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTsdUnit,"select unitname memo,unitcode from sdunit order by UnitCode","memo","UnitCode");
    }
    break;
   case euSdBatch:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTsdBatch,"Select BatchCode from sdBatch order by BatchCode","BatchCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scTsdLoc,"select locname memo,loccode from sdloc order by LocCode","memo","LocCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------



void __fastcall TfrmTsh::seTsdTAmtExit(TObject *Sender)
{
  if(!seTsdTQty->Text.IsEmpty())
    SetDetailValue(fiTsdTQty,seTsdTQty->Text);
  if(!seTsdTAmt->Text.IsEmpty())
    SetDetailValue(fiTsdTAmt,seTsdTAmt->Text);
  BackDisp();
}
//---------------------------------------------------------------------------
void __fastcall TfrmTsh::SetDetail(AnsiString gc)
{
    int IsFound=g_sdRsGoods->LocateByKey(WideString(gc));
    if(IsFound != 0) //输入无效编码
    {
     seTsdGoods->Text=pv_GoodsCode;
     return;
    }
    seTsdGoods->Text=GetGoodsValue("GoodsCode");
    pv_GoodsCode=GetGoodsValue("GoodsCode");
    labTsdGoodsName->Caption=GetGoodsValue("GoodsName");
    scTsdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
    SetDetailValue(fiTsdLoc,scTsdLoc->ItemData[1]);
    SetDetailValue(fiTsdGoods,seTsdGoods->Text);
    if(GetGoodsValue("GoodsTrackSo")=="0")
    {//该物料不跟踪订单,则锁定销售单号和行号
      seTsdSod->Enabled=false;
      seTsdSodLine->Enabled=false;
      seTsdSod->Text="";
      seTsdSodLine->ItemIndex=-1;
    }
    else
    {
      seTsdSod->Enabled=true;
      seTsdSodLine->Enabled=true;
    }
    if(GetGoodsValue("GoodsBatch")=="0")
    {//该物料不采用批次管理,则锁定批号
      scTsdBatch->Enabled=false;
      scTsdBatch->ItemIndex=-1;
    }
    else
    {
      scTsdBatch->Enabled=true;
    }
    BackDisp();
}

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

void __fastcall TfrmTsh::scTsdLocChange(TObject *Sender)
{
 seTsdGoods->Text="";        
}
//---------------------------------------------------------------------------

void __fastcall TfrmTsh::seTshCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seTshCode->Text != GetHeadValue(fiTshCode))
    {
      comServer->LocateByKey(WideString(seTshCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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