| 1 | //kt -- Modified with SourceScanner on 8/8/2007 | 
|---|
| 2 | unit fODValidateAction; | 
|---|
| 3 |  | 
|---|
| 4 | interface | 
|---|
| 5 |  | 
|---|
| 6 | uses | 
|---|
| 7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, | 
|---|
| 8 | ORFn, uCore, StdCtrls, CheckLst, ComCtrls,ExtCtrls,uConst, ORCtrls, | 
|---|
| 9 | DKLang; | 
|---|
| 10 |  | 
|---|
| 11 | type | 
|---|
| 12 | TfrmInvalidActionList = class(TForm) | 
|---|
| 13 | pnlTop: TPanel; | 
|---|
| 14 | lstActDeniedOrders: TCaptionListBox; | 
|---|
| 15 | Label1: TLabel; | 
|---|
| 16 | hdrAction: THeaderControl; | 
|---|
| 17 | pnlBottom: TPanel; | 
|---|
| 18 | Label2: TLabel; | 
|---|
| 19 | lstValidOrders: TCaptionListBox; | 
|---|
| 20 | Panel1: TPanel; | 
|---|
| 21 | btnOK: TButton; | 
|---|
| 22 | DKLanguageController1: TDKLanguageController; | 
|---|
| 23 | procedure lstActDeniedOrdersDrawItem(Control: TWinControl; | 
|---|
| 24 | Index: Integer; TheRect: TRect; State: TOwnerDrawState); | 
|---|
| 25 | procedure lstActDeniedOrdersMeasureItem(Control: TWinControl; | 
|---|
| 26 | Index: Integer; var AHeight: Integer); | 
|---|
| 27 | procedure btnOKClick(Sender: TObject); | 
|---|
| 28 | procedure FormCreate(Sender: TObject); | 
|---|
| 29 | procedure hdrActionSectionResize(HeaderControl: THeaderControl; | 
|---|
| 30 | Section: THeaderSection); | 
|---|
| 31 | procedure lstValidOrdersMeasureItem(Control: TWinControl; | 
|---|
| 32 | Index: Integer; var AHeight: Integer); | 
|---|
| 33 | procedure lstValidOrdersDrawItem(Control: TWinControl; Index: Integer; | 
|---|
| 34 | TheRect: TRect; State: TOwnerDrawState); | 
|---|
| 35 | procedure FormResize(Sender: TObject); | 
|---|
| 36 | private | 
|---|
| 37 | { Private declarations } | 
|---|
| 38 | TheInvaList: TStringList; | 
|---|
| 39 | procedure RedrawActiveList; | 
|---|
| 40 | public | 
|---|
| 41 | { Public declarations } | 
|---|
| 42 | end; | 
|---|
| 43 |  | 
|---|
| 44 | procedure DisplayOrdersForAction(TheInvalidList: TStringList; TheValidList: TStringList; TheAction: String); | 
|---|
| 45 |  | 
|---|
| 46 | implementation | 
|---|
| 47 |  | 
|---|
| 48 | {$R *.DFM} | 
|---|
| 49 |  | 
|---|
| 50 | procedure DisplayOrdersForAction(TheInvalidList: TStringList; TheValidList: TStringList; TheAction: String); | 
|---|
| 51 | var | 
|---|
| 52 | frmInvalidActionList: TfrmInvalidActionList; | 
|---|
| 53 | i: integer; | 
|---|
| 54 | begin | 
|---|
| 55 | frmInvalidActionList := TfrmInvalidActionList.Create(Application); | 
|---|
| 56 | frmInvalidActionList.TheInvaList :=TheInvalidList; | 
|---|
| 57 | if TheAction = OA_CHGEVT then | 
|---|
| 58 | begin | 
|---|
| 59 | //  frmInvalidActionList.Caption  := 'Change Release Event';  <-- original line.  //kt 8/8/2007 | 
|---|
| 60 | frmInvalidActionList.Caption  := DKLangConstW('fODValidateAction_Change_Release_Event'); //kt added 8/8/2007 | 
|---|
| 61 | //  frmInvalidActionList.Label1.Caption := 'You can not change the release event for the following orders.';  <-- original line.  //kt 8/8/2007 | 
|---|
| 62 | frmInvalidActionList.Label1.Caption := DKLangConstW('fODValidateAction_You_can_not_change_the_release_event_for_the_following_ordersx'); //kt added 8/8/2007 | 
|---|
| 63 | //  frmInvalidActionList.Label2.Caption := 'You can change the release event for the following orders.';  <-- original line.  //kt 8/8/2007 | 
|---|
| 64 | frmInvalidActionList.Label2.Caption := DKLangConstW('fODValidateAction_You_can_change_the_release_event_for_the_following_ordersx'); //kt added 8/8/2007 | 
|---|
| 65 | end; | 
|---|
| 66 | if TheAction = OA_EDREL then | 
|---|
| 67 | begin | 
|---|
| 68 | //  frmInvalidActionList.Caption  := 'Release Order(s) To Service';  <-- original line.  //kt 8/8/2007 | 
|---|
| 69 | frmInvalidActionList.Caption  := DKLangConstW('fODValidateAction_Release_Orderxsx_To_Service'); //kt added 8/8/2007 | 
|---|
| 70 | //  frmInvalidActionList.Label1.Caption := 'You can not release the following orders to service.';  <-- original line.  //kt 8/8/2007 | 
|---|
| 71 | frmInvalidActionList.Label1.Caption := DKLangConstW('fODValidateAction_You_can_not_release_the_following_orders_to_servicex'); //kt added 8/8/2007 | 
|---|
| 72 | //  frmInvalidActionList.Label2.Caption := 'You can release the following orders to service.';  <-- original line.  //kt 8/8/2007 | 
|---|
| 73 | frmInvalidActionList.Label2.Caption := DKLangConstW('fODValidateAction_You_can_release_the_following_orders_to_servicex'); //kt added 8/8/2007 | 
|---|
| 74 | end; | 
|---|
| 75 | for i := 0 to TheInvalidList.Count - 1 do | 
|---|
| 76 | begin | 
|---|
| 77 | frmInvalidActionList.lstActDeniedOrders.Items.Add(Piece(TheInvalidList[i], U, 1) + ' ' + Piece(TheInvalidList[i], U, 2)); | 
|---|
| 78 | end; | 
|---|
| 79 | for i := 0 to TheValidList.Count - 1 do | 
|---|
| 80 | begin | 
|---|
| 81 | frmInvalidActionList.lstValidOrders.Items.Add(TheValidList[i]); | 
|---|
| 82 | end; | 
|---|
| 83 | if TheValidList.Count = 0 then | 
|---|
| 84 | begin | 
|---|
| 85 | frmInvalidActionList.lstValidOrders.Visible := False; | 
|---|
| 86 | frmInvalidActionList.pnlBottom.Visible := False; | 
|---|
| 87 | frmInvalidActionList.Height := frmInvalidActionList.Height - frmInvalidActionList.pnlBottom.Height; | 
|---|
| 88 | end; | 
|---|
| 89 | Beep; | 
|---|
| 90 | frmInvalidActionList.ShowModal; | 
|---|
| 91 | frmInvalidActionList.TheInvaList.Free; | 
|---|
| 92 | end; | 
|---|
| 93 |  | 
|---|
| 94 | procedure TfrmInvalidActionList.lstActDeniedOrdersDrawItem( | 
|---|
| 95 | Control: TWinControl; Index: Integer; TheRect: TRect; | 
|---|
| 96 | State: TOwnerDrawState); | 
|---|
| 97 | var | 
|---|
| 98 | x,x1,x2: string; | 
|---|
| 99 | ARect: TRect; | 
|---|
| 100 | i,RightSide: integer; | 
|---|
| 101 | SaveColor: TColor; | 
|---|
| 102 | begin | 
|---|
| 103 | inherited; | 
|---|
| 104 | with lstActDeniedOrders do | 
|---|
| 105 | begin | 
|---|
| 106 | ARect := TheRect; | 
|---|
| 107 | Canvas.FillRect(ARect); | 
|---|
| 108 | Canvas.Pen.Color := clSilver; | 
|---|
| 109 | Canvas.MoveTo(ARect.Left, ARect.Bottom - 1); | 
|---|
| 110 | Canvas.LineTo(ARect.Right, ARect.Bottom - 1); | 
|---|
| 111 | RightSide := -2; | 
|---|
| 112 | for i := 0 to 1 do | 
|---|
| 113 | begin | 
|---|
| 114 | RightSide := RightSide + hdrAction.Sections[i].Width; | 
|---|
| 115 | Canvas.MoveTo(RightSide, ARect.Bottom - 1); | 
|---|
| 116 | Canvas.LineTo(RightSide, ARect.Top); | 
|---|
| 117 | end; | 
|---|
| 118 | if Index < Items.Count then | 
|---|
| 119 | begin | 
|---|
| 120 | x1 := FilteredString(Piece(TheInvaList[index],'^',1)); | 
|---|
| 121 | x2 := Piece(TheInvaList[index],'^',2); | 
|---|
| 122 | for i := 0 to 1 do | 
|---|
| 123 | begin | 
|---|
| 124 | if i > 0 then ARect.Left := ARect.Right + 2 else ARect.Left := 2; | 
|---|
| 125 | ARect.Right := ARect.Left + hdrAction.Sections[i].Width - 6; | 
|---|
| 126 | SaveColor := Canvas.Brush.Color; | 
|---|
| 127 | if i = 0 then | 
|---|
| 128 | x := x1; | 
|---|
| 129 | if i = 1 then | 
|---|
| 130 | x := x2; | 
|---|
| 131 | DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK); | 
|---|
| 132 | Canvas.Brush.Color := SaveColor; | 
|---|
| 133 | ARect.Right := ARect.Right + 4; | 
|---|
| 134 | end; | 
|---|
| 135 | end; | 
|---|
| 136 | end; | 
|---|
| 137 | end; | 
|---|
| 138 |  | 
|---|
| 139 | procedure TfrmInvalidActionList.lstActDeniedOrdersMeasureItem( | 
|---|
| 140 | Control: TWinControl; Index: Integer; var AHeight: Integer); | 
|---|
| 141 | var | 
|---|
| 142 | x1,x2: string; | 
|---|
| 143 | ARect: TRect; | 
|---|
| 144 | TextHeight, ReasonHeight, NewHeight: Integer; | 
|---|
| 145 | begin | 
|---|
| 146 | inherited; | 
|---|
| 147 | AHeight := MainFontHeight + 2; | 
|---|
| 148 | NewHeight := AHeight; | 
|---|
| 149 | with lstActDeniedOrders do if Index < Items.Count then | 
|---|
| 150 | begin | 
|---|
| 151 | x1 := FilteredString(Piece(TheInvaList[index],'^',1)); | 
|---|
| 152 | x2 := Piece(TheInvaList[index],'^',2); | 
|---|
| 153 |  | 
|---|
| 154 | ARect := ItemRect(Index); | 
|---|
| 155 | ARect.Right := hdrAction.Sections[0].Width - 6; | 
|---|
| 156 | ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0; | 
|---|
| 157 | TextHeight := DrawText(Canvas.Handle, PChar(x1), Length(x1), ARect, | 
|---|
| 158 | DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2; | 
|---|
| 159 |  | 
|---|
| 160 | ARect := ItemRect(Index); | 
|---|
| 161 | ARect.Right := hdrAction.Sections[1].Width - 6; | 
|---|
| 162 | ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0; | 
|---|
| 163 | ReasonHeight := DrawText(Canvas.Handle, PChar(x2), Length(x2), ARect, | 
|---|
| 164 | DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2; | 
|---|
| 165 | NewHeight := HigherOf(TextHeight, ReasonHeight); | 
|---|
| 166 | if NewHeight > 255 then NewHeight := 255; | 
|---|
| 167 | if NewHeight <  13 then NewHeight := 13; | 
|---|
| 168 | end; | 
|---|
| 169 | AHeight := NewHeight; | 
|---|
| 170 | end; | 
|---|
| 171 |  | 
|---|
| 172 | procedure TfrmInvalidActionList.btnOKClick(Sender: TObject); | 
|---|
| 173 | begin | 
|---|
| 174 | Close; | 
|---|
| 175 | end; | 
|---|
| 176 |  | 
|---|
| 177 | procedure TfrmInvalidActionList.FormCreate(Sender: TObject); | 
|---|
| 178 | begin | 
|---|
| 179 | TheInvaList := TStringList.Create; | 
|---|
| 180 | end; | 
|---|
| 181 |  | 
|---|
| 182 | procedure TfrmInvalidActionList.hdrActionSectionResize( | 
|---|
| 183 | HeaderControl: THeaderControl; Section: THeaderSection); | 
|---|
| 184 | begin | 
|---|
| 185 | inherited; | 
|---|
| 186 | RedrawSuspend(Self.Handle); | 
|---|
| 187 | RedrawActiveList; | 
|---|
| 188 | RedrawActivate(Self.Handle); | 
|---|
| 189 | lstActDeniedOrders.Invalidate; | 
|---|
| 190 | end; | 
|---|
| 191 |  | 
|---|
| 192 | procedure TfrmInvalidActionList.RedrawActiveList; | 
|---|
| 193 | var | 
|---|
| 194 | i, SaveTop: Integer; | 
|---|
| 195 | begin | 
|---|
| 196 | with lstActDeniedOrders do | 
|---|
| 197 | begin | 
|---|
| 198 | RedrawSuspend(Handle); | 
|---|
| 199 | SaveTop := TopIndex; | 
|---|
| 200 | Clear; | 
|---|
| 201 | for i := 0 to TheInvaList.Count - 1 do | 
|---|
| 202 | Items.Add(Piece(TheInvaList[i], U, 1) + ' ' + Piece(TheInvaList[i], U, 2)); | 
|---|
| 203 | TopIndex := SaveTop; | 
|---|
| 204 | RedrawActivate(Handle); | 
|---|
| 205 | end; | 
|---|
| 206 | end; | 
|---|
| 207 |  | 
|---|
| 208 | procedure TfrmInvalidActionList.lstValidOrdersMeasureItem( | 
|---|
| 209 | Control: TWinControl; Index: Integer; var AHeight: Integer); | 
|---|
| 210 | var | 
|---|
| 211 | x: string; | 
|---|
| 212 | ARect: TRect; | 
|---|
| 213 | NewHeight: Integer; | 
|---|
| 214 | begin | 
|---|
| 215 | inherited; | 
|---|
| 216 | AHeight := MainFontHeight + 2; | 
|---|
| 217 | NewHeight := AHeight; | 
|---|
| 218 | with lstValidOrders do if Index < Items.Count then | 
|---|
| 219 | begin | 
|---|
| 220 | x := FilteredString(lstValidOrders.Items[index]); | 
|---|
| 221 | ARect := ItemRect(Index); | 
|---|
| 222 | ARect.Right := hdrAction.Sections[0].Width - 6; | 
|---|
| 223 | ARect.Left := 0; ARect.Top := 0; ARect.Bottom := 0; | 
|---|
| 224 | NewHeight := DrawText(Canvas.Handle, PChar(x), Length(x), ARect, | 
|---|
| 225 | DT_CALCRECT or DT_LEFT or DT_NOPREFIX or DT_WORDBREAK) + 2; | 
|---|
| 226 | if NewHeight > 255 then NewHeight := 255; | 
|---|
| 227 | if NewHeight <  13 then NewHeight := 13; | 
|---|
| 228 | end; | 
|---|
| 229 | AHeight := NewHeight; | 
|---|
| 230 | end; | 
|---|
| 231 |  | 
|---|
| 232 | procedure TfrmInvalidActionList.lstValidOrdersDrawItem( | 
|---|
| 233 | Control: TWinControl; Index: Integer; TheRect: TRect; | 
|---|
| 234 | State: TOwnerDrawState); | 
|---|
| 235 | var | 
|---|
| 236 | x: string; | 
|---|
| 237 | ARect: TRect; | 
|---|
| 238 | SaveColor: TColor; | 
|---|
| 239 | begin | 
|---|
| 240 | inherited; | 
|---|
| 241 | with lstValidOrders do | 
|---|
| 242 | begin | 
|---|
| 243 | ARect := TheRect; | 
|---|
| 244 | Canvas.FillRect(ARect); | 
|---|
| 245 | Canvas.Pen.Color := clSilver; | 
|---|
| 246 | SaveColor := Canvas.Brush.Color; | 
|---|
| 247 | Canvas.MoveTo(ARect.Left, ARect.Bottom - 1); | 
|---|
| 248 | Canvas.LineTo(ARect.Right, ARect.Bottom - 1); | 
|---|
| 249 | if Index < Items.Count then | 
|---|
| 250 | begin | 
|---|
| 251 | x := FilteredString(lstValidOrders.Items[index]); | 
|---|
| 252 | DrawText(Canvas.Handle, PChar(x), Length(x), ARect, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK); | 
|---|
| 253 | Canvas.Brush.Color := SaveColor; | 
|---|
| 254 | ARect.Right := ARect.Right + 4; | 
|---|
| 255 | end; | 
|---|
| 256 | end; | 
|---|
| 257 | end; | 
|---|
| 258 |  | 
|---|
| 259 | procedure TfrmInvalidActionList.FormResize(Sender: TObject); | 
|---|
| 260 | begin | 
|---|
| 261 | if pnlBottom.Visible then | 
|---|
| 262 | pnlTop.Height := (Height div 5 ) * 2 | 
|---|
| 263 | end; | 
|---|
| 264 |  | 
|---|
| 265 | end. | 
|---|