316 lines
7.9 KiB
ObjectPascal
316 lines
7.9 KiB
ObjectPascal
unit U_MLRklist;
|
||
|
||
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, cxContainer, cxTextEdit, cxCurrencyEdit, cxCheckBox,
|
||
RM_System, RM_Dataset, RM_Common, RM_Class, RM_GridReport, cxPC, Menus;
|
||
|
||
type
|
||
TfrmMLRklist = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBAdd: TToolButton;
|
||
TBEdit: TToolButton;
|
||
TBDel: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1P_CodeName: TcxGridDBColumn;
|
||
v1P_SPEC: TcxGridDBColumn;
|
||
v1P_MF: TcxGridDBColumn;
|
||
v1P_KZ: TcxGridDBColumn;
|
||
v1Qty: TcxGridDBColumn;
|
||
v1QtyUnit: TcxGridDBColumn;
|
||
v1Note: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1CRType: TcxGridDBColumn;
|
||
v1CRTime: TcxGridDBColumn;
|
||
v1Filler: TcxGridDBColumn;
|
||
v1FillTime: TcxGridDBColumn;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
P_CodeName: TEdit;
|
||
P_Color: TEdit;
|
||
CRType: TComboBox;
|
||
Label5: TLabel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
v1MJID: TcxGridDBColumn;
|
||
v1MJXH: TcxGridDBColumn;
|
||
ckName: TComboBox;
|
||
Label6: TLabel;
|
||
v1P_Color: TcxGridDBColumn;
|
||
v1P_Code: TcxGridDBColumn;
|
||
v1INoutNo: TcxGridDBColumn;
|
||
Label7: TLabel;
|
||
inoutNo: TEdit;
|
||
v1Price: TcxGridDBColumn;
|
||
v1money: TcxGridDBColumn;
|
||
kuwei: TEdit;
|
||
Label9: TLabel;
|
||
gangNo: TEdit;
|
||
Label10: TLabel;
|
||
v1Column3: TcxGridDBColumn;
|
||
RMDB_Main: TRMDBDataSet;
|
||
v1Column4: TcxGridDBColumn;
|
||
ADOQueryPrint: TADOQuery;
|
||
RM1: TRMGridReport;
|
||
OrderNo: TEdit;
|
||
Label14: TLabel;
|
||
P_Code: TEdit;
|
||
Label15: TLabel;
|
||
v1Column10: TcxGridDBColumn;
|
||
Label17: TLabel;
|
||
FactoryName: TEdit;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
v1Column1: TcxGridDBColumn;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure TBAddClick(Sender: TObject);
|
||
procedure P_CodeNameChange(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 TBFindClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
{ Private declarations }
|
||
public
|
||
fCKName,canshu1:string;
|
||
fCRType:string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmMLRklist: TfrmMLRklist;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun10,U_ZDYHelp, U_MLRk;
|
||
{$R *.dfm}
|
||
procedure TfrmMLRklist.SetStatus();
|
||
begin
|
||
TBEdit.Visible:=False;
|
||
TBDel.Visible:=False;
|
||
|
||
if Trim(canshu1)='<27><>Ȩ<EFBFBD><C8A8>' then
|
||
begin
|
||
TBEdit.Visible:=true;
|
||
TBDel.Visible:=true;
|
||
end
|
||
else
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.InitGrid();
|
||
begin
|
||
try
|
||
with adoqueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.* from CK_ML_CR A');
|
||
sql.Add(' where A.CRTime>='''+formatdateTime('yyyy-MM-dd',begdate.Date)+''' ');
|
||
sql.Add(' and A.CRTime<'''+formatdateTime('yyyy-MM-dd',enddate.Date+1)+''' ');
|
||
sql.Add(' and CKName=''<27><><EFBFBD>ϲֿ<CFB2>'' and A.CRFlag=''<27><><EFBFBD><EFBFBD>'' and A.Valid=''Y'' ');
|
||
open;
|
||
end;
|
||
SCreateCDS20(adoqueryTmp,CDS_Main);
|
||
SInitCDSData20(adoqueryTmp,CDS_Main);
|
||
TBFind.Click;
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=cafree;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmMLRklist:=nil;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBAddClick(Sender: TObject);
|
||
begin
|
||
frmMLRk:=TfrmMLRk.create(self);
|
||
with frmMLRk do
|
||
begin
|
||
fkeyNo:='';
|
||
fType:=0;
|
||
if showmodal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('crNo',trim(fkeyNo),[]) ;
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.P_CodeNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryTmp.Active=False then Exit;
|
||
SDofilter(ADOQueryTmp,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryTmp,CDS_Main);
|
||
SInitCDSData20(ADOQueryTmp,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmMLRklist.FormShow(Sender: TObject);
|
||
begin
|
||
readCxGrid(self.Caption,Tv1,'<27><><EFBFBD>ϲֿ<CFB2>');
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmMLRklist.FormCreate(Sender: TObject);
|
||
begin
|
||
EndDate.Date:=SGetServerDate10(ADOQueryTmp);
|
||
BegDate.Date:=EndDate.Date-30;
|
||
canshu1:=trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBCloseClick(Sender: TObject);
|
||
begin
|
||
writeCxGrid(self.Caption,Tv1,'<27><><EFBFBD>ϲֿ<CFB2>');
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBEditClick(Sender: TObject);
|
||
begin
|
||
if cds_main.IsEmpty then exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.* ');
|
||
sql.Add('from CK_ML_CR A');
|
||
SQL.Add('inner join CK_ML_KC B on B.MJID=A.MJID ');
|
||
SQL.Add('where A.CRNO='''+trim(cds_main.fieldbyname('CRNO').AsString)+''' ');
|
||
SQL.Add('and B.Qty<>A.Qty and A.valid=''Y'' ');
|
||
Open;
|
||
end;
|
||
if not ADOQueryCmd.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27>˵<EFBFBD><CBB5>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD><E2A3AC><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
frmMLRk:=TfrmMLRk.create(self);
|
||
with frmMLRk do
|
||
begin
|
||
fkeyNo:=self.cds_main.fieldbyname('CRNO').AsString;
|
||
fType:=1;
|
||
fckName:=self.fckName;
|
||
fCRType:=self.fCRType;
|
||
if showmodal=1 then
|
||
begin
|
||
TBRafresh.Click;
|
||
self.CDS_Main.Locate('crNo',trim(fkeyNo),[]) ;
|
||
end;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
if CDS_Main.IsEmpty then Exit;
|
||
if Trim(CDS_Main.fieldbyname('Filler').AsString)<>Trim(DName) then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',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_ML_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_MlKc '+quotedstr(Trim(CDS_Main.FieldByName('MJID').AsString)));
|
||
Open;
|
||
end;
|
||
if Trim(ADOQueryCmd.FieldByName('Msg').AsString)='<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>' then
|
||
begin
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
CDS_Main.Delete;
|
||
end;
|
||
except
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then Exit;
|
||
TcxGridToExcel(self.Caption,cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmMLRklist.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryTmp.Active=False then Exit;
|
||
SDofilter(ADOQueryTmp,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryTmp,CDS_Main);
|
||
SInitCDSData20(ADOQueryTmp,CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmMLRklist.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,True);
|
||
end;
|
||
|
||
procedure TfrmMLRklist.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,False);
|
||
end;
|
||
|
||
end.
|