Exemplo n.º 1
0
        public static DataTable GetRoomBillingDataByClientID(HttpContextBase context, DateTime period, int clientId)
        {
            DataTable dt;

            if (period.Month == DateTime.Now.Month && period.Year == DateTime.Now.Year)
            {
                dt = RoomBillingDA.GetRoomBillingTempDataByClientID(period, clientId);
            }
            else
            {
                dt = BillingTablesBL.GetMultipleTables(context, period.Year, period.Month, clientId, BillingTableType.RoomBilling);
            }

            if (!dt.Columns.Contains("DailyFee"))
            {
                dt.Columns.Add("DailyFee", typeof(decimal));
            }

            if (!dt.Columns.Contains("EntryFee"))
            {
                dt.Columns.Add("EntryFee", typeof(decimal));
            }

            if (!dt.Columns.Contains("LineCost"))
            {
                dt.Columns.Add("LineCost", typeof(decimal));
            }

            BillingType.CalculateRoomLineCost(dt);

            return(dt);
        }
        private DataTable GetRoomBillingDataByClientID(DateTime period, int clientId)
        {
            DataTable dt;

            if (period.Month == DateTime.Now.Month && period.Year == DateTime.Now.Year)
            {
                dt = RoomBillingDA.GetRoomBillingTempDataByClientID(period, clientId);
            }
            else
            {
                dt = RoomBillingDA.GetRoomBillingDataByClientID(period, clientId);
            }

            if (!dt.Columns.Contains("LineCost"))
            {
                dt.Columns.Add("LineCost", typeof(double));
            }

            // Part I: Get the true cost based on billing types
            foreach (DataRow dr in dt.Rows)
            {
                int billingTypeId = dr.Field <int>("BillingTypeID");
                var room          = Rooms.GetRoom(dr.Field <int>("RoomID"));

                if (billingTypeId == BillingTypes.Other)
                {
                    dr["LineCost"] = 0;
                }
                else if (BillingTypes.IsGrowerUserBillingType(billingTypeId))
                {
                    if (room == LabRoom.OrganicsBay)
                    {
                        //Organics bay must be charged for growers as well
                        dr["LineCost"] = dr.Field <decimal>("RoomCharge");
                    }
                    else
                    {
                        dr["LineCost"] = dr.Field <decimal>("AccountDays") * dr.Field <decimal>("RoomRate") + dr.Field <decimal>("EntryCharge");
                    }
                }
                else
                {
                    //Per Use types
                    dr["LineCost"] = dr.Field <decimal>("RoomCharge") + dr.Field <decimal>("EntryCharge");
                }
            }

            return(dt);
        }