U_bmlldgl.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:13k
- unit U_bmlldgl;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, DBCtrls, Buttons, Mask, Grids, DBGrids, ExtCtrls, Db, DBClient,
- ComCtrls, Menus, ImgList, Qrctrls, QuickRpt;
- type
- TfrmBmlld = class(TForm)
- ScrollBox3: TScrollBox;
- Panel2: TPanel;
- Panel8: TPanel;
- btn_insert: TSpeedButton;
- btn_find: TSpeedButton;
- btn_print: TSpeedButton;
- btn_post: TSpeedButton;
- btn_cancel: TSpeedButton;
- btn_refresh: TSpeedButton;
- btn_delete: TSpeedButton;
- btn_edit: TSpeedButton;
- DBNavigator2: TDBNavigator;
- Panel1: TPanel;
- Label28: TLabel;
- Label29: TLabel;
- Label30: TLabel;
- Label31: TLabel;
- Label32: TLabel;
- Label37: TLabel;
- Label38: TLabel;
- Label40: TLabel;
- DBEdit30: TDBEdit;
- DBEdit31: TDBEdit;
- DBEdit32: TDBEdit;
- DBEdit33: TDBEdit;
- DBEdit34: TDBEdit;
- DBEdit39: TDBEdit;
- DBCheckBox3: TDBCheckBox;
- DBComboBox2: TDBComboBox;
- Panel3: TPanel;
- Label33: TLabel;
- Label34: TLabel;
- Label35: TLabel;
- Label36: TLabel;
- DBEdit35: TDBEdit;
- DBEdit36: TDBEdit;
- DBEdit37: TDBEdit;
- DBEdit38: TDBEdit;
- DataSource5: TDataSource;
- DataSource4: TDataSource;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- StatusBar1: TStatusBar;
- Timer1: TTimer;
- DBGrid1: TDBGrid;
- ImageList1: TImageList;
- PopupMenu1: TPopupMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- Label1: TLabel;
- DBEdit1: TDBEdit;
- BitBtn6: TBitBtn;
- QuickRep1: TQuickRep;
- PageHeaderBand1: TQRBand;
- QRLabel1: TQRLabel;
- QRLabel2: TQRLabel;
- QRSysData1: TQRSysData;
- QRSubDetail1: TQRSubDetail;
- QRDBText10: TQRDBText;
- QRDBText11: TQRDBText;
- QRDBText12: TQRDBText;
- QRDBText13: TQRDBText;
- QRDBText14: TQRDBText;
- QRDBText15: TQRDBText;
- TitleBand1: TQRBand;
- QRLabel3: TQRLabel;
- QRLabel4: TQRLabel;
- QRLabel5: TQRLabel;
- QRLabel6: TQRLabel;
- QRLabel7: TQRLabel;
- QRLabel8: TQRLabel;
- QRLabel9: TQRLabel;
- QRLabel10: TQRLabel;
- QRLabel11: TQRLabel;
- QRDBText1: TQRDBText;
- QRDBText2: TQRDBText;
- QRDBText3: TQRDBText;
- QRDBText4: TQRDBText;
- QRDBText5: TQRDBText;
- QRDBText6: TQRDBText;
- QRDBText7: TQRDBText;
- QRDBText8: TQRDBText;
- QRDBText9: TQRDBText;
- QRShape1: TQRShape;
- QRShape2: TQRShape;
- SummaryBand1: TQRBand;
- QRLabel18: TQRLabel;
- QRLabel19: TQRLabel;
- QRLabel20: TQRLabel;
- QRLabel21: TQRLabel;
- QRDBText16: TQRDBText;
- QRDBText17: TQRDBText;
- QRDBText18: TQRDBText;
- QRDBText19: TQRDBText;
- PageFooterBand1: TQRBand;
- QRLabel22: TQRLabel;
- QRLabel23: TQRLabel;
- QRSysData2: TQRSysData;
- ColumnHeaderBand1: TQRBand;
- QRLabel17: TQRLabel;
- QRLabel39: TQRLabel;
- QRLabel40: TQRLabel;
- QRLabel41: TQRLabel;
- QRLabel42: TQRLabel;
- QRLabel43: TQRLabel;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure btn_insertClick(Sender: TObject);
- procedure btn_editClick(Sender: TObject);
- procedure btn_cancelClick(Sender: TObject);
- procedure btn_postClick(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- procedure BitBtn5Click(Sender: TObject);
- procedure btn_refreshClick(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure btn_findClick(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure btn_deleteClick(Sender: TObject);
- procedure N1Click(Sender: TObject);
- procedure DBGrid1DblClick(Sender: TObject);
- procedure N2Click(Sender: TObject);
- procedure BitBtn6Click(Sender: TObject);
- procedure btn_printClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- procedure btn_valid;
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmBmlld: TfrmBmlld;
- implementation
- uses U_mainform, U_fzlr_zgxm, WzglDB, u_public, U_fzlr_clbm;
- {$R *.DFM}
- procedure TfrmBmlld.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action := cafree;
- frmBmlld := nil;
- end;
- procedure TfrmBmlld.btn_insertClick(Sender: TObject);
- begin
- DM.CDS_BMLLD.filter := '';
- DM.CDS_BMLLD.filtered := true;
- DM.CDS_BMLLD.Insert;
- dbedit30.enabled := true;
- btn_valid;
- dbedit31.SetFocus;
- end;
- procedure TfrmBmlld.btn_valid;
- begin
- DBNavigator2.enabled := not dbnavigator2.enabled;
- btn_insert.enabled := not btn_insert.enabled;
- btn_delete.enabled := not btn_delete.enabled;
- btn_edit.enabled := not btn_edit.enabled;
- btn_cancel.enabled := not btn_cancel.enabled;
- btn_post.enabled := not btn_post.enabled;
- btn_find.enabled := not btn_find.enabled;
- btn_refresh.enabled := not btn_refresh.enabled;
- btn_print.enabled := not btn_print.enabled;
- panel3.enabled := not panel3.enabled;
- panel1.enabled := not panel1.enabled;
- dbgrid1.columns[2].readonly := not dbgrid1.columns[2].readonly;
- dbgrid1.columns[3].readonly := not dbgrid1.columns[3].readonly;
- bitbtn1.visible := not bitbtn1.visible;
- bitbtn2.visible := not bitbtn2.visible;
- bitbtn3.visible := not bitbtn3.visible;
- bitbtn4.visible := not bitbtn4.visible;
- bitbtn5.visible := not bitbtn5.visible;
- bitbtn6.visible := not bitbtn6.visible;
- end;
- procedure TfrmBmlld.btn_editClick(Sender: TObject);
- begin
- if DM.CDS_BMLLD.recordcount = 0 then
- begin
- application.MessageBox('没有记录不能编辑', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if DM.CDS_BMLLD.FieldByName('是否审核').value = true then
- begin
- application.messagebox('此单据已审核,不能编辑', '', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- DM.CDS_BMLLD.edit;
- dbedit30.enabled := false;
- btn_valid;
- dbedit31.setfocus;
- end;
- procedure TfrmBmlld.btn_cancelClick(Sender: TObject);
- begin
- DM.CDS_BMLLD.CancelUpdates;
- btn_valid;
- end;
- procedure TfrmBmlld.btn_postClick(Sender: TObject);
- var
- v_date: Tdate;
- s_llzh: string;
- begin
- if trim(dbedit31.text) = '' then
- begin
- application.MessageBox('领料单位不能为空', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit31.SetFocus;
- exit;
- end;
- if length(trim(dbedit30.text)) <> 9 then
- begin
- application.MessageBox('领料字号应为九位', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit30.SetFocus;
- exit;
- end;
- if dbcombobox2.text = '' then
- begin
- application.MessageBox('仓库名称不能为空', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbcombobox2.SetFocus;
- abort;
- end;
- s_llzh := dbedit30.Text;
- DM.CDS_BMLLD_INDEX.IndexFieldNames := '领料字号';
- DM.CDS_BMLLD_INDEX.Refresh;
- if DM.CDS_BMLLD.state = dsinsert then
- begin
- if DM.CDS_BMLLD_INDEX.FindKey([s_llzh]) then
- begin
- application.MessageBox('领料字号已重复', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit30.SetFocus;
- exit;
- end;
- end;
- DM.CDS_BMLLD_DETAIL.First;
- DM.CDS_BMLLD.Post;
- DM.CDS_BMLLD.ApplyUpdates(0);
- btn_valid;
- end;
- procedure TfrmBmlld.BitBtn2Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('材料主管').value := GetEmployeeName;
- end;
- procedure TfrmBmlld.BitBtn3Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('发料人').value := GetEmployeeName;
- end;
- procedure TfrmBmlld.BitBtn4Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('领料主管').value := GetEmployeeName;
- end;
- procedure TfrmBmlld.BitBtn5Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('领料人').value := GetEmployeeName;
- end;
- procedure TfrmBmlld.btn_refreshClick(Sender: TObject);
- begin
- DM.CDS_BMLLD.disablecontrols;
- DM.CDS_BMLLD.close;
- DM.CDS_BMLLD.CommandText := 'select * from cl_bmlld_main order by 领料字号';
- DM.CDS_BMLLD.open;
- DM.CDS_BMLLD.enablecontrols;
- DM.CDS_BMLLD.first;
- end;
- procedure TfrmBmlld.BitBtn1Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('领料单位').value := GetDeptName;
- end;
- procedure TfrmBmlld.btn_findClick(Sender: TObject);
- begin
- { application.createform(Tform77, form77);
- form77.combobox1.items.add('领料字号');
- form77.combobox1.items.add('领料单位');
- form77.combobox1.items.add('领料用途');
- form77.combobox1.items.add('材料主管');
- form77.combobox1.items.add('发料人');
- form77.combobox1.items.add('领料主管');
- form77.combobox1.items.add('领料人');
- v_table := 'CL_BMLLD_MAIN';
- try
- form77.showmodal;
- finally
- form77.free;
- if sf_qr = 'yes' then
- begin
- DM.CDS_BMLLD.filter := xx401;
- DM.CDS_BMLLD.filtered := true;
- end;
- end;
- }
- end;
- procedure TfrmBmlld.Timer1Timer(Sender: TObject);
- begin
- { statusbar1.panels[2].text := '共有: ' + inttostr(DM.CDS_BMLLD.recordcount) + ' 条记录';
- if DM.CDS_BMLLD.fieldbyname('是否审核').value = true then
- begin
- statusbar1.panels[1].text := '此单据已审核';
- end;
- if (DM.CDS_BMLLD.fieldbyname('是否审核').value = null) or (DM.CDS_BMLLD.fieldbyname('是否审核').value = false) then
- begin
- statusbar1.panels[1].text := '此单据未审核';
- end;
- statusbar1.refresh;}
- end;
- procedure TfrmBmlld.btn_deleteClick(Sender: TObject);
- begin
- if DM.CDS_BMLLD.recordcount = 0 then
- begin
- application.MessageBox('没有记录可删除', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if application.messagebox('请确认是否要删除', '物资管理系统', mb_iconinformation + mb_yesno) = idyes then
- begin
- DM.CDS_BMLLD.delete;
- DM.CDS_BMLLD.applyupdates(0);
- end;
- end;
- procedure TfrmBmlld.N1Click(Sender: TObject);
- var
- i: integer;
- s_hint : string;
- begin
- if dbgrid1.columns[2].readonly = true then
- begin
- application.MessageBox('请在添加或编辑状态下添加物资', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- application.createform(TfrmClbm_Fzlr, frmClbm_Fzlr);
- try
- frmClbm_Fzlr.showmodal;
- finally
- frmClbm_Fzlr.free;
- for i := Low(ClbmRec) to High(clbmRec) do
- begin
- DM.CDS_BMLLD_DETAIL_INDEX.refresh;
- DM.CDS_BMLLD_DETAIL_INDEX.Filter := '领料字号=' + '''' + DM.CDS_BMLLD.fieldbyname('领料字号').asstring + '''';
- DM.CDS_BMLLD_DETAIL_INDEX.filtered := true;
- DM.CDS_BMLLD_DETAIL_INDEX.IndexFieldNames := '材料编码';
- if DM.CDS_BMLLD_DETAIL_INDEX.FindKey([clbmRec[i].clbm]) then
- begin
- s_hint := '已有材料编号为' + clbmRec[i].clbm + '的物资';
- application.MessageBox(pchar(s_hint), '物资管理系统', mb_iconinformation + mb_defbutton1);
- continue;
- end;
- DM.CDS_BMLLD_DETAIL.insert;
- DM.CDS_BMLLD_DETAIL.fieldbyname('材料编码').value := clbmRec[i].clbm;
- DM.CDS_BMLLD_DETAIL.fieldbyname('材料名称').value := clbmRec[i].clmc;
- DM.CDS_BMLLD_DETAIL.fieldbyname('规格型号').value := clbmRec[i].ggxh;
- DM.CDS_BMLLD_DETAIL.fieldbyname('计量单位').value := clbmRec[i].jldw;
- DM.CDS_BMLLD_DETAIL.fieldbyname('计划单价').value := clbmRec[i].jhdj;
- DM.CDS_BMLLD_DETAIL.fieldbyname('单价单位').value := clbmRec[i].djdw;
- DM.CDS_BMLLD_DETAIL.fieldbyname('请领数量').value := 0.0;
- DM.CDS_BMLLD_DETAIL.fieldbyname('实发数量').value := 0.0;
- DM.CDS_BMLLD_DETAIL.post;
- end;
- end;
- end;
- procedure TfrmBmlld.DBGrid1DblClick(Sender: TObject);
- begin
- n1.click;
- end;
- procedure TfrmBmlld.N2Click(Sender: TObject);
- begin
- if DM.CDS_BMLLD_DETAIL.recordcount = 0 then
- begin
- application.MessageBox('没有记录可删除', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if dbgrid1.columns[2].readonly = true then
- begin
- application.MessageBox('请在添加或编辑状态下删除物资', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- if application.messagebox('请确认是否要删除', '物资管理系统', mb_iconinformation + mb_yesno) = idyes then
- begin
- DM.CDS_BMLLD_DETAIL.delete;
- end;
- end;
- procedure TfrmBmlld.BitBtn6Click(Sender: TObject);
- begin
- DM.CDS_BMLLD.FieldByName('工程项目').value := GetProjectName;
- end;
- procedure TfrmBmlld.btn_printClick(Sender: TObject);
- begin
- quickrep1.Preview;
- end;
- procedure TfrmBmlld.FormCreate(Sender: TObject);
- var
- s_value: string;
- begin
- with DM do
- begin
- CDS_CKXX_INDEX.Active := True;
- CDS_BMLLD.Active := True;
- CDS_BMLLD_DETAIL.Active := True;
- CDS_BMLLD_INDEX.Active := True;
- CDS_BMLLD_DETAIL_INDEX.Active := True;
- end;
- DM.CDS_CKXX_INDEX.First;
- while not DM.CDS_CKXX_INDEX.eof do
- begin
- s_value := DM.CDS_CKXX_INDEX.fieldbyname('仓库名称').asstring;
- dbcombobox2.Items.Add(s_value);
- DM.CDS_CKXX_INDEX.next;
- end;
- end;
- end.