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

📄 gmth_a.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
         GetDataFromComObject(2);
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("GmthCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
      DisplayBill();
    else
    {
      if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
         AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_A::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGmth_A::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FormCreate(TObject *Sender)
{
    FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgGmth,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TBillBaseForm::FormClose(Sender,Action);
    WriteGridWidth(Name,sgGmth,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::sgGmthSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
      comServer->LocateItemByKey(WideString(sgGmth->TextMatrix[ARow][0]));
    if(!comServer->Eof)
      GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::sgGmthDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgGmth->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::ChangeToBrowseState(bool t_browse)
{
    if(t_browse){
      sgGmth->Visible=true;
      fpGmtd->Visible=false;
      sgGmth->Align=alClient;
      fpGmtd->Align=alNone;
    }
    else{
      sgGmth->Visible=false;
      fpGmtd->Visible=true;
      sgGmth->Align=alNone;
      fpGmtd->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::btnOKClick(TObject *Sender)
{
    try{
      if(CurrentState==caAddDetail||CurrentState==caAddBill)
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         seGmtdLine->SetFocus();
      }
      else
        ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdGoodsButtonClick(TObject *Sender)
{
  AnsiString SqlStr;
  SqlStr="007[物料编码][物料名称][类型][来源方式][计量单位][批量]";
  SqlStr+="Select GoodsCode,GoodsName,case GoodsType when 1 then '1-成品' when 2 then '2-半成品' when 3 then '3-材料'";
  SqlStr+="when 4 then '4-备用件' when 5 then '5-虚拟件' when 6 then '6-费用件' end";
  SqlStr+=" , case GoodsFrom when 1 then '1-采购件' when 2 then '2-制造件' end,GoodsUnitCode,GoodsEoq from sdGoods,sdWsgm where GoodsCode=WsgmGoods  and WsgmWo='"+seGmthWo->Text+"'  order by GoodsCode";
  TfrmWnQuery *p;
  try
  {
    StartWaitForm("正在查询,请稍候...");
    p=new TfrmWnQuery(this,"物料数据查询",SqlStr);
  }
  __finally
  {
    EndWaitForm();
  }
  if(p->ShowModal()==mrOk)
  {
    seGmtdGoods->Text=p->ColData[1];
    if(g_sdRsGoods->LocateByKey(WideString(seGmtdGoods->Text))==0)
    {
      seGmtdGoodsName->Text =  GetGoodsValue("GoodsName");
      scGmtdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
      if(GetGoodsValue("GoodsType")!="")
        scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
      else
        scGmtdGoodsType->ItemIndex=-1;
      if(GetGoodsValue("GoodsFrom")!="")
        scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
      else
        scGmtdGoodsFrom->ItemIndex=-1;
      seGmtdGoodsOoq->Text=GetGoodsValue("GoodsOoq");
    }
  }
  delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGmth_A::seGmtdGoodsExit(TObject *Sender)
{
    AnsiString tempS;
    tempS=seGmtdGoods->Text;
    if(!tempS.IsEmpty())
    {
      if(g_sdRsGoods->LocateByKey(WideString(tempS))==0)
      {
        seGmtdGoodsName->Text=GetGoodsValue("GoodsName");
        scGmtdUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
        if(GetGoodsValue("GoodsType")!="")
          scGmtdGoodsType->ItemIndex=StrToInt(GetGoodsValue("GoodsType"))-1;
        else
          scGmtdGoodsType->ItemIndex=-1;

        if(GetGoodsValue("GoodsFrom")!="")
          scGmtdGoodsFrom->ItemIndex=StrToInt(GetGoodsValue("GoodsFrom"))-1;
        else
          scGmtdGoodsFrom->ItemIndex=-1;
        seGmtdGoodsOoq->Text=GetGoodsValue("GoodsOoq");
      }
      else
        ::MessageBox(Handle,"输入的物料编码不存在!","错误提示",MB_OK|MB_ICONSTOP);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmthCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS=seGmthCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmthWoButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="006[加工单号][加工件码][要求数量][要求日期][订单单号][订单行号]SELECT WoCode,WoGoods,WoQty,WoRDate,";
    SqlStr=SqlStr+"WoSoCode,WoSodLine from sdWo where WoCheck=1 and WoClose=0 ORDER BY WoCode";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"加工订单查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seGmthWo->Text=p->ColData[1];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdProcessButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="004[序号][工序代码][工序名称][货位编码]SELECT WrgNo,WrgProcess,ProcessName,WrgLoc FROM sdWrg,sdProcess ";
    SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+seGmthWo->Text+"' ORDER BY WrgNo";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seGmtdProcess->LocateKey(p->ColData[2]);
       seGmtdDLoc->LocateKey(p->ColData[4]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGmth_A::seGmtdSLocButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    TfrmWnQuery *p;
    SqlStr="007[当前月份][货位编码][货位名称][物料编码][物料名称][计量单位][当前数量]";
    SqlStr+="select MaccFmonth,MaccLoc,LocName,MaccGoods,MaccGoodsName=GoodsName,MaccUnit=GoodsUnitCode,";
    SqlStr+=" MaccAoyQty from sdMacc,sdGoods,sdLg,sdLoc where LocCode=lgLocCode and LocCode=MaccLoc";
    SqlStr+=" and LgGoodsCode=MaccGoods and GoodsCode=MaccGoods and MaccFmonth='"+g_sdMMonth+"'";
    SqlStr+=" and MaccGoods='"+seGmtdGoods->Text+"' and LocType=1 order by LocCode";
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"存储货位库存查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seGmtdSLoc->LocateKey(p->ColData[2]);
    }
    delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGmth_A::seGmtdQtyButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="003[当前月份][计量单位][库存数量]";
    SqlStr+="select MaccFmonth,GoodsUnitCode,MaccAoyQty from sdMacc,sdGoods where MaccGoods=GoodsCode and ";
    SqlStr+=" MaccFmonth='"+g_sdMMonth+"' and MaccLoc='"+seGmtdSLoc->ItemData[cbItem2]+"' and MaccGoods='"+seGmtdGoods->Text+"'";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"库存查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    p->ShowModal();
    delete p;  
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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