📄 browbuyinfo_unit.pas
字号:
unit BrowBuyInfo_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ExtCtrls, StdCtrls, Buttons, ToolWin, ComCtrls;
type
TBrowBuyInfo_Form = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
DBGrid1: TDBGrid;
CoolBar1: TCoolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
StatusBar1: TStatusBar;
Label3: TLabel;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
G_Bar: string;
G_Detail: Boolean;
NoPay, Reinstall, UserType: string;
BrowBuyInfo_Form: TBrowBuyInfo_Form;
implementation
uses Datamodule_Unit, ADODB, BuyInfoUnit, Print_Unit;
{$R *.dfm}
procedure TBrowBuyInfo_Form.FormShow(Sender: TObject);
begin
with Datamodule_Unit.DM.Aq_BuyInfo do
begin
Close;
Sql.Clear;
Sql.Add('select * from 用户购机资料表');
try
Open;
except
end;
DBGrid1.Columns.Items[0].FieldName := 'In_Bar';
DBGrid1.Columns.Items[1].FieldName := 'Out_Bar';
DBGrid1.Columns.Items[2].FieldName := 'User_Name';
DBGrid1.Columns.Items[3].FieldName := 'Mac_Type';
DBGrid1.Columns.Items[4].FieldName := 'Unit_Price';
DBGrid1.Columns.Items[5].FieldName := 'Post_Code';
DBGrid1.Columns.Items[6].FieldName := 'Address';
DBGrid1.Columns.Items[7].FieldName := 'Phone_Code';
DBGrid1.Columns.Items[8].FieldName := 'Home_Phone';
DBGrid1.Columns.Items[9].FieldName := 'Office_Phone';
DBGrid1.Columns.Items[10].FieldName := 'Mobile';
DBGrid1.Columns.Items[11].FieldName := 'BuyShop';
DBGrid1.Columns.Items[12].FieldName := 'Buy_Date';
DBGrid1.Columns.Items[13].FieldName := 'Install_Date';
DBGrid1.Columns.Items[14].FieldName := 'RepairCon';
DBGrid1.Columns.Items[15].FieldName := 'Service_Id';
DBGrid1.Columns.Items[16].FieldName := 'Worker_Name';
DBGrid1.Columns.Items[17].FieldName := 'Cent';
DBGrid1.Columns.Items[18].FieldName := 'Unit_Name';
DBGrid1.Columns.Items[19].FieldName := 'Remark';
DBGrid1.Columns.Items[0].Title.Caption := '室内机条码';
DBGrid1.Columns.Items[1].Title.Caption := '室外机条码';
DBGrid1.Columns.Items[2].Title.Caption := '用户姓名';
DBGrid1.Columns.Items[3].Title.Caption := '机型';
DBGrid1.Columns.Items[4].Title.Caption := '单价';
DBGrid1.Columns.Items[5].Title.Caption := '邮编';
DBGrid1.Columns.Items[6].Title.Caption := '住址';
DBGrid1.Columns.Items[7].Title.Caption := '电话区号';
DBGrid1.Columns.Items[8].Title.Caption := '宅电';
DBGrid1.Columns.Items[9].Title.Caption := '办公电话';
DBGrid1.Columns.Items[10].Title.Caption := '手机';
DBGrid1.Columns.Items[11].Title.Caption := '购机商店';
DBGrid1.Columns.Items[12].Title.Caption := '购机日期';
DBGrid1.Columns.Items[13].Title.Caption := '安装日期';
DBGrid1.Columns.Items[14].Title.Caption := '保修';
DBGrid1.Columns.Items[15].Title.Caption := '服务证号';
DBGrid1.Columns.Items[16].Title.Caption := '安装工姓名';
DBGrid1.Columns.Items[17].Title.Caption := '分数';
DBGrid1.Columns.Items[18].Title.Caption := '单位名称';
DBGrid1.Columns.Items[19].Title.Caption := '备注';
StatusBar1.Panels.Items[0].Text := '共 ' + IntToStr(RecordCount) + ' 条记录';
end;
end;
procedure TBrowBuyInfo_Form.SpeedButton1Click(Sender: TObject);
begin
G_Detail := False;
if not Assigned(BuyInfo_Form) then
begin
BuyInfo_Form := TBuyInfo_Form.Create(Self);
end;
BuyInfo_Form.ShowModal;
end;
procedure TBrowBuyInfo_Form.SpeedButton4Click(Sender: TObject);
begin
Self.Close;
end;
procedure TBrowBuyInfo_Form.SpeedButton2Click(Sender: TObject);
begin
G_Detail := True;
with Datamodule_Unit.DM.Aq_BuyInfo do
begin
G_Bar := FieldByName('In_Bar').AsString;
end;
if not Assigned(BuyInfo_Form) then
begin
BuyInfo_Form := TBuyInfo_Form.Create(Self);
end;
BuyInfo_Form.ShowModal;
end;
procedure TBrowBuyInfo_Form.BitBtn1Click(Sender: TObject);
begin
if (Edit1.Text = '') and (Edit2.Text = '') then
begin
Application.MessageBox('请输入查询条件!', '提示', Mb_Ok or Mb_IconError);
Exit;
end;
with Datamodule_Unit.DM.Aq_BuyInfo do
begin
Filtered := False;
Filter := 'In_Bar = ''' + Edit1.Text + ''' or User_Name = ''' + Edit2.Text + '''';
Filtered := True;
StatusBar1.Panels.Items[0].Text := '共 ' + IntToStr(RecordCount) + ' 条记录';
if RecordCount = 0 then
begin
Application.MessageBox('没有要查询的信息!', '提示', Mb_Ok or Mb_iconerror);
end;
end;
end;
procedure TBrowBuyInfo_Form.BitBtn2Click(Sender: TObject);
begin
with Datamodule_Unit.DM.Aq_BuyInfo do
begin
Filtered := False;
Filter := '';
StatusBar1.Panels.Items[0].Text := '共 ' + IntToStr(RecordCount) + ' 条记录';
end;
end;
procedure TBrowBuyInfo_Form.SpeedButton3Click(Sender: TObject);
begin
Print_Form.QuickRep1.Preview;
end;
procedure TBrowBuyInfo_Form.FormCreate(Sender: TObject);
begin
G_Detail := False;
end;
procedure TBrowBuyInfo_Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := CaFree;
BrowBuyInfo_Form := nil;
end;
procedure TBrowBuyInfo_Form.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DBGrid1.DataSource.DataSet.RecNo mod 2 = 0 then //条件判断
begin
with DBGrid1 do
begin
Canvas.Font.Color := clBlack;
Canvas.Brush.Color := clAqua;
end;
end
Else
begin
with DBGrid1 do
begin
Canvas.Font.Color := clBlack;
Canvas.Brush.Color := clMoneyGreen;
end;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -