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

📄 dmah.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void __fastcall TfrmDmah::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgDmah->RowCount >1)
       {
          AnsiString Keystr;
          Keystr=seDmahCode->Text+"\t"+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();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    ChangeToBrowseState();
    MoveToFirst();
}
//---------------------------------------------------------------------------
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(tempS);
       DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::seDmadGoodsExit(TObject *Sender)
{
    AnsiString v_tempGoods;
    v_tempGoods=seDmadGoods->Text;
    if(!v_tempGoods.IsEmpty())
    {
        if(InitRsGoods(WideString(v_tempGoods)))
        {
          seDmadGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
          scDmadUnit->LocateKey(GetGoodsValue(gtInitRs,"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(InitRsGoods(seDmadGoods->Text))
      {
//      if(l_RsGoods->LocateByKey(seDmadGoods->Text)==0)
        seDmadGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName");
       }
      scDmadUnit->LocateKey(p->ColData[4]);
      seDmadLoc->LocateKey(p->ColData[5]);
      AnsiString sds=seDmadLoc->Text;
    }
    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;
}
//---------------------------------------------------------------------------
void __fastcall TfrmDmah::FormClose(TObject *Sender, TCloseAction &Action)
{
   TGenBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
bool __fastcall TfrmDmah::BeforeCheck()
{
   SetHeadValue("DmahCheck",1);
   SetHeadValue("DmahChecker",g_sdUserCode);
   SetHeadValue("DmahCheckDate",g_sdCurDate);
   return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmDmah::BeforeUnCheck()
{
   SetHeadValue("DmahCheck",0);
   SetHeadValue("DmahChecker","");
   SetHeadValue("DmahCheckDate",NULL);
   return true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmDmah::sgDmahClick(TObject *Sender)
{
    if(sgDmah->Row > 0)
    {
      comServer->LocateItemByKey(seDmahCode->Text+"\t"+sgDmah->TextMatrix[sgDmah->Row][0]);
      GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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