📄 scbrow.pas
字号:
unit scbrow;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Spin, ExtCtrls, Grids, DBGridEh, constb, Db,
DBTables, Menus, DBSumLst, PrnDbgeh, PBNumEdit, comobj, Excel2000, ActnList,
Buttons;
type
Tscbrowfm = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
SpinEdit1: TSpinEdit;
SpinEdit2: TSpinEdit;
Edit1: TEdit;
Edit2: TEdit;
CheckBox1: TCheckBox;
SpinEdit3: TSpinEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
GroupBox2: TGroupBox;
Panel1: TPanel;
DBGridEh1: TDBGridEh;
schscinqy: TQuery;
schscindb: TDataSource;
Label11: TLabel;
ComboBox2: TComboBox;
saveqy: TQuery;
GroupBox3: TGroupBox;
Panel3: TPanel;
Label12: TLabel;
SpinEdit4: TSpinEdit;
Label13: TLabel;
SpinEdit5: TSpinEdit;
Label14: TLabel;
Label15: TLabel;
Edit6: TEdit;
Label16: TLabel;
Edit7: TEdit;
Label17: TLabel;
ComboBox3: TComboBox;
Button2: TButton;
Button3: TButton;
Button4: TButton;
PopupMenu3: TPopupMenu;
n6: TMenuItem;
Panel4: TPanel;
DBGridEh3: TDBGridEh;
schqy: TQuery;
inmxqy: TQuery;
inmxdb: TDataSource;
Button5: TButton;
Label18: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
PrintDBGridEh1: TPrintDBGridEh;
Button6: TButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
ComboBox1: TComboBox;
Label19: TLabel;
work_again_check: TCheckBox;
PBNumEdit1: TPBNumEdit;
BitBtn1: TBitBtn;
PBNumEdit2: TPBNumEdit;
Label20: TLabel;
Label21: TLabel;
Edit8: TEdit;
HeaderControl1: THeaderControl;
Label22: TLabel;
ComboBox4: TComboBox;
Label23: TLabel;
BitBtn2: TBitBtn;
sch2: TQuery;
CheckBox2: TCheckBox;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SpinEdit1Exit(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1Exit(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ComboBox2Exit(Sender: TObject);
procedure schscbrow;
procedure N3Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure TabSheet2Show(Sender: TObject);
procedure DBGridEh1DblClick(Sender: TObject);
procedure Button4Click(Sender: TObject); //查询生产输入
procedure inedshow;
procedure n6Click(Sender: TObject);
procedure Button2Click(Sender: TObject); //新增修改显示
procedure schbb(fieldnm, fieldtxt: string);
procedure Edit6Exit(Sender: TObject);
procedure Edit7Exit(Sender: TObject);
procedure DBGridEh3KeyPress(Sender: TObject; var Key: Char);
procedure SpinEdit4Change(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure DBGridEh3ColExit(Sender: TObject);
procedure DBGridEh3EditButtonClick(Sender: TObject);
procedure SpinEdit4Exit(Sender: TObject);
procedure SpinEdit5Exit(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure inmxqyBeforePost(DataSet: TDataSet);
procedure inmxqyAfterOpen(DataSet: TDataSet);
procedure inmxqyAfterDelete(DataSet: TDataSet);
procedure inmxqyAfterPost(DataSet: TDataSet);
procedure inmxqyPostError(DataSet: TDataSet; E: EDatabaseError;
var Action: TDataAction);
procedure TabSheet2Exit(Sender: TObject);
procedure DBGridEh3KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Button6Click(Sender: TObject);
procedure ComboBox3Exit(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
maxday: integer;
inedflg: char;
idno: integer;
oldstaffid, oldname, olddept: string;
{ Private declarations }
public
{ Public declarations }
end;
const
scinmxsch =
'select a.* ,b.kno,b.kfjz from scinmx a left join scpno b on a.pno=b.pno where a.idno=:idno';
var
scbrowfm: Tscbrowfm;
implementation
uses pnmanage, gxmanage, pprice;
{$R *.dfm}
procedure Tscbrowfm.schbb(fieldnm, fieldtxt: string);
begin
if activecontrol <> button3 then
begin
schqy.sql.clear;
schqy.SQL.Add('select staffid,name,dept from staffs a,depts b where a.deptcode=b.deptcode and ');
schqy.SQL.Add(fieldnm + '=:fieldtxt');
schqy.ParamByName('fieldtxt').asstring := fieldtxt;
schqy.Open;
if bool(schqy.recordcount) then
begin
oldstaffid := schqy.fieldbyname('staffid').AsString;
edit6.Text := oldstaffid;
oldname := schqy.fieldbyname('name').AsString;
edit7.Text := oldname;
olddept := schqy.fieldbyname('dept').AsString;
combobox3.Text := olddept;
end
else
begin
application.MessageBox('没找到!', '提示信息', mb_ok);
end;
end;
end;
procedure tscbrowfm.schscbrow;
var
selectstr, fromstr, wherestr: string;
begin
selectstr := ' select a.years,a.months,a.idno,b.dept1, a.dept,a.staffid,a.name,b.note,b.days,b.pno,b.scgx,b.gxno,b.innum,b.inprice, b.totalin ,b.work_again,b.sg';
fromstr := ' from scintb a ,scinmx b ';
wherestr := ' where a.idno=b.idno ';
if checkbox2.Checked then
wherestr:=wherestr+'and a.years=:years and a.months=:months ';
if edit1.Text <> '' then
wherestr := wherestr + ' and a.staffid=:staffid ';
if edit2.Text <> '' then
wherestr := wherestr + ' and a.name=:name ';
if combobox1.Text <> '' then
wherestr := wherestr + ' and a.dept=:dept';
if combobox4.Text <> '' then
wherestr := wherestr + ' and b.dept1 LIKE :dept1';
if checkbox1.Checked then
begin
wherestr := wherestr + ' and b.days=:days ';
end;
if edit3.Text <> '' then
begin
wherestr := wherestr + ' and b.pno like :pno ';
end;
if pbnumedit1.Value > 0 then
begin
wherestr := wherestr + ' and b.inprice=:inprice ';
end;
if work_again_check.Checked then
begin
wherestr := wherestr + ' and b.work_again=:work_again ';
end;
if combobox2.Text <> '' then
begin
wherestr := wherestr + ' and b.scgx like :scgx ';
end;
if edit4.Text <> '' then
begin
if pos('scpno', fromstr) <= 0 then
begin
fromstr := fromstr + ',scpno c';
wherestr := wherestr + ' and b.pno=c.pno ';
end;
wherestr := wherestr + ' and c.kno like :kno ';
end;
if edit5.Text <> '' then
begin
if pos('scpno', fromstr) <= 0 then
begin
fromstr := fromstr + ',scpno c ';
wherestr := wherestr + ' and b.pno=c.pno ';
end;
wherestr := wherestr + ' and c.kfjz like :kfjz ';
end;
schscinqy.SQl.Clear;
schscinqy.SQL.add(selectstr);
schscinqy.sql.Add(fromstr);
schscinqy.sql.add(wherestr);
if radiobutton1.Checked then
schscinqy.SQL.add(' order by a.dept,a.staffid');
if radiobutton2.Checked then
schscinqy.SQL.add(' order by b.pno,b.scgx,a.dept');
if checkbox2.Checked then
begin
schscinqy.ParamByName('years').asinteger := spinedit1.Value;
schscinqy.ParamByName('months').asinteger := spinedit2.Value;
end;
if checkbox1.Checked then
schscinqy.ParamByName('days').asinteger := spinedit3.Value;
if edit1.Text <> '' then
schscinqy.ParamByName('staffid').asstring := edit1.Text;
if edit2.Text <> '' then
schscinqy.ParamByName('name').asstring := edit2.Text;
if combobox1.Text <> '' then
schscinqy.ParamByName('dept').asstring := combobox1.Text;
if combobox4.Text <> '' then
schscinqy.ParamByName('dept1').asstring := combobox4.Text;
if edit3.Text <> '' then
schscinqy.ParamByName('pno').asstring := '%' + edit3.Text + '%';
if edit4.Text <> '' then
schscinqy.ParamByName('kno').asstring := '%' + edit4.Text + '%';
if edit5.Text <> '' then
schscinqy.ParamByName('kfjz').asstring := '%' + edit5.Text + '%';
if combobox2.Text <> '' then
schscinqy.ParamByName('scgx').asstring := combobox2.Text;
if pbnumedit1.Value > 0 then
begin
schscinqy.ParamByName('inprice').AsFloat := pbnumedit1.Value;
end;
if work_again_check.Checked then
begin
schscinqy.ParamByName('work_again').Asboolean := true;
end;
//schscinqy.sql.SaveToFile('c:\schscin.txt');
schscinqy.open;
end;
procedure Tscbrowfm.inedshow; //新增修改显示
begin
case inedflg of
'1':
begin //新增
groupbox3.Caption := '新增';
if button2.Tag = 0 then
begin
spinedit4.Value := spinedit1.Value;
spinedit5.Value := spinedit2.Value;
end;
edit6.Text := '';
edit7.Text := '';
combobox3.Text := '';
inmxqy.sql.clear;
inmxqy.sql.add('select * from scinmx where 1=2 ');
inmxqy.open;
spinedit4.SetFocus;
oldstaffid := '';
oldname := '';
olddept := '';
end;
'2':
begin
groupbox3.Caption := '修改';
idno := schscinqy.fieldbyname('idno').asinteger;
spinedit4.Value := schscinqy.fieldbyname('years').asinteger;
spinedit5.Value := schscinqy.fieldbyname('months').asinteger;
oldstaffid := schscinqy.fieldbyname('staffid').asstring;
edit6.Text := oldstaffid;
oldname := schscinqy.fieldbyname('name').asstring;
edit7.Text := oldname;
olddept := schscinqy.fieldbyname('dept').asstring;
combobox3.Text := olddept;
inmxqy.SQL.Clear;
inmxqy.sql.Add('select * from scinmx where idno=:idno order by mxidno ');
inmxqy.ParamByName('idno').AsInteger := idno;
inmxqy.Open;
end;
'3':
begin
groupbox3.Caption := '修改';
idno := schscinqy.fieldbyname('idno').asinteger;
spinedit4.Value := schscinqy.fieldbyname('years').asinteger;
spinedit5.Value := schscinqy.fieldbyname('months').asinteger;
oldstaffid := schscinqy.fieldbyname('staffid').asstring;
edit6.Text := oldstaffid;
oldname := schscinqy.fieldbyname('name').asstring;
edit7.Text := oldname;
olddept := schscinqy.fieldbyname('dept').asstring;
combobox3.Text := olddept;
inmxqy.SQL.Clear;
inmxqy.sql.Add('select * from scinmx where idno=:idno and pno=:pno ');
inmxqy.sql.Add('and scgx=:scgx and days=:days order by mxidno ');
inmxqy.ParamByName('idno').AsInteger := idno;
inmxqy.ParamByName('pno').AsString := schscinqy.fieldbyname('pno').asstring;
inmxqy.ParamByName('scgx').AsString := schscinqy.fieldbyname('scgx').asstring;
inmxqy.ParamByName('days').AsString := schscinqy.fieldbyname('days').asstring;
inmxqy.Open;
end;
end;
button2.Enabled := false;
end;
procedure Tscbrowfm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if inmxqy.state in [dsinsert, dsedit] then
begin
if messagedlg('生产资料编辑中,数据没存盘,要放弃存盘退出吗?', mtinformation, mbokcancel, 0) = mrok then
action := cafree
else
abort;
end
else
action := cafree;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -