コード例 #1
0
        private void timePicker_ValueChanged(object sender, EventArgs e)
        {
            RevenueDto revenue = statistiscDao.GetRevenue(timePicker.Value);

            if (revenue != null)
            {
                tbRevenueOfTerm.Text = revenue.RevenueFromTermMode.ToString("###,###");
                tbRevenueOfTurn.Text = revenue.RevenueFromTurnMode.ToString("###,###");
                tbTotalRevenue.Text  = revenue.TotalRevenue.ToString("###,###");
            }
            else
            {
                MessageBox.Show("Chưa có doanh thu cho tháng này!", "Lỗi", MessageBoxButtons.OK);
            }
        }
コード例 #2
0
        private void FrmStatistics_Load(object sender, EventArgs e)
        {
            RevenueDto revenue = statistiscDao.GetRevenue(DateTime.Now);

            if (revenue != null)
            {
                tbRevenueOfTerm.Text = revenue.RevenueFromTermMode.ToString("###,###");
                tbRevenueOfTurn.Text = revenue.RevenueFromTurnMode.ToString("###,###");
                tbTotalRevenue.Text  = revenue.TotalRevenue.ToString("###,###");
            }
            else
            {
                MessageBox.Show("Chưa có doanh thu cho tháng này!", "Lỗi", MessageBoxButtons.OK);
            }

            int[] value = statistiscDao.GetNumberOfTicket();
            if (value != null && value.Length > 0)
            {
                lbNumberOfTicket.Text     = value[0].ToString();
                lbNumberOfUsedTicket.Text = value[1].ToString();
            }
        }
コード例 #3
0
        /// <summary>
        /// Get general infomation about renenue and sales statistics
        /// </summary>
        /// <param name="date">Datetime context</param>
        /// <param name="type">Date or Month or Year?</param>
        public RevenueDto GetRevenue(DateTime dateTime, TimeType type = TimeType.Day)
        {
            RevenueDto dto = new RevenueDto();

            if (type == TimeType.Day)
            { // Get revenue of the day
                // 1. Get sales number
                dto.Sales = _invoiceRepository.GetSalesByDay(dateTime);

                // 2. Get revenue
                dto.Revenue = _invoiceRepository.GetRevenueByDay(dateTime);
            }
            else  // Get revenue of the month
            {
                // 1. Get sales number
                dto.Sales = _invoiceRepository.GetSalesByMonth(dateTime);

                // 2. Get revenue
                dto.Revenue = _invoiceRepository.GetRevenueByMonth(dateTime);
            }

            return(dto);
        }
コード例 #4
0
        public RevenueDto GetRevenue(DateTime date)
        {
            using (SqlConnection connection = new SqlConnection(Config.ConnectionString))
            {
                try
                {
                    connection.Open();
                    SqlCommand cmd =
                        new SqlCommand("usp_get_revenue", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.Add(new SqlParameter("@date", date));

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            reader.Read();
                            RevenueDto revenue = new RevenueDto()
                            {
                                RevenueFromTurnMode = (decimal)reader["DoanhThuTuGuiLuot"],
                                RevenueFromTermMode = (decimal)reader["DoanhThuTuGuiThang"],
                                TotalRevenue        = (decimal)reader["TongDoanhThu"]
                            };
                            return(revenue);
                        }

                        return(null);
                    }
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }