353 lines
10 KiB
ObjectPascal
353 lines
10 KiB
ObjectPascal
unit U_KnitStockTakinglist;
|
||
|
||
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, cxPC, MovePanel,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu,
|
||
cxCheckBox, cxSplitter, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
|
||
U_BaseList, Winapi.MMSystem, dxSkinBasic, dxSkinBlack, dxSkinBlue,
|
||
dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide,
|
||
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
|
||
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
|
||
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
|
||
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
|
||
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
|
||
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
|
||
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
|
||
dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
|
||
dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray,
|
||
dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
|
||
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust,
|
||
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine,
|
||
dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
|
||
dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI,
|
||
dxSkinXmas2008Blue, dxScrollbarAnnotations, cxContainer, cxTextEdit,
|
||
FrameDateSel;
|
||
|
||
type
|
||
TfrmKnitStockTakinglist = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1P_CodeName: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1CRTime: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
C_Name: TcxTextEdit;
|
||
P_Code: TcxTextEdit;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryTmp: TADOQuery;
|
||
DS_1: TDataSource;
|
||
CDS_Main: TClientDataSet;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ckName: TComboBox;
|
||
Label6: TLabel;
|
||
v1P_Color: TcxGridDBColumn;
|
||
v1inoutNO: TcxGridDBColumn;
|
||
kuwei: TcxTextEdit;
|
||
Label8: TLabel;
|
||
custName: TcxTextEdit;
|
||
Label2: TLabel;
|
||
Tchk: TToolButton;
|
||
Tnochk: TToolButton;
|
||
Label5: TLabel;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
ADOQueryMain: TADOQuery;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
cxTabControl1: TcxTabControl;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
Tv1Column9: TcxGridDBColumn;
|
||
Label10: TLabel;
|
||
KCSTMID: TcxTextEdit;
|
||
ToolButton1: TToolButton;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Label7: TLabel;
|
||
Edit1: TcxTextEdit;
|
||
Pnl_msg: TPanel;
|
||
frmFrameDateSel: TfrmFrameDateSel;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure C_NameChange(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure TchkClick(Sender: TObject);
|
||
procedure TnochkClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
|
||
private
|
||
procedure InitGrid();
|
||
procedure PlayWav(MMsg: string);
|
||
{ Private declarations }
|
||
public
|
||
fCKName: string;
|
||
canshu1: string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmKnitStockTakinglist: TfrmKnitStockTakinglist;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp;
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmKnitStockTakinglist.PlayWav(MMsg: string);
|
||
begin
|
||
if MMsg = '<27>̵<EFBFBD><CCB5>ɹ<EFBFBD>' then
|
||
Pnl_msg.Visible := False
|
||
else
|
||
begin
|
||
Pnl_msg.Visible := true;
|
||
Pnl_msg.Caption := MMsg;
|
||
end;
|
||
|
||
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MMsg + '.wav')) then
|
||
begin
|
||
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MMsg + '.wav'), 0, SND_ASYNC);
|
||
end
|
||
else
|
||
begin
|
||
MMsg := '<27>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣';
|
||
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MMsg + '.wav')) then
|
||
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MMsg + '.wav'), 0, SND_ASYNC);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.InitGrid();
|
||
begin
|
||
try
|
||
with ADOQueryMain do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,B.* ');
|
||
sql.Add(',C.* ');
|
||
sql.Add('from Knit_Cloth_Stock_Taking_Main A inner join Knit_Cloth_Stock_Taking_Sub B on A.KCSTMID=B.KCSTMID ');
|
||
sql.Add('left join Knit_Cloth_Stock C on C.StkId=B.StkId where 1=1 ');
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
sql.Add('and isnull(A.Status,''0'') =''0'' ');
|
||
end;
|
||
1:
|
||
begin
|
||
sql.Add('and isnull(A.Status,''0'') =''1'' ');
|
||
sql.Add('and A.begTime>=''' + formatdateTime('yyyy-MM-dd', frmFrameDateSel.begdate.Date) + ''' ');
|
||
sql.Add('and A.begTime<''' + formatdateTime('yyyy-MM-dd', frmFrameDateSel.enddate.Date + 1) + ''' ');
|
||
end;
|
||
2:
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
// ShowMessage(sql.Text);
|
||
open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_Main);
|
||
SInitCDSData(ADOQueryMain, CDS_Main);
|
||
finally
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
|
||
Action := cafree;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmKnitStockTakinglist := nil;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.C_NameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS(ADOQueryMain, CDS_Main);
|
||
SInitCDSData(ADOQueryMain, CDS_Main);
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.Edit1KeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
Sql.Add('exec P_Knit_Cloth_StockTaking ');
|
||
Sql.Add(' @KCSTMID=' + quotedstr(trim(CDS_Main.fieldbyName('KCSTMID').AsString)));
|
||
Sql.Add(',@StkId=' + quotedstr(trim(Edit1.Text)));
|
||
Sql.Add(',@FillId=' + Quotedstr(DCode));
|
||
Sql.Add(',@Filler=' + Quotedstr(DName));
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
||
begin
|
||
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
PlayWav(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString));
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
PlayWav(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString));
|
||
// raise Exception.Create(PChar(Exception(ExceptObject).Message));
|
||
end;
|
||
Edit1.Text := '';
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
readCxGrid(self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
Label7.Font.Color := clRed;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmFrameDateSel.EndDate.Date := SGetServerDateTime(ADOQueryTmp);
|
||
frmFrameDateSel.BegDate.Date := frmFrameDateSel.EndDate.Date - 20;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.TBCloseClick(Sender: TObject);
|
||
begin
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.TBExportClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel(self.Caption, cxgrid1);
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
initGrid();
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.TchkClick(Sender: TObject);
|
||
var
|
||
fKCSTMID: string;
|
||
begin
|
||
with adoqueryTmp do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.* from Knit_Cloth_Stock_Taking_Main A WHERE A.status=0 ');
|
||
open;
|
||
end;
|
||
if not adoqueryTmp.IsEmpty then
|
||
begin
|
||
application.MessageBox('<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>飡', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
|
||
if GetLSNo(ADOQueryCmd, fKCSTMID, 'PD', 'Knit_Cloth_Stock_Taking_Main', 3, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡӦ<C8A1><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
// MovePanel2.Left := (self.Width - MovePanel2.Width) div 2;
|
||
// MovePanel2.Visible := True;
|
||
// MovePanel2.Refresh;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
try
|
||
////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>/////////////////////////////
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('INSERT INTO Knit_Cloth_Stock_Taking_Main(KCSTMID,status,Filler) ');
|
||
sql.Add('Values(' + Quotedstr(fKCSTMID) + ',''0'',' + Quotedstr(DName) + ') ');
|
||
|
||
sql.Add('INSERT INTO Knit_Cloth_Stock_Taking_Sub(KCSTMID,StkId)');
|
||
sql.Add('select ' + QuotedStr(fKCSTMID) + ', StkId ');
|
||
sql.Add('from V_Knit_Cloth_Stk ');
|
||
|
||
execsql;
|
||
end;
|
||
|
||
// MovePanel2.Visible := false;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
TBRafresh.Click;
|
||
except
|
||
// MovePanel2.Visible := false;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmKnitStockTakinglist.TnochkClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
exit;
|
||
|
||
if Application.MessageBox('ȷ<><C8B7><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
|
||
try
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update Knit_Cloth_Stock_Taking_Main SET status=1,endTime=getdate() where KCSTMID=''' + trim(CDS_Main.fieldbyName('KCSTMID').AsString) + ''' ');
|
||
execsql;
|
||
end;
|
||
TBRafresh.Click;
|
||
except
|
||
Application.MessageBox('<27>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
|
||
|
||
procedure TfrmKnitStockTakinglist.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
writeCxGrid(self.Caption, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
end;
|
||
|
||
end.
|
||
|