Esempio n. 1
0
        public incomeForm(Record dataRecord, MainForm parentMain)
        {
            InitializeComponent();
            m_parentMain = parentMain;

            Result = InOutFormResult.Cancel;

            lbHeader.Text = lbHeader.Text + " " + dataRecord.OverallID.ToString();

            dataRec             = dataRecord;
            cbNoteToNumber.Text = dataRec.NoteToNumber;
            edDate.Text         = dataRec.Date;
            edMoney.Text        = MoneyConvertor.MoneyToStr(dataRec.Cost); //todo kontrola konverze
            cbFrom.Text         = dataRec.CustName;
            cbContent.Text      = dataRec.Content;
            edNote.Text         = dataRec.Note;

            string[] hintList;

            /*hintList = Settings.Settings.SettingsHolder.getHints("IncomeNote");
             * foreach (string item in hintList)
             *  cbNoteToNumber.Items.Add(item);*/
            hintList = Settings.Settings.SettingsHolder.getHints("IncomeName");
            foreach (string item in hintList)
            {
                cbFrom.Items.Add(item);
            }
            hintList = Settings.Settings.SettingsHolder.getHints("IncomeFor");
            foreach (string item in hintList)
            {
                cbContent.Items.Add(item);
            }
        }
Esempio n. 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);
        }
Esempio n. 3
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();
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public DiarySettings(Diary diary)
        {
            InitializeComponent();

            ndIncomeCount.Value  = diary.InitTypeCounts[(int)Record.RecordType.Income];
            ndOutcomeCount.Value = diary.InitTypeCounts[(int)Record.RecordType.Expense];
            edInitRemain.Text    = MoneyConvertor.MoneyToStr(diary.InitRemain);
            edRemainLimit.Text   = MoneyConvertor.MoneyToStr(diary.RemainLimit);
            edWarnLimit.Text     = MoneyConvertor.MoneyToStr(diary.RemainWarning);
            edDiaryHeader.Text   = diary.Name;

            m_diary = diary;
        }
Esempio n. 6
0
        private void PrintCommon(Graphics g, int yOffset, bool onlyUpper, FormType formType)
        {
            Font defaultTextFont = new Font("Courier New", 9, FontStyle.Bold);

            printStamp(g, 130, 11);
            //Font stampFont = new Font("Courier New", 7, FontStyle.Bold);

            //string[] Stamp = Settings.Settings.SettingsHolder.Stamp;
            //for (int i = 0; i < Math.Min(6, Stamp.Length); i++)
            //{
            //    g.DrawString(Stamp[i], stampFont, TextBrush, new PointF(130, 11+((6-Math.Min(Stamp.Length,6))/(float)2+i)*11), CenterTopAlign);
            //}

            g.DrawString("číslo " + m_recToPrint.TypeID.ToString() + m_recToPrint.NoteToNumber, defaultTextFont, TextBrush, new Point(260, 45), LeftTopAlign);
            g.DrawString("ze dne " + m_recToPrint.Date, defaultTextFont, TextBrush, new Point(260, 60), LeftTopAlign);

            if (formType == FormType.Income)
            {
                g.DrawString("Přijato od: " + m_recToPrint.CustName, defaultTextFont, TextBrush, new Point(10, 88), LeftTopAlign);
            }
            else
            {
                g.DrawString("Vyplaceno: " + m_recToPrint.CustName, defaultTextFont, TextBrush, new Point(10, 88), LeftTopAlign);
            }
            g.DrawString("Částka: " + MoneyConvertor.MoneyToStr(m_recToPrint.Cost) + ",00 Kč", new Font("Courier New", 11, FontStyle.Bold),
                         TextBrush, new Point(10, 105), LeftTopAlign);

            string castkaSlovy = "Slovy: " + "=" + NumberConvertor.ConvertIntToWord((int)m_recToPrint.Cost) + " Kč=";

            g.DrawString(castkaSlovy, defaultTextFont, TextBrush, new Point(10, 125), LeftTopAlign);
            g.DrawString("Účel platby: " + m_recToPrint.Content, defaultTextFont, TextBrush, new Point(10, 142), LeftTopAlign);

            if (!onlyUpper)
            {
                g.DrawString("Text", defaultTextFont, TextBrush, new Point(70, 224), CenterCenterAlign);
                g.DrawString("Účt. předpis (Má dáti-účet)", defaultTextFont, TextBrush, new Point(255, 224), CenterCenterAlign);
                g.DrawString("Kč", defaultTextFont, TextBrush, new Point(437, 224), CenterCenterAlign);

                g.DrawString("Schválil:", defaultTextFont, TextBrush, new Point(10, 317), LeftCenterAlign);
                g.DrawString("Zaúčtoval:", defaultTextFont, TextBrush, new Point(195, 317), LeftCenterAlign);
                g.DrawString("Dne: ", defaultTextFont, TextBrush, new Point(383, 317), LeftCenterAlign);
            }

            g.DrawString(footerText, m_footerFont, TextBrush, 500, 325, RightTopAlign);
        }
Esempio n. 7
0
        public outcomeForm(Record dataRecord)
        {
            InitializeComponent();

            Result = InOutFormResult.Cancel;

            dataRec = dataRecord;

            lbHeader.Text = lbHeader.Text + " " + dataRecord.OverallID.ToString();

            cbNoteToNumber.Text = dataRec.NoteToNumber;
            edDate.Text         = dataRec.Date;
            edMoney.Text        = MoneyConvertor.MoneyToStr(dataRec.Cost); //todo kontrola konverze
            cbFrom.Text         = dataRec.CustName;
            cbContent.Text      = dataRec.Content;
            edNote.Text         = dataRec.Note;
            cbOther.Text        = dataRec.PayedTo;

            string[] hintList;
            // hintList = Settings.Settings.SettingsHolder.getHints("OutcomeNote");
            //foreach (string item in hintList)
            // cbNoteToNumber.Items.Add(item);
            hintList = Settings.Settings.SettingsHolder.getHints("OutcomeName");
            foreach (string item in hintList)
            {
                cbFrom.Items.Add(item);
            }
            hintList = Settings.Settings.SettingsHolder.getHints("OutcomeFor");
            foreach (string item in hintList)
            {
                cbContent.Items.Add(item);
            }
            hintList = Settings.Settings.SettingsHolder.getHints("OutcomeRecipient");
            foreach (string item in hintList)
            {
                cbOther.Items.Add(item);
            }
            cbOther.Text = Settings.Settings.SettingsHolder.getLastHint("OutcomeRecipient");
        }
Esempio n. 8
0
        private void UpdateCurrentPage()
        {
            if (m_currentPage >= m_mainDiary.PageCount)
            {
                m_currentPage = m_mainDiary.PageCount - 1;
            }
            lbPageId.Text = "Stránka " + (m_currentPage + 1).ToString() + ".";
            Record[] records = m_mainDiary.GetPage(m_currentPage);
            ClearGrid();
            String [] cells = new String[8];

            for (int i = 0; i < records.Length && records[i] != null; i++)
            {
                /*
                 * gridHistory.Rows[i].Cells[0].Value = records[i].OverallID.ToString();
                 * gridHistory.Rows[i].Cells[1].Value = records[i].Date;
                 * gridHistory.Rows[i].Cells[2].Value = records[i].TypeID.ToString();
                 * gridHistory.Rows[i].Cells[3].Value = records[i].Content;
                 * if (records[i].Type == Record.RecordType.Expense)
                 * {
                 *  gridHistory.Rows[i].Cells[4].Value = "";
                 *  gridHistory.Rows[i].Cells[5].Value = records[i].Cost.ToString();
                 * }
                 * else
                 * {
                 *  gridHistory.Rows[i].Cells[5].Value = "";
                 *  gridHistory.Rows[i].Cells[4].Value = records[i].Cost.ToString();
                 * }
                 * gridHistory.Rows[i].Cells[6].Value = records[i].Remaining.ToString();
                 * gridHistory.Rows[i].Cells[7].Value = records[i].Note;*/
                cells[0] = records[i].OverallID.ToString();
                cells[1] = records[i].Date;
                cells[2] = records[i].TypeID.ToString();
                cells[3] = records[i].Content;
                if (records[i].Type == Record.RecordType.Expense)
                {
                    cells[4] = "";
                    cells[5] = MoneyConvertor.MoneyToStr(records[i].Cost) + ",-";
                }
                else
                {
                    cells[5] = "";
                    cells[4] = MoneyConvertor.MoneyToStr(records[i].Cost) + ",-";
                }
                cells[6] = MoneyConvertor.MoneyToStr(records[i].Remaining) + ",-";
                cells[7] = records[i].Note.Equals("") ? records[i].CustName : records[i].Note;

                //for (int j=0; j<8; j++)
                //    dataSource[i*8+j] = cells[j];
                if (records[i].Remaining > m_mainDiary.RemainLimit)
                {
                    for (int j = 0; j < gridHistory.Rows[i].Cells.Count; j++)
                    {
                        gridHistory.Rows[i].Cells[j].Style.ForeColor = Color.Red;
                    }
                }
                else if (records[i].Remaining > m_mainDiary.RemainWarning)
                {
                    for (int j = 0; j < gridHistory.Rows[i].Cells.Count; j++)
                    {
                        gridHistory.Rows[i].Cells[j].Style.ForeColor = Color.Blue;
                    }
                }
                else
                {
                    for (int j = 0; j < gridHistory.Rows[i].Cells.Count; j++)
                    {
                        gridHistory.Rows[i].Cells[j].Style.ForeColor = Color.Black;
                    }
                }
                gridHistory.Rows[i].SetValues(cells);
            }
            //gridHistory.DataSource = dataSource;
        }
Esempio n. 9
0
        private void PrintDiaryPage(Graphics g, int page)
        {
            Debug.Assert(page <= m_diaryToPrint.PageCount);
            if (page > m_diaryToPrint.PageCount)
            {
                return;
            }

            Record[] records = m_diaryToPrint.GetPage(page);
            Debug.Assert(records.Length >= 0);
            if (records.Length < 0)
            {
                return;
            }

            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            //g.TextRenderingHin
            Font defaultTextFont = new Font("Times New Roman", 12, FontStyle.Bold);
            Font mainTextFont    = new Font("Times New Roman", 18, FontStyle.Bold);

            //Tisk razitka
            printStamp(g, 130, 6);

            g.ResetTransform();
            g.ScaleTransform((g.VisibleClipBounds.Width - 8) / 827,
                             (g.VisibleClipBounds.Height - 8) / 1169);
            float width = (float)827;

            int[]    colBorders      = { 32, 50, 57, 266, 83, 83, 101, 138 };
            string[] colDescriptions = { "Poř.\nčíslo", "Datum",    "Obsah zápisu", "Příjmy",
                                         "Výdaje",      "Zůstatek", "Poznámka" };

            Rectangle tableRect   = new Rectangle(5, 80, 817, 1064);
            int       tableHeader = 40;

            //g.ScaleTransform(g.VisibleClipBounds.Width/width , g.VisibleClipBounds.Height/height);

            g.DrawString(m_diaryToPrint.Name, mainTextFont, TextBrush, width / 2, 35, CenterCenterAlign);
            if (records.Length > 0)
            {
                g.DrawString("Od: " + records[0].DateDiary + "   Do: " + records[records.Length - 1].DateDiary,
                             defaultTextFont, TextBrush, width / 2, 60, CenterCenterAlign);
            }
            g.DrawString("Stránka: " + (page + 1).ToString() + ".  ",
                         defaultTextFont, TextBrush, tableRect.Right - 20, 35, RightCenterAlign);


            Brush borderBrush = new SolidBrush(Color.Black);
            Pen   borderPen   = new Pen(borderBrush, 3);
            Pen   normalPen   = new Pen(borderBrush, 1);

            g.DrawRectangle(borderPen, tableRect);
            g.DrawLine(borderPen, tableRect.Left, tableRect.Top + tableHeader, tableRect.Right, tableRect.Top + tableHeader);

            float rowHeight = (tableRect.Height - tableHeader) / (float)m_diaryToPrint.PageSize;
            int   tableTop  = tableHeader + tableRect.Top;

            for (int row = 1; row <= m_diaryToPrint.PageSize; row++)
            {
                g.DrawLine(normalPen, tableRect.Left, row * rowHeight + tableTop, tableRect.Right,
                           row * rowHeight + tableTop);
            }
            int sumCol = tableRect.Left;

            Font tableHeaderFont = new Font("Times New Roman", 10, FontStyle.Bold);

            for (int colId = 1; colId < colBorders.Length; colId++)
            {
                if (colId == colBorders.Length - 1)
                {
                    colBorders[colId] = tableRect.Right - sumCol;
                    sumCol            = tableRect.Right;
                }
                else
                {
                    sumCol += colBorders[colId];
                }
                g.DrawLine(normalPen, sumCol, tableRect.Top, sumCol, tableRect.Bottom);
                g.DrawString(colDescriptions[colId - 1], tableHeaderFont, TextBrush,
                             new RectangleF(sumCol - colBorders[colId], tableRect.Top, colBorders[colId], tableHeader),
                             CenterCenterAlign);
            }

            Font tableBodyFont = new Font("Courier New", 9, FontStyle.Bold);

            for (int row = 0; row < records.Length; row++)
            {
                Record         record    = records[row];
                string         costIn    = (record.Type == Record.RecordType.Income)?(MoneyConvertor.MoneyToStr(record.Cost) + ",-"):("");
                string         costOut   = (record.Type == Record.RecordType.Expense) ? (MoneyConvertor.MoneyToStr(record.Cost) + ",-") : ("");
                string         remaining = MoneyConvertor.MoneyToStr(record.Remaining) + ",-";
                string         note      = record.Note.Equals("") ? record.CustName : record.Note;
                string[]       rowVals   = { record.OverallID.ToString(), record.DateDiary.ToString(),
                                             record.Content,                      costIn,                     costOut,remaining, note };
                StringFormat[] colFormats = { RightCenterAlign, RightCenterAlign, LeftCenterAlign, RightCenterAlign, RightCenterAlign, RightCenterAlign, LeftCenterAlign, LeftCenterAlign };

                sumCol = tableRect.Left;
                float rowTop = tableRect.Top + tableHeader + row * rowHeight;
                for (int colId = 1; colId < colBorders.Length; colId++)
                {
                    if (colId == colBorders.Length - 1)
                    {
                        colBorders[colId] = tableRect.Right - sumCol;
                        sumCol            = tableRect.Right;
                    }
                    else
                    {
                        sumCol += colBorders[colId];
                    }
                    // g.DrawLine(normalPen, sumCol, tableRect.Top, sumCol, tableRect.Bottom);
                    g.DrawString(rowVals[colId - 1], tableBodyFont, TextBrush,
                                 new RectangleF(sumCol - colBorders[colId] + 2, rowTop + 2, colBorders[colId] - 5, rowHeight),
                                 colFormats[colId - 1]);
                }
            }

            g.DrawString(footerText, m_footerFont, TextBrush, (float)tableRect.Right - 10, (float)tableRect.Bottom + 15, RightCenterAlign);
        }