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

📄 test_manage.cpp

📁 基于嵌入式QT和DBstar SQL关系数据库的应用软件
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    }    else if( ListBox1->text(item+1) == "Normal" ){  //has be expanded,so zoom it in      ListBox1->changeItem(  *image3, currentText, item );      for( times=0; times<=2; times++ ){	ListBox1->removeItem( item+1 );      }    }    else{      ListBox1->changeItem( *image4, currentText, item );      ListBox1->insertItem( *image5, "Normal", item+1 );      ListBox1->insertItem( *image5, "PHY", item+2 );      ListBox1->insertItem( *image5, "DMM", item+3 );    }    databaseFind( currentText );    delButton->setEnabled( TRUE );}void test_Manage::multiLineEditTextChanged(){    int length,lineNum;    QString enterChar;    enterChar = "\n";    length = addressEdit->length()+1 ;    lineNum = addressEdit->numLines();    if( ( length % 10 ) == 0 ){      addressEdit->insert ( enterChar );    }}void test_Manage::databaseFind(QString str){    int errorNo,intTemp;    QString strTemp;    if( str != "" ){      switch( checkedRadioButton ){      case cName:	str = str.utf8();	errorNo =  d_keyfind( NAME, str, currTask, CURR_DB );	break;      case cCommPhone:	errorNo =  d_keyfind( COMMPHONE, str, currTask, CURR_DB );	break;      case cTelphone:	errorNo =  d_keyfind( OVERTELPHONE, str, currTask, CURR_DB );	break;      case cSerierNo:	errorNo =  d_keyfind( SERIESNO, str, currTask, CURR_DB );	break;      }      if( errorNo == S_NOTFOUND ){	QMessageBox::information( this, tr( "database find" ), tr( "Can't found in current database!" ) );	//qWarning( "name not found!" );      }      else{	d_recread( &irec, currTask, CURR_DB);	commPhoneEdit->setText( irec.commPhone );	overTelphoneEdit->setText( irec.overTelphone );	ipAddressEdit->setText( irec.seriesNo );	equipmentEdit->setText( irec.equipment );	portNoEdit->setText( irec.portNo );	zhiLieEdit->setText( irec.zhiLie );	zhuGanEdit->setText( irec.zhuGan );	jiaoJieXiangEdit->setText( irec.jiaoJieXiang );	fenXianXiangEdit->setText( irec.fenXianXiang );	addressEdit->setText( strTemp.fromUtf8( irec.address, -1) );	if( checkedRadioButton == cCommPhone )	  commPhoneEdit->setText( strTemp.fromUtf8( irec.name, -1) );	else if( checkedRadioButton == cTelphone )	  overTelphoneEdit->setText( strTemp.fromUtf8( irec.name, -1) );	else if( checkedRadioButton == cSerierNo )	  ipAddressEdit->setText( strTemp.fromUtf8( irec.name, -1) );	ListBox1->setSelected( ListBox1->currentItem(), false );	for( intTemp=1; intTemp < (ListBox1->numRows()); intTemp++){	  if( ListBox1->text( intTemp ) == strTemp.fromUtf8( str, -1) ){	    ListBox1->setSelected( intTemp, true );	    break;	  }	}	find->setText( "Find:" );      }    }    else{      delButton->setEnabled( FALSE );      ListBox1->clear();      ListBox1->insertItem( *image2, "New Item" );      ListBox1->setSelected( 0, true );      switch( checkedRadioButton ){      case cName:	for( errorNo=d_keyfrst(NAME,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(NAME,currTask,CURR_DB)){	  d_recread(&irec, currTask, CURR_DB);	  if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	      strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0){	    ListBox1->insertItem( *image3, strTemp.fromUtf8( irec.name, -1) );	  }	}	break;      case cCommPhone:	for( errorNo=d_keyfrst(COMMPHONE,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(COMMPHONE,currTask,CURR_DB)){	  d_recread(&irec, currTask, CURR_DB);	  if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	      strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0){	    ListBox1->insertItem( *image3, irec.commPhone );	  }	}	break;      case cTelphone:	for( errorNo=d_keyfrst(OVERTELPHONE,currTask,CURR_DB);	     errorNo==S_OKAY;	     errorNo=d_keynext(OVERTELPHONE,currTask,CURR_DB)){	  d_recread(&irec, currTask, CURR_DB);	  if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	      strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0){	    ListBox1->insertItem( *image3, irec.overTelphone );	  }	}	break;      case cSerierNo:	for( errorNo=d_keyfrst(SERIESNO,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(SERIESNO,currTask,CURR_DB)){	  d_recread(&irec, currTask, CURR_DB);	  if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	      strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0){	    ListBox1->insertItem( *image3, irec.seriesNo );	  }	}	break;      }    }}void test_Manage::databaseAppend(){    int errorNo;    QString strTemp;    struct info temprecord;    memset( &irec, 0, sizeof(irec) );    strcpy( irec.equipment, equipmentEdit->text() );    strcpy( irec.portNo, portNoEdit->text() );    strcpy( irec.zhiLie, zhiLieEdit->text() );    strcpy( irec.zhuGan, zhuGanEdit->text() );    strcpy( irec.jiaoJieXiang, jiaoJieXiangEdit->text() );    strcpy( irec.fenXianXiang, fenXianXiangEdit->text() );    strTemp=(addressEdit->text()).utf8();    strcpy( irec.address, strTemp );    if( fineEdit->text() == ""         ||    commPhoneEdit->text() == "" || 	overTelphoneEdit->text() == "" ||    ipAddressEdit->text() == "" ){      QMessageBox::information( this, tr( "database Append" ), tr( "The key is empty, retry it again!" ) );    }    else{      switch( checkedRadioButton ){      case cName:	strTemp=( fineEdit->text() ).utf8();	strcpy( irec.name, strTemp );	strcpy( irec.commPhone, commPhoneEdit->text() );	strcpy( irec.overTelphone, overTelphoneEdit->text() );	strcpy( irec.seriesNo, ipAddressEdit->text() );	break;      case cCommPhone:	strTemp=( commPhoneEdit->text() ).utf8();	strcpy( irec.name, strTemp );	strcpy( irec.commPhone, fineEdit->text() );	strcpy( irec.overTelphone, overTelphoneEdit->text() );	strcpy( irec.seriesNo, ipAddressEdit->text() );	break;      case cTelphone:	strTemp=( overTelphoneEdit->text() ).utf8();	strcpy( irec.name, strTemp );	strcpy( irec.commPhone, commPhoneEdit->text() );	strcpy( irec.overTelphone, fineEdit->text() );	strcpy( irec.seriesNo, ipAddressEdit->text() );	break;      case cSerierNo:	strTemp=( ipAddressEdit->text() ).utf8();	strcpy( irec.name, strTemp );	strcpy( irec.commPhone, commPhoneEdit->text() );	strcpy( irec.overTelphone, overTelphoneEdit->text() );	strcpy( irec.seriesNo, fineEdit->text() );	break;      }      if( d_keyfind( NAME, irec.name, currTask, CURR_DB ) == S_NOTFOUND &&	  d_keyfind( COMMPHONE, irec.commPhone, currTask, CURR_DB ) == S_NOTFOUND &&	  d_keyfind( OVERTELPHONE, irec.overTelphone, currTask, CURR_DB ) == S_NOTFOUND &&	  d_keyfind( SERIESNO, irec.seriesNo, currTask, CURR_DB ) == S_NOTFOUND ){	strTemp.sprintf( "%d", 0);	errorNo =  d_keyfind( SERIESNO, strTemp, currTask, CURR_DB );	if( errorNo != S_NOTFOUND ){	qWarning( "Found temp record!!" );	  d_recread(&temprecord, currTask, CURR_DB);	  /****************************************************	   *************APPEND 0 SERIAL RECORD*****************           ****************************************************/	  irec.USConRate = temprecord.USConRate;	  irec.DSConRate = temprecord.DSConRate;	  irec.vci_vpi_val = temprecord.vci_vpi_val;	  irec.usTxPower = temprecord.usTxPower;	  irec.dsTxPower = temprecord.dsTxPower;	  irec.usLineAttn = temprecord.usLineAttn;	  irec.dsLineAttn = temprecord.dsLineAttn;	  irec.usMargin = temprecord.usMargin;	  irec.dsMargin = temprecord.dsMargin;	  irec.usMaxRate = temprecord.usMaxRate;	  irec.dsMaxRate = temprecord.dsMaxRate;	  irec.LOS_errors = temprecord.LOS_errors;	  irec.SEF_errors = temprecord.SEF_errors;	  irec.coLosErrors = temprecord.coLosErrors;	  irec.coRdiErrors = temprecord.coRdiErrors;	  irec.usICRC_errors = temprecord.usICRC_errors;	  irec.usFCRC_errors = temprecord.usFCRC_errors;	  irec.dsICRC_errors = temprecord.dsICRC_errors;	  irec.dsFCRC_errors = temprecord.dsFCRC_errors;	  irec.usIFEC_errors = temprecord.usIFEC_errors;	  irec.usFFEC_errors = temprecord.usFFEC_errors;	  irec.dsIFEC_errors = temprecord.dsIFEC_errors;	  irec.dsFFEC_errors = temprecord.dsFFEC_errors;	  irec.usIHEC_errors = temprecord.usIHEC_errors;	  irec.usFHEC_errors = temprecord.usFHEC_errors;	  irec.dsIHEC_errors = temprecord.dsIHEC_errors;	  irec.dsFHEC_errors = temprecord.dsFHEC_errors;	  irec.usAtm_count = temprecord.usAtm_count;	  irec.usIdle_count = temprecord.usIdle_count;	  irec.usPdu_count = temprecord.usPdu_count;	  irec.dsGood_count = temprecord.dsGood_count;	  irec.dsIdle_count = temprecord.dsIdle_count;	  irec.dsBadHec_count = temprecord.dsBadHec_count;	  irec.dsOVFDrop_count = temprecord.dsOVFDrop_count;	  irec.dsPdu_count = temprecord.dsPdu_count;	  strcpy( irec.capacitance, temprecord.capacitance );	  strcpy( irec.s_resistor, temprecord.s_resistor );	  strcpy( irec.l_resistor, temprecord.l_resistor );	  strcpy( irec.dc_voltage, temprecord.dc_voltage );	  strcpy( irec.ac_voltage, temprecord.ac_voltage );/*	  irec.capacitance = temprecord.capacitance;	  irec.s_resistor = temprecord.s_resistor;	  irec.l_resistor = temprecord.l_resistor;	  irec.dc_voltage = temprecord.dc_voltage;	  irec.ac_voltage = temprecord.ac_voltage;*/	  for(int i=0; i<=30; i++){	    irec.TrainedPath[i] = temprecord.TrainedPath[i];	    irec.TrainedMode[i] = temprecord.TrainedMode[i];	    irec.atucVendorId[i] = temprecord.atucVendorId[i];	    irec.usBitAllocTbl[i] = temprecord.usBitAllocTbl[i];	  }	  irec.usBitAllocTbl[31] = temprecord.usBitAllocTbl[31];	  for(int i=0; i<=512; i++ ){	    irec.dsBitAllocTbl[i] = temprecord.dsBitAllocTbl[i];	  }	  d_delete( currTask, CURR_DB );	}	d_fillnew( INFO, &irec, currTask, CURR_DB );	databaseFind( "" );	listBoxClicked();      }      else{	QMessageBox::information( this, tr( "database Append" ), 				  tr( "The same keyrecord found\n in current database!" ) );      }    }}void test_Manage::databaseDelete(){    int listBox1CurrentItem, errorNo;    QString listBox1CurrentItemText;    listBox1CurrentItem = ListBox1->currentItem();    listBox1CurrentItemText = ListBox1->text( listBox1CurrentItem );    if( listBox1CurrentItem != 0 ){      if( ListBox1->text( listBox1CurrentItem+1 ) == "Normal" ){	listBoxClicked();      }      if( checkedRadioButton == cName ){	listBox1CurrentItemText = listBox1CurrentItemText.utf8();	errorNo =  d_keyfind( NAME, listBox1CurrentItemText, currTask, CURR_DB );      }      else if( checkedRadioButton == cCommPhone )	errorNo =  d_keyfind( COMMPHONE, listBox1CurrentItemText, currTask, CURR_DB );      else if( checkedRadioButton == cTelphone )	errorNo =  d_keyfind( OVERTELPHONE, listBox1CurrentItemText, currTask, CURR_DB );      else	errorNo =  d_keyfind( SERIESNO, listBox1CurrentItemText, currTask, CURR_DB );      if( errorNo == S_NOTFOUND ){	qWarning( "record not been found, Can't delete it!" );      }      else{	d_delete( currTask, CURR_DB );	ListBox1->removeItem( listBox1CurrentItem );	listBox1CurrentItemText = ListBox1->text( listBox1CurrentItem );      }    }}void test_Manage::databaseModify(){    int listBox1CurrentItem, errorNo;    QString listBox1CurrentItemText;    listBox1CurrentItem = ListBox1->currentItem();    listBox1CurrentItemText = ListBox1->text( listBox1CurrentItem );    strcpy( irec.equipment, equipmentEdit->text() );    strcpy( irec.portNo, portNoEdit->text() );    strcpy( irec.zhiLie, zhiLieEdit->text() );    strcpy( irec.zhuGan, zhuGanEdit->text() );    strcpy( irec.jiaoJieXiang, jiaoJieXiangEdit->text() );    strcpy( irec.fenXianXiang, fenXianXiangEdit->text() );    strcpy( irec.address, ( addressEdit->text() ).utf8() );    switch( checkedRadioButton ){    case cName:      strcpy( irec.name, listBox1CurrentItemText.utf8() );      strcpy( irec.commPhone, commPhoneEdit->text() );      strcpy( irec.overTelphone, overTelphoneEdit->text() );      strcpy( irec.seriesNo, ipAddressEdit->text() );      errorNo =  d_keyfind( NAME, irec.name, currTask, CURR_DB );      break;    case cCommPhone:      strcpy( irec.name, ( commPhoneEdit->text() ).utf8() );      strcpy( irec.commPhone, listBox1CurrentItemText );      strcpy( irec.overTelphone, overTelphoneEdit->text() );      strcpy( irec.seriesNo, ipAddressEdit->text() );      errorNo =  d_keyfind( COMMPHONE, irec.commPhone, currTask, CURR_DB );      break;    case cTelphone:      strcpy( irec.name, ( overTelphoneEdit->text() ).utf8() );      strcpy( irec.commPhone, commPhoneEdit->text() );      strcpy( irec.overTelphone, listBox1CurrentItemText );      strcpy( irec.seriesNo, ipAddressEdit->text() );      errorNo =  d_keyfind( OVERTELPHONE, irec.overTelphone, currTask, CURR_DB );      break;    case cSerierNo:      strcpy( irec.name, ( ipAddressEdit->text() ).utf8() );      strcpy( irec.commPhone, commPhoneEdit->text() );      strcpy( irec.overTelphone, overTelphoneEdit->text() );      strcpy( irec.seriesNo, listBox1CurrentItemText );      errorNo =  d_keyfind( SERIESNO, irec.seriesNo, currTask, CURR_DB );      break;    }    if( errorNo != S_NOTFOUND ){      d_recwrite( &irec, currTask, CURR_DB );    }}void test_Manage::listboxInit(){    int errorNo;    QString strTemp;    delButton->setEnabled( FALSE );    ListBox1->clear();    ListBox1->insertItem( *image2, "New Item" );    ListBox1->setSelected( 0, true );    switch( checkedRadioButton ){    case cName:      for( errorNo=d_keyfrst(NAME,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(NAME,currTask,CURR_DB)){	d_recread(&irec, currTask, CURR_DB);	if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	    strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0 ){	  ListBox1->insertItem( *image3, strTemp.fromUtf8( irec.name, -1) );	}      }      break;    case cCommPhone:      for( errorNo=d_keyfrst(COMMPHONE,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(COMMPHONE,currTask,CURR_DB)){	d_recread(&irec, currTask, CURR_DB);	if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	    strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0 ){	  ListBox1->insertItem( *image3, irec.commPhone );	}      }      break;    case cTelphone:      for( errorNo=d_keyfrst(OVERTELPHONE,currTask,CURR_DB);errorNo==S_OKAY;	   errorNo=d_keynext(OVERTELPHONE,currTask,CURR_DB)){	d_recread(&irec, currTask, CURR_DB);	if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	    strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0 ){	  ListBox1->insertItem( *image3, irec.overTelphone );	}      }      break;    case cSerierNo:      for( errorNo=d_keyfrst(SERIESNO,currTask,CURR_DB);errorNo==S_OKAY;errorNo=d_keynext(SERIESNO,currTask,CURR_DB)){	d_recread(&irec, currTask, CURR_DB);	if( strlen( irec.name ) != 0 && strlen( irec.commPhone ) != 0 && 	    strlen( irec.overTelphone ) != 0 && strlen( irec.seriesNo ) != 0){	  ListBox1->insertItem( *image3, irec.seriesNo );	}      }    }    ListBox1->setSelected( 0, TRUE );    find->setText( "Append:" );    mainPageEditTextClear();}void test_Manage::mainPageEditTextClear(){    delButton->setEnabled( FALSE );    find->setText( "Append:" );    fineEdit->setText( "" );    commPhoneEdit->setText( "" );    overTelphoneEdit->setText( "" );    ipAddressEdit->setText( "" );    equipmentEdit->setText( "" );    portNoEdit->setText( "" );    zhiLieEdit->setText( "" );    zhuGanEdit->setText( "" );    jiaoJieXiangEdit->setText( "" );    fenXianXiangEdit->setText( "" );    addressEdit->setText( "" );}

⌨️ 快捷键说明

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