unit U_EmptyRollerCklist; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Common, RM_Class, RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, cxTextEdit, cxPC, cxCheckBox, Menus; type TfrmEmptyRollerCklist = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBAdd: TToolButton; TBEdit: TToolButton; TBDel: TToolButton; TBExport: TToolButton; TBClose: TToolButton; Panel1: TPanel; Label1: TLabel; BegDate: TDateTimePicker; EndDate: TDateTimePicker; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1Qty: TcxGridDBColumn; v1Note: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; v1CRType: TcxGridDBColumn; v1CRTime: TcxGridDBColumn; v1CRNO: TcxGridDBColumn; v1Filler: TcxGridDBColumn; v1FillTime: TcxGridDBColumn; Label2: TLabel; CRType: TComboBox; Label5: TLabel; ADOQueryCmd: TADOQuery; ADOQueryTmp: TADOQuery; DataSource1: TDataSource; CDS_Main: TClientDataSet; cxGridPopupMenu1: TcxGridPopupMenu; ADOPrint: TADOQuery; RMXLSExport1: TRMXLSExport; v1inoutNO: TcxGridDBColumn; inoutNo: TEdit; Label7: TLabel; v1custName: TcxGridDBColumn; RMDB_Main: TRMDBDataSet; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyle2: TcxStyle; cxStyle_gridRow: TcxStyle; cxStyle_gridFoot: TcxStyle; cxStyle_gridHead: TcxStyle; cxStyle_gridGroupBox: TcxStyle; cxStyle_yellow: TcxStyle; cxStyle_Red: TcxStyle; cxStyle_fontBlack: TcxStyle; cxStyle_fontclFuchsia: TcxStyle; cxStyle_fontclPurple: TcxStyle; cxStyle_fontclGreen: TcxStyle; cxStyle_fontclBlue: TcxStyle; cxStyle_fontclTeal: TcxStyle; cxStyle_fontclOlive: TcxStyle; Label8: TLabel; ToFactoryName: TEdit; ADOQueryMain: TADOQuery; RM1: TRMGridReport; v1Column5: TcxGridDBColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; v1Column1: TcxGridDBColumn; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure TBAddClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBEditClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); private procedure InitGrid(); procedure InitForm(); procedure SetStatus(); { Private declarations } public canshu1, canshu2: string; { Public declarations } end; var frmEmptyRollerCklist: TfrmEmptyRollerCklist; implementation uses U_DataLink, U_Fun10, U_ZDYHelp, U_EmptyRollerCk; {$R *.dfm} procedure TfrmEmptyRollerCklist.InitForm(); var fsj: string; begin readCxGrid(self.Caption, Tv1, '仓储管理'); SetStatus(); fsj := 'select distinct(CRType) name from CK_WarpRoller_CR where CKName=''空轴'' and CRFlag=''出库'' and Valid=''Y'' '; SInitComBoxBySql(ADOQueryCmd, CRType, False, fsj); end; procedure TfrmEmptyRollerCklist.SetStatus(); begin TBEdit.Visible := False; TBDel.Visible := False; if Trim(canshu1) = '管理' then begin TBEdit.Visible := true; TBDel.Visible := true; end else begin end; end; procedure TfrmEmptyRollerCklist.InitGrid(); begin try with ADOQueryMain do begin close; sql.Clear; sql.Add(' select A.* '); SQL.Add(' from CK_WarpRoller_CR A '); sql.Add(' where CRTime>=''' + formatdateTime('yyyy-MM-dd', begdate.Date) + ''' '); sql.Add(' and CRTime<''' + formatdateTime('yyyy-MM-dd', enddate.Date + 1) + ''' '); sql.Add(' and CKName=''空轴'' and CRFlag=''出库'' and A.valid=''Y'' '); open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); finally end; end; procedure TfrmEmptyRollerCklist.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := cafree; end; procedure TfrmEmptyRollerCklist.FormDestroy(Sender: TObject); begin frmEmptyRollerCklist := nil; end; procedure TfrmEmptyRollerCklist.TBAddClick(Sender: TObject); begin frmEmptyRollerCk := TfrmEmptyRollerCk.create(self); with frmEmptyRollerCk do begin fkeyNo := ''; fType := 0; if showmodal = 1 then begin TBRafresh.Click; self.CDS_Main.Locate('crNo', trim(fkeyNo), []); end; free; end; end; procedure TfrmEmptyRollerCklist.OrderNoChange(Sender: TObject); begin if ADOQuerymain.Active = False then Exit; SDofilter(ADOQuerymain, SGetFilters(Panel1, 1, 2)); SCreateCDS20(ADOQuerymain, CDS_Main); SInitCDSData20(ADOQuerymain, CDS_Main); end; procedure TfrmEmptyRollerCklist.FormShow(Sender: TObject); begin InitForm(); InitGrid(); end; procedure TfrmEmptyRollerCklist.FormCreate(Sender: TObject); begin EndDate.Date := SGetServerDate10(ADOQueryTmp); BegDate.Date := EndDate.Date - 30; cxGrid1.Align := alclient; canshu1 := trim(DParameters1); end; procedure TfrmEmptyRollerCklist.TBCloseClick(Sender: TObject); begin writeCxGrid(self.Caption, Tv1, '仓储管理'); close; end; procedure TfrmEmptyRollerCklist.TBEditClick(Sender: TObject); begin if cds_main.IsEmpty then exit; if (cds_main.fieldbyname('Filler').AsString <> trim(DName)) and (trim(canshu2) <> '高权限') then begin application.MessageBox('操作员不正确,不能修改!', '提示信息', MB_ICONERROR); exit; end; frmEmptyRollerCk := TfrmEmptyRollerCk.create(self); with frmEmptyRollerCk do begin fkeyNo := self.cds_main.fieldbyname('CRNO').AsString; fType := 1; InoutNo.Enabled := false; if showmodal = 1 then begin TBRafresh.Click; self.CDS_Main.Locate('CRNO', trim(fkeyNo), []); end; free; end; end; procedure TfrmEmptyRollerCklist.TBDelClick(Sender: TObject); var YFID, CRID, note: string; begin if CDS_Main.IsEmpty then Exit; if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人数据!', '提示', 0); Exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; try if Trim(CDS_Main.FieldByName('CRNO').AsString) <> '' then begin ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('update CK_WarpRoller_CR set Valid=''N'' where CRNO=' + quotedstr(Trim(CDS_Main.FieldByName('CRNO').AsString))); ExecSQL; end; with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_Up_EmptyRoller ' + quotedstr(Trim(CDS_Main.FieldByName('CRNO').AsString))); Open; end; if Trim(ADOQueryCmd.FieldByName('Msg').AsString) = '操作失败' then begin CDS_Main.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('出库数量超出库存数量!', '提示', 0); Exit; end; ADOQueryCmd.Connection.CommitTrans; CDS_Main.Delete; end; except Application.MessageBox('数据删除失败!', '提示信息', 0); end; end; procedure TfrmEmptyRollerCklist.TBRafreshClick(Sender: TObject); begin initGrid(); end; procedure TfrmEmptyRollerCklist.TBExportClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; TcxGridToExcel(self.Caption, cxgrid1); end; procedure TfrmEmptyRollerCklist.v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); var colIdx0, colIdx1: integer; begin colIdx0 := tv1.GetColumnByFieldName('CRNO').Index; if (ARow1.Values[colIdx0] = ARow2.Values[colIdx0]) then AAreEqual := True else AAreEqual := False; end; procedure TfrmEmptyRollerCklist.N1Click(Sender: TObject); begin SelOKNo(CDS_Main, True); end; procedure TfrmEmptyRollerCklist.N2Click(Sender: TObject); begin SelOKNo(CDS_Main, False); end; end.