RTFormwork/项目代码/RTBasicsV1/D03针织坯布仓库/U_KnitDRtInPut.pas
“ddf” b5fbedfd26 1
2024-08-08 16:35:41 +08:00

495 lines
16 KiB
ObjectPascal
Raw Permalink 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_KnitDRtInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo,
cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit,
StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils,
cxDropDownEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters,
dxDateRanges, dxBarBuiltInMenu, U_BaseList, 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, dxCore, cxDateUtils;
type
TfrmKnitDRtInPut = class(Tform)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ScrollBox1: TScrollBox;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
ADOTemp: TADOQuery;
ADOCmd: TADOQuery;
DataSource1: TDataSource;
Order_Sub: TClientDataSet;
ADOQuery1: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
Label1: TLabel;
Note: TcxTextEdit;
Label12: TLabel;
Label11: TLabel;
v1Column1: TcxGridDBColumn;
cv1Column3: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
dazi1: TcxStyle;
v1Column2: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
Label2: TLabel;
Tv1Column2: TcxGridDBColumn;
ToolButton3: TToolButton;
Tv1Column3: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
ToolButton4: TToolButton;
Label27: TLabel;
Tv1Column1: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Label5: TLabel;
DRAddWet: TcxTextEdit;
Tv1Column10: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
DlyDate: TcxDateEdit;
OutType: TcxComboBox;
QtyUnit: TcxComboBox;
ToCoName: TcxButtonEdit;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure JSQtyUnitChange(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure ToCoNameDblClick(Sender: TObject);
procedure ToCoNameButtonClick(Sender: TObject; AButtonIndex: Integer);
private
fuserName: string;
procedure InitData();
function SaveData(): Boolean;
{ Private declarations }
public
PState, CopyInt: Integer;
FDRMID: string;
{ Public declarations }
end;
var
frmKnitDRtInPut: TfrmKnitDRtInPut;
newh: hwnd;
implementation
uses
U_DataLink, U_ZDYHelp, U_RTFun, U_CompanySel, U_KnitPlanSel;
// U_TradePlanSel, U_TradeSalesContractSel,
{$R *.dfm}
procedure TfrmKnitDRtInPut.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmKnitDRtInPut.InitData();
var
fsj: string;
begin
if PState = 0 then
begin
DlyDate.Date := strtodatetime(Trim(FormatDateTime('yyyy-MM-dd', Now)));
end;
with ADOQuery1 do
begin
Close;
SQL.Clear;
sql.Add(' select A.*,B.OrdQty,B.OrdPiece ');
sql.Add(' from Knit_Cloth_DR_Sub A');
sql.Add(' left join Knit_Plan_Sub B on A.SubId=B.SubId ');
if PState = 1 then
begin
sql.Add('where A.DRMID=''' + Trim(FDRMID) + '''');
end;
if PState = 0 then
begin
sql.Add(' where 1<>1');
end;
Open;
end;
SCreateCDS(ADOQuery1, Order_Sub);
SInitCDSData(ADOQuery1, Order_Sub);
with ADOQuery1 do
begin
Close;
sql.Clear;
sql.Add('select A.* ');
sql.Add(' from Knit_Cloth_DR_Main A');
sql.Add(' where DRMID=''' + Trim(FDRMID) + ''' ');
Open;
end;
SCSHData(ADOQuery1, ScrollBox1, 1);
ToCoName.Properties.LookupItems.Text := ADOQuery1.FieldByName('ToCoNo').asstring;
end;
procedure TfrmKnitDRtInPut.JSQtyUnitChange(Sender: TObject);
begin
if not Order_Sub.IsEmpty then
begin
exit;
end;
end;
procedure TfrmKnitDRtInPut.FormShow(Sender: TObject);
var
fsj: string;
begin
readCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
InitData();
end;
function TfrmKnitDRtInPut.SaveData(): Boolean;
var
MaxMid, MaxSid: string;
begin
try
ADOCmd.Connection.BeginTrans;
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
if Trim(FDRMID) = '' then
begin
if GetLSNo(ADOCmd, MaxMid, 'DM', 'Knit_Cloth_DR_Main', 4, 1) = False then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxMid := Trim(FDRMID);
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from Knit_Cloth_DR_Main where DRMID=''' + Trim(MaxMid) + '''');
Open;
end;
with ADOCmd do
begin
if Trim(FDRMID) = '' 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(ADOTemp);
end;
RTSetsavedata(ADOCmd, 'Knit_Cloth_DR_Main', ScrollBox1, 1);
FieldByName('DRMID').Value := Trim(MaxMid);
FieldByName('ToCoNo').Value := Trim(ToCoName.Properties.LookupItems.Text);
FieldByName('Status').Value := '9';
Post;
end;
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
///
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD> /////////////////
Order_Sub.DisableControls;
with Order_Sub do
begin
First;
while not Eof do
begin
if Trim(Order_Sub.fieldbyname('DRSID').AsString) = '' then
begin
if GetLSNo(ADOCmd, MaxSid, 'DS', 'Knit_Cloth_DR_Sub', 4, 1) = False then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxSid := Trim(Order_Sub.fieldbyname('DRSID').AsString);
end;
with ADOCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from Knit_Cloth_DR_Sub ');
sql.Add(' where DRMID=''' + Trim(MaxMid) + '''');
sql.Add(' and DRSID=''' + Trim(MaxSid) + '''');
Open;
if ADOCmd.IsEmpty then
begin
Append;
end
else
begin
Edit;
end;
RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'Knit_Cloth_DR_Sub', 0);
FieldByName('DRMID').Value := Trim(MaxMid);
FieldByName('DRSID').Value := Trim(MaxSid);
FieldByName('QtyUnit').Value := QtyUnit.Text;
FieldByName('MainId').Value := Order_Sub.fieldbyname('MainId').Value;
FieldByName('SubId').Value := Order_Sub.fieldbyname('SubId').Value;
FieldByName('ConMId').Value := Order_Sub.fieldbyname('ConMId').Value;
FieldByName('ConSId').Value := Order_Sub.fieldbyname('ConSId').Value;
Post;
end;
Order_Sub.Edit;
Order_Sub.FieldByName('DRSID').Value := Trim(MaxSid);
Next;
end;
end;
Order_Sub.EnableControls;
///////////////// <20><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD> /////////////////
FDRMID := Trim(MaxMid);
ADOCmd.Connection.CommitTrans;
Result := True;
except
ADOCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
Result := False;
end;
end;
procedure TfrmKnitDRtInPut.TBSaveClick(Sender: TObject);
var
Freal: Double;
begin
ToolBar1.SetFocus;
if Trim(OutType.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if Trim(ToCoName.Text) = '' then
begin
Application.MessageBox('<27>ջ<EFBFBD><D5BB><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if (Order_Sub.Locate('Piece', null, [])) and (Order_Sub.Locate('Qty', null, [])) = True then
begin
Application.MessageBox(<><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫΪ<C8AB>գ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmKnitDRtInPut.ToolButton1Click(Sender: TObject);
var
FQtyUnit, FFSubid: string;
begin
{
try
frmTradePlanSel := TfrmTradePlanSel.Create(Application);
with frmTradePlanSel do
begin
if ShowModal = 1 then
begin
while CDS_1.locate('SSel', true, []) do
begin
// Self.CustomerNoName.Text := Trim(frmTradePlanSel.Order_Main.fieldbyname('CustomerNoName').AsString);
// FQtyUnit := Trim(frmTradePlanSel.Order_Main.fieldbyname('orderUnit').AsString);
// if Self.Order_Sub.Locate('Subid', Trim(frmTradePlanSel.Order_Main.fieldbyname('Subid').AsString), []) = False then
begin
with Self.Order_Sub do
begin
Append;
FieldByName('SCConNo').Value := Trim(frmTradePlanSel.CDS_1.fieldbyname('Orderno').AsString);
FieldByName('SSConMainId').Value := frmTradePlanSel.CDS_1.fieldbyname('ConMainId').Value;
FieldByName('SSConSubId').Value := frmTradePlanSel.CDS_1.fieldbyname('ConSubId').Value;
FieldByName('MainId').Value := frmTradePlanSel.CDS_1.fieldbyname('MainId').Value;
FieldByName('SubId').Value := frmTradePlanSel.CDS_1.fieldbyname('SubId').Value;
FieldByName('PRTColor').Value := Trim(frmTradePlanSel.CDS_1.fieldbyname('P_Color').AsString);
FieldByName('SPrtCode').Value := Trim(frmTradePlanSel.CDS_1.fieldbyname('P_Code').AsString);
FieldByName('SPrtCodeName').Value := Trim(frmTradePlanSel.CDS_1.fieldbyname('P_CodeName').AsString);
FieldByName('PRTHX').Value := Trim(frmTradePlanSel.CDS_1.fieldbyname('P_HX').AsString);
// FieldByName('orderUnit').Value := JSQtyUnit.Text;
// if Trim(JSQtyUnit.Text) = 'Kg' then
// begin
// FieldByName('sqqty').Value := frmTradePlanSel.Order_Main.fieldbyname('JYGW').Value;
// end
// else if Trim(JSQtyUnit.Text) = 'M' then
// begin
// FieldByName('sqqty').Value := frmTradePlanSel.Order_Main.fieldbyname('JYLen').Value;
// end
// else if Trim(JSQtyUnit.Text) = 'Y' then
// begin
// FieldByName('sqqty').Value := frmTradePlanSel.Order_Main.fieldbyname('JYYLen').Value;
// end;
end;
end;
CDS_1.Delete;
end;
end;
end;
finally
frmTradePlanSel.Free;
end; }
end;
procedure TfrmKnitDRtInPut.ToolButton2Click(Sender: TObject);
begin
if Order_Sub.IsEmpty then
Exit;
if Trim(Order_Sub.fieldbyname('DRSID').AsString) <> '' then
begin
with ADOTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Knit_Cloth_DR_Sub where DRSID=''' + Trim(Order_Sub.fieldbyname('DRSID').AsString) + '''');
sql.add(' and isnull(DlyPiece,0)>0');
Open;
end;
if ADOTemp.IsEmpty = False then
begin
Application.MessageBox('<27>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
exit;
end;
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('delete Knit_Cloth_DR_Sub where DRSID=''' + Trim(Order_Sub.fieldbyname('DRSID').AsString) + '''');
ExecSQL;
end;
end;
Order_Sub.Delete;
end;
procedure TfrmKnitDRtInPut.ToolButton3Click(Sender: TObject);
var
FConMainId, FMPRTCode: string;
begin
try
frmKnitPlanSel := TfrmKnitPlanSel.Create(Application);
with frmKnitPlanSel do
begin
// frmKnitPlanSel.CustName.Text := Self.ToCoName.Text;
if ShowModal = 1 then
begin
while CDS_1.locate('SSel', true, []) do
begin
// if not self.Order_Sub.locate('ConSId', trim(frmKnitPlanSel.CDS_1.Fieldbyname('ConSId').AsString), []) then
// begin
with Self.Order_Sub do
begin
Append;
FieldByName('ConNo').Value := Trim(frmKnitPlanSel.CDS_1.fieldbyname('ConNo').AsString);
FieldByName('ConMId').Value := Trim(frmKnitPlanSel.CDS_1.fieldbyname('ConMId').AsString);
FieldByName('ConSId').Value := frmKnitPlanSel.CDS_1.fieldbyname('ConSId').Value;
FieldByName('BuyConNo').Value := frmKnitPlanSel.CDS_1.fieldbyname('BuyConNo').Value;
FieldByName('orderno').Value := Trim(frmKnitPlanSel.CDS_1.fieldbyname('orderno').AsString);
FieldByName('MainId').Value := Trim(frmKnitPlanSel.CDS_1.fieldbyname('MainId').AsString);
FieldByName('SubId').Value := frmKnitPlanSel.CDS_1.fieldbyname('SubId').Value;
FieldByName('C_Code').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Code').Value;
FieldByName('C_Name').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Name').Value;
FieldByName('C_Spec').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Spec').Value;
FieldByName('C_Width').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Width').Value;
FieldByName('C_GramWeight').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_GramWeight').Value;
FieldByName('C_Color').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Color').Value;
FieldByName('C_ColorNo').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_ColorNo').Value;
FieldByName('C_Pattern').Value := frmKnitPlanSel.CDS_1.fieldbyname('C_Pattern').Value;
FieldByName('BatchNo').Value := frmKnitPlanSel.CDS_1.fieldbyname('BatchNo').Value;
FieldByName('Loom').Value := frmKnitPlanSel.CDS_1.fieldbyname('Loom').Value;
FieldByName('Piece').Value := frmKnitPlanSel.CDS_1.fieldbyname('SumPiece').Value;
FieldByName('Qty').Value := frmKnitPlanSel.CDS_1.fieldbyname('SumStkGrossWeight').Value;
FieldByName('OrdPiece').Value := frmKnitPlanSel.CDS_1.fieldbyname('OrdPiece').Value;
FieldByName('OrdQty').Value := frmKnitPlanSel.CDS_1.fieldbyname('OrdQty').Value;
end;
// end;
CDS_1.Edit;
CDS_1.fieldbyname('SSel').value := false;
end;
end;
end;
finally
frmKnitPlanSel.Free;
end;
end;
procedure TfrmKnitDRtInPut.ToolButton4Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
end;
procedure TfrmKnitDRtInPut.ToCoNameDblClick(Sender: TObject);
begin
ToCoName.Text := '';
ToCoName.Properties.LookupItems.Text := '';
end;
procedure TfrmKnitDRtInPut.ToCoNameButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27>ͻ<EFBFBD>';
if ShowModal = 1 then
begin
self.ToCoName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString);
self.ToCoName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
end.