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

📄 pieceh_t.cpp

📁 科思ERP部分源码及控件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
       case 0:
         sgPieceh->AddItem(ItemStr);
         sgPieceh->Row=sgPieceh->RowCount-1;
         break;
       case 1:
         sgPieceh->ChangeItem(ItemStr,sgPieceh->Row);
         break;
       case 2:
         sgPieceh->RemoveItem(sgPieceh->Row);
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPieceh_T::GetItemStringToGrid()
{
    AnsiString s_ItemStr,s;
    s_ItemStr=GetDetailValue("PiecedLine")+
              "\t"+GetDetailValue("PiecedEmployee")+
              "\t"+GetDetailValue("PiecedWo")+
              "\t"+GetDetailValue("PiecedProcess")+
              "\t"+GetDetailValue("PiecedQty")+
              "\t"+GetDetailValue("PiecedPrice");

    return s_ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::DisplayBill()
{
    if(comServer->RecordCount>0)
    {
       GetDataFromComObject(1);
       FillGridWithData();
       if(sgPieceh->RowCount >1)
       {
          AnsiString Keystr;
          Keystr=sgPieceh->Cells[1][sgPieceh->Row];
          comServer->LocateItemByKey(sePiecehCode->Text+"\t"+Keystr);
          GetDataFromComObject(2);
       }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::GetBill(AnsiString BillID)
{
    bool iRow;
    iRow=comServer->Find("PiecehCode='"+BillID+"'");
    if(iRow)      //FIND THIS BILL
       DisplayBill();
    else
    {
       if(ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
          AddHeadRecord();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FillGridWithData()
{
    int i;
    AnsiString ItemStr;
    sgPieceh->RowCount=1;
    if(comServer->RecordCount>0)
    {
      for(i=0;i<comServer->ItemCount;i++)
      {
         comServer->LocateItemByIndex(i);
         RefreshGridData(0);
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FormClose(TObject *Sender,
      TCloseAction &Action)
{
    TGenBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::FormShow(TObject *Sender)
{
    ClearControl(1,false);
    ClearControl(2,false);
    tbAddDetail->Visible=false;
    sgPieceh->RowCount=1;
    TGenBaseForm::MoveToFirst();
    ChangeToBrowseState();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sgPiecehDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgPieceh->Row;
    if(iRow == 0)
       return;
    ChangeToBrowseState(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::ChangeToBrowseState(bool agree)
{
    if(agree)
    {
       sgPieceh->Visible=true;
       FloatPanel2->Visible=false;
       sgPieceh->Align=alClient;
       FloatPanel2->Align=alNone;
    }
    else
    {
       sgPieceh->Visible=false;
       FloatPanel2->Visible=true;
       sgPieceh->Align=alNone;
       FloatPanel2->Align=alClient;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::btnOKClick(TObject *Sender)
{
    try{
      if((CurrentState==caAddDetail)||(CurrentState==caAddBill))
      {
         if(DetailState==caAddDetail)
            comServer->AddItem();
         SendDataToComObject(2);
         comServer->AddToObject();
         ClearControl(2,false);
         sePiecedLine->SetFocus();
      }
      else
         ChangeToBrowseState();
    }
    catch(Exception &e)
    {
        throw Exception(e.Message);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::btnCancelClick(TObject *Sender)
{
    CancelChange();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::GenrateBill()
{
    int BefoICount=comServer->ItemCount;
   //try
   // {
      StartWaitForm("正在启动<团体计件单明细生成>界面...");
      AnsiString t_PiecehCode=Trim(sePiecehCode->Text);
      AnsiString t_PiecehShop=scPiecehShop->ItemData[cbItem2];
      AnsiString t_PiecehTeam=sePiecehTeam->ItemData[cbItem2];
      AnsiString ParamString;
      ParamString=t_PiecehCode+"\t"+t_PiecehShop+"\t"+t_PiecehTeam;
      Pieced_Tfrm=new TfrmPieced_T(this,g_ClientHandle,"1060507",ParamString);
      Pieced_Tfrm->SetcomServer(comServer);
      EndWaitForm();
      Pieced_Tfrm->ShowModal();
      if(comServer->ItemCount>BefoICount)
        TGenBaseForm::SaveRecord();
      else
        CancelChange();
    //}
   // __finally
   // {
    //  delete Pieced_Tfrm;
   // }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecehCodeKeyDown(TObject *Sender,
      WORD &Key, TShiftState Shift)
{
    AnsiString tempS=sePiecehCode->Text;
    if(Key==13 && CurrentState==caNormal && !tempS.IsEmpty())
    {
       comServer->LocateByKey(WideString(tempS));
       DisplayBill();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecehTeamButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="002[班组代码][班组名称]SELECT TeamCode,TeamName FROM sdTeam where TeamShopCode=";
    SqlStr=SqlStr+"'"+scPiecehShop->ItemData[1]+"' ORDER BY TeamCode";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"班组资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       sePiecehTeam->LocateKey(p->ColData[1]);
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedEmployeeButtonClick(TObject *Sender)
{
    AnsiString tempS1,tempS2,SqlStr;
    tempS1=scPiecehShop->ItemData[1];
    tempS2=sePiecehTeam->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)
    {
       sePiecedEmployee->Text=p->ColData[1];
       seEmployeeName->Text=p->ColData[2];
       seEmployeeSex->Text=p->ColData[3];
       seEmployeeTow->Text=p->ColData[4];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedWoButtonClick(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)
    {
       sePiecedWo->Text=p->ColData[1];
    }
    delete p;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sePiecedProcessButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    SqlStr="003[序号][工序代码][工序名称]SELECT WrgNo,WrgProcess,ProcessName FROM sdWrg,sdProcess ";
    SqlStr=SqlStr+"where WrgProcess=ProcessCode and WrgWo='"+sePiecedWo->Text+"' ORDER BY WrgNo";
    TfrmWnQuery *p;
    try
    {
       StartWaitForm("正在查询,请稍候...");
       p=new TfrmWnQuery(this,"工序资料查询",SqlStr);
    }
    __finally
    {
       EndWaitForm();
    }
    if(p->ShowModal()==mrOk)
    {
       sePiecedProcess->LocateKey(p->ColData[2]);
    }
    delete p;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmPieceh_T::BeforeCheck()
{
   SetHeadValue("PiecehCheck",1);
   SetHeadValue("PiecehChecker",g_sdUserCode);
   SetHeadValue("PiecehCheckDate",g_sdCurDate);
   return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmPieceh_T::BeforeUnCheck()
{
   SetHeadValue("PiecehCheck",0);
   SetHeadValue("PiecehChecker","");
   SetHeadValue("PiecehCheckDate",NULL);
   return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPieceh_T::sgPiecehClick(TObject *Sender)
{
     if(sgPieceh->Row > 0)
    {
      comServer->LocateItemByKey(sePiecehCode->Text+"\t"+sgPieceh->TextMatrix[sgPieceh->Row][1]);
      GetDataFromComObject(2);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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