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

📄 rpoh.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
//    WriteGridWidth(Name,sgRpoh,FormIniFile);
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::FormShow(TObject *Sender)
{
    InitEditControl();
    ClearControl(1,false);
    ClearControl(2,false);
    TGenBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::sgRpohSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if (ARow > 0)
    {
      comServer->LocateItemByKey(WideString(sgRpoh->TextMatrix[ARow][1]));
    }
    if (!comServer->Eof)
    {
       GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmRpoh::ChangeToBrowseState(bool agree)
{
      sgRpoh->Visible=true;
      FloatPanel2->Visible=false;
      if(agree == false)
       sgRpoh->SetFocus();
}
//---------------------------------------------------------------------------

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

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



void __fastcall TfrmRpoh::AutoCalculation()
{
  double FVal;
  if(seRpodQty->Text =="")
    seRpodQty->Text="0";
  if(seRpodPrice->Text =="")
    seRpodPrice->Text="0";
  if(seRpodQty->Text.ToDouble() < 0 )
    throw Exception("请购数量不能小于零");
  if(seRpodPrice->Text.ToDouble() < 0 )
    throw Exception("单价不能小于零");
  FVal=DataCarry(seRpodQty->Text.ToDouble()*seRpodPrice->Text.ToDouble(),2,0);
  seRpodAmt->Text=FVal;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::seRpodQtyExit(TObject *Sender)
{
  AutoCalculation();
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::seRpodGoodsCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[物料编码][物料名称][计量单位]select GoodsCode,GoodsName,GoodsUnitCode from sdgoods,sdpgd where ";
  SqlStr+="PgdSupplyCode='"+scRpohSupplyCode->ItemData[1]+"' and PgdGoodsCode=GoodsCode order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"供应商物料查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seRpodGoodsCode->Text=p->ColData[1];
    SetDetail(seRpodGoodsCode->Text);
  }
  delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpoh::seRpodGoodsCodeExit(TObject *Sender)
{
  SetDetail(Trim(seRpodGoodsCode->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpoh::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdTax:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohTaxCode,"SELECT TaxCode,TaxName FROM sdTax order by TaxCode","TaxName","TaxCode");
    }
    break;
   case euSdSettleMode:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohSettleMode,"SELECT SettleModeCode,SettleModeName FROM sdSettleMode order by SettleModeCode",
                  "SettleModeName","SettleModeCode");
    }
    break;
   case euSdSupply:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohSupplyCode,"SELECT SupplyCode,SupplyName,SupplyTaxCode,SupplyTaxNo FROM sdSupply  where supplycancel=0  order by SupplyCode",
                  "SupplyName","SupplyCode","SupplyTaxCode","SupplyTaxNo");
    }
    break;
   case euSdDeliver:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohDeliver,"SELECT DeliverCode,DeliverName FROM sdDeliver order by DeliverCode","DeliverName","DeliverCode");
    }
    break;
   case euSdTransMode:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohTransMode,"SELECT TransModeCode,TransModeName FROM sdTransMode order by TransModeCode","TransModeName","TransModeCode");
    }
    break;
   case euSdBuyer:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpohBuyerCode,"select UserCode,UserName from sdBuyer,sduser where UserCode=BuyerCode order by UserCode","UserName","UserCode");
    }
    break;
   case euSdUnit:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillEdit(seRpodUnitCode,"SELECT UnitCode,UnitName,UnitRate FROM sdUnit order by UnitCode","UnitName","UnitCode","UnitRate");
    }
    break;
   case euSdDept:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scRpodDeptCode,"SELECT DeptCode,DeptName FROM sdDept order by DeptCode","DeptName","DeptCode");
    }
    break;
   case euSdLoc:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     AnsiString sSql;
     if(g_sdQuality == false) //无需质量管理
      sSql = "select LocCode,LocName from sdLoc where LocType=1 order by locCode";
     else                    //需要质量管理
      sSql = "select LocCode,LocName from sdLoc where LocType=3 order by loccode";
     FillEdit(seRpodLocCode,sSql,"LocName","LocCode");
    }
   default:
    break;
  }
}
//---------------------------------------------------------------------------


void __fastcall TfrmRpoh::SetDetail(AnsiString gc)
{
   int IsFound=g_sdRsGoods->LocateByKey(WideString(Trim(gc)));
   if(IsFound != 0) //输入无效编码
   {
    seRpodGoodsCode->Text=pv_GoodsCode;
    return;
   }
   seRpodGoodsCode->Text=GetGoodsValue("GoodsCode");
   pv_GoodsCode=GetGoodsValue("GoodsCode");
   labRpodGoodsName->Caption=GetGoodsValue("GoodsName");
   seRpodUnitCode->LocateKey(GetGoodsValue("GoodsUnitCode"));
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpoh::GenrateBill()
{
    int TempCount;
    TempCount = comServer->ItemCount;

    SetControlState(caAddBill);
    TfrmRpod *p=new TfrmRpod(this);
    p->GetComObject(comServer);
    try
    {
      p->ShowModal();
    }
    __finally
    {
       delete p;
    }
    if (TempCount < comServer->ItemCount)
      TGenBaseForm::tbSaveClick(NULL);
    else
      CancelChange();
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::scRpodDeptCodeExit(TObject *Sender)
{
 CheckComboBoxText(scRpodDeptCode);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpoh::scRpohTaxCodeExit(TObject *Sender)
{
 CheckComboBoxText(scRpohTaxCode);
}
//---------------------------------------------------------------------------


void __fastcall TfrmRpoh::seRpodLocCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="002[货位编码][货位名称]select Loccode,LocName from sdLoc,sdLg where LocCode=lgLocCode and lgState=1 and ";
  if(g_sdQuality == false) //无需质量管理
   SqlStr+=" LocType=1 and lggoodscode='"+seRpodGoodsCode->Text+"' order by LocCode";
  else                    //需要质量管理
   SqlStr+=" LocType=3 and lggoodscode='"+seRpodGoodsCode->Text+"' order by LocCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货位查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seRpodLocCode->LocateKey(p->ColData[1]);
  }
  delete p;

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

void __fastcall TfrmRpoh::seRpodUnitCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="004[计量单位代码][计量单位名称][换算系数][单位类型]";
  SqlStr+=" select GmuUnit,UnitName,GmuConv,Prm=(case when GmuPrimary=1 then '主单位' else '辅助单位' end) ";
  SqlStr+=" from sdGmu,sdUnit where GmuUnit=UnitCode and GmuGoods='"+seRpodGoodsCode->Text+"' ";
  SqlStr+=" order by GmuPrimary desc,GmuUnit  ";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"计量单位查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seRpodUnitCode->LocateKey(p->ColData[1]);
    seRpodConvRate->Text=p->ColData[3];
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::seRpohCurrencyCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[货币代码][货币名称][币种类别]select Currencycode,CurrencyName,Prm=(case when PsdPrimary=1 then '主币种' else '辅币种' end) ";
  SqlStr+=" from sdCurrency,sdpsd where PsdCurrencyCode=CurrencyCode and ";
  SqlStr+=" PsdSupplyCode='"+scRpohSupplyCode->ItemData[cbItem2]+"' order by CurrencyCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货币查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seRpohCurrencyCode->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::seRpohPsiteCodeButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="003[货运地址代码][货运地址名称][联系人]select PsiteCode,PsiteName,psitelinkman from sdpsite where ";
  SqlStr+="PsiteSupplyCode='"+scRpohSupplyCode->ItemData[cbItem2]+"' order by PsiteCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"货运地址查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seRpohPsiteCode->LocateKey(p->ColData[1]);
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::scRpohSupplyCodeClick(TObject *Sender)
{
  scRpohTaxCode->LocateKey(scRpohSupplyCode->ItemData[cbItem3]);
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::scRpohSupplyCodeChange(TObject *Sender)
{
 seRpohCurrencyCode->ItemIndex=-1;
 seRpohPsiteCode->ItemIndex=-1;
}
//---------------------------------------------------------------------------

void __fastcall TfrmRpoh::seRpohCodeExit(TObject *Sender)
{
    if(CurrentState==caNormal && seRpohCode->Text != GetHeadValue(fiRpohCode))
    {
      comServer->LocateByKey(WideString(seRpohCode->Text));
      DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRpoh::UnDoChange()
{
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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