Разработка программы на языке C/С++, страница 6

    base[i]->dec_m=tm.minute();  

}

else base[i]->dec_h=25;

base[i]->stcode=editstatForm->stcodespinBox->value();

base[i]->dist=editstatForm->distspinBox->value();

nelem++;

isChanged=TRUE;

redrawtable();

    }

    delete editstatForm;

}

void MainForm::editRecord()

{

    int i=trainTimeTable->currentRow();

    if (i>nelem-1)

    {

editinsertstation();

return;

    }

    switch (base[i]->id){

    case 0:

{

    EditStationForm  *editstatForm = new EditStationForm( this, "editstat", TRUE );

    if (base[i]->arr_h!=25)

    {   

QTime tm(base[i]->arr_h,base[i]->arr_m);

editstatForm->ArrtimeEdit->setTime(tm);

    }

    else editstatForm->IgnoreArrTimecheckBox->setChecked(TRUE);

    if (base[i]->dec_h!=25)

    {

QTime tm(base[i]->dec_h,(int)base[i]->dec_m,0);

editstatForm->DeptimeEdit->setTime(tm);

    }

    else editstatForm->IgnoreDepTimecheckBox->setChecked(TRUE);

    editstatForm->stcodespinBox->setValue(base[i]->stcode);

    editstatForm->distspinBox->setValue(base[i]->dist);

    editstatForm->stnamelineEdit->setText(QString::fromLocal8Bit(resolvestat(base[i]->stcode)));

    if (editstatForm->exec())

    {

QTime tm;

if (!(editstatForm->IgnoreArrTimecheckBox->isChecked()))

{

    tm=editstatForm->ArrtimeEdit->time();

    base[i]->arr_h=tm.hour();

    base[i]->arr_m=tm.minute();

}

else base[i]->arr_h=25;

if (!(editstatForm->IgnoreDepTimecheckBox->isChecked()))

{

    tm=editstatForm->DeptimeEdit->time();

    base[i]->dec_h=tm.hour();

    base[i]->dec_m=tm.minute();  

}

else base[i]->dec_h=25;

base[i]->stcode=editstatForm->stcodespinBox->value();

base[i]->dist=editstatForm->distspinBox->value();

redrawtable();

isChanged=TRUE;

    }

   delete editstatForm;

}

break;

    case 1:

break;

    case 2:

//Change number

{

    ChNumForm *chnumform = new ChNumForm(this,"chnumform",TRUE);

    chnum=(datastr10*)base[i];

    chnumform->TrainnumspinBox->setValue(chnum->trnum);

    QChar lett1((ushort)chnum->lett1),lett2((ushort)chnum->lett2);

    chnumform->TrainCodeLineEdit->setText(QString(lett1)+QString(lett2));

    if (chnumform->exec())

    {

chnum->trnum=chnumform->TrainnumspinBox->value();

QString trnlett = chnumform->TrainCodeLineEdit->text();

QChar lett;

lett=trnlett.at(0);

chnum->lett1=lett.unicode();

lett=trnlett.at(1);

chnum->lett2=lett.unicode();

redrawtable();

    }

}

break;

    case 3:

// Change railway

{

    QString railw,railw1;

    int k;

    chroadForm  *chrdForm = new chroadForm( this, "chrform", TRUE );

    chrail=(datastr11*)base[i];

    railw=QString::fromLocal8Bit(resolveroad(chrail->dorcode));

    for (k=0 ;k<chrdForm->chrcomboBox->count(); k++)

    {

railw1=chrdForm->chrcomboBox->text(k);

if (railw1==railw)

{

    chrdForm->chrcomboBox->setCurrentItem(k);

    break;

}

                                                                                                                                                                                                                                               }

    if (chrdForm->exec())

    {

railw=chrdForm->chrcomboBox->currentText();

chrail->dorcode=resolveroadcode(railw.local8Bit());

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  redrawtable();

    }

    delete chrdForm;   

}

                                                                                                                                                                                                                                  break;