Пример #1
0
        public static double GetTotalCostByBillingType(int billingTypeId, double hours, double entries, LabRoom room, double totalCalcCost)
        {
            double result = 0;

            if (room == LabRoom.CleanRoom)
            {
                if (billingTypeId == BillingTypes.Int_Ga)
                {
                    return((totalCalcCost / 1315) * 875);
                }

                else if (billingTypeId == BillingTypes.Int_Si)
                {
                    return(totalCalcCost);
                }

                else if (billingTypeId == BillingTypes.Int_Hour)
                {
                    return(2.5 * entries + 15 * hours);
                }

                else if (billingTypeId == BillingTypes.Int_Tools)
                {
                    return(2.5 * entries);
                }

                else if (billingTypeId == BillingTypes.ExtAc_Ga)
                {
                    return((totalCalcCost / 1315) * 875);
                }

                else if (billingTypeId == BillingTypes.ExtAc_Si)
                {
                    return(totalCalcCost);
                }

                else if (billingTypeId == BillingTypes.ExtAc_Tools)
                {
                    return(2.5 * entries);
                }

                else if (billingTypeId == BillingTypes.ExtAc_Hour)
                {
                    return(2.5 * entries + 15 * hours);
                }

                else if (billingTypeId == BillingTypes.NonAc)
                {
                    return(hours * 77);
                }

                else if (billingTypeId == BillingTypes.NonAc_Tools)
                {
                    return(2.5 * hours);
                }

                else if (billingTypeId == BillingTypes.NonAc_Hour)
                {
                    return(2.5 * entries + 45 * hours);
                }

                else if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
            }
            else if (room == LabRoom.ChemRoom)
            {
                if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
                else if (billingTypeId >= BillingTypes.NonAc)
                {
                    return(190);
                }
                else
                {
                    return(95);
                }
            }
            else if (room == LabRoom.TestingLab)
            {
                if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
                else if (billingTypeId >= BillingTypes.NonAc)
                {
                    return(50);
                }
                else
                {
                    return(25);
                }
            }
            else
            {
                return(99999);
            }

            return(result);
        }
        private void PopulateRoomDetailData(DateTime period, int clientId)
        {
            // gets either current or prior period data
            DataTable dtRoom = RoomBillingBL.GetRoomBillingDataByClientID(ContextBase, period, clientId);

            if (!dtRoom.Columns.Contains("IsParent"))
            {
                dtRoom.Columns.Add("IsParent", typeof(bool));
            }

            if (!dtRoom.Columns.Contains("ParentID"))
            {
                dtRoom.Columns.Add("ParentID", typeof(int));
            }

            if (!dtRoom.Columns.Contains("RowCssClass"))
            {
                dtRoom.Columns.Add("RowCssClass", typeof(string));
            }

            var rooms = CacheManager.Current.Rooms();

            foreach (DataRow dr in dtRoom.Rows)
            {
                var r = rooms.FirstOrDefault(x => x.RoomID == dr.Field <int>("RoomID"));

                if (r.ParentID.HasValue)
                {
                    dr.SetField("IsParent", false);
                    dr.SetField("ParentID", r.ParentID.Value);
                    dr.SetField("RowCssClass", "child");
                }
                else
                {
                    dr.SetField("IsParent", true);
                    dr.SetField("ParentID", r.RoomID);
                    dr.SetField("RowCssClass", "parent");
                }
            }

            dtRoom.DefaultView.Sort = "ParentID ASC, IsParent DESC, Room ASC";

            rptRoomDetail.DataSource = dtRoom.DefaultView;
            rptRoomDetail.DataBind();

            decimal totalCleanRoomHours = 0, totalWetChemHours = 0, totalTestLabHours = 0, totalOrganicsHours = 0, totalLnfHours = 0;

            foreach (DataRow dr in dtRoom.Rows)
            {
                LabRoom room = Rooms.GetRoom(dr.Field <int>("RoomID"));

                // Using Convert.ToDecimal because value might be decimal or double depending no if it is from RoomBilling or RoomBillingTemp
                decimal hours = Convert.ToDecimal(dr["Hours"]);

                if (room == LabRoom.CleanRoom)
                {
                    totalCleanRoomHours += hours;
                }
                else if (room == LabRoom.ChemRoom)
                {
                    totalWetChemHours += hours;
                }
                else if (room == LabRoom.TestLab)
                {
                    totalTestLabHours += hours;
                }
                else if (room == LabRoom.OrganicsBay)
                {
                    totalOrganicsHours += hours;
                }
                else if (room == LabRoom.LNF)
                {
                    totalLnfHours += hours;
                }
            }

            string lnfName = "LNF";
            string cleanRoomName = "Clean Room";
            string wetChemName   = "ROBIN";

            lblRoomHours.Text = $"|  {lnfName}: {totalLnfHours:#0.00} hours, {cleanRoomName}: {totalCleanRoomHours:#0.00} hours, {wetChemName}: {totalWetChemHours:#0.00} hours";

            lblRoomsSum.Text = string.Empty;
            if (dtRoom.Rows.Count > 0)
            {
                double totalRoomCharge = Convert.ToDouble(dtRoom.Compute("SUM(LineCost)", string.Empty));
                lblRoom.Text = string.Format("Total room usage fees: {0:$#,##0.00}", totalRoomCharge);
                UpdateRoomSums(dtRoom, lblRoomsSum);
            }
            else
            {
                lblRoom.Text = "No room usage in this period";
            }

            lblRoom.Visible = true;
        }
        public static decimal GetTotalCostByBillingType(int billingTypeId, decimal hours, decimal entries, LabRoom room, decimal totalCalcCost, decimal totalHours = 0)
        {
            decimal result = 0;

            if (room == LabRoom.CleanRoom)
            {
                if (billingTypeId == BillingTypes.Int_Ga)
                {
                    if (totalHours > 0)
                    {
                        return((hours / totalHours) * 875);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (billingTypeId == BillingTypes.Int_Si)
                {
                    if (totalHours > 0)
                    {
                        return((hours / totalHours) * 1315);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (billingTypeId == BillingTypes.Int_Hour)
                {
                    return(2.5M * entries + 15 * hours);
                }
                else if (billingTypeId == BillingTypes.Int_Tools)
                {
                    return(2.5M * entries);
                }
                else if (billingTypeId == BillingTypes.ExtAc_Ga)
                {
                    if (totalHours > 0)
                    {
                        return((hours / totalHours) * 875);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (billingTypeId == BillingTypes.ExtAc_Si)
                {
                    if (totalHours > 0)
                    {
                        return((hours / totalHours) * 1315);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else if (billingTypeId == BillingTypes.ExtAc_Tools)
                {
                    return(2.5M * entries);
                }
                else if (billingTypeId == BillingTypes.ExtAc_Hour)
                {
                    return(2.5M * entries + 15 * hours);
                }
                else if (billingTypeId == BillingTypes.NonAc)
                {
                    return(hours * 77);
                }
                else if (billingTypeId == BillingTypes.NonAc_Tools)
                {
                    return(2.5M * hours);
                }
                else if (billingTypeId == BillingTypes.NonAc_Hour)
                {
                    return(2.5M * entries + 45 * hours);
                }
                else if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
            }
            else if (room == LabRoom.ChemRoom)
            {
                if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
                else if (billingTypeId >= BillingTypes.NonAc)
                {
                    if (hours > 0)
                    {
                        return(190);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    if (hours > 0)
                    {
                        if (totalHours > 0)
                        {
                            return((hours / totalHours) * 95);
                        }
                        else
                        {
                            return(95); //2009-05-07 For hourly users, it's possible for them to come here
                        }
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            else if (room == LabRoom.TestLab)
            {
                if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
                else if (billingTypeId >= BillingTypes.NonAc)
                {
                    if ((entries > 0 || hours > 0) && totalCalcCost > 0)
                    {
                        return(50);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    if ((entries > 0 || hours > 0) && totalCalcCost > 0)
                    {
                        return(25);
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            else if (room == LabRoom.OrganicsBay)
            {
                if (billingTypeId == BillingTypes.Other)
                {
                    return(0);
                }
                else if (billingTypeId >= BillingTypes.NonAc)
                {
                    if (entries > 0 || hours > 0)
                    {
                        return(190);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    if (entries > 0 || hours > 0)
                    {
                        return(95);
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            else
            {
                return(99999);
            }

            return(result);
        }