Pridana funkcnost zmeny planovaneho ukonceni prikazu podle tabulky (comObject akce 36) + prvni verze generovani KoopObj dle stare HDC funkcnosti ctecky
This commit is contained in:
@@ -0,0 +1,171 @@
|
||||
unit frmVPrZmenaPlanuUkonceni;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, NxGridView6, NxColumns6,
|
||||
NxControls6, NxCustomGrid6, NxVirtualGrid6, NxGrid6,
|
||||
ddPlugin_TLB;
|
||||
|
||||
type
|
||||
TformVPrZmenaPlanuUkonceni = class(TForm)
|
||||
grdPrikazy: TNextGrid6;
|
||||
cbZmenaVPlanu: TCheckBox;
|
||||
dtPlanUkonceni: TDateTimePicker;
|
||||
Label1: TLabel;
|
||||
lblPrikaz: TLabel;
|
||||
Label2: TLabel;
|
||||
btnOK: TButton;
|
||||
btnStorno: TButton;
|
||||
grdPrikazyView: TNxReportGridView6;
|
||||
colZmena: TNxCheckBoxColumn6;
|
||||
colRadaPrikaz: TNxTextColumn6;
|
||||
colNazev1: TNxTextColumn6;
|
||||
lblDilec: TLabel;
|
||||
colID: TNxIncrementColumn6;
|
||||
procedure FormShow (Sender: TObject);
|
||||
procedure btnStornoClick (Sender: TObject);
|
||||
procedure btnOKClick (Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
Helios: IHelios;
|
||||
idVPr: integer;
|
||||
end;
|
||||
|
||||
var
|
||||
formVPrZmenaPlanuUkonceni: TformVPrZmenaPlanuUkonceni;
|
||||
|
||||
|
||||
implementation
|
||||
uses System.StrUtils,
|
||||
helUtils;
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
|
||||
|
||||
procedure TformVPrZmenaPlanuUkonceni.btnOKClick (Sender: TObject);
|
||||
var lSQL: string;
|
||||
i: integer;
|
||||
zmeny, eMsg: string;
|
||||
canCont: boolean;
|
||||
begin
|
||||
zmeny := '';
|
||||
for i:=0 to grdPrikazy.RowCount-1 do
|
||||
zmeny := zmeny + IfThen(grdPrikazy.Cell[0, i].AsBoolean, '1', '0') + ',';
|
||||
if (zmeny<>'') then
|
||||
zmeny := LeftStr(zmeny, zmeny.Length-1); // odstran koncovou carku
|
||||
|
||||
canCont := true;
|
||||
if (zmeny.LastIndexOf('0')<zmeny.LastIndexOf('1')) then
|
||||
canCont := false;
|
||||
|
||||
if (canCont) then
|
||||
begin
|
||||
eMsg := '';
|
||||
lSQL := 'DECLARE @eMsg NVARCHAR(500)=N''''' + CRLF + 'DROP TABLE IF EXISTS #TabPrikazyZmenaUkonceni' + CRLF
|
||||
+ 'CREATE TABLE #TabPrikazyZmenaUkonceni (ID INT IDENTITY(1,1) NOT NULL, RadaPrikaz NVARCHAR(50) NOT NULL)' + CRLF;
|
||||
|
||||
for i:=0 to grdPrikazy.RowCount-1 do
|
||||
if (grdPrikazy.Cell [0, i].AsBoolean) then
|
||||
lSQL := lSQL + 'INSERT #TabPrikazyZmenaUkonceni (RadaPrikaz) SELECT N' + grdPrikazy.Cells [1, i].QuotedString + CRLF;
|
||||
|
||||
lSQL := lSQL + 'IF OBJECT_ID(N''dbo.ep_HDC_Vyroba_Prikazy_ZmenaPlanuUkonceni'', ''P'') IS NOT NULL EXEC dbo.ep_HDC_Vyroba_Prikazy_ZmenaPlanuUkonceni @idPrikaz=' + idVpr.ToString
|
||||
+ ', @datPlanUkonceni=N' + FormatDateTime('dd.mm.yyyy', dtPlanUkonceni.Date).QuotedString + ', @zmenaDoPlanu=' + IfThen(cbZmenaVPlanu.Checked, '1', '0')
|
||||
+ ', @errMsg=@eMsg OUT' + CRLF + 'SELECT @eMsg AS ErrMsg';
|
||||
try
|
||||
with Helios.OpenSQL (lSQL) do
|
||||
if (RecordCount>0) then
|
||||
eMsg := FieldByNameValues('ErrMsg')
|
||||
else
|
||||
eMsg := 'Nemám zpìtnou vazbu z výpoètu dat zahájení/ukonèení';
|
||||
if (eMsg<>'') then
|
||||
Helios.Error (#1 + eMsg + #1)
|
||||
else
|
||||
Close;
|
||||
except on E:Exception do
|
||||
Helios.Error (#1'Chyba zpracování: '#1 + E.Message);
|
||||
end;
|
||||
end
|
||||
else
|
||||
Helios.Error (#1'V øadì pøíkazù s povolenou zmìnou plánovaného data ukonèení nesmí být pøíkaz bez zmìny.'#1);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure TformVPrZmenaPlanuUkonceni.btnStornoClick (Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure TformVPrZmenaPlanuUkonceni.FormShow (Sender: TObject);
|
||||
var lSQL: string;
|
||||
pSZ, pRC, pNazev1, pRPr: string;
|
||||
pStav, pUroven: byte;
|
||||
cnt: integer;
|
||||
begin
|
||||
grdPrikazy.RowCount := 0;
|
||||
self.Height := 325;
|
||||
lblPrikaz.Caption := '';
|
||||
lblDilec.Caption := '';
|
||||
|
||||
dtPlanUkonceni.Date := Now;
|
||||
|
||||
if (idVPr>0) then
|
||||
begin
|
||||
pSZ := '';
|
||||
|
||||
lSQL := 'SELECT p.RadaPrikaz, k.SkupZbo, k.RegCis, k.Nazev1, p.StavPrikazu, p.UrovenVnoreni, p.Plan_ukonceni_X FROM ' + tblVPr + ' p JOIN ' + tblKZ
|
||||
+ ' k ON (k.ID=p.IDTabKmen) WHERE p.ID=' + idVPr.ToString;
|
||||
with Helios.OpenSQL (lSQL) do
|
||||
if not(EOF) then
|
||||
begin
|
||||
First;
|
||||
pSZ := FieldByNameValues('SkupZbo');
|
||||
pRC := FieldByNameValues('RegCis');
|
||||
pNazev1 := FieldByNameValues('Nazev1');
|
||||
pRPr := FieldByNameValues('RadaPrikaz');
|
||||
pStav := FieldByNameValues('StavPrikazu');
|
||||
pUroven := FieldByNameValues('UrovenVnoreni');
|
||||
lblPrikaz.Caption := pRPr + ' ' + pRC;
|
||||
lblDilec.Caption := pNazev1;
|
||||
dtPlanUkonceni.Date := FieldByNameValues('Plan_ukonceni_X');
|
||||
end;
|
||||
|
||||
if (pSZ<>'') then
|
||||
begin
|
||||
lSQL := 'SELECT p.RadaPrikaz, k.SkupZbo, k.RegCis, k.Nazev1, p.StavPrikazu, p.UrovenVnoreni FROM ' + tblVPr + ' p JOIN ' + tblKZ + ' k ON (k.ID=p.IDTabKmen) WHERE p.IDPrikazRidici=' + idVPr.ToString
|
||||
+ ' AND p.UrovenVnoreni>' + pUroven.ToString + ' AND p.StavPrikazu IN (20,30) /*AND k.SkupZbo LIKE N''P[45]%''*/ ORDER BY p.UrovenVnoreni, k.SkupZbo DESC';
|
||||
with Helios.OpenSQL (lSQL) do
|
||||
if (RecordCount>0) then
|
||||
begin
|
||||
cnt := 0;
|
||||
First;
|
||||
while not(EOF) do
|
||||
begin
|
||||
Inc (cnt);
|
||||
grdPrikazy.RowCount := cnt;
|
||||
pSZ := FieldByNameValues('SkupZbo');
|
||||
if (LeftStr(pSZ,2)='P4') or (LeftStr(pSZ,2)='P5') then
|
||||
grdPrikazy.Cell [0, cnt-1].AsBoolean := true;
|
||||
|
||||
grdPrikazy.Cells [1, cnt-1] := FieldByNameValues('RadaPrikaz');
|
||||
grdPrikazy.Cells [2, cnt-1] := FieldByNameValues('Nazev1');
|
||||
grdPrikazy.Cells [3, cnt-1] := cnt.ToString;
|
||||
self.Height := self.Height + 28;
|
||||
Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user