268 lines
6.9 KiB
ObjectPascal
268 lines
6.9 KiB
ObjectPascal
![]() |
unit U_BaseOutList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
|||
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
|||
|
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
|
|||
|
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
|||
|
cxGridDBTableView, cxGrid, cxCalendar, cxButtonEdit, cxDropDownEdit;
|
|||
|
|
|||
|
type
|
|||
|
TfrmBaseOutList = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBAdd: TToolButton;
|
|||
|
TBEdit: TToolButton;
|
|||
|
TBDel: TToolButton;
|
|||
|
TBPrint: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
TBExport: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
Label1: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
Label3: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
Label5: TLabel;
|
|||
|
Label6: TLabel;
|
|||
|
Label7: TLabel;
|
|||
|
Label8: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
PlanNo: TEdit;
|
|||
|
P_ChnName20: TEdit;
|
|||
|
P_ChnName10: TEdit;
|
|||
|
DefStr3: TEdit;
|
|||
|
ShorName: TEdit;
|
|||
|
HD: TEdit;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1PlanNo: TcxGridDBColumn;
|
|||
|
v1P_ChnName: TcxGridDBColumn;
|
|||
|
v1P_ChnName10: TcxGridDBColumn;
|
|||
|
v1ShortName: TcxGridDBColumn;
|
|||
|
v1DefStr3: TcxGridDBColumn;
|
|||
|
v1DefFlt1: TcxGridDBColumn;
|
|||
|
v1Quantity: TcxGridDBColumn;
|
|||
|
v1UnitName: TcxGridDBColumn;
|
|||
|
v1DefStr4: TcxGridDBColumn;
|
|||
|
v1Note: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
v1P_Spec10: TcxGridDBColumn;
|
|||
|
v1BSTypeName: TcxGridDBColumn;
|
|||
|
v1DepotClass: TcxGridDBColumn;
|
|||
|
v1batchnum: TcxGridDBColumn;
|
|||
|
Label9: TLabel;
|
|||
|
batchnum: TEdit;
|
|||
|
Label10: TLabel;
|
|||
|
BSTypeName: TEdit;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure TBFindClick(Sender: TObject);
|
|||
|
procedure TBEditClick(Sender: TObject);
|
|||
|
procedure TBDelClick(Sender: TObject);
|
|||
|
procedure TBExportClick(Sender: TObject);
|
|||
|
procedure TBPrintClick(Sender: TObject);
|
|||
|
procedure TBAddClick(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure PlanNoChange(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitGrid();
|
|||
|
procedure InitForm();
|
|||
|
function DelData():Boolean;
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmBaseOutList: TfrmBaseOutList;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_adodbmd,U_SelfForm,U_CxGridSet,U_FormPas,U_BaseOut,U_global;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmBaseOutList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmBaseOutList:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
cxgrid1.Align:=alClient;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><>˹<EFBFBD>ֿ<EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered:=False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('exec P_Get_ClothInOutList :begdate,:enddate,:DepotNo,:DepotCode,:PState,:CRK');
|
|||
|
Parameters.ParamByName('DepotCode').Value:=Trim(gDef1);
|
|||
|
Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',BegDate.DateTime));
|
|||
|
Parameters.ParamByName('enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',enddate.DateTime+1));
|
|||
|
Parameters.ParamByName('PState').Value:=1;
|
|||
|
Parameters.ParamByName('CRK').Value:=0;
|
|||
|
Open;
|
|||
|
end;
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.InitForm();
|
|||
|
begin
|
|||
|
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',Tv1,'<27><>˹<EFBFBD>ֿ<EFBFBD>');
|
|||
|
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
|||
|
EndDate.DateTime:=BegDate.DateTime;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBFindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBEditClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
try
|
|||
|
frmBaseOut:=TfrmBaseOut.Create(Application);
|
|||
|
with frmBaseOut do
|
|||
|
begin
|
|||
|
DepotNo:=Trim(self.ADOQueryMain.fieldbyname('DepotNo').AsString);
|
|||
|
QuantityCK:=Trim(self.ADOQueryMain.fieldbyname('Quantity').AsString);
|
|||
|
if ShowModal=1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
Self.TBFind.Click;
|
|||
|
Self.ADOQueryMain.Locate('DepotNo',DepotNo,[]);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmBaseOut.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBDelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
|||
|
if DelData() then
|
|||
|
begin
|
|||
|
TBRafresh.Click;
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmBaseOutList.DelData():Boolean;
|
|||
|
begin
|
|||
|
try
|
|||
|
Result:=false;
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('delete WC_ClothInout_Info where depotno='''+Trim(ADOQueryMain.fieldbyname('depotno').AsString)+'''');
|
|||
|
sql.Add(' delete WC_ClothInout where depotno='''+Trim(ADOQueryMain.fieldbyname('depotno').AsString)+'''');
|
|||
|
SQL.Add(' Update WC_ClothClothing Set Quantity=Quantity+'+Trim(ADOQueryMain.fieldbyname('Quantity').AsString));
|
|||
|
sql.Add(' where KCID='+Trim(ADOQueryMain.fieldbyname('KCID').AsString));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result:=True;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Result:=False;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid1);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBPrintClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBAddClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmBaseOut:=TfrmBaseOut.Create(Application);
|
|||
|
with frmBaseOut do
|
|||
|
begin
|
|||
|
if ShowModal=1 then
|
|||
|
begin
|
|||
|
Self.InitGrid();
|
|||
|
Self.TBFind.Click;
|
|||
|
Self.ADOQueryMain.Locate('DepotNo',DepotNo,[]);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmBaseOut.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.PlanNoChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
InitForm();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaseOutList.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SeniorFilter(Tv1,ADOQueryMain);
|
|||
|
end;
|
|||
|
|
|||
|
end.
|