U_kcpd.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:12k
- unit U_kcpd;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, Mask, ComCtrls, Db, DBClient, Grids, DBGrids, Buttons,
- DBCtrls, QuickRpt, Qrctrls, Menus;
- type
- TForm5 = class(TForm)
- Panel1: TPanel;
- Label1: TLabel;
- Label2: TLabel;
- Panel2: TPanel;
- StatusBar1: TStatusBar;
- DBGrid1: TDBGrid;
- Panel3: TPanel;
- SpeedButton1: TSpeedButton;
- SpeedButton2: TSpeedButton;
- SpeedButton4: TSpeedButton;
- SpeedButton7: TSpeedButton;
- Label3: TLabel;
- ClientDataSet3: TClientDataSet;
- SpeedButton8: TSpeedButton;
- ClientDataSet2: TClientDataSet;
- DataSource2: TDataSource;
- Label4: TLabel;
- DBEdit1: TDBEdit;
- Label5: TLabel;
- DBEdit2: TDBEdit;
- DBComboBox1: TDBComboBox;
- DBEdit3: TDBEdit;
- DBEdit4: TDBEdit;
- SpeedButton5: TSpeedButton;
- SpeedButton6: TSpeedButton;
- ClientDataSet_index: TClientDataSet;
- SpeedButton3: TSpeedButton;
- QuickRep1: TQuickRep;
- PageHeaderBand1: TQRBand;
- QRLabel1: TQRLabel;
- QRLabel2: TQRLabel;
- QRSysData1: TQRSysData;
- PageFooterBand1: TQRBand;
- QRLabel8: TQRLabel;
- QRLabel9: TQRLabel;
- QRSysData2: TQRSysData;
- ColumnHeaderBand1: TQRBand;
- QRLabel3: TQRLabel;
- QRLabel4: TQRLabel;
- QRLabel5: TQRLabel;
- QRLabel6: TQRLabel;
- QRLabel7: TQRLabel;
- QRLabel15: TQRLabel;
- TitleBand1: TQRBand;
- QRLabel10: TQRLabel;
- QRLabel11: TQRLabel;
- QRLabel12: TQRLabel;
- QRLabel13: TQRLabel;
- QRLabel14: TQRLabel;
- QRDBText6: TQRDBText;
- QRDBText7: TQRDBText;
- QRDBText8: TQRDBText;
- QRDBText9: TQRDBText;
- QRDBText10: TQRDBText;
- QRShape1: TQRShape;
- QRShape2: TQRShape;
- QRSubDetail1: TQRSubDetail;
- QRDBText1: TQRDBText;
- QRDBText2: TQRDBText;
- QRDBText3: TQRDBText;
- QRDBText4: TQRDBText;
- QRDBText5: TQRDBText;
- QRDBText11: TQRDBText;
- BitBtn3: TBitBtn;
- PopupMenu1: TPopupMenu;
- N1: TMenuItem;
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton2Click(Sender: TObject);
- procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure SpeedButton8Click(Sender: TObject);
- procedure SpeedButton4Click(Sender: TObject);
- procedure SpeedButton7Click(Sender: TObject);
- procedure SpeedButton5Click(Sender: TObject);
- procedure SpeedButton6Click(Sender: TObject);
- procedure SpeedButton3Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure N1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form5: TForm5;
- implementation
- uses U_mainform, U_clkcqk, U_fzlr_clbm, U_kcpd_child, U_fzlr_zgxm;
- {$R *.DFM}
- procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- action := cafree;
- form65.clientdataset1.Cancel;
- form65.clientdataset1.CancelUpdates;
- end;
- procedure TForm5.SpeedButton1Click(Sender: TObject);
- begin
- speedbutton1.enabled := not speedbutton1.Enabled;
- speedbutton2.enabled := not speedbutton2.enabled;
- speedbutton3.enabled := not speedbutton3.enabled;
- speedbutton4.enabled := not speedbutton4.enabled;
- speedbutton5.enabled := not speedbutton5.enabled;
- speedbutton6.enabled := not speedbutton6.enabled;
- speedbutton7.enabled := not speedbutton7.enabled;
- speedbutton8.enabled := not speedbutton8.enabled;
- dbedit4.enabled := true;
- bitbtn3.visible := not bitbtn3.visible;
- dbgrid1.columns[3].readonly := not dbgrid1.columns[3].readonly;
- panel1.enabled := not panel1.enabled;
- form65.clientdataset1.Insert;
- dbgrid1.PopupMenu := popupMenu1;
- end;
- procedure TForm5.SpeedButton2Click(Sender: TObject);
- var
- i: integer;
- d_date: Tdatetime;
- vs_pdbh: string;
- begin
- if dbcombobox1.text = '' then
- begin
- application.MessageBox('请先选择仓库', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbcombobox1.setfocus;
- exit;
- end;
- { try
- d_date := strtodate(dbedit3.text);
- except
- application.MessageBox('盘点日期输入是否正确', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbedit3.setfocus;
- exit;
- end; }
- if length(trim(dbedit4.text)) <> 9 then
- begin
- application.MessageBox('当前盘店号应为九位', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbedit4.setfocus;
- exit;
- end;
- vs_pdbh := dbedit4.Text;
- clientdataset_index.IndexFieldNames := '盘点编号';
- clientdataset_index.Refresh;
- if form65.clientdataset1.state = dsinsert then
- begin
- if clientdataset_index.FindKey([vs_pdbh]) then
- begin
- application.MessageBox('盘点编号已重复', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit4.SetFocus;
- exit;
- end;
- end;
- application.createform(tform64, form64);
- try
- form64.showmodal;
- finally
- form64.free;
- for i := 0 to gi_count1 - 1 do
- begin
- clientdataset2.insert;
- clientdataset2.fieldbyname('材料编码').value := gs_clbm1[i];
- clientdataset2.fieldbyname('材料名称').value := gs_clmc1[i];
- clientdataset2.fieldbyname('规格型号').value := gs_ggxh1[i];
- clientdataset2.fieldbyname('计量单位').value := gs_jldw1[i];
- clientdataset2.fieldbyname('计划单价').value := gs_jhdj1[i];
- clientdataset2.fieldbyname('单价单位').value := gs_djdw1[i];
- clientdataset2.fieldbyname('实存数量').value := gs_xykcl1[i];
- clientdataset2.fieldbyname('盘点数量').value := 0.00;
- clientdataset2.post;
- end;
- end;
- end;
- procedure TForm5.DBGrid1KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- if key = 46 then //当按下Delete键
- begin
- form65.clientdataset1.delete;
- end;
- end;
- procedure TForm5.SpeedButton8Click(Sender: TObject);
- var
- i: integer;
- d_date: Tdate;
- vs_pdbh: string;
- begin
- if dbcombobox1.text = '' then
- begin
- application.MessageBox('请先选择仓库', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbcombobox1.setfocus;
- exit;
- end;
- { try
- d_date := strtodate(dbedit3.text);
- except
- application.MessageBox('盘点日期输入是否正确', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbedit3.setfocus;
- exit;
- end; }
- if length(trim(dbedit4.text)) <> 9 then
- begin
- application.MessageBox('当前盘店号应为九位', '材料与计划管理系统', mb_iconinformation + mb_defbutton1);
- dbedit4.setfocus;
- exit;
- end;
- vs_pdbh := dbedit4.Text;
- clientdataset_index.IndexFieldNames := '盘点编号';
- clientdataset_index.Refresh;
- if form65.clientdataset1.state = dsinsert then
- begin
- if clientdataset_index.FindKey([vs_pdbh]) then
- begin
- application.MessageBox('盘点编号已重复', '物资管理系统', mb_iconinformation + mb_defbutton1);
- dbedit4.SetFocus;
- exit;
- end;
- end;
- application.createform(tform27, form27);
- try
- form27.showmodal;
- finally
- form27.free;
- for i := 0 to gi_count - 1 do
- begin
- { clientdataset2.IndexFieldNames := '材料编码';
- if clientdataset2.FindKey([gs_clbm[i]]) then
- begin
- application.MessageBox('已有此物资', '物资管理系统', mb_iconinformation + mb_defbutton1);
- continue;
- end; }
- clientdataset2.insert;
- clientdataset2.fieldbyname('材料编码').value := gs_clbm[i];
- clientdataset2.fieldbyname('材料名称').value := gs_clmc[i];
- clientdataset2.fieldbyname('规格型号').value := gs_ggxh[i];
- clientdataset2.fieldbyname('计量单位').value := gs_jldw[i];
- clientdataset2.fieldbyname('计划单价').value := gs_jhdj[i];
- clientdataset2.fieldbyname('单价单位').value := gs_djdw[i];
- clientdataset2.fieldbyname('实存数量').value := 0.0;
- clientdataset2.fieldbyname('盘点数量').value := 0.0;
- clientdataset2.post;
- end;
- end;
- end;
- procedure TForm5.SpeedButton4Click(Sender: TObject);
- var
- i: integer;
- vi_count: integer;
- begin
- vi_count := clientdataset2.recordcount;
- clientdataset2.DisableControls;
- clientdataset2.First;
- for i := 0 to vi_count - 1 do
- begin
- if clientdataset2.fieldbyname('实存数量').asfloat = clientdataset2.fieldbyname('盘点数量').asfloat then
- clientdataset2.Delete;
- end;
- clientdataset2.EnableControls;
- dbgrid1.Refresh;
- end;
- procedure TForm5.SpeedButton7Click(Sender: TObject);
- var
- i: integer;
- vi_count: integer;
- begin
- vi_count := clientdataset2.recordcount;
- clientdataset2.DisableControls;
- clientdataset2.First;
- if clientdataset2.recordcount = 0 then
- begin
- application.messagebox('请添加物资', '物资管理系统', mb_iconinformation + mb_defbutton1);
- exit;
- end;
- for i := 0 to vi_count - 1 do
- begin
- if clientdataset2.fieldbyname('实存数量').asfloat = clientdataset2.fieldbyname('盘点数量').asfloat then
- begin
- application.messagebox('有实存数量同盘店数量一致', '物资管理系统', mb_iconinformation + mb_defbutton1);
- clientdataset2.enablecontrols;
- exit;
- end;
- end;
- clientdataset2.EnableControls;
- form65.clientdataset1.Post;
- form65.clientdataset1.ApplyUpdates(0);
- speedbutton1.enabled := not speedbutton1.Enabled;
- speedbutton2.enabled := not speedbutton2.enabled;
- speedbutton3.enabled := not speedbutton3.enabled;
- speedbutton4.enabled := not speedbutton4.enabled;
- speedbutton5.enabled := not speedbutton5.enabled;
- speedbutton6.enabled := not speedbutton6.enabled;
- speedbutton7.enabled := not speedbutton7.enabled;
- speedbutton8.enabled := not speedbutton8.enabled;
- bitbtn3.visible := not bitbtn3.visible;
- panel1.enabled := not panel1.enabled;
- dbgrid1.columns[3].readonly := not dbgrid1.columns[3].readonly;
- dbgrid1.PopupMenu := nil;
- end;
- procedure TForm5.SpeedButton5Click(Sender: TObject);
- begin
- form65.clientdataset1.CancelUpdates;
- speedbutton1.enabled := not speedbutton1.Enabled;
- speedbutton2.enabled := not speedbutton2.enabled;
- speedbutton3.enabled := not speedbutton3.enabled;
- speedbutton4.enabled := not speedbutton4.enabled;
- speedbutton5.enabled := not speedbutton5.enabled;
- speedbutton6.enabled := not speedbutton6.enabled;
- speedbutton7.enabled := not speedbutton7.enabled;
- speedbutton8.enabled := not speedbutton8.enabled;
- bitbtn3.visible := not bitbtn3.visible;
- panel1.enabled := not panel1.enabled;
- dbgrid1.columns[3].readonly := not dbgrid1.columns[3].readonly;
- dbgrid1.PopupMenu := nil;
- end;
- procedure TForm5.SpeedButton6Click(Sender: TObject);
- begin
- speedbutton1.enabled := not speedbutton1.Enabled;
- speedbutton2.enabled := not speedbutton2.enabled;
- speedbutton3.enabled := not speedbutton3.enabled;
- speedbutton4.enabled := not speedbutton4.enabled;
- speedbutton5.enabled := not speedbutton5.enabled;
- speedbutton6.enabled := not speedbutton6.enabled;
- speedbutton7.enabled := not speedbutton7.enabled;
- speedbutton8.enabled := not speedbutton8.enabled;
- dbedit4.Enabled := false;
- bitbtn3.visible := not bitbtn3.visible;
- dbgrid1.columns[3].readonly := not dbgrid1.columns[3].readonly;
- panel1.enabled := not panel1.enabled;
- form65.clientdataset1.edit;
- dbgrid1.PopupMenu := popupmenu1;
- end;
- procedure TForm5.SpeedButton3Click(Sender: TObject);
- begin
- quickrep1.Preview;
- end;
- procedure TForm5.FormCreate(Sender: TObject);
- begin
- clientdataset3.first;
- while not clientdataset3.Eof do
- begin
- dbcombobox1.Items.add(clientdataset3.fieldbyname('仓库名称').asstring);
- clientdataset3.Next;
- end;
- end;
- procedure TForm5.FormActivate(Sender: TObject);
- begin
- // dbcombobox1.SetFocus;
- end;
- procedure TForm5.BitBtn3Click(Sender: TObject);
- begin
- application.createform(Tform31, form31);
- try
- form31.showmodal;
- finally
- form65.clientdataset1.FieldByName('盘点人').value := gs_zgxm;
- form31.free;
- end;
- end;
- procedure TForm5.N1Click(Sender: TObject);
- begin
- if clientdataset2.recordcount <> 0 then
- clientdataset2.Delete;
- end;
- end.