Ejemplo n.º 1
0
        public void AddNetConsumePoint(Int64 userID, string userName, tbl_NetConsumeDetail _netConsumeDetail)
        {
            try
            {
                CRUDOperation        cRUDOperation        = new CRUDOperation();
                decimal              pointValue           = 0;
                decimal              priceValue           = 0;
                int                  operatorEVID         = NetConsumeHelper.GetOperatorValueByKey(_netConsumeDetail.OperatorName.Trim());
                NetConsumeRepository netConsumeRepository = new NetConsumeRepository();
                if (_netConsumeDetail.Source_EVID == 4)
                {
                    tbl_PackagePrice packagePrice = netConsumeRepository.GetPackagePrice(operatorEVID, _netConsumeDetail.Consumed);
                    if (packagePrice != null)
                    {
                        pointValue = 1 * (packagePrice.Point == null ? 0 : (decimal)packagePrice.Point);
                        priceValue = 1 * (packagePrice.Price == null ? 0 : (decimal)packagePrice.Price);
                    }
                }

                AddUserPointAndPrice(userID, _netConsumeDetail.Month, _netConsumeDetail.Year, pointValue, priceValue, (int)ChanelType.NetConsume);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public List <NetConsumeReportDTO> SW_GetNetConsumeReports(int userID, string userName, int year)
        {
            var           result   = new List <NetConsumeReportDTO>();
            StringBuilder allQuery = new StringBuilder();
            var           query    = @"select * from  [GetNetUsage](@P_USERID,@P_year) ";

            allQuery.Append(query);

            using (var connection = new SqlConnection(ConnectionStrings.ConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand(allQuery.ToString(), connection))
                {
                    SqlParameter puserID = new SqlParameter("@P_USERID", SqlDbType.Int);
                    puserID.Value = userID;
                    command.Parameters.Add(puserID);
                    SqlParameter pyear = new SqlParameter("@P_year", SqlDbType.Int);
                    pyear.Value = year;
                    command.Parameters.Add(pyear);
                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        NetConsumeReportDTO netConsumeReportDTO = new NetConsumeReportDTO()
                        {
                            INOUT_EVType = reader.GetInt32OrDefaultValue(0),
                            SourceDesc   = reader.GetStringOrEmpty(1),
                            OperatorName = reader.GetStringOrEmpty(2),
                            Year         = reader.GetInt32OrDefaultValue(3),
                            January      = reader.GetDecimalOrDefaultValue2(4),
                            February     = reader.GetDecimalOrDefaultValue2(5),
                            March        = reader.GetDecimalOrDefaultValue2(6),
                            April        = reader.GetDecimalOrDefaultValue2(7),
                            May          = reader.GetDecimalOrDefaultValue2(8),
                            June         = reader.GetDecimalOrDefaultValue2(9),
                            July         = reader.GetDecimalOrDefaultValue2(10),
                            August       = reader.GetDecimalOrDefaultValue2(11),
                            September    = reader.GetDecimalOrDefaultValue2(12),
                            October      = reader.GetDecimalOrDefaultValue2(13),
                            November     = reader.GetDecimalOrDefaultValue2(14),
                            December     = reader.GetDecimalOrDefaultValue2(15),
                        };


                        netConsumeReportDTO.Average      = GetAverage(netConsumeReportDTO);
                        netConsumeReportDTO.OperatorEVID = NetConsumeHelper.GetOperatorValueByKey(netConsumeReportDTO.OperatorName);

                        if (netConsumeReportDTO.SourceDesc == "Mobil")
                        {
                            if (netConsumeReportDTO.Average == 0)
                            {
                                netConsumeReportDTO.AveragePrice = 0;
                                netConsumeReportDTO.AveragePoint = 0;
                            }
                            else
                            {
                                tbl_PackagePrice packagePrice = GetPackagePrice(netConsumeReportDTO.OperatorEVID, netConsumeReportDTO.Average);
                                if (packagePrice == null)
                                {
                                    netConsumeReportDTO.AveragePrice = null;
                                    netConsumeReportDTO.AveragePoint = null;
                                }
                                else
                                {
                                    netConsumeReportDTO.AveragePrice = packagePrice.Price;
                                    netConsumeReportDTO.AveragePoint = packagePrice.Point;
                                }
                            }
                        }


                        result.Add(netConsumeReportDTO);
                    }
                }
                connection.Close();
            }

            return(result);
        }