437 lines
13 KiB
ObjectPascal
437 lines
13 KiB
ObjectPascal
unit U_CPSMCK;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
|
||
cxStyles, dxSkinsCore, 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, dxSkinPumpkin, dxSkinSeven,
|
||
dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
|
||
dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
|
||
dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
|
||
dxSkinXmas2008Blue, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, cxNavigator, DB, cxDBData, cxCheckBox, ComCtrls,
|
||
StdCtrls, ExtCtrls, cxGridLevel, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid, DBClient,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, Menus, ToolWin, ADODB, MovePanel,
|
||
RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset;
|
||
|
||
type
|
||
TFRMCPSMCK = class(TForm)
|
||
DS_MainSel: TDataSource;
|
||
CDS_MainSel: TClientDataSet;
|
||
cxGrid3: TcxGrid;
|
||
Tv3: TcxGridDBTableView;
|
||
v3Column5: TcxGridDBColumn;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
v3Column3: TcxGridDBColumn;
|
||
cxGridDBColumn4: TcxGridDBColumn;
|
||
v3MJID: TcxGridDBColumn;
|
||
v3BaoNo: TcxGridDBColumn;
|
||
v3BAOID: TcxGridDBColumn;
|
||
v3Column1: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
v3Column2: TcxGridDBColumn;
|
||
v3Column6: TcxGridDBColumn;
|
||
v3Column7: TcxGridDBColumn;
|
||
v3Column4: TcxGridDBColumn;
|
||
Tv3Column1: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Panel1: TPanel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label7: TLabel;
|
||
Label9: TLabel;
|
||
Label12: TLabel;
|
||
Label1: TLabel;
|
||
BaoID: TEdit;
|
||
Button1: TButton;
|
||
CRTime: TDateTimePicker;
|
||
CKOrdNo: TEdit;
|
||
RKOrdID: TEdit;
|
||
mjid: TEdit;
|
||
gangno: TEdit;
|
||
ToolBar1: TToolBar;
|
||
ToolButton1: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
TBClose: TToolButton;
|
||
PopupMenu2: TPopupMenu;
|
||
MenuItem1: TMenuItem;
|
||
MenuItem2: TMenuItem;
|
||
cxGridPopupMenu4: TcxGridPopupMenu;
|
||
ADOQueryMain: TADOQuery;
|
||
Button2: TButton;
|
||
MovePanel2: TMovePanel;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryPrint: TADOQuery;
|
||
CDS_HZ: TClientDataSet;
|
||
RMDBHZ: TRMDBDataSet;
|
||
RM2: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
ADOQueryCmd: TADOQuery;
|
||
ToolButton2: TToolButton;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure Button2Click(Sender: TObject);
|
||
procedure mjidKeyPress(Sender: TObject; var Key: Char);
|
||
procedure Button1Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure MenuItem1Click(Sender: TObject);
|
||
procedure MenuItem2Click(Sender: TObject);
|
||
private
|
||
procedure InitGrid();
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
FRMCPSMCK: TFRMCPSMCK;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, MMSystem;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TFRMCPSMCK.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.FormDestroy(Sender: TObject);
|
||
begin
|
||
FRMCPSMCK := nil;
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.FormShow(Sender: TObject);
|
||
begin
|
||
|
||
ReadCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Sels', Tv3, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
// InitSubGrid();
|
||
InitGrid();
|
||
CRTime.DateTime := SGetServerDate(ADOQueryTemp);
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
|
||
sql.Add(',KHName=(select isnull(customerNoName,OrderNo) from JYOrder_Main where MainId=A.MainId)');
|
||
SQL.Add(',PRTColor=(select PRTColor from JYOrder_Sub where SubId=A.SubId)');
|
||
SQL.Add(',SOrddefstr1=(select SOrddefstr1 from JYOrder_Sub where SubId=A.SubId)');
|
||
SQL.Add(',SOrddefstr5=(select SOrddefstr5 from JYOrder_Sub where SubId=A.SubId)');
|
||
sql.Add(',AOrdDefstr1=(select AOrdDefstr1 from JYOrder_Sub_AnPai where ApId=A.ApId)');
|
||
sql.Add(',MJXH=(select MJXH from WFB_MJJY where MJID=A.MJID)');
|
||
sql.Add('from CK_BanCP_CR A');
|
||
sql.Add('where CKOrdNo=''' + trim(CKOrdNo.text) + ''' and CRflag=''<27><><EFBFBD><EFBFBD>''');
|
||
// sql.add('where 1=2');
|
||
// ShowMessage(SQL.text);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_MainSel);
|
||
SInitCDSData20(ADOQueryMain, CDS_MainSel);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
if trim(CKOrdNo.Text) <> '' then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select count(distinct baoid) as CKbao from WFB_MJJY where ckno=''' + Trim(CKOrdNo.Text) + ''' ');
|
||
Open;
|
||
end;
|
||
Label12.caption := '<27><>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + Trim(ADOQueryTemp.fieldbyname('CKbao').AsString);
|
||
end;
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>Sels', Tv3, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.Button2Click(Sender: TObject);
|
||
var
|
||
maxno: string;
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, maxno, 'CK', 'CK_BanCP_CR', 3, 1) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD>ⵥ<EFBFBD><E2B5A5>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
CKOrdNo.Text := Trim(maxno);
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.mjidKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
if trim(CKOrdNo.Text) = '' then
|
||
begin
|
||
PlaySound('wav\<5C><><EFBFBD><EFBFBD>.wav', 0, SND_FILENAME or SND_ASYNC);
|
||
application.MessageBox('<27><><EFBFBD>ⵥ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>', '<27><>ʾ');
|
||
exit;
|
||
end;
|
||
if trim(mjid.Text) = '' then
|
||
exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.clear;
|
||
sql.add('select count(distinct CKFlag) as baos,baoid,CKFlag');
|
||
sql.add('from WFB_MJJY A ');
|
||
sql.add(' where A.baoid=''' + trim(mjid.Text) + ''' GROUP BY A.baoid,CKFlag ');
|
||
// showmessage(sql.Text);
|
||
open;
|
||
end;
|
||
if ADOQueryCmd.isempty then
|
||
begin
|
||
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>.wav')) then
|
||
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>.wav'), 0, SND_ASYNC);
|
||
mjid.Text := '';
|
||
exit;
|
||
end
|
||
else
|
||
begin
|
||
if StrToFloat(ADOQueryCmd.fieldbyname('baos').AsString) > 1 then
|
||
begin
|
||
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C>˰<EFBFBD><CBB0>ѳ<EFBFBD><D1B3><EFBFBD>.wav'), 0, SND_ASYNC);
|
||
mjid.Text := '';
|
||
exit;
|
||
end;
|
||
end;
|
||
if Trim(ADOQueryCmd.fieldbyname('CKFlag').AsString) = '<27>ѳ<EFBFBD><D1B3><EFBFBD>' then
|
||
begin
|
||
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C>ظ<EFBFBD>ɨ<EFBFBD><C9A8>.wav'), 0, SND_ASYNC);
|
||
mjid.Text := '';
|
||
exit;
|
||
end
|
||
else
|
||
begin
|
||
try
|
||
// <20><><EFBFBD><EFBFBD>
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Do_JYSMCK @MJID=''' + trim(mjid.Text) + ''',@CKOrdNo=''' + trim(CKOrdNo.Text) + '''');
|
||
execsql;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('update WFB_MJJY set MJStr2=''<27>ѳ<EFBFBD><D1B3><EFBFBD>'',CKFlag=''<27>ѳ<EFBFBD><D1B3><EFBFBD>'',CKNO=''' + trim(CKOrdNo.Text) + ''' where baoid=''' + Trim(mjid.text) + '''');
|
||
ExecSQL;
|
||
end;
|
||
PlaySound('wav\<5C><>ȷ.wav', 0, SND_FILENAME or SND_ASYNC);
|
||
except
|
||
PlaySound('wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav', 0, SND_FILENAME or SND_ASYNC);
|
||
end;
|
||
end;
|
||
|
||
mjid.Text := '';
|
||
InitGrid();
|
||
end;
|
||
// if trim(CKOrdNo.Text) <> '' then
|
||
// begin
|
||
// with ADOQueryTemp do
|
||
// begin
|
||
// Close;
|
||
// sql.Clear;
|
||
// sql.Add('select count(distinct baoid) as CKbao from WFB_MJJY where ckno=''' + Trim(CKOrdNo.Text) + ''' ');
|
||
// Open;
|
||
// end;
|
||
// Label12.caption := '<27><>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' + Trim(ADOQueryTemp.fieldbyname('CKbao').AsString);
|
||
// end;
|
||
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.Button1Click(Sender: TObject);
|
||
begin
|
||
if CDS_MainSel.IsEmpty then
|
||
Exit;
|
||
if CDS_MainSel.Locate('SSel', True, []) = False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
MovePanel2.Visible := True;
|
||
MovePanel2.Refresh;
|
||
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_MainSel.DisableControls;
|
||
with CDS_MainSel do
|
||
begin
|
||
while CDS_MainSel.Locate('SSel', True, []) = True do
|
||
begin
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
// sql.Add('delete CK_BanCP_CR where BCID=''' + Trim(CDS_MainSel.fieldbyname('BCID').AsString) + '''');
|
||
// sql.Add('Update WFB_MJJY Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',CKFlag=''δ<><CEB4><EFBFBD><EFBFBD>'',CKNO=null where MJID=''' + Trim(CDS_MainSel.fieldbyname('MJID').AsString) + '''');
|
||
|
||
sql.Add('UPdate CK_BanCP_KC Set KCKgQty=(select KgQty from CK_BanCP_CR A where A.MJID=CK_BanCP_KC.MJID and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') ');
|
||
sql.Add(',KCQty=(select Qty from CK_BanCP_CR A where A.MJID=CK_BanCP_KC.MJID and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') ');
|
||
SQL.Add(' where MJID=' + CDS_MainSel.fieldbyname('MJID').AsString);
|
||
|
||
sql.Add('delete CK_BanCP_CR where baoid=''' + Trim(CDS_MainSel.fieldbyname('baoid').AsString) + ''' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
||
sql.Add('Update WFB_MJJY Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',CKFlag=''δ<><CEB4><EFBFBD><EFBFBD>'',CKNO=null where baoid=''' + Trim(CDS_MainSel.fieldbyname('baoid').AsString) + '''');
|
||
ShowMessage(SQL.text);
|
||
ExecSQL;
|
||
end;
|
||
|
||
CDS_MainSel.Delete;
|
||
end;
|
||
end;
|
||
end;
|
||
CDS_MainSel.EnableControls;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
MovePanel2.Visible := False;
|
||
Exit;
|
||
except
|
||
MovePanel2.Visible := False;
|
||
CDS_MainSel.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
||
end;
|
||
initgrid();
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.ToolButton1Click(Sender: TObject);
|
||
var
|
||
fPrintFile, fPrintFile10, FMainID: string;
|
||
sqlStr: string;
|
||
begin
|
||
if CDS_MainSel.IsEmpty then
|
||
Exit;
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>Ӣ<EFBFBD><D3A2>Ʒ<EFBFBD><C6B7><EFBFBD>뵥.rmf';
|
||
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('exec P_Do_PrintMd10_PMYW '); //''' + CDS_Main.fieldbyname('CKNO').AsString + '''
|
||
sql.add('@mainID=''' + Trim(CKOrdNo.Text) + '''');
|
||
sql.add(',@orderNo=''' + CDS_MainSel.fieldbyname('mainid').AsString + '''');
|
||
sql.add(',@Sorddefstr5=''' + CDS_MainSel.fieldbyname('Sorddefstr5').AsString + '''');
|
||
ShowMessage(SQL.text);
|
||
Open;
|
||
// ShowMessage(SQL.text);
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_HZ);
|
||
SInitCDSData20(ADOQueryTemp, CDS_HZ);
|
||
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.add('exec P_Do_PrintMd_HZ ');
|
||
sql.add('@mainID=' + quotedstr(Trim('')));
|
||
sql.add(',@DName=' + quotedstr(Trim(DCode)));
|
||
sql.add(',@flag=''2'' ');
|
||
Open;
|
||
end;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM2.LoadFromFile(fPrintFile);
|
||
RM2.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.ToolButton3Click(Sender: TObject);
|
||
var
|
||
fPrintFile, fPrintFile10, FMainID: string;
|
||
sqlStr: string;
|
||
begin
|
||
if CDS_MainSel.IsEmpty then
|
||
Exit;
|
||
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD>뵥.rmf';
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
// sql.Add('exec P_Do_PrintMd10 ''' + CDS_Main.fieldbyname('CKNO').AsString + ''' ');
|
||
sql.Add('exec P_Do_PrintMd10 ''' + trim(CKOrdNo.Text) + ''' ');
|
||
Open;
|
||
// ShowMessage(SQL.text);
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp, CDS_HZ);
|
||
SInitCDSData20(ADOQueryTemp, CDS_HZ);
|
||
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.add('exec P_Do_PrintMd_HZ ');
|
||
sql.add('@mainID=' + quotedstr(Trim('')));
|
||
sql.add(',@DName=' + quotedstr(Trim(DCode)));
|
||
sql.add(',@flag=''2'' ');
|
||
Open;
|
||
end;
|
||
end;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RM2.LoadFromFile(fPrintFile);
|
||
RM2.ShowReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.MenuItem1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_MainSel, True);
|
||
end;
|
||
|
||
procedure TFRMCPSMCK.MenuItem2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_MainSel, False);
|
||
end;
|
||
|
||
end.
|
||
|