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

📄 dmah.cpp

📁 速达开源ERP系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void __fastcall TfrmDmah::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgDmah->RowCount >1)
       {
          AnsiString Keystr;
          Keystr=sgDmah->Cells[0][sgDmah->Row];
          comServer->LocateItemByKey(WideString(Keystr));
          GetDataFromComObject(2);
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("DmahCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDmah::GetHeadValue(int Index)
{
    return ReadFieldValue(comServer,Index);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmDmah::GetDetailValue(int Index)
{
    return ReadItemValue(comServer,Index);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::SetHeadValue(int Index,AnsiString Value)
{
    WriteFieldValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::SetDetailValue(int Index,AnsiString Value)
{
    WriteItemValue(comServer,Index,Value);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::sgDmahSelectCell(TObject *Sender, int ACol,
      int ARow, bool &CanSelect)
{
    if(ARow > 0)
       comServer->LocateItemByKey(WideString(sgDmah->TextMatrix[ARow][0]));
    if(!comServer->Eof)
       GetDataFromComObject(2);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::sgDmahDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgDmah->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::ChangeToBrowseState(bool t_browse)
{
    if(t_browse)
    {
      sgDmah->Visible=true;
      fpDmad->Visible=false;
      sgDmah->Align=alClient;
      fpDmad->Align=alNone;
    }
    else
    {
      sgDmah->Visible=false;
      fpDmad->Visible=true;
      sgDmah->Align=alNone;
      fpDmad->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::btnOKClick(TObject *Sender)
{
    try{
      if(CurrentState==caAddDetail || CurrentState==caAddBill)
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         seDmadLine->SetFocus();
      }
      else
        ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::seDmahCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS;
    tempS=seDmahCode->Text;
    if(CurrentState==caNormal && !tempS.IsEmpty() && Key==13)
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::seDmadGoodsExit(TObject *Sender)
{
    AnsiString v_tempGoods;
    v_tempGoods=seDmadGoods->Text;
    if(!v_tempGoods.IsEmpty())
    {
        if(g_sdRsGoods->LocateByKey(WideString(v_tempGoods))==0)
        {
          seDmadGoodsName->Text=GetGoodsValue("GoodsName");
          scDmadUnit->LocateKey(GetGoodsValue("GoodsUnitCode"));
        }
        else
          throw Exception("物料编码:'"+v_tempGoods+"'不存在!");
    }
    else
       throw Exception("共用件分摊的物料编码:'"+v_tempGoods+"'不能为空!");
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::seDmadWoCodeButtonClick(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)
    {
       seDmadWoCode->Text=p->ColData[1];
    }
    delete p;

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

void __fastcall TfrmDmah::GenrateBill()
{
    int TempCount;
    TempCount = comServer->ItemCount;
    TfrmDmad *p=new TfrmDmad(this);
    try
    {
      p->GetComObject(comServer);
      p->ShowModal();
      if (TempCount < comServer->ItemCount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    }
    __finally
    {
      delete p;
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmDmah::seDmadGmtCodeButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    TfrmWnQuery *p;
    SqlStr="007[领料单号][行号][物料编码][计量单位][领料货位][领料数量][分摊数量]";
    SqlStr+="SELECT gmtdcode,gmtdline,gmtdgoods,gmtdunit,gmtddloc,gmtdqty,gmtddqty from sdgmtd,sdgmth ";
    SqlStr+=" WHERE gmthcode=gmtdcode and gmthcheck=1 and GmthType=4 and GmtdQty-GmtdDQty>0 order by gmtdcode,gmtdline";
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"共用件领料单查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
      seDmadGmtCode->Text=p->ColData[1];
      seDmadGmtdLine->Text=p->ColData[2];
      seDmadGoods->Text=p->ColData[3];
      if(g_sdRsGoods->LocateByKey(WideString(seDmadGoods->Text))==0)
        seDmadGoodsName->Text=GetGoodsValue("GoodsName");
      scDmadUnit->LocateKey(p->ColData[4]);
      seDmadLoc->LocateKey(p->ColData[5]);
    }
    delete p;
}
//---------------------------------------------------------------------------

void __fastcall TfrmDmah::seDmadQtyButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    TfrmWnQuery *p;
    SqlStr="005[物料编码][计量单位][领料货位][领料数量][分摊数量]";
    SqlStr+="SELECT GmtdGoods,GmtdUnit,GmtddLoc,GmtdQty,GmtdDQty from sdGmtd ";
    SqlStr+=" WHERE GmtdCode='"+seDmadGmtCode->Text+"' and GmtdLine="+seDmadGmtdLine->Text;
    try
    {
      StartWaitForm("正在查询,请稍候...");
      p=new TfrmWnQuery(this,"共用件领料数量查询",SqlStr);
    }
    __finally
    {
      EndWaitForm();
    }
    p->ShowModal();
    delete p;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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