362 lines
11 KiB
ObjectPascal
362 lines
11 KiB
ObjectPascal
unit U_PurClothEnterInput;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
|
||
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
|
||
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
||
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
||
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
|
||
cxTextEdit, cxDropDownEdit, BtnEdit, cxLookAndFeels, cxLookAndFeelPainters,
|
||
cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges,
|
||
dxBarBuiltInMenu, U_BaseInput, System.ImageList, Vcl.ImgList, cxContainer,
|
||
cxMemo, dxSkinWXI, dxScrollbarAnnotations, dxCore, cxDateUtils, cxCurrencyEdit,
|
||
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, dxSkinXmas2008Blue;
|
||
|
||
type
|
||
TfrmPurClothEnterInput = class(TfrmBaseInput)
|
||
ToolBar1: TToolBar;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ToolButton3: TToolButton;
|
||
ScrollBox1: TScrollBox;
|
||
Label2: TLabel;
|
||
Label7: TLabel;
|
||
Label1: TLabel;
|
||
BatchNo: TcxTextEdit;
|
||
C_Code: TcxTextEdit;
|
||
Label8: TLabel;
|
||
Label5: TLabel;
|
||
StkPosition: TcxButtonEdit;
|
||
FromCoName: TcxButtonEdit;
|
||
ToolButton1: TToolButton;
|
||
Note: TcxMemo;
|
||
lbl5: TLabel;
|
||
IOTime: TcxDateEdit;
|
||
Label10: TLabel;
|
||
Label11: TLabel;
|
||
Qty: TcxCurrencyEdit;
|
||
Piece: TcxCurrencyEdit;
|
||
Label4: TLabel;
|
||
StkCoName: TcxButtonEdit;
|
||
Label6: TLabel;
|
||
C_Name: TcxTextEdit;
|
||
QtyUnit: TcxTextEdit;
|
||
Label3: TLabel;
|
||
C_Color: TcxTextEdit;
|
||
Label9: TLabel;
|
||
FromPurNo: TcxTextEdit;
|
||
FromPurSId: TcxTextEdit;
|
||
FromPurMId: TcxTextEdit;
|
||
Label12: TLabel;
|
||
C_Composition: TcxTextEdit;
|
||
Label13: TLabel;
|
||
C_Spec: TcxTextEdit;
|
||
C_Degree: TcxTextEdit;
|
||
C_Width: TcxTextEdit;
|
||
C_GramWeight: TcxTextEdit;
|
||
Price: TcxTextEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure BuyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
procedure CoBusinessTypeDblClick(Sender: TObject);
|
||
procedure StkCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
procedure FormCreate(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
function SaveData(): Boolean;
|
||
public
|
||
{ Public declarations }
|
||
FBCIOID, FPurSId: string;
|
||
end;
|
||
|
||
var
|
||
frmPurClothEnterInput: TfrmPurClothEnterInput;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp, U_CompanySel;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmPurClothEnterInput.InitGrid();
|
||
begin
|
||
if trim(FBCIOID) <> '' then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(' from BS_Cloth_IO A');
|
||
sql.Add(' where BCIOID=''' + Trim(FBCIOID) + '''');
|
||
Open;
|
||
end;
|
||
FromCoName.Properties.LookupItems.Text := ADOQueryTemp.FieldByName('FromCoNo').ASString;
|
||
StkCoName.Properties.LookupItems.Text := ADOQueryTemp.FieldByName('StkCoNo').ASString;
|
||
SCSHData(ADOQueryTemp, ScrollBox1, 0);
|
||
end
|
||
else
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.*,B.* ');
|
||
sql.Add(' from Pur_ClothPlan_Main A inner join Pur_ClothPlan_Sub B on A.PurMId=B.PurMId ');
|
||
sql.Add(' where PurSId=''' + Trim(FPurSId) + '''');
|
||
Open;
|
||
end;
|
||
FromCoName.Properties.LookupItems.Text := ADOQueryTemp.FieldByName('SellNo').ASString;
|
||
FromCoName.Text := ADOQueryTemp.FieldByName('SellName').ASString;
|
||
FromPurNo.Text := ADOQueryTemp.FieldByName('PurNo').ASString;
|
||
FromPurMId.Text := ADOQueryTemp.FieldByName('PurMId').ASString;
|
||
FromPurSId.Text := ADOQueryTemp.FieldByName('PurSId').ASString;
|
||
C_Spec.Text := ADOQueryTemp.FieldByName('C_Spec').ASString;
|
||
QtyUnit.Text := ADOQueryTemp.FieldByName('QtyUnit').ASString;
|
||
C_Composition.Text := ADOQueryTemp.FieldByName('C_Composition').ASString;
|
||
|
||
C_Code.Text := ADOQueryTemp.FieldByName('C_Code').ASString;
|
||
C_Name.Text := ADOQueryTemp.FieldByName('C_Code').ASString;
|
||
C_Color.Text := ADOQueryTemp.FieldByName('C_Color').ASString;
|
||
C_Degree.Text := ADOQueryTemp.FieldByName('C_Degree').ASString;
|
||
C_GramWeight.Text := ADOQueryTemp.FieldByName('C_GramWeight').ASString;
|
||
C_Width.Text := ADOQueryTemp.FieldByName('C_Width').ASString;
|
||
Price.Text := ADOQueryTemp.FieldByName('Price').ASString;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmPurClothEnterInput := nil;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.BuyNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
var
|
||
fsj: string;
|
||
FWZ: Integer;
|
||
begin
|
||
fsj := Trim(TcxButtonEdit(Sender).Hint);
|
||
FWZ := Pos('/', fsj);
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
MainType := 'Cust';
|
||
flag := Copy(fsj, 1, FWZ - 1);
|
||
flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
|
||
if ShowModal = 1 then
|
||
begin
|
||
TcxButtonEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.CoBusinessTypeDblClick(Sender: TObject);
|
||
begin
|
||
TcxButtonEdit(Sender).Text := '';
|
||
TcxButtonEdit(Sender).Properties.LookupItems.Text := '';
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
IOTime.Date := SGetServerDate(ADOQueryTemp);
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
close;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.FormShow(Sender: TObject);
|
||
var
|
||
i: integer;
|
||
a: string;
|
||
begin
|
||
inherited;
|
||
InitGrid();
|
||
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
function TfrmPurClothEnterInput.SaveData(): Boolean;
|
||
var
|
||
Maxno: string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
if Trim(FBCIOID) = '' then
|
||
begin
|
||
if not GetLSNo(ADOQueryCmd, Maxno, 'MR', 'BS_Cloth_IO', 4, 1) then
|
||
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
end
|
||
else
|
||
begin
|
||
Maxno := Trim(FBCIOID);
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from BS_Cloth_IO where BCIOID=''' + Trim(FBCIOID) + '''');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
if Trim(FBCIOID) = '' then
|
||
begin
|
||
Append;
|
||
FieldByName('FillId').Value := Trim(DCode);
|
||
FieldByName('Filler').Value := Trim(DName);
|
||
|
||
end
|
||
else
|
||
begin
|
||
Edit;
|
||
FieldByName('EditId').Value := Trim(DCode);
|
||
FieldByName('Editer').Value := Trim(DName);
|
||
FieldByName('Edittime').Value := SGetServerDateTime(ADOQueryTemp);
|
||
end;
|
||
RTSetsavedata(ADOQueryCmd, 'BS_Cloth_IO', ScrollBox1, 0);
|
||
FieldByName('FromCoNo').Value := FromCoName.Properties.LookupItems.Text;
|
||
FieldByName('StkCoNo').Value := StkCoName.Properties.LookupItems.Text;
|
||
FieldByName('BCIOID').Value := Trim(Maxno);
|
||
FieldByName('STKID').Value := Trim(Maxno);
|
||
FieldByName('STKName').Value := 'ó<>ײ<EFBFBD>ƥ';
|
||
FieldByName('IOFlag').Value := '<27><><EFBFBD><EFBFBD>';
|
||
FieldByName('IOType').Value := '<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('IOQtyFlag').Value := 1;
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update BS_Cloth_IO Set StkPiece=(select Sum(isnull(Piece,0)*IOQtyFlag) from BS_Cloth_IO A where A.STKID=BS_Cloth_IO.BCIOID )');
|
||
sql.Add(',StkQty=(select Sum(isnull(Qty,0)*IOQtyFlag) from BS_Cloth_IO A where A.STKID=BS_Cloth_IO.BCIOID )');
|
||
sql.Add(' where BCIOID=''' + Trim(Maxno) + '''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select stkQty,StkPiece from BS_Cloth_IO where BCIOID=''' + Trim(Maxno) + '''');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.FieldByName('stkQty').Value < 0 then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!');
|
||
if ADOQueryTemp.FieldByName('StkPiece').Value < 0 then
|
||
raise Exception.Create('<27><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>С<EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>!');
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) ');
|
||
sql.Add('values(''ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
||
sql.Add(',' + quotedstr(Maxno));
|
||
sql.Add(',''<27><><EFBFBD><EFBFBD>'' ');
|
||
sql.Add(',' + quotedstr(DName));
|
||
sql.Add(',' + quotedstr(trim(self.Caption)));
|
||
sql.Add(',' + quotedstr(Maxno));
|
||
sql.Add(') ');
|
||
ExecSQL;
|
||
end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result := True;
|
||
except
|
||
Result := false;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.StkCoNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmCompanySel := TfrmCompanySel.Create(Application);
|
||
with frmCompanySel do
|
||
begin
|
||
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
|
||
if ShowModal = 1 then
|
||
begin
|
||
self.StkCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
|
||
self.StkCoName.Properties.LookupItems.Text := Trim(CDS_1.fieldbyname('CoCode').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmCompanySel.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPurClothEnterInput.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
|
||
// if Trim(CoAbbrName.Text) = '' then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
// if Trim(CoName.Text) = '' then
|
||
// begin
|
||
// Application.MessageBox('<27><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
||
// Exit;
|
||
// end;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
||
ModalResult := 1;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|