unit Unit1;
interface
uses
ShellAPI, XLSFile, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, RzGrids, RzButton, StdCtrls, RzCmboBx, ExtCtrls, RzPanel,
XLSExportComp;
type
TForm1 = class(TForm)
RzStringGrid38: TRzStringGrid;
RzPanel10: TRzPanel;
Label92: TLabel;
Label37: TLabel;
RzBitBtn25: TRzBitBtn;
RzComboBox45: TRzComboBox;
RzBitBtn1: TRzBitBtn;
XLSExportRzStringGrid38: TXLSExportStringGrid;
procedure RzButton1Click(Sender: TObject);
procedure RzStringGrid38DblClick(Sender: TObject);
procedure RzBitBtn25Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
xf: TXLSFile;
R, C, N: integer;
S, L: string;
implementation
{$R *.dfm}
procedure OpenFileInOSShell(AFile: string);
begin
ShellExecute(0, 'open', PChar(AFile), nil, nil, SW_SHOW);
end;
procedure TForm1.RzButton1Click(Sender: TObject);
begin
xf:= TXLSFile.Create;
xf.OpenFile('db.xls');
L:='не пусто';
N:=0;
with xf.Workbook.Sheets[0] do begin//определение количества заполненных строк в базе
while L<>'' do begin
S:=Cells[N, 1].Value;
L:=Cells[N, 0].Value;
N:=N+1;
end;
RzStringGrid38.ColCount:=21;
RzStringGrid38.RowCount:=N-1;
end;
for R:=1 to N do begin
for C:=0 to 20 do begin
with xf.Workbook.Sheets[0] do L:=Cells[R,C].Value;
RzStringGrid38.Cells[C,R-1]:=L;
end;
end;
xf.Destroy;
end;
procedure TForm1.RzStringGrid38DblClick(Sender: TObject);
begin
RzPanel10.Visible:=true;
Label37.Caption:=RzStringGrid38.cells[0,RzStringGrid38.row];
if (RzStringGrid38.cells[20,RzStringGrid38.row]='в производстве') or (RzStringGrid38.cells[20,RzStringGrid38.row]='') then RzComboBox45.ItemIndex:=0;
if RzStringGrid38.cells[20,RzStringGrid38.row]='сдан на склад' then RzComboBox45.ItemIndex:=1;
if RzStringGrid38.cells[20,RzStringGrid38.row]='отменен' then RzComboBox45.ItemIndex:=2;
end;
procedure TForm1.RzBitBtn25Click(Sender: TObject);
begin
RzStringGrid38.cells[20,RzStringGrid38.row]:=RzComboBox45.Text;//изменение статуса заказа
RzStringGrid38.cells[2,RzStringGrid38.row]:=datetostr(date);//дата изменения статуса
RzStringGrid38.cells[5,RzStringGrid38.row]:=timetostr(time);//время изменения статуса
xf:= TXLSFile.Create;
xf.OpenFile('db.xls');
with xf.Workbook.Sheets[0] do XLSExportRzStringGrid38.ExportData(0, 3, 0);
xf.SaveAs('db.xls');
xf.Destroy;
RzPanel10.Visible:=false;
end;
end.