Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.09 KB | None | 0 0
  1. procedure CalculateClick(Sender: TObject);
  2.     procedure FormCreate(Sender: TObject);
  3.   private
  4.     { Private declarations }
  5.   public
  6.     { Public declarations }
  7.   end;
  8.  
  9.   TMaterial = class
  10.   private
  11.   public
  12.     MatStr, ID, Color, Qty, SizeInFt, SizeInIn : String;
  13.   published
  14.     constructor Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String);
  15.     procedure DisplayListing();
  16.   end;
  17.  
  18. var
  19.   Form1: TForm1;
  20.   MatDict : TDictionary<String, TMaterial>;
  21.   Material, Value : TMaterial;
  22.   Key : String;
  23.  
  24.  
  25. implementation
  26.  
  27.  
  28. {$R *.fmx}
  29.  
  30. {$R *.NmXhdpiPh.fmx ANDROID}
  31.  
  32. {$R *.SmXhdpiPh.fmx ANDROID}
  33.  
  34. {$R *.LgXhdpiPh.fmx ANDROID}
  35.  
  36. {$R *.LgXhdpiTb.fmx ANDROID}
  37.  
  38.  
  39. constructor TMaterial.Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String); begin
  40.  
  41.   Self.ID := ID;
  42.   Self.Color := Color;
  43.   Self.Qty := Qty;
  44.   Self.SizeInFt := SizeInFt;
  45.   Self.SizeInIn := SizeInIn;
  46. end;
  47.  
  48. procedure TMaterial.DisplayListing(); begin
  49.   MatStr := Self.Qty + ' ' + Self.Color + ' ' + Self.ID + ' @ ' + Self.SizeI10t + #39 + Self.SizeInIn + '"';
  50.   Form1.Printoff.Items.Add(MatStr);
  51. end;
  52.  
  53. procedure AddMaterial(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String);
  54.  
  55. var
  56.     SizeFound : boolean;
  57.  
  58. begin
  59.   SizeFound := false;
  60.   for Key in MatDict.Keys do begin
  61.     if MatDict[Key].ID = ID then begin
  62.       if (MatDict[Key].SizeInFt = SizeInFt) and (MatDict[Key].SizeInIn = SizeInIn) then begin
  63.         SizeFound := true;
  64.       end;
  65.     end;
  66.  
  67.     if Key = IntToStr(MatDict.Count) then begin
  68.       if not SizeFound then begin
  69.         Material := TMaterial.Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn);
  70.  
  71.         MatDict.Add(IntToStr(MatDict.Count), Material);
  72.       end
  73.       else begin
  74.         MatDict[Key].Qty := MatDict[Key].Qty + Qty;
  75.       end;
  76.     end;
  77.   end;
  78. end;
  79.  
  80. procedure SetDivisible(Measurement, Divisible : Integer);
  81. begin
  82.   if Measurement mod 10 = 0 then begin
  83.     Divisible := 10;
  84.   end
  85.   else begin
  86.     Divisible := 12;
  87.   end;
  88. end;
  89.  
  90. procedure TForm1.CalculateClick(Sender: TObject);
  91.  
  92. var
  93.   Width, Length, Height : Integer;
  94.   RollUpWidth, RollUpHeight : Integer;
  95.   RollUpQty, WindowQty, WalkInQty : Integer;
  96.   RoofColor, WallColor, TrimColor : String;
  97.   Pitch : Integer;
  98.   WidthDiv, LengthDiv : Integer;
  99.   RollUpWidthDiv, RollUpHeightDiv : Integer;
  100.   GableFloat, Increment, GetDecimal : Double;
  101.   GetInch : Integer;
  102.   GableLength, RoofLength : Array of Integer;
  103.   RoofPocLength : Integer;
  104.   i : Integer;
  105.  
  106. begin
  107.  
  108.   WidthDiv := 10;
  109.   LengthDiv := 10;
  110.   RollUpWidthDiv := 10
  111.   RollUpHeightDiv := 10;
  112.  
  113.  
  114.   Pitch := StrToInt(PitchDrop.Text[1]);
  115.  
  116.   Width := StrToInt(BuildingWidth.Text); Length := StrToInt(BuildingLength.Text); Height := StrToInt(BuildingHeight.Text);
  117.  
  118.   RollUpWidth := StrToInt(RollUpDoorWidth.Text); RollUpHeight := StrToInt(RollUpDoorHeight.Text);
  119.  
  120.   RollUpQty := StrToInt(RollUpQuantity.Text); WindowQty := StrToInt(WindowQuantity.Text); WalkInQty := StrToInt(WalkInQuantity.Text);
  121.  
  122.   RoofColor := ColorForRoof.Text; WallColor := ColorForWalls.Text; TrimColor := ColorForTrim.Text;
  123.  
  124.   SetDivisible(Width, WidthDiv);
  125.   SetDivisible(Length, LengthDiv);
  126.   SetDivisible(RollUpWidth, RollUpWidthDiv);
  127.   SetDivisible(RollUpHeight, RollUpHeightDiv);
  128.  
  129.   case Pitch of
  130.     4 :    case Width of
  131.                   24 :  RoofLength := [12, 10];
  132.                   30 :  RoofLength := [16, 0];
  133.                   36 :  RoofLength := [19, 3];
  134.                   40 :  RoofLength := [21, 4];
  135.                   50 :  RoofLength := [26, 8];
  136.                 end;
  137.     5 :    case Width of
  138.                   24 :  RoofLength := [13, 4];
  139.                   30 :  RoofLength := [16, 7];
  140.                   36 :  RoofLength := [19, 10];
  141.                   40 :  RoofLength := [21, 11];
  142.                   50 :  RoofLength := [27, 4];
  143.                 end;
  144.     6 :    case Width of
  145.                   24 :  RoofLength := [13, 9];
  146.                   30 :  RoofLength := [17, 1];
  147.                   36 :  RoofLength := [20, 5];
  148.                   40 :  RoofLength := [22, 8];
  149.                   50 :  RoofLength := [28, 4];
  150.                 end;
  151.     7 :    case Width of
  152.                   24 :  RoofLength := [14, 2];
  153.                   30 :  RoofLength := [17, 8];
  154.                   36 :  RoofLength := [21, 2];
  155.                   40 :  RoofLength := [23, 6];
  156.                   50 :  RoofLength := [29, 3];
  157.                 end;
  158.   end;
  159.   Printoff.Clear;
  160.  
  161.   MatDict := TDictionary<String, TMaterial>.Create;
  162.  
  163.   case Pitch of
  164.     4  :   Increment := 0.0;
  165.     5  :   Increment := 0.25;
  166.     6  :   Increment := 0.5;
  167.     7  :   Increment := 0.75;
  168.   end;
  169.  
  170.   GableFloat := Height * 1.0;
  171.  
  172.   for i := Ceil((Width / 3) /2) -1 downto 0 do begin
  173.  
  174.     GableFloat := GableFloat + Increment;
  175.  
  176.     GetDecimal := GableFloat - Trunc(GableFloat);
  177.  
  178.     GetInch := GetInch * 4;
  179.     case GetInch of {Was mishap here.}
  180.       0   : GableLength := [4, 0];
  181.       1  : GableLength := [4, 3];
  182.       2   : GableLength := [4, 6];
  183.       3  : GableLength := [4, 9];
  184.     end;
  185.  
  186.     AddMaterial('Gable', 'Panel', RoofColor, IntToStr(4), IntToStr(GableLength[0]), IntToStr(GableLength[1]));
  187.   end;
  188.  
  189.   AddMaterial('RoofPanel', 'Panel', RoofColor, IntToStr((Ceil(Length / 3)) + Ceil(Length / 3)), IntToStr(RoofLength[0]), IntToStr(RoofLength[1]));
  190.  
  191.   AddMaterial('RoofPanel', 'Panel', RoofColor, IntToStr(Ceil(Length / 3) + Ceil(Length / 3)), IntToStr(Height), IntToStr(0));
  192.  
  193.   AddMaterial('RidgeCap', 'Ridge Cap', TrimColor, IntToStr(Ceil(Length div LengthDiv)), IntToStr(Ceil(((Length / 10) * 12) / (Length / LengthDiv))), IntToStr(0));
  194.  
  195.   AddMaterial('DoorTrim', 'Door Trim', TrimColor, IntToStr(Ceil(RollUpWidth div RollUpWidthDiv) * RollUpQty), IntToStr(RollUpWidthDiv), IntToStr(0));
  196.  
  197.   AddMaterial('DoorTrim', 'Door Trim', TrimColor, IntToStr((Ceil(RollUpHeight div RollUpHeightDiv) * 2) * RollUpQty), IntToStr(RollUpHeightDiv), IntToStr(0));
  198.  
  199.   AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr(Ceil(RollUpWidth div RollUpWidthDiv) * RollUpQty), IntToStr(RollUpWidthDiv), IntToStr(0));
  200.  
  201.   AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr((Ceil(RollUpHeight div RollUpHeightDiv) * 2) * RollUpQty), IntToStr(RollUpHeightDiv), IntToStr(0));
  202.  
  203.   AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr(((WindowQty * 2) + (WalkInQty * 2))), IntToStr(10), IntToStr(0));
  204.  
  205.   AddMaterial('RatGuard', 'Rat Guard', TrimColor, IntToStr(Ceil(Width div WidthDiv) + Ceil(Width div WidthDiv)), IntToStr(WidthDiv), IntToStr(0));
  206.  
  207.   AddMaterial('RatGuard', 'Rat Guard', TrimColor, IntToStr(Ceil(Length div LengthDiv) + Ceil(Length div LengthDiv)), IntToStr(LengthDiv), IntToStr(0));
  208.  
  209.   RoofPocLength := RoofLength[0];
  210.  
  211.   if RoofPocLength mod 2 <> 0 then begin
  212.     RoofPocLength := RoofPocLength + 1;
  213.   end;
  214.  
  215.   RoofPocLength := RoofPocLength + 2;
  216.  
  217.   if (RoofPocLength < 21) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(4), IntToStr(RoofPocLength), IntToStr(0)); end
  218.  
  219.   else if (RoofPocLength > 20) and (RoofPocLength <= 24) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(12), IntToStr(0)); end
  220.  
  221.   else if (RoofPocLength > 24) and (RoofPocLength <= 26) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(13), IntToStr(0)); end
  222.  
  223.   else if (RoofPocLength > 26) and (RoofPocLength <= 28) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(14), IntToStr(0)); end
  224.  
  225.   else if (RoofPocLength > 28) and (RoofPocLength <= 30) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(15), IntToStr(0)); end
  226.  
  227.   else if (RoofPocLength > 30) and (RoofPocLength <= 32) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(16), IntToStr(0)); end;
  228.  
  229.   AddMaterial('WallPOC', 'POC Corners', TrimColor, IntToStr(4), IntToStr(Height), IntToStr(0));
  230.  
  231.   AddMaterial('EaveTrim', 'Eave Trim', TrimColor, IntToStr(Ceil(Length div LengthDiv) + Ceil(Length div LengthDiv)), IntToStr(LengthDiv), IntToStr(0));
  232.  
  233.   for Key in MatDict.Keys do begin
  234.     MatDict[Key].DisplayListing();
  235.   end;
  236.  
  237.   MatDict.Clear;
  238.   MatDict.Free;
  239.   Material.Free;
  240.   TabControl1.Next();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement