Пример #1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (gvProductsToBills.Rows.Count == 0)
            {
                MessageBox.Show("Choose product, Please!", "Message");
                return;
            }
            List <PrintDto> lstProductForPrint = new List <PrintDto>();

            for (int i = 0; i < gvProductsToBills.Rows.Count; i++)
            {
                PrintDto printDto = new PrintDto()
                {
                    ProductName = gvProductsToBills.Rows[i].Cells["colProductName"].Value.ToString(),
                    Price       = float.Parse(gvProductsToBills.Rows[i].Cells["colRealPrice"].Value.ToString()),
                    Amounts     = int.Parse(gvProductsToBills.Rows[i].Cells["colAmounts"].Value.ToString()),
                    Sum         = float.Parse(gvProductsToBills.Rows[i].Cells["colTotal"].Value.ToString()),
                    Total       = SumTotal()
                };
                lstProductForPrint.Add(printDto);
            }
            CRReport frm = new CRReport(lstProductForPrint);

            frm.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Gets the last transaction of the user that allows him to print a recipt
        /// </summary>
        /// <param name="cardId"></param>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public PrintDto GetLastTransaction(int cardId, int accountId)
        {
            try
            {
                var transaction = _context.TransactionHistories.OrderByDescending(x => x.CreatedOn).FirstOrDefault();

                var printDto = new PrintDto
                {
                    UserName          = transaction.User.UserName,
                    TransactionAmount = transaction.TransactionAmount,
                    AccountNumber     = transaction.Account.AccountNumber,
                    CardNumber        = transaction.Card.CardNumber,
                    Transaction       = (TransactionType)transaction.TransactionType,
                    CreatedOn         = transaction.CreatedOn,
                    Status            = (TransactionStatus)transaction.Status
                };

                return(printDto);
            }
            catch (Exception)
            {
                throw;
            }
        }