コード例 #1
0
        public List <TranzactionsVO> getTranzByIdAccOnDate(int _id, DateTime _dt)
        {
            DataTable dataTable = new DataTable();

            try
            {
                dataTable = _tranzDAO.searchByIdAccAndDate(_id, _dt);
                foreach (DataRow dr in dataTable.Rows)
                {
                    TranzactionsVO _newTranzVo = new TranzactionsVO();
                    _newTranzVo.idAcc  = Int32.Parse(dr["idAcc"].ToString());
                    _newTranzVo.type   = dr["Type"].ToString();
                    _newTranzVo.amount = Int32.Parse(dr["Amount"].ToString());
                    _newTranzVo.date   = DateTime.Parse(dr["DateCreated"].ToString());
                    this._listTranzVO.Add(_newTranzVo);
                }
            }
            catch (NullReferenceException e)
            {
                Console.Write("Error:", e.ToString());
                Console.ReadLine();
            }

            return(this._listTranzVO);
        }
コード例 #2
0
ファイル: FormClient.cs プロジェクト: hackero03/Assignment1
        //------------------------ReportPanel
        private void buttonRepOk_Click(object sender, EventArgs e)
        {
            DateTime  _dt        = new DateTime();
            DataTable _dataTable = new DataTable();
            int       idAcc      = Int32.Parse(comboReport.Text);

            try
            {
                _dt          = DateTime.Parse(dateTimePickerReport.Text);
                _listTranzVO = _tranzBUS.getTranzByIdAccOnDate(idAcc, _dt);
                _dataTable   = _tranzDAO.searchByIdAccAndDate(idAcc, _dt);
                string s = DateTime.Parse(dateTimePickerReport.Text).ToString();
                MessageBox.Show("Your tranzactions after this date: \n" + s);
                this.dataGridViewReport.DataSource = _dataTable;

                //--------------------PDF - Report
                Document  doc       = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
                PdfWriter pdfWrite  = PdfWriter.GetInstance(doc, new FileStream("Tranzactions.pdf", FileMode.Create));
                Paragraph paragraph = new Paragraph("Your account tranzactions: !!\n\n");
                PdfPTable pdfTable  = new PdfPTable(_dataTable.Columns.Count);
                doc.Open();
                iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 5);

                float[] widths = new float[] { 4f, 4f, 4f, 4f, 4f };
                pdfTable.SetWidths(widths);
                pdfTable.WidthPercentage = 60;


                PdfPCell cell = new PdfPCell(new Phrase("idAcc"));
                cell.Colspan = _dataTable.Columns.Count;
                foreach (DataColumn c in _dataTable.Columns)
                {
                    pdfTable.AddCell(new Phrase(c.ColumnName, font5));
                }

                foreach (DataRow r in _dataTable.Rows)
                {
                    if (_dataTable.Rows.Count > 0)
                    {
                        pdfTable.AddCell(new Phrase(r[0].ToString(), font5));
                        pdfTable.AddCell(new Phrase(r[1].ToString(), font5));
                        pdfTable.AddCell(new Phrase(r[2].ToString(), font5));
                        pdfTable.AddCell(new Phrase(r[3].ToString(), font5));
                        pdfTable.AddCell(new Phrase(r[4].ToString(), font5));
                    }
                }


                paragraph.Font.SetFamily("Georgia");
                paragraph.Font.SetColor(122, 122, 44);

                doc.Add(paragraph);
                doc.Add(pdfTable);
                doc.Close();
            }
            catch (DataException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }