Calculation.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace WSUniversalLib
  7. {
  8. public class Calculation
  9. {
  10. public static int GetQuantityForProduct(int productType, int materialType, int count, float width, float length)
  11. {
  12. double sqaure = width * length;
  13. double quantity;
  14. switch(productType)
  15. {
  16. case 1:
  17. quantity = sqaure * 1.1;
  18. break;
  19. case 2:
  20. quantity = sqaure * 2.5;
  21. break;
  22. case 3:
  23. quantity = sqaure * 8.43;
  24. break;
  25. default:
  26. return -1;
  27. break;
  28. }
  29. quantity = quantity * count;
  30. switch(materialType)
  31. {
  32. case 1:
  33. quantity = quantity * 1.003;
  34. break;
  35. case 2:
  36. quantity = quantity * 1.0012;
  37. break;
  38. default:
  39. return -1;
  40. break;
  41. }
  42. return Convert.ToInt32(Math.Ceiling(quantity));
  43. }
  44. }
  45. }