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

📄 labh_t.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
      FillGridWithData();
      if(sgLabh->RowCount >1)
      {
         AnsiString Keystr;
         Keystr=sgLabh->Cells[1][sgLabh->Row];
         comServer->LocateItemByKey(seLabhCode->Text+"\t"+WideString(Keystr));
         GetDataFromComObject(2);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("LabhCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgLabh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    tbAddDetail->Visible=false;
    sgLabh->RowCount=1;
    TGenBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::sgLabhDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgLabh->Row;
    if(iRow == 0)
      return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------

void __fastcall TfrmLabh_T::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
       sgLabh->Visible=true;
       FloatPanel2->Visible=false;
       sgLabh->Align=alClient;
       FloatPanel2->Align=alNone;
    }
    else
    {
       sgLabh->Visible=false;
       FloatPanel2->Visible=true;
       sgLabh->Align=alNone;
       FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::btnOKClick(TObject *Sender)
{
    try{
      if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         seLabdLine->SetFocus();
      }
      else
         ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::GenrateBill()
{
    //保存生成之前的明细记录数
    int BefoICount=comServer->ItemCount;
    //try
    //{
      StartWaitForm("正在启动<团体计件单明细>界面...");
      AnsiString t_LabhCode=Trim(seLabhCode->Text);
      AnsiString t_LabhShop=scLabhShop->ItemData[1];
      AnsiString t_LabhTeam=seLabhTeam->ItemData[1];
      AnsiString ParamString;
      ParamString=t_LabhCode+"\t"+t_LabhShop+"\t"+t_LabhTeam;
      Labd_Tfrm=new TfrmLabd_T(this,g_ClientHandle,"1060506",ParamString);
      Labd_Tfrm->SetcomServer(comServer);
      EndWaitForm();
      Labd_Tfrm->ShowModal();
      if(comServer->ItemCount>BefoICount)
      {
         TGenBaseForm::SaveRecord();
      }
      else
         CancelChange();
    //}
   // __finally
   // {
   //   delete Labd_Tfrm;
   // }
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::seLabhCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    AnsiString tempS=seLabhCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmLabh_T::seLabhTeamButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="002[班组代码][班组名称]SELECT TeamCode,TeamName FROM sdTeam where TeamShopCode=";
    SqlStr=SqlStr+"'"+scLabhShop->ItemData[1]+"' ORDER BY TeamCode";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"班组资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seLabhTeam->LocateKey(p->ColData[1]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::seLabdEmployeeButtonClick(TObject *Sender)
{
    AnsiString tempS1,tempS2,SqlStr;
    tempS1=scLabhShop->ItemData[1];
    tempS2=seLabhTeam->ItemData[1];
    if(tempS1.IsEmpty())
       throw Exception("计时登记时,员工所在的车间不能为空,请输入一个车间的代码.");
    if(!tempS2.IsEmpty()){
       SqlStr="006[员工编码][员工姓名][性别][部门][工种][职务]SELECT distinct TeEmployee,EmployeeName,EmployeeSex=";
       SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeDept,EmployeeTow,";
       SqlStr=SqlStr+"EmployeeRank from sdEmployee,sdTe,sdTeam where TeEmployee=EmployeeCode and TeTeam=TeamCode and TeamShopCode=";
       SqlStr=SqlStr+"'"+tempS1+"' and TeTeam='" +tempS2+"' Order by TeEmployee";
    }
    else{
       SqlStr="006[员工编码][员工姓名][性别][部门][工种][职务]SELECT distinct TeEmployee,EmployeeName,EmployeeSex=";
       SqlStr=SqlStr+"(case EmployeeSex when 0 then '男' when 1 then '女' end),EmployeeDept,EmployeeTow,";
       SqlStr=SqlStr+"EmployeeRank from sdEmployee,sdTe,sdTeam where TeEmployee=EmployeeCode and TeTeam=TeamCode and TeamShopCode=";
       SqlStr=SqlStr+"'"+tempS1+"' Order by TeEmployee";
    }
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"员工资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seLabdEmployee->Text=p->ColData[1];
       seEmployeeName->Text=p->ColData[2];
       seEmployeeSex->Text=p->ColData[3];
       scEmployeeDept->LocateKey(p->ColData[4]);
       seEmployeeTow->Text=p->ColData[5];
       seEmployeeRank->Text=p->ColData[6];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::seLabdWoButtonClick(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)
    {
       seLabdWo->Text=p->ColData[1];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLabh_T::seLabdProcessButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="003[序号][工序代码][工序名称]SELECT WrgNo,WrgProcess,ProcessName FROM sdWrg,sdProcess ";
    SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+seLabdWo->Text+"' ORDER BY WrgNo";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       seLabdProcess->LocateKey(p->ColData[2]);
    }
    delete p;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmLabh_T::BeforeCheck()
{
   SetHeadValue("LabhCheck",1);
   SetHeadValue("LabhChecker",g_sdUserCode);
   SetHeadValue("LabhCheckDate",g_sdCurDate);
   return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmLabh_T::BeforeUnCheck()
{
   SetHeadValue("LabhCheck",0);
   SetHeadValue("LabhChecker","");
   SetHeadValue("LabhCheckDate",NULL);
   return true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmLabh_T::sgLabhClick(TObject *Sender)
{
     if(sgLabh->Row > 0)
    {
      comServer->LocateItemByKey(seLabhCode->Text+"\t"+sgLabh->TextMatrix[sgLabh->Row][1]);
      GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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