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

772 lines
25 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_CKSMEdit;
interface
uses
Windows, Messages, strutils, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
cxGrid, StdCtrls, cxContainer, cxTextEdit, cxCurrencyEdit, BtnEdit, ExtCtrls,
ComCtrls, ToolWin, DBClient, ADODB, MovePanel, cxCheckBox, RM_Common, RM_Class,
RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, MMSystem, 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
TfrmCKSMEdit = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
PHYG: TBtnEditA;
defstr2: TComboBox;
Label16: TLabel;
Label15: TLabel;
packNo: TcxCurrencyEdit;
Label14: TLabel;
Label1: TLabel;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1MJID: TcxGridDBColumn;
v1MJXH: TcxGridDBColumn;
v1P_Code: TcxGridDBColumn;
v1P_Color: TcxGridDBColumn;
v1RollNum: TcxGridDBColumn;
v1Qty: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
Panel2: TPanel;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn2: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn4: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridDBColumn6: TcxGridDBColumn;
cxGridDBColumn7: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
ADOQueryMain: TADOQuery;
ADOQueryCmd: TADOQuery;
CDSOrder: TClientDataSet;
CDSMJID: TClientDataSet;
DataSource1: TDataSource;
DataSource2: TDataSource;
SmNO: TEdit;
ADOQueryTmp: TADOQuery;
MovePanel1: TMovePanel;
Label2: TLabel;
Edit2: TEdit;
Button4: TButton;
V2Column1: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
cxStyle2: TcxStyle;
cxStyle_gridRow: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_gridHead: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_yellow: TcxStyle;
cxStyle_Red: TcxStyle;
cxStyle_fontBlack: TcxStyle;
cxStyle_fontclFuchsia: TcxStyle;
cxStyle_fontclPurple: TcxStyle;
cxStyle_fontclGreen: TcxStyle;
cxStyle_fontclBlue: TcxStyle;
cxStyle_fontclTeal: TcxStyle;
cxStyle_fontclOlive: TcxStyle;
ToolButton1: TToolButton;
V2Column2: TcxGridDBColumn;
CheckBox1: TCheckBox;
ToolButton2: TToolButton;
RMGridReport1: TRMGridReport;
RMXLSExport2: TRMXLSExport;
ADOQueryPrint: TADOQuery;
RMDB_Main: TRMDBDataSet;
ADOQuery1: TADOQuery;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure SmNOKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
procedure TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure TBSaveClick(Sender: TObject);
procedure PHYGBtnClick(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
private
procedure InitGrid();
procedure InitOrder();
procedure InitMJID();
function SavePH(): Boolean;
{ Private declarations }
public
FphRollNum, FphQty: double;
FOrderType: string;
{ Public declarations }
end;
var
frmCKSMEdit: TfrmCKSMEdit;
implementation
uses
U_DataLink, U_Fun, U_UserHelp, U_KCEdit;
{$R *.dfm}
function TfrmCKSMEdit.SavePH(): Boolean;
var
phRollNum, phQty: double;
phID: string;
P_ID: integer;
begin
if FOrderType = '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
phRollNum := 0;
phQty := 0;
with CDSMJID do
begin
DisableControls;
first;
while not eof do
begin
phRollNum := phRollNum + CDSMJID.fieldbyname('RollNum').AsFloat;
phQty := phQty + CDSMJID.fieldbyname('Qty').AsFloat;
next;
end;
first;
EnableControls;
end;
if (phRollNum > FphRollNum) or (phQty > FphQty) then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
Exit;
// 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;
end;
Result := false;
ADOQueryCmd.Connection.BeginTrans;
P_ID := 1;
try
with CDSMJID do
begin
DisableControls;
first;
while not eof do
begin
if trim(CDSMJID.fieldbyname('SDefNote').AsString) = <><C9A8><EFBFBD>ɹ<EFBFBD>' then
begin
if GetLSNo(ADOQueryTmp, phID, 'PH', 'CK_BanCP_PH', 4, 1) = False then
begin
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 1=2 ');
open;
end;
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('phID').Value := trim(phID);
ADOQueryCmd.FieldByName('p_No').Value := trim(fieldbyname('p_No').AsString);
ADOQueryCmd.FieldByName('p_ID').Value := P_ID;
// ADOQueryCmd.FieldByName('conNo').Value:=trim(fieldbyname('conNo').AsString);
ADOQueryCmd.FieldByName('MainID').Value := trim(fieldbyname('MainID').AsString);
ADOQueryCmd.FieldByName('SubID').Value := trim(fieldbyname('SubID').AsString);
ADOQueryCmd.FieldByName('PMainID').Value := trim(fieldbyname('PMainID').AsString);
ADOQueryCmd.FieldByName('PSubID').Value := trim(fieldbyname('PSubID').AsString);
ADOQueryCmd.FieldByName('mjID').Value := trim(fieldbyname('mjID').AsString);
ADOQueryCmd.FieldByName('CRID').Value := trim(fieldbyname('CRID').AsString);
ADOQueryCmd.FieldByName('qtyunit').Value := trim(fieldbyname('qtyunit').AsString);
ADOQueryCmd.FieldByName('defstr2').Value := trim(defstr2.Text);
ADOQueryCmd.FieldByName('packNo').Value := trim(packNO.Text);
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(ADOQueryTmp);
ADOQueryCmd.FieldByName('BCGangNo').Value := trim(fieldbyname('BCgangNO').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(CDSMJID.fieldbyname('mjid').AsString)));
sql.Add('and CRID=' + quotedstr(trim(CDSMJID.fieldbyname('CRID').AsString)));
open;
edit;
fieldbyname('kcstatus').Value := '1';
post;
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from JYOrder_sub ');
sql.Add('where mainID=' + quotedstr(trim(CDSMJID.fieldbyname('mainID').AsString)));
sql.Add('and subID=' + quotedstr(trim(CDSMJID.fieldbyname('subID').AsString)));
open;
edit;
fieldbyname('substatus').Value := '2';
post;
end;
P_ID := P_ID + 1;
end;
next;
end;
first;
EnableControls;
end;
ADOQueryCmd.Connection.CommitTrans;
Result := true;
except
ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmCKSMEdit.InitGrid();
begin
// FphRollNum := FphRollNum;
// FphQty :=FphQty;
// FOrderType := FOrderType;
with ADOQueryMain do
begin
Close;
sql.Clear;
SQL.Add('select A.*,B.OrderType,B.CustomerNoName,PHRollNum=0.00,PHQty=0.00 from JYOrder_sub A');
SQL.Add('inner join JYOrder_main B on B.mainID=A.mainID');
SQL.Add('where 1=2 ');
Open;
end;
SCreateCDS20(ADOQueryMain, CDSOrder);
SInitCDSData20(ADOQueryMain, CDSOrder);
with ADOQueryMain do
begin
Close;
sql.Clear;
SQL.Add('select A.*,B.PmainID,PSubID,P_NO from CK_BanCP_CR A ');
SQL.Add('inner join CK_BanCP_PH B on B.PHID=A.PHID ');
SQL.Add('where 1=2 ');
Open;
end;
SCreateCDS20(ADOQueryMain, CDSMJID);
SInitCDSData20(ADOQueryMain, CDSMJID);
end;
procedure TfrmCKSMEdit.InitOrder();
var
fP_No: string;
begin
MovePanel1.Visible := false;
CDSMJID.EmptyDataSet;
with ADOQueryMain do
begin
Close;
sql.Clear;
SQL.Add(' select A.*,B.CustomerNoName,PHRollNum=0.00,PHQty=0.00,P_No=A.SOrdDefNote2 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(SmNO.text)));
SQL.Add(' and isnull(A.substatus,''0'')<=''2'' ');
Open;
end;
if ADOQueryMain.IsEmpty then
begin
MovePanel1.Visible := true;
Edit2.text := SmNO.Text;
Label2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>˻<EFBFBD><CBBB>߲<EFBFBD><DFB2><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD>';
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
exit;
end
else
begin
SCreateCDS20(ADOQueryMain, CDSOrder);
SInitCDSData20(ADOQueryMain, CDSOrder);
with CDSOrder do
begin
DisableControls;
first;
while not eof do
begin
if GetLSNo(ADOQueryTmp, fP_No, 'PN', 'CK_BanCP_PH', 4, 1) then
begin
edit;
fieldbyname('P_No').Value := trim(fP_No);
post;
end
else
begin
MovePanel1.Visible := true;
Edit2.Enabled := false;
Label2.Caption := '<27><><EFBFBD>ɱ<EFBFBD><C9B1>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>';
EnableControls;
exit;
end;
next;
end;
first;
EnableControls;
end;
end;
end;
procedure TfrmCKSMEdit.InitMJID();
var
fP_No: string;
begin
MovePanel1.Visible := false;
with ADOQueryMain do
begin
Close;
sql.Clear;
SQL.Add('select A.*,B.mainID,B.subID from CK_BanCP_KC A');
sql.add('left join CK_BanCP_CR B on B.BCID=A.BCID and B.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
SQL.Add('where A.MJID=' + quotedstr(trim(SmNO.text)));
sql.Add('and isnull(A.KCStatus,''0'')=''0'' ');
sql.Add('and KCQty>0 ');
Open;
if not IsEmpty then
begin
if Fieldbyname('KCQty').AsFloat <= 0 then
begin
CDSMJID.Append;
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>';
CDSMJID.FieldByName('MJID').Value := trim(SmNO.Text);
CDSMJID.Post;
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD>.wav'), 0, SND_ASYNC);
end
else
begin
with ADOQueryTmp do
begin
Close;
sql.Clear;
SQL.Add('select B.mainID,B.subID from CK_BanCP_KC A');
sql.Add('inner join JYorder_Sub B on B.PRTCodeName=A.C_CodeName and B.PRtColor=A.C_Color');
SQL.Add('where A.MJID=' + quotedstr(trim(SmNO.text)));
SQL.Add('and B.mainID=' + quotedstr(trim(CDSOrder.Fieldbyname('mainID').AsString)));
Open;
if ADOQueryTmp.IsEmpty then
begin
CDSMJID.Append;
CDSMJID.FieldByName('SDefNote').Value := 'Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ӧ';
CDSMJID.FieldByName('MJID').Value := trim(SmNO.Text);
CDSMJID.Post;
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\Ʒ<><C6B7><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ӧ.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\Ʒ<><C6B7><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>Ӧ.wav'), 0, SND_ASYNC);
end
else
begin
if (ADOQueryMain.fieldbyName('BHFlag').AsBoolean) and (trim(ADOQueryMain.fieldbyName('BHOrderNo').AsString) <> trim(ADOQueryTmp.fieldbyName('mainID').AsString)) then
begin
// if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
// PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
// if Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
// Exit;
end;
if CDSOrder.Locate('subID', trim(ADOQueryTmp.fieldbyname('subID').AsString), []) then
begin
fP_No := CDSOrder.fieldbyname('P_NO').AsString;
end;
if CDSMJID.Locate('MJID', trim(ADOQueryMain.fieldbyname('MJID').AsString), []) then
CDSMJID.Edit
else
CDSMJID.Append;
CDSMJID.FieldByName('SDefNote').Value := <><C9A8><EFBFBD>ɹ<EFBFBD>';
CDSMJID.FieldByName('MJID').Value := trim(ADOQueryMain.Fieldbyname('MJID').AsString);
CDSMJID.FieldByName('CRID').Value := trim(ADOQueryMain.Fieldbyname('CRID').AsString);
CDSMJID.FieldByName('C_CodeName').Value := trim(ADOQueryMain.Fieldbyname('C_CodeName').AsString);
CDSMJID.FieldByName('C_Color').Value := trim(ADOQueryMain.Fieldbyname('C_Color').AsString);
CDSMJID.FieldByName('CPType').Value := trim(ADOQueryMain.Fieldbyname('CPType').AsString);
CDSMJID.FieldByName('RollNum').Value := ADOQueryMain.Fieldbyname('kcRollNum').AsFloat;
CDSMJID.FieldByName('Qty').Value := ADOQueryMain.Fieldbyname('kcQty').AsFloat;
CDSMJID.FieldByName('QtyUnit').Value := trim(ADOQueryMain.Fieldbyname('kcQtyUnit').AsString);
CDSMJID.FieldByName('mainID').Value := trim(ADOQueryTmp.Fieldbyname('mainID').AsString);
CDSMJID.FieldByName('subID').Value := trim(ADOQueryTmp.Fieldbyname('subID').AsString);
CDSMJID.FieldByName('P_NO').Value := trim(fP_No);
CDSMJID.FieldByName('PmainID').Value := trim(ADOQueryMain.Fieldbyname('mainID').AsString);
CDSMJID.FieldByName('PsubID').Value := trim(ADOQueryMain.Fieldbyname('subID').AsString);
CDSMJID.FieldByName('BCgangNO').Value := trim(ADOQueryMain.Fieldbyname('BCgangNO').AsString);
// CDSMJID.FieldByName('conNo').Value:=trim(ADOQueryMain.Fieldbyname('conNo').AsString);
CDSMJID.Post;
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><>ȷ.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><>ȷ.wav'), 0, SND_ASYNC);
end;
end;
end;
end
else
begin
CDSMJID.Append;
CDSMJID.FieldByName('SDefNote').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB2BB><EFBFBD>ڻ<EFBFBD><DABB>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>';
CDSMJID.FieldByName('MJID').Value := trim(SmNO.Text);
CDSMJID.Post;
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.wav'), 0, SND_ASYNC);
end;
end;
if trim(CDSMJID.FieldByName('SDefNote').AsString) <> <><C9A8><EFBFBD>ɹ<EFBFBD>' then
begin
MovePanel1.Visible := true;
Edit2.Text := SmNO.Text;
Label2.Caption := trim(CDSMJID.FieldByName('SDefNote').AsString);
end;
end;
procedure TfrmCKSMEdit.FormDestroy(Sender: TObject);
begin
wRITECxGrid(self.Caption + tV1.Name, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
wRITECxGrid(self.Caption + TV2.Name + '2', Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
frmCKSMEdit := nil;
end;
procedure TfrmCKSMEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := cafree;
end;
procedure TfrmCKSMEdit.TBCloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmCKSMEdit.FormCreate(Sender: TObject);
begin
Panel2.Align := alClient;
end;
procedure TfrmCKSMEdit.SmNOKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
MovePanel1.Visible := false;
if trim(smno.Text) = '' then
exit;
if (uppercase(leftBstr(trim(smno.Text), 2)) = 'JM') or (uppercase(leftBstr(trim(smno.Text), 3)) = 'ZJM') then
begin
inItorder();
end
else
begin
if CDSOrder.IsEmpty then
begin
MovePanel1.Visible := true;
Edit2.Text := SmNO.Text;
Label2.Caption := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>';
smno.Text := '';
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>.wav'), 0, SND_ASYNC);
exit;
end;
if not CDSMJID.Locate('MJID', trim(smNo.Text), []) then
initMjid();
end;
smno.Text := '';
smno.SetFocus;
end;
end;
procedure TfrmCKSMEdit.FormShow(Sender: TObject);
begin
ReadCxGrid(self.Caption + tV1.Name, Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
ReadCxGrid(self.Caption + TV2.Name + '2', Tv2, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
MovePanel1.Left := (Width - MovePanel1.Width) div 2;
MovePanel1.top := (Height - MovePanel1.Height - 200) div 2;
InitGrid();
end;
procedure TfrmCKSMEdit.TV2CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
i: integer;
begin
i := tv2.GetColumnByFieldName('SDefNote').Index;
if (AViewInfo.GridRecord.Values[i] <> <><C9A8><EFBFBD>ɹ<EFBFBD>') then
ACanvas.Brush.Color := clred;
end;
procedure TfrmCKSMEdit.TBSaveClick(Sender: TObject);
begin
if CDSOrder.IsEmpty then
exit;
if CDSMJID.IsEmpty then
exit;
if trim(CDSOrder.FieldByName('CustomerNoName').AsString) = '<27><EFBFBD><E3B6AB><EFBFBD>в<EFBFBD>' then
begin
if trim(packNo.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
if trim(defstr2.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
end;
{ IF tv1.DataController.Summary.FooterSummaryValues[0]<>0 then
begin
IF tv1.DataController.Summary.FooterSummaryValues[0]<> tv2.DataController.Summary.FooterSummaryValues[0] 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;
end; }
{ IF tv1.DataController.Summary.FooterSummaryValues[1]>0 then
begin
{ IF tv1.DataController.Summary.FooterSummaryValues[1]<> tv2.DataController.Summary.FooterSummaryValues[1] 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 tv2.DataController.Summary.FooterSummaryValues[1]>tv1.DataController.Summary.FooterSummaryValues[1] then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
exit;
end;
end; }
try
// ADOQueryCmd.Connection.BeginTrans;
if not savePh() then
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end
else
begin
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
initGrid();
exit;
end;
// ADOQueryCmd.Connection.CommitTrans;
except
// ADOQueryCmd.Connection.RollbackTrans;
end;
end;
procedure TfrmCKSMEdit.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 TfrmCKSMEdit.Button4Click(Sender: TObject);
begin
MovePanel1.Visible := false;
end;
procedure TfrmCKSMEdit.ToolButton1Click(Sender: TObject);
var
kcQty, num1: double;
i: integer;
isEdit: boolean;
begin
if not CDSMJID.Active then
exit;
if CDSMJID.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 CDSMJID do
begin
while CDSMJID.Locate('SSel', True, []) do
begin
if trim(Fieldbyname('SDefNote').AsString) = <><C9A8><EFBFBD>ɹ<EFBFBD>' then
begin
if i = 0 then
kcQty := CDSMJID.fieldbyname('Qty').AsFloat + num1;
if i = 1 then
kcQty := CDSMJID.fieldbyname('Qty').AsFloat - num1;
if i = 2 then
kcQty := strtofloat(format('%.1f', [CDSMJID.fieldbyname('Qty').AsFloat * num1]));
if i = 3 then
kcQty := strtofloat(format('%.1f', [CDSMJID.fieldbyname('Qty').AsFloat / num1]));
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add(' Update CK_BanCP_KC Set ZDYFlote1=KCqty ');
sql.Add(' where CRID=' + CDSMJID.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(' where CRID=' + CDSMJID.Fieldbyname('CRID').AsString);
sql.Add(' Update CK_BanCP_KC Set kcRollNum=0 ');
sql.Add(' where CRID=' + CDSMJID.Fieldbyname('CRID').AsString);
sql.Add(' and kcqty=0 and kcRollNum<>0 ');
ExecSQL;
end;
Edit;
FieldByName('qty').Value := kcQty;
FieldByName('SSel').Value := False;
post;
end
else
begin
Edit;
FieldByName('SSel').Value := False;
post;
end;
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;
procedure TfrmCKSMEdit.CheckBox1Click(Sender: TObject);
begin
if CDSMJID.IsEmpty then
exit;
with CDSMJID do
begin
DisableControls;
first;
while not eof do
begin
edit;
fieldbyname('ssel').Value := checkbox1.Checked;
post;
next;
end;
First;
EnableControls;
end;
end;
procedure TfrmCKSMEdit.ToolButton2Click(Sender: TObject);
var
fPrintFile: string;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
begin
if CDSMJID.IsEmpty then
Exit;
if CDSMJID.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
CDSMJID.DisableControls;
with CDSMJID do
begin
First;
while not Eof do
begin
if CDSMJID.FieldByName('SSel').AsBoolean = True then
begin
try
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
Txt := Trim(CDSMJID.fieldbyname('MJID').AsString);
fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
if FileExists(fImagePath) then
DeleteFile(fImagePath);
Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
except
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
CDSMJID.EnableControls;
exit;
end;
with ADOQueryPrint do //Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1>Ҫ<EFBFBD>ڿͻ<DABF><CDBB>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><C8A1>note<74>ֶΡ<D6B6>
begin
Close;
SQL.Clear;
sql.Add('select A.*,kcQty as mjlen,kcQtyUnit as MJTypeother ');
sql.Add(' from CK_BanCP_KC A');
SQL.Add(' where A.MJID=''' + Trim(CDSMJID.fieldbyname('MJID').AsString) + '''');
SQL.Add(' and KCQty>0 ');
Open;
end;
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\ͨ<>ñ<EFBFBD>ǩ.rmf';
if FileExists(fPrintFile) then
begin
RMVariables['QRBARCODE'] := fImagePath;
RMGridReport1.LoadFromFile(fPrintFile);
// RMGridReport1.ShowReport;
RMGridReport1.PrintReport;
end
else
begin
CDSMJID.EnableControls;
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD>ǩ.rmf'), '<27><>ʾ', 0);
Exit;
end;
end;
Next;
end;
end;
CDSMJID.EnableControls;
end;
end.