📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Mask, DBCtrlsEh, ComCtrls, ExtCtrls,
Buttons, ToolWin, DB, WinSkinData, Menus, Registry, SHELLAPI, ImgList,math,
XPMan;
type
TForm1 = class(TForm)
Panel1: TPanel;
StatusBar1: TStatusBar;
Panel2: TPanel;
Shape1: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape12: TShape;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
CoolBar1: TCoolBar;
ToolBar_main: TToolBar;
TB_kctj: TToolButton;
ToolButton1: TToolButton;
TB_spfb: TToolButton;
Panel3: TPanel;
ToolButton4: TToolButton;
Shape3: TShape;
Eljh: TEdit;
Ebh: TEdit;
Erq: TEdit;
Ecx: TEdit;
egyy: TComboBox;
Label8: TLabel;
Label9: TLabel;
ComboBox2: TComboBox;
ToolButton3: TToolButton;
ToolButton5: TToolButton;
ToolButton2: TToolButton;
ecj: TComboBox;
Panel4: TPanel;
StringGrid1: TStringGrid;
ComboBox1: TComboBox;
Button1: TButton;
ImageList1: TImageList;
XPManifest1: TXPManifest;
procedure StringGrid1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure ComboBox1Change(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure Panel4Exit(Sender: TObject);
procedure ComboBox2KeyPress(Sender: TObject; var Key: Char);
procedure ToolButton1Click(Sender: TObject);
procedure TB_kctjClick(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ErqDblClick(Sender: TObject);
procedure TB_spfbClick(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
Private
{ Private declarations }
Public
{ Public declarations }
end;
type
TMyGrid = class(TDrawGrid);
var
Form1: TForm1;
implementation
{$R *.dfm}
uses UNIT3, mylib, unit2, unit4;
procedure TForm1.StringGrid1Click(Sender: TObject);
var Rect: TRect;
var I: Integer;
var s1: string;
begin
ComboBox1.Clear;
case StringGrid1.Col of
0:
begin
ComboBox1.Style := csDropDown;
ComboBox1.Perform(CB_SETDROPPEDWIDTH, 42, 0);
for I := 1 to 25 do
ComboBox1.Items.Add(inttostr(I));
end;
1:
begin
// OPENAdoQ(DM.ADOQ1, 'select * from gx');
ComboBox1.Style := csDropDown;
if StringGrid1.Cells[0, StringGrid1.row] = '' then
begin
ComboBox1.Visible := false;
MsgError('工序号不能空着呀!');
exit;
end;
ComboBox1.Perform(CB_SETDROPPEDWIDTH, 80, 0);
addcombox(DM.ADOQ1, 'gymc', 'gx', ComboBox1);
end;
2:
begin
ComboBox1.Style := csDropDown;
// OPENAdoQ(DM.ADOQ1, 'select * from jc');
if StringGrid1.Cells[1, StringGrid1.row] = '' then
begin
ComboBox1.Visible := false;
MsgError('工序名称还没添哪!');
exit;
end;
ComboBox1.Perform(CB_SETDROPPEDWIDTH, 90, 0);
addcombox3(DM.ADOQ1, 'sbxh', 'jc', ComboBox1);
end;
9:
begin
ComboBox1.Style := csDropDown;
ComboBox1.Perform(CB_SETDROPPEDWIDTH, 42, 0);
for I := 1 to 4 do
ComboBox1.Items.Add(inttostr(I));
end;
10:
begin
ComboBox1.Style := csDropDownList;
// OPENAdoQ(DM.ADOQ1, 'select * from jc');
s1 := 'select * from jc where sbxh=''' +
trim(StringGrid1.Cells[2, StringGrid1.row]) + '''';
ComboBox1.Perform(CB_SETDROPPEDWIDTH, 140, 0);
addcombox1(DM.ADOQ2, 'gjfmc', 'bcde', 'jc', s1, ComboBox1);
end;
end;
if StringGrid1.Col in [0, 1, 2, 9, 10] then
begin
Rect := StringGrid1.CellRect(StringGrid1.Col, StringGrid1.row);
ComboBox1.Left := StringGrid1.Left + Rect.Left + 2;
ComboBox1.Top := StringGrid1.Top + Rect.Top + 2;
ComboBox1.Height := Rect.Bottom - Rect.Top - 2;
ComboBox1.Width := Rect.Right - Rect.Left;
ComboBox1.text := StringGrid1.Cells[StringGrid1.Col, StringGrid1.row];
ComboBox1.Visible := true;
ComboBox1.SetFocus;
end else
begin
ComboBox1.Visible := false;
ComboBox1.Clear;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
StringGrid1.Cells[0, 0] := '工序号';
StringGrid1.Cells[1, 0] := '工序名称';
StringGrid1.Cells[2, 0] := '设备型号';
StringGrid1.Cells[3, 0] := '设备名称';
StringGrid1.Cells[4, 0] := '每车件数';
StringGrid1.Cells[5, 0] := '作业时间';
StringGrid1.Cells[6, 0] := '基本';
StringGrid1.Cells[7, 0] := '辅助';
StringGrid1.Cells[8, 0] := '附加时间';
StringGrid1.Cells[9, 0] := '操作人数';
StringGrid1.Cells[10, 0] := '班产定额';
StringGrid1.Cells[11, 0] := '单件工分';
StringGrid1.Cells[12, 0] := '每车工分';
StringGrid1.Cells[13, 0] := '单件工组分';
StringGrid1.Cells[14, 0] := '标准页次';
StringGrid1.ColWidths[0] := 40;
StringGrid1.ColWidths[2] := 70;
StringGrid1.ColWidths[3] := 80;
StringGrid1.ColWidths[4] := 50;
StringGrid1.ColWidths[9] := 50;
StringGrid1.ColWidths[13] := 60;
StringGrid1.ColWidths[5] := 50;
StringGrid1.ColWidths[6] := 30;
StringGrid1.ColWidths[7] := 30;
StringGrid1.ColWidths[8] := 50;
addcombox(DM.ADOQ1, 'gyy', 'gyy', egyy);
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
RC: TRect;
begin
RC := Rect;
StringGrid1.Canvas.FillRect(Rect);
DrawText(StringGrid1.Canvas.Handle, PChar(StringGrid1.Cells[ACol, ARow]),
Length(StringGrid1.Cells[ACol, ARow]), RC, DT_CENTER or DT_VCENTER or
DT_SINGLELINE);
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
s: string;
s1: real;
I, rn: Integer;
begin
s := trim(ComboBox1.text);
rn := StringGrid1.row;
if StringGrid1.Col in [1] then
begin
StringGrid1.Cells[StringGrid1.Col, StringGrid1.row] := s;
end;
if StringGrid1.Col = 0 then
begin
//ComboBox1.Style:=csDropDown;
if editisNUM2(ComboBox1, '注意:输入不是序号') = false then exit;
StringGrid1.Cells[0, StringGrid1.row] := s;
for I := 0 to rn - 1 do
if StringGrid1.Cells[0, StringGrid1.row] = StringGrid1.Cells[0, I]
then
begin
MsgError('工序号有重复!');
StringGrid1.Cells[0, StringGrid1.row] := '';
exit;
end;
end;
if StringGrid1.Col = 9 then
begin
//ComboBox1.Style:=csDropDown;
if editisNUM2(ComboBox1, '注意:输入不是数字') = false then exit;
StringGrid1.Cells[StringGrid1.Col, StringGrid1.row] := s;
if StringGrid1.Cells[10, StringGrid1.row] = '' then exit;
s1 := strtofloat(StringGrid1.Cells[9, StringGrid1.row]) * 480 /
strtofloat(StringGrid1.Cells[10, StringGrid1.row]);
StringGrid1.Cells[11, StringGrid1.row] := FloatToStr(round(s1 * 10000) /
10000);
end;
if StringGrid1.Col = 2 then
begin
//ComboBox1.Style:=csDropDown;
StringGrid1.Cells[9, StringGrid1.row] := '';
StringGrid1.Cells[10, StringGrid1.row] := '';
StringGrid1.Cells[11, StringGrid1.row] := '';
OPENAdoQ(DM.ADOQ2, 'select sbmc,CZRS from jc where sbxh=''' + s + '''');
StringGrid1.Cells[3, StringGrid1.row] :=
DM.ADOQ2.FieldByName('sbmc').AsString;
StringGrid1.Cells[9, StringGrid1.row] :=
DM.ADOQ2.FieldByName('CZRS').AsString;
StringGrid1.Cells[2, StringGrid1.row] := s;
end;
if StringGrid1.Col = 10 then
begin
//ComboBox1.Style:=csDropDownList;
if StringGrid1.Cells[9, StringGrid1.row] = '' then exit;
StringGrid1.Cells[10, StringGrid1.row] := GetCode('>',
trim(ComboBox1.Items[ComboBox1.ItemIndex]));
s1 := strtofloat(StringGrid1.Cells[9, StringGrid1.row]) * 480 /
strtofloat(StringGrid1.Cells[10, StringGrid1.row]);
StringGrid1.Cells[11, StringGrid1.row] := FloatToStr(round(s1 * 10000) /
10000);
end;
//ComboBox1.Visible:=false;
end;
procedure TForm1.ToolButton2Click(Sender: TObject);
var
s, s1: string;
I: Integer;
begin
s1 := trim(ComboBox2.text);
s := 'select ljh from LJXX where ljh like ''' + '%' + s1 + '%' + '''';
addcombox2(DM.ADOQ1, 'ljh', 'mx', s, ComboBox2);
I := DM.ADOQ1.RecordCount;
if I >= 1 then
begin
ComboBox2.text := '查获到符合条件的零件' + inttostr(I) + '个';
end else
ComboBox2.text := '没有找到符合条件的零件';
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
var
I, F, i1, f1: Integer;
begin
Eljh.text := '';
Ebh.text := '';
Erq.text := '';
Ecx.text := '';
ecj.text := '';
egyy.text := '';
//stringgrid1.cl
for i1 := 1 to 25 do
begin
for f1 := 0 to 14 do
begin
StringGrid1.Cells[f1, i1] := '';
end;
end;
OPENAdoQ(DM.ADOQ1, 'select * from ljxx where ljh=''' + ComboBox2.text +
'''');
OPENAdoQ(DM.ADOQ2, 'select * from MX where ljh=''' + ComboBox2.text + '''' +
' order by gxh');
with DM.ADOQ1 do
begin
Eljh.text := FieldByName('ljh').AsString;
Ebh.text := FieldByName('bh').AsString;
Erq.text := FieldByName('rq').AsString;
Ecx.text := FieldByName('cx').AsString;
ecj.text := FieldByName('cj').AsString;
egyy.text := FieldByName('gyy').AsString;
end;
F := DM.ADOQ2.RecordCount;
with DM.ADOQ2 do
begin
for I := 1 to F do
begin
StringGrid1.Cells[0, I] := FieldByName('gxh').AsString;
StringGrid1.Cells[1, I] := FieldByName('gxmc').AsString;
StringGrid1.Cells[2, I] := FieldByName('sbxh').AsString;
StringGrid1.Cells[3, I] := FieldByName('sbmc').AsString;
StringGrid1.Cells[4, I] := FieldByName('mcjs').AsString;
StringGrid1.Cells[5, I] := FieldByName('zysj').AsString;
StringGrid1.Cells[6, I] := FieldByName('jbsj').AsString;
StringGrid1.Cells[7, I] := FieldByName('fzsj').AsString;
StringGrid1.Cells[8, I] := FieldByName('fjsj').AsString;
StringGrid1.Cells[9, I] := FieldByName('czrs').AsString;
StringGrid1.Cells[10, I] := FieldByName('bcde').AsString;
StringGrid1.Cells[11, I] := FieldByName('djgf').AsString;
StringGrid1.Cells[12, I] := FieldByName('mcgf').AsString;
StringGrid1.Cells[13, I] := FieldByName('djgzf').AsString;
StringGrid1.Cells[14, I] := FieldByName('bzyc').AsString;
DM.ADOQ2.Next;
end;
end;
end;
procedure TForm1.Panel4Exit(Sender: TObject);
begin
ComboBox1.Visible := false;
end;
procedure TForm1.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
ToolButton2Click(Sender);
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -