RTFormwork/项目代码/RTBasicsV1/F03染色配方管理/U_DyeFormulaLargeInput.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

866 lines
22 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_DyeFormulaLargeInput;
interface
uses
Windows, Messages, strUtils, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxCurrencyEdit, cxTextEdit,
cxDropDownEdit, Menus, cxLookAndFeelPainters, StdCtrls, ComCtrls, BtnEdit,
Buttons, cxButtons, cxContainer, cxListBox, ExtCtrls, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
cxControls, cxGridCustomView, cxGrid, ToolWin, cxLookAndFeels, cxNavigator,
ADODB, DBClient, RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset,
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, cxCustomListBox, U_BaseList,
cxButtonEdit, dxBarBuiltInMenu, cxGridCustomPopupMenu, cxGridPopupMenu, cxPC,
RM_BarCode, U_BaseInput, System.ImageList, Vcl.ImgList;
type
TfrmDyeFormulaLargeInput = class(TfrmBaseInput)
Panel1: TPanel;
Panel3: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryTmp: TADOQuery;
CDS_SheetDye: TClientDataSet;
DS_SheetDye: TDataSource;
GPM_1: TcxGridPopupMenu;
ToolBar1: TToolBar;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
cxGrid1: TcxGrid;
TV1: TcxGridDBTableView;
TV1Column5: TcxGridDBColumn;
TV1DyeCode: TcxGridDBColumn;
TV1dyeName: TcxGridDBColumn;
TV1dyeStyle: TcxGridDBColumn;
TV1curUnitDyeNum: TcxGridDBColumn;
TV1pbUnit: TcxGridDBColumn;
TV1sumNum: TcxGridDBColumn;
TV1sumNum_KG: TcxGridDBColumn;
TV1Column1: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
Panel2: TPanel;
Panel4: TPanel;
GroupBox3: TGroupBox;
cxGrid2: TcxGrid;
TV2: TcxGridDBTableView;
tv1gangNo: TcxGridDBColumn;
tv1sheetNo: TcxGridDBColumn;
tv1sheetStyle: TcxGridDBColumn;
tv1filltime: TcxGridDBColumn;
tv1Column4: TcxGridDBColumn;
cxGridDBColumn1: TcxGridDBColumn;
tv1Column2: TcxGridDBColumn;
tv1Column3: TcxGridDBColumn;
tv1Column6: TcxGridDBColumn;
tv1DeviceNo: TcxGridDBColumn;
tv1curNum: TcxGridDBColumn;
tv1YB: TcxGridDBColumn;
tv1Volume: TcxGridDBColumn;
tv1filler: TcxGridDBColumn;
tv1beizhu: TcxGridDBColumn;
tv1Column8: TcxGridDBColumn;
tv1Column9: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
Panel5: TPanel;
Label23: TLabel;
Label2: TLabel;
Label4: TLabel;
Label21: TLabel;
Label6: TLabel;
Label5: TLabel;
Label13: TLabel;
Label14: TLabel;
Label18: TLabel;
Label25: TLabel;
Label36: TLabel;
Label22: TLabel;
Label1: TLabel;
Label7: TLabel;
Label19: TLabel;
Label8: TLabel;
Label9: TLabel;
Label20: TLabel;
Note: TMemo;
C_Color: TEdit;
PCID: TEdit;
C_Name: TEdit;
CustName: TEdit;
C_ColorNo: TEdit;
DFLDate: TDateTimePicker;
Qty: TEdit;
Piece: TEdit;
C_ColorDepth: TEdit;
BathNo: TEdit;
DFLType: TComboBox;
ClothWeight: TEdit;
BathRatio: TEdit;
WaterNum: TEdit;
DFLMID: TEdit;
ToolButton2: TToolButton;
Panel6: TPanel;
Panel7: TPanel;
ToolBar2: TToolBar;
Tsave: TToolButton;
ToolButton1: TToolButton;
Tclose: TToolButton;
edtPCID: TEdit;
Label37: TLabel;
CDS_2: TClientDataSet;
DS_2: TDataSource;
GPM_2: TcxGridPopupMenu;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure tv2curUnitDyeNumPropertiesEditValueChanged(Sender: TObject);
procedure tv2sumNumPropertiesEditValueChanged(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TcloseClick(Sender: TObject);
procedure WaterNumChange(Sender: TObject);
procedure ClothWeightExit(Sender: TObject);
procedure TsaveClick(Sender: TObject);
procedure edtPCIDKeyPress(Sender: TObject; var Key: Char);
procedure tv2dyeStylePropertiesEditValueChanged(Sender: TObject);
procedure cxButton4Click(Sender: TObject);
procedure tv2DyeCodePropertiesEditValueChanged(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure ToolButton6Click(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure TV1pbUnitPropertiesEditValueChanged(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure TV2DblClick(Sender: TObject);
private
procedure formulaDyeCalcAll(); //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure formulaDyeCalcSingle(); //<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure InitData(); //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function SaveData(): Boolean; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure InitCard(); //ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD>̿<EFBFBD>
procedure ClearFormula(); //<2F><><EFBFBD><EFBFBD><EFBFBD>
procedure InitOldFormula(); //<2F><>ȡ<EFBFBD><C8A1>ʷ<EFBFBD>
{ Private declarations }
public
FDFLMID: string;
{ Public declarations }
end;
var
frmDyeFormulaLargeInput: TfrmDyeFormulaLargeInput;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmDyeFormulaLargeInput.InitOldFormula();
begin
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select top 20 * from Dye_Formula_Large_Main ');
sql.Add('where DFLType=''<27><><EFBFBD><EFBFBD>'' ');
sql.Add('and C_Name=''' + trim(C_Name.Text) + ''' ');
sql.Add('and isnull(C_Color,'''')=''' + trim(C_Color.Text) + ''' ');
sql.Add('order by DFLDate desc ');
open;
end;
SCreateCDS(ADOQueryTmp, CDS_2);
SInitCDSData(ADOQueryTmp, CDS_2);
end;
procedure TfrmDyeFormulaLargeInput.formulaDyeCalcSingle();
var
MClothWeight: double; //* <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> *//
MBathRatio: double; //* <20><>ǰԡ<C7B0><D4A1>*//
MWaterNum: double; //* ˮ<><CBAE>*//
MDyeRatio: double; //* <20><><EFBFBD><EFBFBD>*//
MDyeGQty: double; //* Ⱦ<><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*//
MDyeUnit: string;
begin
MClothWeight := strToFloatDef(trim(WaterNum.text), 0);
MWaterNum := strtoFloatDef(trim(WaterNum.text), 0);
MBathRatio := strToFloatDef(trim(BathRatio.text), 1);
if MClothWeight <= 0.0 then
exit;
with CDS_SheetDye do
begin
try
DisableControls;
MDyeRatio := CDS_SheetDye.fieldByName('DyeRatio').AsFloat;
MDyeUnit := Trim(CDS_SheetDye.fieldByName('DyeUnit').AsString);
if (MDyeUnit = '%') or (MDyeUnit = 'g/l') then
begin
if MDyeUnit = '%' then
MDyeGQty := RoundFloat(MClothWeight * MDyeRatio / 100.0 * 1000, 1) //Ⱦ<><C8BE>=<3D><>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>*<2A>
else if MDyeUnit = 'g/l' then
MDyeGQty := RoundFloat(MWaterNum * MDyeRatio, 1); //<2F><><EFBFBD><EFBFBD><><CBAE>*<2A>
with CDS_SheetDye do
begin
Edit;
CDS_SheetDye.fieldByName('DyeGQty').value := MDyeGQty;
CDS_SheetDye.fieldByName('DyeKgQty').value := MDyeGQty / 1000;
Post;
end;
end;
finally
EnableControls;
end;
end;
end;
procedure TfrmDyeFormulaLargeInput.formulaDyeCalcAll();
var
MClothWeight: double; //* <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> *//
MBathRatio: double; //* <20><>ǰԡ<C7B0><D4A1>*//
MWaterNum: double; //* ˮ<><CBAE>*//
MDyeRatio: double; //* <20><><EFBFBD><EFBFBD>*//
MDyeGQty: double; //* Ⱦ<><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*//
MDyeUnit: string;
begin
MClothWeight := strToFloatDef(trim(WaterNum.text), 0);
MWaterNum := strtoFloatDef(trim(WaterNum.text), 0);
MBathRatio := strToFloatDef(trim(BathRatio.text), 1);
if MClothWeight <= 0.0 then
exit;
with CDS_SheetDye do
begin
try
DisableControls;
First;
while not Eof do
begin
MDyeRatio := CDS_SheetDye.fieldByName('DyeRatio').AsFloat;
MDyeUnit := Trim(CDS_SheetDye.fieldByName('DyeUnit').AsString);
if (MDyeUnit = '%') or (MDyeUnit = 'g/l') then
begin
if MDyeUnit = '%' then
MDyeGQty := RoundFloat(MClothWeight * MDyeRatio / 100.0 * 1000, 1) //Ⱦ<><C8BE>=<3D><>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>*<2A>
else if MDyeUnit = 'g/l' then
MDyeGQty := RoundFloat(MWaterNum * MDyeRatio, 1); //<2F><><EFBFBD><EFBFBD><><CBAE>*<2A>
with CDS_SheetDye do
begin
Edit;
CDS_SheetDye.fieldByName('DyeGQty').value := MDyeGQty;
CDS_SheetDye.fieldByName('DyeKgQty').value := MDyeGQty / 1000;
Post;
end;
end;
Next;
end;
finally
EnableControls;
end;
end;
end;
procedure TfrmDyeFormulaLargeInput.ClearFormula();
begin
DFLMID.Text := '';
DFLType.ItemIndex := 0;
DFLMID.Text := '';
BathNo.Text := '';
PCID.Text := '';
edtPCID.Text := '';
WaterNum.Text := '';
FDFLMID := '';
with CDS_SheetDye do
begin
try
DisableControls;
First;
while not Eof do
begin
with CDS_SheetDye do
begin
Edit;
Fieldbyname('DFLMID').Value := '';
Fieldbyname('DFLSID').Value := '';
Post;
end;
Next;
end;
finally
First;
EnableControls;
end;
end;
end;
procedure TfrmDyeFormulaLargeInput.edtPCIDKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
if trim(edtPCID.Text) = '' then
exit;
InitCard();
InitOldFormula();
end;
end;
function TfrmDyeFormulaLargeInput.SaveData(): Boolean;
var
MaxMid, MaxSid: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
if trim(FDFLMID) = '' then
begin
if GetLSNo(ADOQuerytmp, MaxMid, 'LP', 'Dye_Formula_Large_Main', 4, 1) = false then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
MaxMid := FDFLMID;
////////////////////////////////////
//<2F><><EFBFBD><EFBFBD>
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Large_Main');
sql.Add('where DFLMID=' + QuotedStr(MaxMid));
open;
if Trim(FDFLMID) = '' 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(ADOQueryTmp);
end;
RTSetsavedata(ADOQueryCmd, 'Dye_Formula_Large_Main', panel5, 0);
Fieldbyname('DFLMID').Value := trim(MaxMid);
Post;
end;
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /////////////////
///
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD> /////////////////
with CDS_SheetDye do
begin
DisableControls;
first;
while not eof do
begin
if (trim(CDS_sheetDye.fieldByName('P_Name').AsString) = '') then
begin
CDS_SheetDye.Next;
Continue;
end;
if (CDS_sheetDye.fieldByName('DyeRatio').AsFloat <= 0) then
begin
CDS_SheetDye.Next;
Continue;
end;
if trim(CDS_SheetDye.FieldByName('DFLSID').AsString) = '' then
begin
if GetLSNo(ADOQuerytmp, MaxSid, 'LS', 'Dye_Formula_Large_Sub', 4, 1) = false then
raise Exception.Create(<><C8A1><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
MaxSid := trim(CDS_SheetDye.FieldByName('DFLSID').AsString);
end;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Large_Sub');
sql.Add('where DFLMID=' + quotedStr(MaxMid));
sql.Add('and DFLSID=' + quotedStr(MaxSid));
open;
if IsEmpty then
begin
Append;
end
else
begin
Edit;
end;
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_SheetDye, 'Dye_Formula_Sample_Sub', 0);
Fieldbyname('DFLMID').Value := trim(MaxMid);
Fieldbyname('DFLSID').Value := trim(MaxSid);
Post;
end;
next;
end;
EnableControls;
end;
ADOQueryCmd.Connection.CommitTrans;
DFLMID.Text := trim(MaxMid);
////////////////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD> /////////////////
Result := true;
except
Result := false;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmDyeFormulaLargeInput.InitCard();
begin
with AdoQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * ');
sql.Add('from Dye_Formula_Large_Main A');
sql.Add('where A.PCID=''' + trim(edtPCID.Text) + '''');
open;
end;
if AdoQueryTmp.IsEmpty then
begin
DFLType.ItemIndex := 0;
DFLMID.Text := '';
end
else
begin
DFLType.ItemIndex := 1;
DFLMID.Text := '';
end;
with AdoQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * ');
sql.Add('from Dye_Plan_Card A');
sql.Add('where Status=''9'' and A.PCID=''' + trim(edtPCID.Text) + '''');
open;
if not IsEmpty then
begin
CustName.Text := fieldbyName('CustName').asstring;
C_Name.Text := fieldbyName('C_Name').asstring;
C_ColorNo.Text := fieldbyName('C_ColorNo').asstring;
C_Color.Text := fieldbyName('C_Color').asstring;
Piece.text := fieldbyName('PCPiece').asstring;
Qty.text := fieldbyName('PCQty').asstring;
PCID.text := fieldbyName('PCID').asstring;
FDFLMID := '';
edtPCID.Text := '';
formulaDyeCalcAll();
end
else
begin
DFLType.ItemIndex := 0;
DFLMID.Text := '';
BathNo.Text := '';
PCID.Text := '';
edtPCID.Text := '';
WaterNum.Text := '';
FDFLMID := '';
end;
end;
end;
procedure TfrmDyeFormulaLargeInput.InitData();
begin
with ADOQueryTmp do
begin
close;
filtered := false;
sql.Clear;
sql.Add('select A.* ');
sql.Add('from Dye_Formula_Large_Main A');
sql.Add('where DFLMID=' + quotedStr(trim(FDFLMID)));
open;
end;
SCSHData(ADOQueryTmp, Panel5, 0);
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Large_Sub where DFLMID=''' + trim(FDFLMID) + ''' ');
open;
end;
SCreateCDS(ADOQueryTmp, CDS_SheetDye);
SInitCDSData(ADOQueryTmp, CDS_SheetDye);
end;
procedure TfrmDyeFormulaLargeInput.FormDestroy(Sender: TObject);
begin
inherited;
frmDyeFormulaLargeInput := nil;
end;
procedure TfrmDyeFormulaLargeInput.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := cafree;
end;
procedure TfrmDyeFormulaLargeInput.FormCreate(Sender: TObject);
begin
inherited;
DFLDate.DateTime := now();
end;
procedure TfrmDyeFormulaLargeInput.tv2curUnitDyeNumPropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
if Trim(mvalue) = '' then
mvalue := '0';
with CDS_SheetDye do
begin
Edit;
FieldByName(FFieldName).Value := mvalue;
Post;
end;
formulaDyeCalcSingle();
TV1.Controller.EditingController.ShowEdit();
end;
procedure TfrmDyeFormulaLargeInput.TV2DblClick(Sender: TObject);
begin
if Trim(FDFLMID) <> '' then
Exit;
with ADOQueryTmp do
begin
close;
filtered := false;
sql.Clear;
sql.Add('select A.* ');
sql.Add('from Dye_Formula_Large_Main A');
sql.Add('where DFLMID=' + QuotedStr(trim(CDS_2.fieldByName('DFLMID').AsString)));
open;
end;
ClothWeight.Text := trim(CDS_2.fieldByName('ClothWeight').AsString);
BathRatio.Text := trim(CDS_2.fieldByName('BathRatio').AsString);
WaterNum.Text := trim(CDS_2.fieldByName('WaterNum').AsString);
with ADOQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from Dye_Formula_Large_Sub where DFLMID=' + QuotedStr(trim(CDS_2.fieldByName('DFLMID').AsString)));
open;
end;
SCreateCDS(ADOQueryTmp, CDS_SheetDye);
SInitCDSData(ADOQueryTmp, CDS_SheetDye);
with CDS_SheetDye do
begin
try
DisableControls;
First;
while not Eof do
begin
with CDS_SheetDye do
begin
Edit;
Fieldbyname('DFLMID').Value := '';
Fieldbyname('DFLSID').Value := '';
Post;
end;
Next;
end;
finally
First;
EnableControls;
end;
end;
end;
procedure TfrmDyeFormulaLargeInput.tv2DyeCodePropertiesEditValueChanged(Sender: TObject);
var
mvalue: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
with CDS_SheetDye do
begin
Edit;
FieldByName('P_Code').Value := Trim(mvalue);
Post;
end;
with AdoQueryTmp do
begin
close;
sql.Clear;
sql.Add('select * from BS_Product_Info A ');
sql.Add('where STKName='<><C8BE><EFBFBD><EFBFBD>'' and P_Code=' + quotedstr(trim(mvalue)));
open;
end;
with CDS_SheetDye do
begin
Edit;
FieldByName('P_Code').Value := AdoQueryTmp.FieldByName('P_Code').Value;
FieldByName('P_Name').Value := AdoQueryTmp.FieldByName('P_Name').Value;
FieldByName('P_Spec').Value := AdoQueryTmp.FieldByName('P_Spec').Value;
FieldByName('P_Type').Value := AdoQueryTmp.FieldByName('P_Type').Value;
FieldByName('DyeUnit').Value := AdoQueryTmp.FieldByName('TakeUnit').Value;
Post;
end;
Self.TV1.Controller.EditingController.ShowEdit();
end;
procedure TfrmDyeFormulaLargeInput.tv2dyeStylePropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName, M, N: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_SheetDye do
begin
Edit;
FieldByName(FFieldName).Value := mvalue;
Post;
M := FieldByName('dye_kind_name').AsString; //<2F><><EFBFBD><EFBFBD>
N := FieldByName('DyeUnit').AsString; //<2F><>λ
end;
if M = <><C8BE>' then
N := '%'
else
N := 'g/l';
with CDS_SheetDye do
begin
Edit;
FieldByName('DyeUnit').Value := N;
Post;
end;
TV1.Controller.EditingController.ShowEdit();
end;
procedure TfrmDyeFormulaLargeInput.tv2sumNumPropertiesEditValueChanged(Sender: TObject);
var
mvalue: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
if Trim(mvalue) = '' then
mvalue := '0';
with CDS_SheetDye do
begin
Edit;
FieldByName('DyeGQty').Value := mvalue;
FieldByName('DyeKgQty').Value := StrToFloatdef(mvalue, 0) / 1000;
Post;
end;
TV1.Controller.EditingController.ShowEdit();
end;
procedure TfrmDyeFormulaLargeInput.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(self.Caption + tv1.Name, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
ReadCxGrid(self.Caption + tv2.Name, Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
InitData();
end;
procedure TfrmDyeFormulaLargeInput.TcloseClick(Sender: TObject);
begin
close;
end;
procedure TfrmDyeFormulaLargeInput.WaterNumChange(Sender: TObject);
begin
if strToFloatDef(trim(WaterNum.text), 0) > 0 then
BathRatio.text := format('%.3f', [strTofloatDef(trim(WaterNum.Text), 0) / strToFloatDef(trim(WaterNum.text), 0)]);
end;
procedure TfrmDyeFormulaLargeInput.ClothWeightExit(Sender: TObject);
begin
if CDS_SheetDye.IsEmpty then
exit;
formulaDyeCalcAll();
end;
procedure TfrmDyeFormulaLargeInput.cxButton4Click(Sender: TObject);
begin
CDS_SheetDye.Prior;
end;
procedure TfrmDyeFormulaLargeInput.ToolButton1Click(Sender: TObject);
begin
if trim(PCID.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
if SaveData() then
begin
ClearFormula();
end;
end;
procedure TfrmDyeFormulaLargeInput.ToolButton2Click(Sender: TObject);
begin
WriteCxGrid(self.Caption + tv1.Name, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
WriteCxGrid(self.Caption + tv2.Name, Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD>䷽');
end;
procedure TfrmDyeFormulaLargeInput.ToolButton3Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to 10 do
begin
CDS_SheetDye.append;
CDS_SheetDye.fieldbyname('SerialNo').Value := CDS_SheetDye.RecordCount + 1;
CDS_SheetDye.Post;
end;
end;
procedure TfrmDyeFormulaLargeInput.ToolButton4Click(Sender: TObject);
begin
if CDS_SheetDye.IsEmpty then
exit;
with ADOQueryCmd do
begin
close;
sql.Clear;
sql.Add('update Dye_Formula_Large_Sub set DelId=' + quotedstr(DCode) + ',Deler=' + quotedstr(DName) + ',Deltime=getdate() where DFLSID=' + quotedstr(trim(CDS_SheetDye.fieldByName('DFLSID').AsString)));
sql.Add('insert into Dye_Formula_Large_Sub_Del select * from Dye_Formula_Large_Sub where DFLSID=' + quotedstr(trim(CDS_SheetDye.fieldByName('DFLSID').AsString)));
sql.Add('delete Dye_Formula_Large_Sub where DFLSID=' + quotedstr(trim(CDS_SheetDye.fieldByName('DFLSID').AsString)));
execsql;
end;
CDS_SheetDye.Delete;
end;
procedure TfrmDyeFormulaLargeInput.ToolButton5Click(Sender: TObject);
begin
with CDS_SheetDye do
begin
if IsEmpty then
Exit;
if RecNo >= 1 then
begin
//Prior;
Edit;
fieldByName('SerialNo').Value := fieldByName('SerialNo').Value - 1;
Post;
Prior;
Edit;
fieldByName('SerialNo').Value := fieldByName('SerialNo').Value + 1;
Post;
end;
Prior;
end;
end;
procedure TfrmDyeFormulaLargeInput.ToolButton6Click(Sender: TObject);
begin
CDS_SheetDye.IndexFieldNames := 'SerialNo';
with CDS_SheetDye do
begin
if IsEmpty then
Exit;
Next;
if not Eof then
Prior
else
begin
exit;
end;
if not Eof then
begin
Edit;
fieldByName('SerialNo').Value := fieldByName('SerialNo').Value + 1;
Post;
Prior;
Edit;
fieldByName('SerialNo').Value := fieldByName('SerialNo').Value - 1;
Post;
end;
Next;
end;
end;
procedure TfrmDyeFormulaLargeInput.TsaveClick(Sender: TObject);
begin
if trim(PCID.Text) = '' then
begin
application.MessageBox('<27><><EFBFBD>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
exit;
end;
if SaveData() then
begin
ModalResult := 1;
end;
end;
procedure TfrmDyeFormulaLargeInput.TV1pbUnitPropertiesEditValueChanged(Sender: TObject);
var
mvalue, FFieldName: string;
begin
mvalue := TcxTextEdit(Sender).EditingText;
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_SheetDye do
begin
Edit;
FieldByName(FFieldName).Value := mvalue;
Post;
end;
formulaDyeCalcSingle();
TV1.Controller.EditingController.ShowEdit();
end;
end.