unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
tch: TGroupBox;
sls: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
jsyno: TEdit;
jsyxm: TEdit;
hours: TEdit;
Label5: TLabel;
xsyno: TEdit;
Label6: TLabel;
xsyxm: TEdit;
xsl: TEdit;
Label7: TLabel;
Label8: TLabel;
result: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
lblHrRate: TLabel;
edtHrRate: TEdit;
lblComm: TLabel;
edtComm: TEdit;
GroupBox3: TGroupBox;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ResetTech(flag: boolean); //设置只读属性
procedure ResetSale(flag: boolean);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject); //flag标志着只读属性,true则只读,false则可修改
procedure SetEmptyTech();
procedure SetEmptySale();
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
t1: technician;
s1: salesman;
begin
if RadioButton1.Checked =true then
begin
// 计算技术员的月薪
number:=jsyno.Text ;
name1:= jsyxm.Text ;
t1:=technician.create ();
t1.MyHourlyRate := edtHrRate.Text;
t1.MyWorkHours := hours.Text;
t1.pay ();
t1.displaystatus ();
end
else begin
// 计算销售员的月薪
number:= xsyno.Text ;
name1:= xsyxm.Text ;
s1:=salesman.create ();
s1.MySales := xsl.Text;
s1.MyCommRate := edtComm.Text;
s1.pay ();
s1.displaystatus ();
end;
// 将信息显示在result文本框中
SetEmptyTech();
SetEmptySale();
result.Text :=result1;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.ResetTech(flag: boolean); //根据radio button选择情况设置各输入组的只读情况
begin
if flag = true then
begin
jsyno.ReadOnly := true;
jsyxm.ReadOnly := true;
hours.ReadOnly := true;
edtHrRate.ReadOnly := true;
jsyno.Enabled := false;
jsyxm.Enabled := false;
hours.Enabled := false;
edtHrRate.Enabled := false;
end
else begin
jsyno.ReadOnly := false;
jsyxm.ReadOnly := false;
hours.ReadOnly := false;
edtHrRate.ReadOnly := false;
jsyno.Enabled := true;
jsyxm.Enabled := true;
hours.Enabled := true;
edtHrRate.Enabled := true;
end;
end;
procedure TForm1.ResetSale(flag: boolean);
begin
if flag = true then
begin
xsyno.ReadOnly := true;
xsyxm.ReadOnly := true;
xsl.ReadOnly := true;
edtComm.ReadOnly := true;
xsyno.Enabled := false;
xsyxm.Enabled := false;
xsl.Enabled := false;
edtComm.Enabled := false;
end
else begin
xsyno.ReadOnly := false;
xsyxm.ReadOnly := false;
xsl.ReadOnly := false;
edtComm.ReadOnly := false;
xsyno.Enabled := true;
xsyxm.Enabled := true;
xsl.Enabled := true;
edtComm.Enabled := true;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if RadioButton1.Checked =true then//选中了技术员
begin
ResetTech(false); //将技术员的只读属性设置为false
ResetSale(true);//将销售员的只读属性设置为true
end
else begin
ResetTech(true); //将技术员的只读属性设置为true
ResetSale(false);//将销售员的只读属性设置为false
end;
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
ResetTech(false); //将技术员的只读属性设置为false
ResetSale(true);//将销售员的只读属性设置为true
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
ResetTech(true); //将技术员的只读属性设置为true
ResetSale(false);//将销售员的只读属性设置为false
end;
procedure TForm1.SetEmptySale;
begin
xsyno.Text := '';
xsyxm.Text := '';
xsl.Text := '';
edtComm.Text := '';
end;
procedure TForm1.SetEmptyTech;
begin
jsyno.Text := '';
jsyxm.Text := '';
hours.Text := '';
edtHrRate.Text := '';
end;
end.
Mar 7, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment