小弟愚笨,还望高手能来讲解一下这些代码的含义!!! ( 积分: 50 )

  • 主题发起人 主题发起人 kazj
  • 开始时间 开始时间
K

kazj

Unregistered / Unconfirmed
GUEST, unregistred user!
希望大哥大姐们能给我讲解一下每句话的意思,谢谢拉!!

unit yp;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, DB, ADODB, cxStyles,
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit,
cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid,QDialogs,
DBTables,U_Function, ComCtrls;

type
TForm1 = class(TForm)
Panel2: TPanel;
scypButton: TButton;
dyButton: TButton;
bcButton: TButton;
Panel1: TPanel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1DBTableView1yp_bh: TcxGridDBColumn;
cxGrid1DBTableView1yp_bm: TcxGridDBColumn;
cxGrid1DBTableView1yp_name: TcxGridDBColumn;
cxGrid1DBTableView1yp_changjia: TcxGridDBColumn;
cxGrid1DBTableView1yp_xingzhi: TcxGridDBColumn;
cxGrid1DBTableView1yp_guige: TcxGridDBColumn;
cxGrid1DBTableView1yp_danwei: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
xgButton: TButton;
gjjeLabeledEdit: TLabeledEdit;
yfjeLabeledEdit: TLabeledEdit;
yhtjComboBox: TComboBox;
Label1: TLabel;
ssjeLabeledEdit: TLabeledEdit;
yzjeLabeledEdit: TLabeledEdit;
zlButton: TButton;
Label2: TLabel;
ADOCon_yd: TADOConnection;
DataSource1: TDataSource;
DataSource2: TDataSource;
Button1: TButton;
Label3: TLabel;
Label4: TLabel;
ADOQ_cx_bh: TADOQuery;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ADOQ_cx_name: TADOQuery;
ADODataSet1: TADOQuery;
cxGrid1DBTableView1yp_ls: TcxGridDBColumn;
cxGrid1DBTableView1yp_pf: TcxGridDBColumn;
Edit3: TEdit;
UpDown1: TUpDown;
CheckBox1: TCheckBox;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
cxGrid1DBTableView1yp_sysl: TcxGridDBColumn;
cxGrid1DBTableView1yp_bzq: TcxGridDBColumn;
cxGrid1DBTableView1yp_jhrq: TcxGridDBColumn;
cxGrid2: TcxGrid;
cxGridDBTableView1: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
ADODataSet2: TADOQuery;
cxGridDBTableView1DBColumn1: TcxGridDBColumn;
ADOQ_sc: TADOQuery;
procedure Edit3KeyPress(Sender: TObject
var Key: Char);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject
var Key: Char);
procedure ComboBox1Click(Sender: TObject);
procedure cxGrid1DBTableView1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo
AButton: TMouseButton;
AShift: TShiftState
var AHandled: Boolean);
procedure Edit3Exit(Sender: TObject);
procedure xgButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
str,tj : string;
begin
if combobox1.ItemIndex= 1 then
begin
str := 'yp_bh';
tj := ' where '+str+'='+trim(combobox2.Text);
end
else if combobox1.ItemIndex= 2 then
begin
str := 'yp_name';
tj := ' where '+str+'='+''''+trim(combobox2.Text)+'''';
end;
if trim(COMBOBOx1.Text)<>'' then
liulan(ADODataSet1,'yp_xinxi',tj)
else liulan(ADODataSet1,'yp_xinxi','');
end;

procedure TForm1.Edit3KeyPress(Sender: TObject
var Key: Char);
begin
_int(panel1,key,sender);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
ADODataSet1.Active :=false;
ADODataSet1.Active :=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
try
ADOCon_yd.Connected := true;
except
showmessage('请先配置yaodian.UDL!') ;
end;
end;

procedure TForm1.ComboBox1KeyPress(Sender: TObject
var Key: Char);
begin
key := #0;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
if combobox1.ItemIndex=1 then
begin
ADOQ_cx_bh.Close;
ADOQ_cx_bh.Open;
klb_com(ADOQ_cx_bh,combobox2,0);
end
else if combobox1.ItemIndex=2 then
begin
ADOQ_cx_name.Close;
ADOQ_cx_name.Open;
klb_com(ADOQ_cx_name,combobox2,0);
end
else combobox2.Items.Clear;
end;

procedure TForm1.cxGrid1DBTableView1CellClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo
AButton: TMouseButton;
AShift: TShiftState
var AHandled: Boolean);
begin
if ADODataSet1.RecordCount<>0 then
begin
if checkbox1.Checked then
edit1.Text := ADODataSet1.Fields[8].AsString
else Edit1.Text := ADODataSet1.Fields[7].AsString;
end

end;

procedure TForm1.Edit3Exit(Sender: TObject);
begin
if trim(edit3.Text)='' then
edit3.Text := '0';
end;

procedure TForm1.xgButtonClick(Sender: TObject);
VAR
I,ljje : INTEGER;
je : string;
begin
je := '0';
ljje := 0;
ADOQ_sc.Close;
ADOQ_sc.SQL.Clear;
ADOQ_sc.SQL.Add('select * FROM yp_xiaoshou');
ADOQ_sc.Open;
ADOQ_sc.Insert;
for i := 0 to 6 do
ADOQ_sc.Fields.AsString := ADODataSet1.Fields.AsString;
if checkbox1.Checked then
begin
ADOQ_sc.Fields[7].AsBoolean := true;
je := ADODataSet1.Fields[8].AsString ;
ADOQ_sc.Fields[8].AsString := je;
end
else begin
ADOQ_sc.Fields[7].AsBoolean := false;
je := ADODataSet1.Fields[7].AsString ;
ADOQ_sc.Fields[8].AsString := je;
end;

ADOQ_sc.Fields[9].AsString := trim(EDIT1.Text) ;
ADOQ_sc.Fields[10].AsString := datetostr(now) ;
ADOQ_sc.Fields[11].AsString := ADODataSet1.Fields[11].AsString ;
ADOQ_sc.Fields[12].AsString := 'good';
ADOQ_sc.Fields[13].AsString := inttostr(strtoint(trim(EDIT1.Text))*(strtoint(je)));
ADOQ_sc.Post;
ADODataSet2.Close;
ADODataSet2.Open;
ADODataSet2.First;
for i := 0 to ADODataSet2.RecordCount-1 do
begin
ljje := ljje+ strtoint(trim(ADODataSet2.Fields[13].asstring));
ADODataSet2.Next;
end;
ADODataSet2.First;
gjjeLabeledEdit.Text := inttostr(ljje);
end;

end.
 
希望大哥大姐们能给我讲解一下每句话的意思,谢谢拉!!

unit yp;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, DB, ADODB, cxStyles,
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit,
cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid,QDialogs,
DBTables,U_Function, ComCtrls;

type
TForm1 = class(TForm)
Panel2: TPanel;
scypButton: TButton;
dyButton: TButton;
bcButton: TButton;
Panel1: TPanel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1DBTableView1yp_bh: TcxGridDBColumn;
cxGrid1DBTableView1yp_bm: TcxGridDBColumn;
cxGrid1DBTableView1yp_name: TcxGridDBColumn;
cxGrid1DBTableView1yp_changjia: TcxGridDBColumn;
cxGrid1DBTableView1yp_xingzhi: TcxGridDBColumn;
cxGrid1DBTableView1yp_guige: TcxGridDBColumn;
cxGrid1DBTableView1yp_danwei: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
xgButton: TButton;
gjjeLabeledEdit: TLabeledEdit;
yfjeLabeledEdit: TLabeledEdit;
yhtjComboBox: TComboBox;
Label1: TLabel;
ssjeLabeledEdit: TLabeledEdit;
yzjeLabeledEdit: TLabeledEdit;
zlButton: TButton;
Label2: TLabel;
ADOCon_yd: TADOConnection;
DataSource1: TDataSource;
DataSource2: TDataSource;
Button1: TButton;
Label3: TLabel;
Label4: TLabel;
ADOQ_cx_bh: TADOQuery;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ADOQ_cx_name: TADOQuery;
ADODataSet1: TADOQuery;
cxGrid1DBTableView1yp_ls: TcxGridDBColumn;
cxGrid1DBTableView1yp_pf: TcxGridDBColumn;
Edit3: TEdit;
UpDown1: TUpDown;
CheckBox1: TCheckBox;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
cxGrid1DBTableView1yp_sysl: TcxGridDBColumn;
cxGrid1DBTableView1yp_bzq: TcxGridDBColumn;
cxGrid1DBTableView1yp_jhrq: TcxGridDBColumn;
cxGrid2: TcxGrid;
cxGridDBTableView1: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
ADODataSet2: TADOQuery;
cxGridDBTableView1DBColumn1: TcxGridDBColumn;
ADOQ_sc: TADOQuery;
procedure Edit3KeyPress(Sender: TObject
var Key: Char);
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject
var Key: Char);
procedure ComboBox1Click(Sender: TObject);
procedure cxGrid1DBTableView1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo
AButton: TMouseButton;
AShift: TShiftState
var AHandled: Boolean);
procedure Edit3Exit(Sender: TObject);
procedure xgButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
str,tj : string;
begin
if combobox1.ItemIndex= 1 then
begin
str := 'yp_bh';
tj := ' where '+str+'='+trim(combobox2.Text);
end
else if combobox1.ItemIndex= 2 then
begin
str := 'yp_name';
tj := ' where '+str+'='+''''+trim(combobox2.Text)+'''';
end;
if trim(COMBOBOx1.Text)<>'' then
liulan(ADODataSet1,'yp_xinxi',tj)
else liulan(ADODataSet1,'yp_xinxi','');
end;

procedure TForm1.Edit3KeyPress(Sender: TObject
var Key: Char);
begin
_int(panel1,key,sender);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
ADODataSet1.Active :=false;
ADODataSet1.Active :=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
try
ADOCon_yd.Connected := true;
except
showmessage('请先配置yaodian.UDL!') ;
end;
end;

procedure TForm1.ComboBox1KeyPress(Sender: TObject
var Key: Char);
begin
key := #0;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
if combobox1.ItemIndex=1 then
begin
ADOQ_cx_bh.Close;
ADOQ_cx_bh.Open;
klb_com(ADOQ_cx_bh,combobox2,0);
end
else if combobox1.ItemIndex=2 then
begin
ADOQ_cx_name.Close;
ADOQ_cx_name.Open;
klb_com(ADOQ_cx_name,combobox2,0);
end
else combobox2.Items.Clear;
end;

procedure TForm1.cxGrid1DBTableView1CellClick(
Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo
AButton: TMouseButton;
AShift: TShiftState
var AHandled: Boolean);
begin
if ADODataSet1.RecordCount<>0 then
begin
if checkbox1.Checked then
edit1.Text := ADODataSet1.Fields[8].AsString
else Edit1.Text := ADODataSet1.Fields[7].AsString;
end

end;

procedure TForm1.Edit3Exit(Sender: TObject);
begin
if trim(edit3.Text)='' then
edit3.Text := '0';
end;

procedure TForm1.xgButtonClick(Sender: TObject);
VAR
I,ljje : INTEGER;
je : string;
begin
je := '0';
ljje := 0;
ADOQ_sc.Close;
ADOQ_sc.SQL.Clear;
ADOQ_sc.SQL.Add('select * FROM yp_xiaoshou');
ADOQ_sc.Open;
ADOQ_sc.Insert;
for i := 0 to 6 do
ADOQ_sc.Fields.AsString := ADODataSet1.Fields.AsString;
if checkbox1.Checked then
begin
ADOQ_sc.Fields[7].AsBoolean := true;
je := ADODataSet1.Fields[8].AsString ;
ADOQ_sc.Fields[8].AsString := je;
end
else begin
ADOQ_sc.Fields[7].AsBoolean := false;
je := ADODataSet1.Fields[7].AsString ;
ADOQ_sc.Fields[8].AsString := je;
end;

ADOQ_sc.Fields[9].AsString := trim(EDIT1.Text) ;
ADOQ_sc.Fields[10].AsString := datetostr(now) ;
ADOQ_sc.Fields[11].AsString := ADODataSet1.Fields[11].AsString ;
ADOQ_sc.Fields[12].AsString := 'good';
ADOQ_sc.Fields[13].AsString := inttostr(strtoint(trim(EDIT1.Text))*(strtoint(je)));
ADOQ_sc.Post;
ADODataSet2.Close;
ADODataSet2.Open;
ADODataSet2.First;
for i := 0 to ADODataSet2.RecordCount-1 do
begin
ljje := ljje+ strtoint(trim(ADODataSet2.Fields[13].asstring));
ADODataSet2.Next;
end;
ADODataSet2.First;
gjjeLabeledEdit.Text := inttostr(ljje);
end;

end.
 
怎么好象用了好多第三方控件。
那么我的代码想说清楚很难,你至少要先知道哪个按扭是做什么的,不然。。。很乱。。。让人费解
 
好象太长了,短一点还可以详细注释;
好象有四个控件我没有;
另外你的名字是不是起的也太长了?
cxGridDBTableView1DBColumn1: TcxGridDBColumn;
仔细看了一下,好象是对数据库修改之类的操作?对不对?
 
每一句的解释?! 不如你提出哪一句不懂吧
 
真的太长了阿
我都不想看了呀
 
代码书写的没有严格的构思,太乱了。
有好多代码,是可以提炼出来的。
并且这段代码我调试不了!
 
你当然调试不了,他里面用了几个三方控件;
 
后退
顶部