123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace WSUniversalLib
- {
- public class Calculation
- {
- public static int GetQuantityForProduct(int productType, int materialType,
- int count, float width, float length)
- {
- float materialCount = 0f;
- if (width == null)
- {
- throw new ArgumentNullException("ширина = Null");
- }
- if (length == null)
- {
- throw new ArgumentNullException("длинна = Null");
- }
- if (count < 0)
- {
- throw new ArgumentException("Количество < 0");
- }
- if (width < 0)
- {
- throw new ArgumentException("Ширина < 0");
- }
- if (length < 0)
- {
- throw new ArgumentException("Длинна < 0");
- }
- switch (productType)
- {
- case 1:
- materialCount = width * length * 1.1f * count;
- break;
- case 2:
- materialCount = width * length * 2.5f * count;
- break;
- case 3:
- materialCount = width * length * 8.43f * count;
- break;
- default:
- return -1;
- }
- switch (materialType)
- {
- case 1:
- materialCount *= 1.003f;
- break;
- case 2:
- materialCount *= 1.0012f;
- break;
- default:
- return -1;
- }
- return (int)Math.Ceiling((decimal)materialCount);
- }
- }
- }
|