D7wmguihua/桂华管理系统/U_CKProductBCPKCListSel.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

858 lines
27 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_CKProductBCPKCListSel;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
cxGridBandedTableView, cxGridDBBandedTableView, cxGridLevel, cxClasses,
cxControls, cxGridCustomView, cxGridDBTableView, cxGrid, StdCtrls, ComCtrls,
ExtCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, ADODB, DBClient,
cxDropDownEdit, MovePanel, cxCheckBox, cxSplitter, cxCalendar, BtnEdit,
cxContainer, cxTextEdit, cxCurrencyEdit, cxLookAndFeels, cxLookAndFeelPainters,
cxNavigator, 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;
type
TfrmCKProductBCPKCListsel = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
cxGridPopupMenu1: TcxGridPopupMenu;
Label3: TLabel;
Label4: TLabel;
C_CodeName: TEdit;
C_Color: TEdit;
Label1: TLabel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
CDS_Main: TClientDataSet;
Tv1: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
v2Column1: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
Label5: TLabel;
conNo: TEdit;
Label6: TLabel;
MJID: TEdit;
v1Column7: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
Label8: TLabel;
KZ: TEdit;
Label9: TLabel;
MF: TEdit;
Label7: TLabel;
CPType: TComboBox;
v1Column3: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
Panel4: TPanel;
Label11: TLabel;
Panel10: TPanel;
Image2: TImage;
RichEdit1: TRichEdit;
MovePanel2: TMovePanel;
ToolButton1: TToolButton;
v1KCRollNum: TcxGridDBColumn;
v1gangNO: TcxGridDBColumn;
v1C_Color: TcxGridDBColumn;
cxGrid1: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridDBColumn8: TcxGridDBColumn;
cxGridDBColumn9: TcxGridDBColumn;
cxGridDBColumn10: TcxGridDBColumn;
cxGridDBColumn11: TcxGridDBColumn;
cxGridDBColumn12: TcxGridDBColumn;
cxGridDBColumn13: TcxGridDBColumn;
cxGridDBColumn14: TcxGridDBColumn;
cxGridDBColumn15: TcxGridDBColumn;
cxGridDBColumn16: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
cxSplitter1: TcxSplitter;
CDS_SubSel: TClientDataSet;
DSSubSel: TDataSource;
cxGridPopupMenu2: TcxGridPopupMenu;
Label10: TLabel;
KCQtyStr: TEdit;
Label12: TLabel;
AOrdDefStr1: TEdit;
v1KCKW: TcxGridDBColumn;
Label13: TLabel;
KCKW: TEdit;
Panel2: TPanel;
Panel3: TPanel;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
v1OrderNo: TcxGridDBColumn;
v1ConNo: TcxGridDBColumn;
v1OrdDefStr1: TcxGridDBColumn;
cxGridDBColumn17: TcxGridDBColumn;
v1OrdPerson1: TcxGridDBColumn;
v1JGFactoryName: TcxGridDBColumn;
v1PRTColor: TcxGridDBColumn;
v1OrdDate: TcxGridDBColumn;
v1DeliveryDate: TcxGridDBColumn;
v1CustomerNoName: TcxGridDBColumn;
v1MPRTCodeName: TcxGridDBColumn;
v1MPRTSpec: TcxGridDBColumn;
v1MPRTCF: TcxGridDBColumn;
v1MPRTMF: TcxGridDBColumn;
v1MPRTKZ: TcxGridDBColumn;
cxGridDBColumn18: TcxGridDBColumn;
v1PRTRollNum: TcxGridDBColumn;
v1PRTOrderQty: TcxGridDBColumn;
cxGridDBColumn19: TcxGridDBColumn;
cxGridDBColumn20: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Order_Main: TClientDataSet;
DataSource2: TDataSource;
v2RollNum: TcxGridDBColumn;
v2Qty: TcxGridDBColumn;
cxGridPopupMenu3: TcxGridPopupMenu;
v1Ssel: TcxGridDBColumn;
Button1: TButton;
v3Column1: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
v3Column3: TcxGridDBColumn;
v3Column4: TcxGridDBColumn;
v3Column5: TcxGridDBColumn;
v3Column6: TcxGridDBColumn;
v3Column7: TcxGridDBColumn;
v3Column8: TcxGridDBColumn;
v3Column9: TcxGridDBColumn;
v3Column10: TcxGridDBColumn;
v3gangNum: TcxGridDBColumn;
Label14: TLabel;
v2Column2: TcxGridDBColumn;
Label15: TLabel;
PHYG: TBtnEditA;
CDS_Print: TClientDataSet;
CheckBox1: TCheckBox;
packNo: TcxCurrencyEdit;
ToolButton2: TToolButton;
v1Column5: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ConNoMChange(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure C_CodeNameChange(Sender: TObject);
procedure Panel10MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure Image2Click(Sender: TObject);
procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
procedure ToolButton1Click(Sender: TObject);
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
procedure Tv3FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
procedure Button1Click(Sender: TObject);
procedure PHYGBtnClick(Sender: TObject);
procedure Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
procedure Tv2CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
procedure CheckBox1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
private
FLeft, FTop: Integer;
procedure InitGrid();
procedure InitGridNull();
procedure DoQuery();
function SaveData(): Boolean;
{ Private declarations }
public
fCodeName: string;
fColor: string;
fmainID: string;
{ Public declarations }
end;
var
frmCKProductBCPKCListsel: TfrmCKProductBCPKCListsel;
implementation
uses
U_DataLink, U_Fun, U_UserHelp, U_KCEdit;
{$R *.dfm}
function TfrmCKProductBCPKCListsel.SaveData(): Boolean;
var
phID: string;
P_No: string;
P_ID: integer;
begin
Result := false;
if GetLSNo(ADOQueryTemp, P_No, 'PN', 'CK_BanCP_PH', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
P_ID := 1;
ADOQueryCmd.Connection.BeginTrans;
try
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update CK_BanCP_KC SET kcstatus=null ');
sql.Add('from CK_BanCP_KC A ');
sql.Add('inner join CK_BanCP_PH B on B.CRID=A.crid and B.mjid=A.mjid ');
sql.Add('where B.mainID=' + quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and B.subID=' + quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
execsql;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('delete from CK_BanCP_PH ');
sql.Add('where mainID=' + quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID=' + quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
execsql;
end;
with CDS_SubSel do
begin
DisableControls;
first;
while not eof do
begin
if fieldbyname('qty').AsFloat = 0 then
continue;
if GetLSNo(ADOQueryTemp, phID, 'PH', 'CK_BanCP_PH', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_PH ');
sql.Add('where mainID=' + quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID=' + quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
end;
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('phID').Value := trim(phID);
ADOQueryCmd.FieldByName('p_No').Value := trim(P_No);
ADOQueryCmd.FieldByName('p_ID').Value := P_ID;
ADOQueryCmd.FieldByName('conNo').Value := trim(fieldbyname('conNo').AsString);
ADOQueryCmd.FieldByName('MainID').Value := trim(Order_Main.fieldbyname('MainID').AsString);
ADOQueryCmd.FieldByName('SubID').Value := trim(Order_Main.fieldbyname('SubID').AsString);
ADOQueryCmd.FieldByName('PMainID').Value := trim(fieldbyname('MainID').AsString);
ADOQueryCmd.FieldByName('PSubID').Value := trim(fieldbyname('SubID').AsString);
ADOQueryCmd.FieldByName('mjID').Value := trim(fieldbyname('mjID').AsString);
ADOQueryCmd.FieldByName('CRID').Value := trim(fieldbyname('CRID').AsString);
ADOQueryCmd.FieldByName('qtyunit').Value := trim(fieldbyname('kcqtyunit').AsString);
ADOQueryCmd.FieldByName('packNo').Value := trim(fieldbyname('packNo').AsString);
ADOQueryCmd.FieldByName('qty').Value := fieldbyname('qty').AsFloat;
ADOQueryCmd.FieldByName('Rollnum').Value := fieldbyname('Rollnum').AsFloat;
ADOQueryCmd.FieldByName('Filler').Value := trim(DName);
ADOQueryCmd.FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
ADOQueryCmd.FieldByName('BCGangNo').Value := trim(fieldbyname('AOrdDefStr1').AsString);
ADOQueryCmd.FieldByName('PHYG').Value := trim(PHYG.Text);
ADOQueryCmd.Post;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from CK_BanCP_KC ');
sql.Add('where mjid=' + quotedstr(trim(CDS_SubSel.fieldbyname('mjid').AsString)));
sql.Add('and CRID=' + quotedstr(trim(CDS_SubSel.fieldbyname('CRID').AsString)));
open;
edit;
fieldbyname('kcstatus').Value := '1';
post;
end;
P_ID := P_ID + 1;
next;
end;
first;
EnableControls;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID=' + quotedstr(trim(Order_Main.fieldbyname('mainID').AsString)));
sql.Add('and subID=' + quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '2';
post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>')));
sql.Add(',' + quotedstr(trim('<27>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>' + trim(fmainID))));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
Result := true;
except
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmCKProductBCPKCListsel.DoQuery();
begin
// Order_Main.DisableControls;
try
with AdoqueryTemp do
begin
close;
sql.Clear;
sql.Add('select A.*,B.* ');
sql.Add('from JYOrder_sub A ');
sql.Add('inner JOIN JYOrder_Main B on B.mainID=A.mainID and isnull(B.status,''0'')>''0'' ');
sql.Add('where A.mainId=' + quotedstr(trim(fmainID)));
sql.Add('and isnull(A.substatus,''0'')<''3'' ');
open;
end;
SCreateCDS20(AdoqueryTemp, Order_Main);
SInitCDSData20(AdoqueryTemp, Order_Main);
finally
// Order_Main.EnableControls;
end;
end;
procedure TfrmCKProductBCPKCListsel.FormDestroy(Sender: TObject);
begin
frmCKProductBCPKCListsel := nil;
end;
procedure TfrmCKProductBCPKCListsel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmCKProductBCPKCListsel.FormCreate(Sender: TObject);
begin
Panel3.Align := alClient;
// cxGrid1.Height:= Panel3.Height div 2;
cxGrid2.Align := alClient;
BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp);
// TBRafresh.Click;
end;
procedure TfrmCKProductBCPKCListsel.InitGrid();
begin
try
// ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
SQL.Add('exec P_View_CPKCMX_SEL');
SQL.Add('@P_Codename=' + quotedstr(trim(fCodeName)));
SQL.Add(',@P_Color=' + quotedstr(trim(fColor)));
SQL.Add(',@mainID=' + quotedstr(trim('')));
SQL.Add(',@subID=' + quotedstr(trim('')));
SQL.Add(',@Flag=' + quotedstr(trim('0')));
Open;
end;
SCreateCDS20(ADOQueryMain, CDS_Main);
SInitCDSData20(ADOQueryMain, CDS_Main);
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
SQL.Add('exec P_View_CPKCMX_SEL');
SQL.Add('@P_Codename=' + quotedstr(trim(fCodeName)));
SQL.Add(',@P_Color=' + quotedstr(trim(fColor)));
SQL.Add(',@mainID=' + quotedstr(trim(Order_Main.fieldbyname('MainID').AsString)));
SQL.Add(',@subID=' + quotedstr(trim(Order_Main.fieldbyname('subID').AsString)));
SQL.Add(',@Flag=' + quotedstr(trim('1')));
Open;
end;
SCreateCDS20(ADOQueryMain, CDS_SubSel);
SInitCDSData20(ADOQueryMain, CDS_SubSel);
finally
// ADOQueryMain.EnableControls;
TBFind.Click;
end;
end;
procedure TfrmCKProductBCPKCListsel.InitGridNull();
begin
try
ADOQueryTemp.DisableControls;
with ADOQueryTemp do
begin
Filtered := False;
Close;
sql.Clear;
SQL.Add('exec P_View_CPKCMXNull');
Open;
end;
SCreateCDS20(ADOQueryTemp, CDS_SubSel);
SInitCDSData20(ADOQueryTemp, CDS_SubSel);
finally
ADOQueryTemp.EnableControls;
end;
end;
procedure TfrmCKProductBCPKCListsel.TBRafreshClick(Sender: TObject);
begin
// BegDate.SetFocus;
MovePanel2.Visible := True;
MovePanel2.Refresh;
DOquery();
MovePanel2.Visible := False;
end;
procedure TfrmCKProductBCPKCListsel.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
end;
end;
procedure TfrmCKProductBCPKCListsel.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv11', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv22', Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
WriteCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv3', Tv3, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmCKProductBCPKCListsel.FormShow(Sender: TObject);
begin
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv11', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv22', Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv3', Tv3, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
// InitGridNull();
// InitGrid();
Doquery();
end;
procedure TfrmCKProductBCPKCListsel.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
exit;
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid2);
end;
procedure TfrmCKProductBCPKCListsel.TBFindClick(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter10(CDS_Main, SGetFilters(Panel1, 1, 2));
//SCreateCDS20(ADOQueryMain,CDS_Main);
//SInitCDSData20(ADOQueryMain,CDS_Main);
end;
end;
procedure TfrmCKProductBCPKCListsel.C_CodeNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmCKProductBCPKCListsel.Panel10MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
TWinControl(Panel4).Perform(WM_SYSCOMMAND, $F012, 0);
end;
procedure TfrmCKProductBCPKCListsel.Image2Click(Sender: TObject);
begin
Panel4.Visible := False;
end;
procedure TfrmCKProductBCPKCListsel.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FLeft := X;
FTop := Y;
end;
procedure TfrmCKProductBCPKCListsel.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
var
i: Integer;
begin
//if CDS_Sel.Locate('CYID',Trim(CDS_Main.fieldbyname('CYID').AsString),[])=False then
//begin
{ if CDS_Main.IsEmpty then Exit;
CDS_SubSel.Append;
for i:=0 to CDS_SubSel.FieldCount-1 do
begin
CDS_SubSel.Fields[i].Value:=CDS_Main.Fields[i].Value;
end;
CDS_SubSel.Post;
CDS_Main.Delete;
//end; }
end;
procedure TfrmCKProductBCPKCListsel.ToolButton1Click(Sender: TObject);
var
phRollNum, phQty: double;
begin
if CDS_SubSel.IsEmpty then
exit;
conNo.SetFocus;
with CDS_SubSel do
begin
DisableControls;
first;
while not eof do
begin
if (trim(fieldbyname('C_CodeName').AsString) <> trim(Order_Main.FieldByName('PRTCodeName').AsString)) or (uppercase(trim(fieldbyname('C_Color').AsString)) <> uppercase(trim(Order_Main.FieldByName('PRTColor').AsString))) then
begin
application.MessageBox('<27><>Ʒ<EFBFBD><C6B7><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
EnableControls;
exit;
end;
next;
end;
first;
EnableControls;
end;
phRollNum := 0;
phQty := 0;
with CDS_SubSel do
begin
DisableControls;
first;
while not eof do
begin
phRollNum := phRollNum + CDS_SubSel.fieldbyname('RollNum').AsFloat;
phQty := phQty + CDS_SubSel.fieldbyname('Qty').AsFloat;
next;
end;
first;
EnableControls;
end;
{ IF Order_Main.FieldByName('PRTRollNum').AsFloat<>0 then
begin
if (phRollNum<>Order_Main.FieldByName('PRTRollNum').AsFloat) then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
// if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFB5BD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',32+4)<>IDYES then Exit;
end;
IF Order_Main.FieldByName('PRTOrderQty').AsFloat<>0 then
begin
if (format('%.2f',[phQty])<>format('%.2f',[Order_Main.FieldByName('PRTOrderQty').AsFloat])) then
begin
// if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>Ƿ񱣴棿','<27><>ʾ',32+4)<>IDYES then Exit;
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
// if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFB5BD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',32+4)<>IDYES then Exit;
end;
}
if SaveData() then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ<EFBFBD><CABE>Ϣ');
Order_Main.Delete;
CDS_SubSel.EmptyDataSet;
// TBRafresh.Click;
end
else
begin
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmCKProductBCPKCListsel.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
var
i: Integer;
begin
//if CDS_Sel.Locate('CYID',Trim(CDS_Main.fieldbyname('CYID').AsString),[])=False then
//begin
if CDS_SubSel.IsEmpty then
Exit;
CDS_Main.Append;
for i := 0 to CDS_Main.FieldCount - 1 do
begin
CDS_Main.Fields[i].Value := CDS_SubSel.Fields[i].Value;
end;
CDS_Main.FieldByName('ssel').Value := false;
CDS_Main.Post;
CDS_SubSel.Delete;
//end;
end;
procedure TfrmCKProductBCPKCListsel.Tv3FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
if Order_Main.IsEmpty then
begin
fCodeName := '!##@';
fColor := '!##@';
end
else
begin
FCodeName := trim(Order_Main.FieldByName('PRTCodeName').AsString);
fColor := trim(Order_Main.FieldByName('PRTColor').AsString);
end;
initGrid();
end;
procedure TfrmCKProductBCPKCListsel.Button1Click(Sender: TObject);
var
i: integer;
begin
if CDS_Main.IsEmpty then
Exit;
CDS_SubSel.DisableControls;
with CDS_Main do
begin
DisableControls;
First;
while not eof do
begin
if (CDS_Main.Locate('ssel', true, [])) and not CDS_SubSel.Locate('CRID', CDS_Main.fieldbyname('CRID').AsInteger, []) then
begin
CDS_SubSel.Append;
for i := 0 to CDS_SubSel.FieldCount - 1 do
begin
CDS_SubSel.Fields[i].Value := CDS_Main.Fields[i].Value;
end;
CDS_SubSel.FieldByName('packNo').Value := trim(packNO.Text);
CDS_SubSel.Post;
CDS_Main.Delete;
end;
next;
end;
EnableControls;
First;
end;
with CDS_Main do
begin
DisableControls;
First;
while not eof do
begin
if (CDS_Main.Locate('ssel', true, [])) and not CDS_SubSel.Locate('CRID', CDS_Main.fieldbyname('CRID').AsInteger, []) then
begin
CDS_SubSel.Append;
for i := 0 to CDS_SubSel.FieldCount - 1 do
begin
CDS_SubSel.Fields[i].Value := CDS_Main.Fields[i].Value;
end;
CDS_SubSel.FieldByName('packNo').Value := trim(packNO.Text);
CDS_SubSel.Post;
CDS_Main.Delete;
end;
next;
end;
EnableControls;
First;
end;
CDS_SubSel.EnableControls;
end;
procedure TfrmCKProductBCPKCListsel.PHYGBtnClick(Sender: TObject);
begin
frmUserHelp := TfrmUserHelp.Create(self);
with frmUserHelp do
begin
if showmodal = 1 then
begin
PHYG.Text := trim(ADOQueryHelp.fieldbyname('userName').AsString);
end;
free;
end;
end;
procedure TfrmCKProductBCPKCListsel.Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
FValue: string;
FBounds: TRect;
begin
FBounds := AViewInfo.Bounds;
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
begin
ACanvas.FillRect(FBounds);
ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
InflateRect(FBounds, -1, -1);
ACanvas.Font.Color := clBlack;
ACanvas.Brush.Style := bsClear;
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
ADone := True;
end;
end;
procedure TfrmCKProductBCPKCListsel.Tv2CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
FValue: string;
FBounds: TRect;
begin
FBounds := AViewInfo.Bounds;
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
begin
ACanvas.FillRect(FBounds);
ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
InflateRect(FBounds, -1, -1);
ACanvas.Font.Color := clBlack;
ACanvas.Brush.Style := bsClear;
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
ADone := True;
end;
end;
procedure TfrmCKProductBCPKCListsel.CheckBox1Click(Sender: TObject);
begin
if CDS_Main.IsEmpty then
exit;
with CDS_Main do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmCKProductBCPKCListsel.ToolButton2Click(Sender: TObject);
var
kcQty, num1: double;
i: integer;
isEdit: boolean;
begin
if not CDS_Main.Active then
exit;
if CDS_Main.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
isEdit := false;
frmKCEdit := TfrmKCEdit.create(self);
with frmKCEdit do
begin
if showmodal = 1 then
begin
num1 := strtofloatdef(cxCurrencyEdit2.Text, 0);
i := RadioGroup1.ItemIndex;
isEdit := true;
end;
free;
end;
if isEdit = false then
exit;
try
ADOQueryCmd.Connection.BeginTrans;
with CDS_Main do
begin
while CDS_Main.Locate('SSel', True, []) do
begin
if i = 0 then
kcQty := CDS_Main.fieldbyname('kcQty').AsFloat + num1;
if i = 1 then
kcQty := CDS_Main.fieldbyname('kcQty').AsFloat - num1;
if i = 2 then
kcQty := strtofloat(format('%.1f', [CDS_Main.fieldbyname('kcQty').AsFloat * num1]));
if i = 3 then
kcQty := strtofloat(format('%.1f', [CDS_Main.fieldbyname('kcQty').AsFloat / num1]));
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' Update CK_BanCP_KC Set ZDYFlote1=KCqty ');
sql.Add(' where CRID=' + Cds_Main.Fieldbyname('CRID').AsString);
sql.Add(' and ZDYFlote1=0 ');
sql.Add(' Update CK_BanCP_KC Set kcqty=''' + floattostr(kcQty) + ''',ZDYStr1=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' ,kcNote=' + quotedstr(trim(CDS_Main.fieldbyname('kcnote').AsString)));
sql.Add(' ,CPType=' + quotedstr(trim(CDS_Main.fieldbyname('CPType').AsString)));
sql.Add(' where CRID=' + Cds_Main.Fieldbyname('CRID').AsString);
sql.Add(' Update CK_BanCP_KC Set kcRollNum=0 ');
sql.Add(' where CRID=' + Cds_Main.Fieldbyname('CRID').AsString);
sql.Add(' and kcqty=0 and kcRollNum<>0 ');
ExecSQL;
end;
Edit;
FieldByName('kcqty').Value := kcQty;
FieldByName('SSel').Value := False;
post;
end;
end;
ADOQueryCmd.Connection.CommitTrans;
initGrid();
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
except
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
end;
end;
end.