예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int initTypeCountsIn = decimal.ToInt32(ndIncomeCount.Value);
            int initTypeCountsOut = decimal.ToInt32(ndOutcomeCount.Value);
            int initRemain, remainWarning, remainLimit;

            try
            {
                initRemain    = (int)MoneyConvertor.StrToMoney(edInitRemain.Text, int.MaxValue);
                remainWarning = (int)MoneyConvertor.StrToMoney(edWarnLimit.Text, int.MaxValue);
                remainLimit   = (int)MoneyConvertor.StrToMoney(edRemainLimit.Text, int.MaxValue);
            }
            catch
            {
                MessageBox.Show("Nevyhovující částky.");
                return;
            }

            m_diary.InitTypeCounts[(int)Record.RecordType.Income]  = initTypeCountsIn;
            m_diary.InitTypeCounts[(int)Record.RecordType.Expense] = initTypeCountsOut;
            m_diary.Name          = edDiaryHeader.Text;
            m_diary.InitRemain    = initRemain;
            m_diary.RemainWarning = remainWarning;
            m_diary.RemainLimit   = remainLimit;

            DialogResult = DialogResult.OK;
            Close();
        }
예제 #2
0
        // private Record m_record;
        private Denik.Record createDataRec(Denik.Record initRecord)
        {
            //todo pridat do seznamu
            Denik.Record result = initRecord;

            try
            {
                result.Cost = MoneyConvertor.StrToMoney(edMoney.Text, MaxValue - 1);        //todo kontrola konverze
                if (result.Cost < 0 || result.Cost >= MaxValue)
                {
                    throw new Exception();
                }
            }
            catch
            {
                MessageBox.Show("Částka musí být celé číslo menší než " + (MaxValue - 1).ToString() + ".", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            result.NoteToNumber = cbNoteToNumber.Text;
            result.Date         = edDate.Text;
            result.CustName     = cbFrom.Text;
            result.Content      = cbContent.Text;
            result.Note         = edNote.Text;
            result.Type         = Record.RecordType.Income;
            return(result);
        }
예제 #3
0
        private bool finishOK()
        {
            //todo pridat do seznamu
            dataRec.NoteToNumber = cbNoteToNumber.Text;
            dataRec.Date         = edDate.Text;
            try
            {
                dataRec.Cost = MoneyConvertor.StrToMoney(edMoney.Text, MaxValue - 1);        //todo kontrola konverze
                if (dataRec.Cost < 0 || dataRec.Cost >= MaxValue)
                {
                    throw new Exception();
                }
            }
            catch
            {
                MessageBox.Show("Částka musí být celé číslo menší než " + (MaxValue - 1).ToString() + "."
                                , "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(false);
            }
            dataRec.CustName = cbFrom.Text;
            dataRec.Content  = cbContent.Text;
            dataRec.Note     = edNote.Text;
            dataRec.Type     = Record.RecordType.Expense;
            dataRec.PayedTo  = cbOther.Text;

            //Settings.Settings.SettingsHolder.addHint("OutcomeNote", dataRec.NoteToNumber);
            Settings.Settings.SettingsHolder.addHint("OutcomeName", dataRec.CustName);
            Settings.Settings.SettingsHolder.addHint("OutcomeFor", dataRec.Content);
            Settings.Settings.SettingsHolder.addHint("OutcomeRecipient", dataRec.PayedTo);

            return(true);
        }