Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure CalculateClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- TMaterial = class
- private
- public
- MatStr, ID, Color, Qty, SizeInFt, SizeInIn : String;
- published
- constructor Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String);
- procedure DisplayListing();
- end;
- var
- Form1: TForm1;
- MatDict : TDictionary<String, TMaterial>;
- Material, Value : TMaterial;
- Key : String;
- implementation
- {$R *.fmx}
- {$R *.NmXhdpiPh.fmx ANDROID}
- {$R *.SmXhdpiPh.fmx ANDROID}
- {$R *.LgXhdpiPh.fmx ANDROID}
- {$R *.LgXhdpiTb.fmx ANDROID}
- constructor TMaterial.Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String); begin
- Self.ID := ID;
- Self.Color := Color;
- Self.Qty := Qty;
- Self.SizeInFt := SizeInFt;
- Self.SizeInIn := SizeInIn;
- end;
- procedure TMaterial.DisplayListing(); begin
- MatStr := Self.Qty + ' ' + Self.Color + ' ' + Self.ID + ' @ ' + Self.SizeI10t + #39 + Self.SizeInIn + '"';
- Form1.Printoff.Items.Add(MatStr);
- end;
- procedure AddMaterial(MatType, ID, Color, Qty, SizeInFt, SizeInIn : String);
- var
- SizeFound : boolean;
- begin
- SizeFound := false;
- for Key in MatDict.Keys do begin
- if MatDict[Key].ID = ID then begin
- if (MatDict[Key].SizeInFt = SizeInFt) and (MatDict[Key].SizeInIn = SizeInIn) then begin
- SizeFound := true;
- end;
- end;
- if Key = IntToStr(MatDict.Count) then begin
- if not SizeFound then begin
- Material := TMaterial.Create(MatType, ID, Color, Qty, SizeInFt, SizeInIn);
- MatDict.Add(IntToStr(MatDict.Count), Material);
- end
- else begin
- MatDict[Key].Qty := MatDict[Key].Qty + Qty;
- end;
- end;
- end;
- end;
- procedure SetDivisible(Measurement, Divisible : Integer);
- begin
- if Measurement mod 10 = 0 then begin
- Divisible := 10;
- end
- else begin
- Divisible := 12;
- end;
- end;
- procedure TForm1.CalculateClick(Sender: TObject);
- var
- Width, Length, Height : Integer;
- RollUpWidth, RollUpHeight : Integer;
- RollUpQty, WindowQty, WalkInQty : Integer;
- RoofColor, WallColor, TrimColor : String;
- Pitch : Integer;
- WidthDiv, LengthDiv : Integer;
- RollUpWidthDiv, RollUpHeightDiv : Integer;
- GableFloat, Increment, GetDecimal : Double;
- GetInch : Integer;
- GableLength, RoofLength : Array of Integer;
- RoofPocLength : Integer;
- i : Integer;
- begin
- WidthDiv := 10;
- LengthDiv := 10;
- RollUpWidthDiv := 10
- RollUpHeightDiv := 10;
- Pitch := StrToInt(PitchDrop.Text[1]);
- Width := StrToInt(BuildingWidth.Text); Length := StrToInt(BuildingLength.Text); Height := StrToInt(BuildingHeight.Text);
- RollUpWidth := StrToInt(RollUpDoorWidth.Text); RollUpHeight := StrToInt(RollUpDoorHeight.Text);
- RollUpQty := StrToInt(RollUpQuantity.Text); WindowQty := StrToInt(WindowQuantity.Text); WalkInQty := StrToInt(WalkInQuantity.Text);
- RoofColor := ColorForRoof.Text; WallColor := ColorForWalls.Text; TrimColor := ColorForTrim.Text;
- SetDivisible(Width, WidthDiv);
- SetDivisible(Length, LengthDiv);
- SetDivisible(RollUpWidth, RollUpWidthDiv);
- SetDivisible(RollUpHeight, RollUpHeightDiv);
- case Pitch of
- 4 : case Width of
- 24 : RoofLength := [12, 10];
- 30 : RoofLength := [16, 0];
- 36 : RoofLength := [19, 3];
- 40 : RoofLength := [21, 4];
- 50 : RoofLength := [26, 8];
- end;
- 5 : case Width of
- 24 : RoofLength := [13, 4];
- 30 : RoofLength := [16, 7];
- 36 : RoofLength := [19, 10];
- 40 : RoofLength := [21, 11];
- 50 : RoofLength := [27, 4];
- end;
- 6 : case Width of
- 24 : RoofLength := [13, 9];
- 30 : RoofLength := [17, 1];
- 36 : RoofLength := [20, 5];
- 40 : RoofLength := [22, 8];
- 50 : RoofLength := [28, 4];
- end;
- 7 : case Width of
- 24 : RoofLength := [14, 2];
- 30 : RoofLength := [17, 8];
- 36 : RoofLength := [21, 2];
- 40 : RoofLength := [23, 6];
- 50 : RoofLength := [29, 3];
- end;
- end;
- Printoff.Clear;
- MatDict := TDictionary<String, TMaterial>.Create;
- case Pitch of
- 4 : Increment := 0.0;
- 5 : Increment := 0.25;
- 6 : Increment := 0.5;
- 7 : Increment := 0.75;
- end;
- GableFloat := Height * 1.0;
- for i := Ceil((Width / 3) /2) -1 downto 0 do begin
- GableFloat := GableFloat + Increment;
- GetDecimal := GableFloat - Trunc(GableFloat);
- GetInch := GetInch * 4;
- case GetInch of {Was mishap here.}
- 0 : GableLength := [4, 0];
- 1 : GableLength := [4, 3];
- 2 : GableLength := [4, 6];
- 3 : GableLength := [4, 9];
- end;
- AddMaterial('Gable', 'Panel', RoofColor, IntToStr(4), IntToStr(GableLength[0]), IntToStr(GableLength[1]));
- end;
- AddMaterial('RoofPanel', 'Panel', RoofColor, IntToStr((Ceil(Length / 3)) + Ceil(Length / 3)), IntToStr(RoofLength[0]), IntToStr(RoofLength[1]));
- AddMaterial('RoofPanel', 'Panel', RoofColor, IntToStr(Ceil(Length / 3) + Ceil(Length / 3)), IntToStr(Height), IntToStr(0));
- AddMaterial('RidgeCap', 'Ridge Cap', TrimColor, IntToStr(Ceil(Length div LengthDiv)), IntToStr(Ceil(((Length / 10) * 12) / (Length / LengthDiv))), IntToStr(0));
- AddMaterial('DoorTrim', 'Door Trim', TrimColor, IntToStr(Ceil(RollUpWidth div RollUpWidthDiv) * RollUpQty), IntToStr(RollUpWidthDiv), IntToStr(0));
- AddMaterial('DoorTrim', 'Door Trim', TrimColor, IntToStr((Ceil(RollUpHeight div RollUpHeightDiv) * 2) * RollUpQty), IntToStr(RollUpHeightDiv), IntToStr(0));
- AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr(Ceil(RollUpWidth div RollUpWidthDiv) * RollUpQty), IntToStr(RollUpWidthDiv), IntToStr(0));
- AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr((Ceil(RollUpHeight div RollUpHeightDiv) * 2) * RollUpQty), IntToStr(RollUpHeightDiv), IntToStr(0));
- AddMaterial('JChannel', 'J Channel', TrimColor, IntToStr(((WindowQty * 2) + (WalkInQty * 2))), IntToStr(10), IntToStr(0));
- AddMaterial('RatGuard', 'Rat Guard', TrimColor, IntToStr(Ceil(Width div WidthDiv) + Ceil(Width div WidthDiv)), IntToStr(WidthDiv), IntToStr(0));
- AddMaterial('RatGuard', 'Rat Guard', TrimColor, IntToStr(Ceil(Length div LengthDiv) + Ceil(Length div LengthDiv)), IntToStr(LengthDiv), IntToStr(0));
- RoofPocLength := RoofLength[0];
- if RoofPocLength mod 2 <> 0 then begin
- RoofPocLength := RoofPocLength + 1;
- end;
- RoofPocLength := RoofPocLength + 2;
- if (RoofPocLength < 21) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(4), IntToStr(RoofPocLength), IntToStr(0)); end
- else if (RoofPocLength > 20) and (RoofPocLength <= 24) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(12), IntToStr(0)); end
- else if (RoofPocLength > 24) and (RoofPocLength <= 26) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(13), IntToStr(0)); end
- else if (RoofPocLength > 26) and (RoofPocLength <= 28) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(14), IntToStr(0)); end
- else if (RoofPocLength > 28) and (RoofPocLength <= 30) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(15), IntToStr(0)); end
- else if (RoofPocLength > 30) and (RoofPocLength <= 32) then begin AddMaterial('RoofPOC', 'POC Corners', TrimColor, IntToStr(8), IntToStr(16), IntToStr(0)); end;
- AddMaterial('WallPOC', 'POC Corners', TrimColor, IntToStr(4), IntToStr(Height), IntToStr(0));
- AddMaterial('EaveTrim', 'Eave Trim', TrimColor, IntToStr(Ceil(Length div LengthDiv) + Ceil(Length div LengthDiv)), IntToStr(LengthDiv), IntToStr(0));
- for Key in MatDict.Keys do begin
- MatDict[Key].DisplayListing();
- end;
- MatDict.Clear;
- MatDict.Free;
- Material.Free;
- TabControl1.Next();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement