private void btnOK_Click(object sender, EventArgs e)
 {
     Cancel      = false;
     WhatToPrint = GetCardPrint();
     if (!WhatToPrint.CANCEL)
     {
         if (WhatToPrint.lead != null && WhatToPrint.lead.qFlash)
         {
             ClComp cSet = ClComp.Default;
             cSet.CardFlashRN = WhatToPrint.lead.qFlashRN;
             cSet.Save();
         }
         this.Close();
     }
 }
 private void btnCancel_Click(object sender, EventArgs e)
 {
     Cancel      = true;
     WhatToPrint = GetCardPrint();
     this.Close();
 }
        private CardPrint GetCardPrint()
        {
            CardPrint retVal = new CardPrint();

            retVal.CANCEL           = Cancel;
            retVal.OnlyParticipants = cbOnlyReal.Checked;
            if (Cancel)
            {
                return(retVal);
            }
            if (!(cbLead.Checked || cbSpeed.Checked || cbBoulder.Checked))
            {
                MessageBox.Show(this, "Для печати в карточку ничего не выбрано.");
                retVal.CANCEL = true;
                return(retVal);
            }
            if (cbLead.Checked)
            {
                Lead l = new Lead();
                l.quali = cbLQuali.Checked;
                l.q1g   = rbL1gr.Checked;
                l.q2g   = rbL2gr.Checked;
                if (cbLead.Enabled && cbLead.Checked && rbLFlash.Enabled && rbLFlash.Checked)
                {
                    int nRn;
                    if (!int.TryParse(tbFlashRN.Text, out nRn))
                    {
                        MessageBox.Show(this, "Число трасс для квалификации flash введено неверно");
                        retVal.CANCEL = true;
                        return(retVal);
                    }
                    l.qFlashRN = nRn;
                }

                l.final     = cbLFinal.Checked;
                l.semi      = cbLSemi.Checked;
                l.super     = cbLSuper.Checked;
                retVal.lead = l;
            }

            if (cbSpeed.Checked)
            {
                Speed s = new Speed();
                if (rbS1q.Checked)
                {
                    s.q1 = !(s.q2 = false);
                }
                else
                {
                    s.q1 = s.q2 = true;
                }
                if (rbSF16.Checked)
                {
                    s.f16 = s.f8 = s.f4 = true;
                }
                else
                {
                    if (rbSF08.Checked)
                    {
                        s.f16 = false;
                        s.f4  = s.f8 = true;
                    }
                    else
                    {
                        s.f16 = s.f8 = false;
                        s.f4  = true;
                    }
                }
                retVal.speed = s;
            }

            if (cbBoulder.Checked)
            {
                int     nTmp;
                Boulder b = new Boulder();
                b.quali = cbBQuali.Checked;
                ClComp cSet = ClComp.Default;
                if (b.quali)
                {
                    b.q2g = rbB2g.Checked;
                    if (!int.TryParse(tbQroute.Text, out nTmp))
                    {
                        MessageBox.Show("Число трасс в квалификации боулдеринга введено неверно.");
                        retVal.CANCEL = true;
                        return(retVal);
                    }
                    cSet.tbQroute = nTmp.ToString();
                    b.rQuali      = nTmp;
                }

                b.semi = cbBSemi.Checked;
                if (b.semi)
                {
                    if (!int.TryParse(tbSroute.Text, out nTmp))
                    {
                        MessageBox.Show("Число трасс в полуфинале боулдеринга введено неверно.");
                        retVal.CANCEL = true;
                        return(retVal);
                    }
                    cSet.tbSroute = nTmp.ToString();
                    b.rSemi       = nTmp;
                }
                b.final = cbBFinal.Checked;
                if (b.final)
                {
                    if (!int.TryParse(tbFroute.Text, out nTmp))
                    {
                        MessageBox.Show("Число трасс в финале боулдеринга введено неверно.");
                        retVal.CANCEL = true;
                        return(retVal);
                    }
                    cSet.tbFroute = nTmp.ToString();
                    b.rFinal      = nTmp;
                }
                b.super        = cbBSuper.Checked;
                retVal.boulder = b;
            }
            return(retVal);
        }