D7zzHanglin/坯布生产计划(WeavingSchedule)/U_ClothGMInPut.pas

643 lines
17 KiB
ObjectPascal
Raw Permalink Normal View History

2025-08-06 16:42:07 +08:00
unit U_ClothGMInPut;
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, cxDropDownEdit,
StrUtils, cxPC, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport,
cxCheckBox;
type
TfrmClothGMInPut = class(TForm)
ToolBar1: TToolBar;
TBClose: TToolButton;
ADOTemp: TADOQuery;
ADOCmd: TADOQuery;
ADOQuery1: TADOQuery;
ADOQueryTemp: TADOQuery;
Panel2: TPanel;
ADOQueryCmd: TADOQuery;
cxGrid6: TcxGrid;
Tv6: TcxGridDBTableView;
cxGridLevel4: TcxGridLevel;
Panel1: TPanel;
Label39: TLabel;
Label40: TLabel;
Label41: TLabel;
Label42: TLabel;
www: TLabel;
Edit12: TEdit;
Edit7: TEdit;
Label43: TLabel;
ClothType: TComboBox;
BTPrint: TButton;
MJMaoZ: TEdit;
v6Column1: TcxGridDBColumn;
v6Column2: TcxGridDBColumn;
v6Column3: TcxGridDBColumn;
v6Column4: TcxGridDBColumn;
v6Column5: TcxGridDBColumn;
DataSource1: TDataSource;
CDS_MJID: TClientDataSet;
Label44: TLabel;
Label36: TLabel;
JXPerson: TBtnEditA;
Label37: TLabel;
SCPerson: TEdit;
Button3: TButton;
Label38: TLabel;
CarNo: TEdit;
ADOQueryPrint: TADOQuery;
RM2: TRMGridReport;
RMDB_Main: TRMDBDataSet;
CDS_Print: TClientDataSet;
Button1: TButton;
v6Column6: TcxGridDBColumn;
CheckBox1: TCheckBox;
ScrollBox1: TScrollBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label9: TLabel;
Label18: TLabel;
Label19: TLabel;
Label22: TLabel;
Label5: TLabel;
Label4: TLabel;
Label8: TLabel;
Label12: TLabel;
Label13: TLabel;
Label26: TLabel;
Label31: TLabel;
Label33: TLabel;
Label34: TLabel;
Label35: TLabel;
Label45: TLabel;
Label46: TLabel;
ConNo: TEdit;
QDTime: TDateTimePicker;
C_CodeName: TcxButtonEdit;
KZQty: TEdit;
MFQty: TEdit;
DeliveryDate: TDateTimePicker;
C_Color: TEdit;
PiKgQty: TEdit;
PiQty: TEdit;
C_Qty: TEdit;
C_Code: TEdit;
C_Spec: TEdit;
PiKgQtyFD: TEdit;
Label7: TLabel;
Label11: TLabel;
WFJHPS: TEdit;
WFJHQty: TEdit;
WFGYSName: TEdit;
Label6: TLabel;
Label10: TLabel;
WFWCPSZP: TEdit;
WFWCQtyZP: TEdit;
Label14: TLabel;
Label15: TLabel;
WFWCPSCP: TEdit;
WFWCQtyCP: TEdit;
Label17: TLabel;
Label16: TLabel;
BatchNoHZ: TEdit;
v6Column7: TcxGridDBColumn;
Label20: TLabel;
APBatchNo: TEdit;
v6Column8: TcxGridDBColumn;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BTPrintClick(Sender: TObject);
procedure Edit7Click(Sender: TObject);
procedure Edit12Click(Sender: TObject);
procedure MJMaoZKeyPress(Sender: TObject; var Key: Char);
procedure Tv6DblClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure JXPersonBtnClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
FXS: Integer;
procedure InitData();
function SaveData(): Boolean;
procedure PrintData(FFFMJID: string);
procedure SavedataCK();
{ Private declarations }
public
PState, FCopyInt: Integer;
FMainId, FConNo, PType, FSubId, PZFlag, FJGID, FAPID: string;
{ Public declarations }
end;
var
frmClothGMInPut: TfrmClothGMInPut;
newh: hwnd;
implementation
uses
U_DataLink, U_RTFun, U_SCPerson, U_ZDYHelp;
{$R *.dfm}
procedure TfrmClothGMInPut.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmClothGMInPut.InitData();
var
PBNO, PBFlag, fsj: string;
begin
if PState = 1 then
begin
ConNo.ReadOnly := True;
end;
with ADOQuery1 do
begin
Close;
SQL.Clear;
sql.Add('select A.ConNo,A.QDTime,A.DeliveryDate,A.MainId,B.C_CodeName,B.C_Code,B.C_Color ');
sql.Add(',B.MFQty,B.KZQty,B.PiKgQty,B.PiQty,B.C_Qty,B.SubId,B.PiKgQtyFD,B.C_Spec,B.BatchNoHZ,C.JGID');
sql.Add(',C.JHJiaoQi,C.WFGYSName,C.WFGYSNameJC,C.WFJHPS,C.WFJHQty,C.WFWCPS,C.WFWCQty,C.WFWCPSZP,C.WFWCQtyZP,C.WFWCPSCP,C.WFWCQtyCP');
sql.Add(' from Cloth_Main A inner join CLoth_Sub B on A.Mainid=B.MainId');
sql.Add(' inner join Cloth_WJG C on C.MainId=A.MainId ');
sql.Add(' where C.JGID=''' + Trim(FJGID) + '''');
Open;
end;
SCSHData(ADOQuery1, ScrollBox1, 0);
SCSHData(ADOQuery1, ScrollBox1, 2);
fsj := 'select Name=ZdyName from KH_Zdy where Type=''ClothType'' ';
SInitComBoxBySql(ADOQueryTemp, ClothType, True, fsj);
ClothType.ItemIndex := 0;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from WFB_MJJY_PB where JGID=''' + Trim(FJGID) + ''' and JTType=''<27><><EFBFBD><EFBFBD>'' ');
open;
end;
SCreateCDS20(ADOQueryTemp, CDS_MJID);
SInitCDSData20(ADOQueryTemp, CDS_MJID);
end;
procedure TfrmClothGMInPut.FormShow(Sender: TObject);
begin
InitData();
end;
procedure TfrmClothGMInPut.BTPrintClick(Sender: TObject);
var
mvalue: Double;
begin
if Trim(ClothType.Text) = '' then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD>ȼ<EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Trim(MJMaoZ.Text) <> '' then
begin
if TryStrToFloat(MJMaoZ.Text, mvalue) = False then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
end;
{if StrToFloat(MJMaoZ.Text)>50 then
begin
Application.MessageBox(<><C3AB>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end; }
if StrToFloat(MJMaoZ.Text) < 10 then
begin
if Application.MessageBox(<><C3AB>С<EFBFBD><D0A1>10ȷ<30><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
end;
if SaveData() then
begin
MJMaoZ.SetFocus;
end;
end;
procedure TfrmClothGMInPut.SavedataCK();
var
CRID: Integer;
MaxCkNo: string;
begin
with ADOCmd do
begin
Close;
sql.Clear;
SQL.add('Update CK_PBCP_CRID Set CRID=CRID+1');
sql.Add('select * from CK_PBCP_CRID');
Open;
end;
CRID := ADOCmd.fieldbyname('CRID').Value;
if GetLSNo(ADOCmd, MaxCkNo, 'JR', 'CK_PBCP_CR', 4, 1) = False then
begin
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_PBCP_CR where 1<>1');
Open;
end;
with ADOCmd do
begin
Append;
FieldByName('MainId').Value := Trim(FMainId);
FieldByName('SubId').Value := Trim(FSubId);
FieldByName('APID').Value := Trim(FAPID);
FieldByName('JGID').Value := Trim(FJGID);
FieldByName('MJID').Value := Trim(FAPID);
FieldByName('BCID').Value := Trim(MaxCkNo);
FieldByName('CRTime').Value := SGetServerDate(ADOTemp);
FieldByName('CRFlag').Value := '<27><><EFBFBD><EFBFBD>';
FieldByName('CRType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('CRID').Value := CRID;
FieldByName('KGQty').Value := StrToFloat(MJMaoZ.Text);
FieldByName('CPType').Value := ClothType.Text;
FieldByName('Filler').Value := Trim(DName);
Post;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('select * from CK_PBCP_KC where 1<>1');
Open;
end;
with ADOCmd do
begin
Append;
FieldByName('CRID').Value := CRID;
FieldByName('BCID').Value := Trim(MaxCkNo);
FieldByName('MJID').Value := Trim(FAPID);
FieldByName('JGID').Value := Trim(FJGID);
FieldByName('KCKGQty').Value := StrToFloat(MJMaoZ.Text);
Post;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFB_MJJY_PB Set MJStr2=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' where MJID=''' + Trim(FAPID) + '''');
ExecSQL;
end;
end;
function TfrmClothGMInPut.SaveData(): Boolean;
var
maxno: string;
begin
Result := False;
try
ADOCmd.Connection.BeginTrans;
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if GetLSNo(ADOCmd, maxno, '8', 'WFB_MJJY_PB', 4, 1) = False then
begin
ADOCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from WFB_MJJY_PB where MJId=''' + Trim(maxno) + '''');
Open;
end;
with ADOCmd do
begin
Append;
FieldByName('MainId').value := Trim(FMainId);
FieldByName('SubId').value := Trim(FSubId);
FieldByName('JGId').value := Trim(FJGId);
FieldByName('APId').value := Trim(maxno);
FieldByName('MJID').Value := Trim(maxno);
FieldByName('MJStr2').Value := <><CEB4><EFBFBD><EFBFBD>';
if Trim(MJMaoZ.Text) <> '' then
begin
FieldByName('MJMaoZ').Value := StrToFloat(MJMaoZ.Text);
FieldByName('MJJingZ').Value := StrToFloat(MJMaoZ.Text);
FieldByName('MJPiZ').Value := 0;
end;
if Trim(Edit12.Text) <> '' then
begin
FieldByName('MJStr3').Value := '<27><>ɫ';
end;
if Trim(Edit7.Text) <> '' then
begin
FieldByName('MJStr3').Value := <><C6AF>';
end;
FieldByName('Filler').Value := Trim(DName);
FieldByName('ClothType').Value := Trim(clothType.Text);
FieldByName('ChuLiFlag').Value := 1;
FieldByName('JTType').Value := '<27><><EFBFBD><EFBFBD>';
FieldByName('JXPerson').Value := Trim(JXPerson.Text);
FieldByName('SCPerson').Value := Trim(SCPerson.Text);
FieldByName('APBatchNo').Value := Trim(APBatchNo.Text);
FieldByName('ckBatchNo').Value := Trim(APBatchNo.Text);
FieldByName('CarNo').Value := Trim(CarNo.Text);
Post;
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('UPdate WFB_MJJY_PB Set MJXH=(select isnull(max(MJXH),0)+1 from WFB_MJJY_PB A where A.MainID=WFB_MJJY_PB.MainID)');
sql.Add(' where MJID=''' + Trim(maxno) + '''');
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
SQL.Add('UPdate WFB_MJJY_PB Set APXH=MJXH ');
sql.Add(' where MJID=''' + Trim(maxno) + '''');
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('Update WFB_MJJY_PB Set CheJian=(select Top 1 Note from KH_ZDY A ');
sql.Add(' where A.ZDYName=WFB_MJJY_PB.CarNo and A.Type=''CarNo'')');
sql.Add(' where MJID=''' + Trim(maxno) + '''');
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Update_Cloth_WJG_Qty :JGID');
Parameters.ParamByName('JGID').Value := Trim(FJGID);
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Update_Cloth_Sub_WJG_Qty :MainId');
Parameters.ParamByName('MainId').Value := Trim(FMainId);
ExecSQL;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from WFB_MJJY_PB where MJID=''' + Trim(maxno) + '''');
Open;
end;
with CDS_MJID do
begin
Append;
FieldByName('MJID').Value := ADOQueryTemp.fieldbyname('MJID').Value;
FieldByName('MJXH').Value := ADOQueryTemp.fieldbyname('MJXH').Value;
FieldByName('MJMaoZ').Value := ADOQueryTemp.fieldbyname('MJMaoZ').Value;
FieldByName('ClothType').Value := ADOQueryTemp.fieldbyname('ClothType').Value;
FieldByName('MJStr3').Value := ADOQueryTemp.fieldbyname('MJStr3').Value;
FieldByName('CarNo').Value := ADOQueryTemp.fieldbyname('CarNo').Value;
FieldByName('APBATCHNO').Value := ADOQueryTemp.fieldbyname('APBATCHNO').Value;
Post;
end;
FAPID := Trim(maxno);
// SavedataCK();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Do_PBJYCRK @MJID=' + quotedstr(trim(Trim(FAPID))));
ExecSQL;
end;
ADOCmd.Connection.CommitTrans;
Result := True;
if CheckBox1.Checked = True then
begin
PrintData(Trim(maxno));
end;
except
Result := False;
ADOCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end;
end;
procedure TfrmClothGMInPut.PrintData(FFFMJID: string);
var
fPrintFile: string;
i: Integer;
FDate: string;
Txt, fImagePath: string;
Moudle: THandle;
Makebar: TMakebar;
Mixtext: TMixtext;
begin
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩBP.rmf';
if FileExists(fPrintFile) then
begin
try
Moudle := LoadLibrary('MakeQRBarcode.dll');
@Makebar := GetProcAddress(Moudle, 'Make');
@Mixtext := GetProcAddress(Moudle, 'MixText');
Txt := Trim(FFFMJID);
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);
exit;
end;
with ADOQueryPrint do
begin
Close;
SQL.Clear;
SQL.Add('exec P_Print_PBLab :MJID');
Parameters.ParamByName('MJID').Value := Trim(FFFMJID);
Open;
end;
SCreateCDS20(ADOQueryPrint, CDS_Print);
SInitCDSData20(ADOQueryPrint, CDS_Print);
RM2.LoadFromFile(fPrintFile);
RMVariables['QRBARCODE'] := fImagePath;
//RM2.ShowReport;
RM2.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩBP.rmf'), '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmClothGMInPut.Edit7Click(Sender: TObject);
begin
if Trim(Edit7.Text) = '' then
begin
//Edit10.Text:='';
Edit12.Text := '';
Edit7.Text := '<27><>';
end
else
begin
//Edit10.Text:='';
Edit12.Text := '';
Edit7.Text := '';
end;
end;
procedure TfrmClothGMInPut.Edit12Click(Sender: TObject);
begin
if Trim(Edit12.Text) = '' then
begin
Edit12.Text := '<27><>';
Edit7.Text := '';
end
else
begin
Edit12.Text := '';
Edit7.Text := '';
end;
end;
procedure TfrmClothGMInPut.MJMaoZKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
if Trim(MJMaoZ.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
BTPrint.Click;
MJMaoZ.Text := '';
end;
end;
procedure TfrmClothGMInPut.Tv6DblClick(Sender: TObject);
begin
if CDS_MJID.IsEmpty then
Exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from CK_PBCP_CR where CRFlag=''<27><><EFBFBD><EFBFBD>'' and MJID=''' + Trim(CDS_MJID.fieldbyname('MJID').AsString) + '''');
Open;
end;
if ADOQueryTemp.IsEmpty = False then
begin
Application.MessageBox('<27>ѳ<EFBFBD><D1B3><EFBFBD><E2B2BB>ɾ<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 WFB_MJJY_PB where MJID=''' + Trim(CDS_MJID.fieldbyname('MJID').AsString) + '''');
sql.Add('delete CK_PBCP_CR where MJID=''' + Trim(CDS_MJID.fieldbyname('MJID').AsString) + '''');
sql.Add('delete CK_PBCP_KC where MJID=''' + Trim(CDS_MJID.fieldbyname('MJID').AsString) + '''');
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Update_Cloth_WJG_Qty :JGID');
Parameters.ParamByName('JGID').Value := Trim(FJGID);
ExecSQL;
end;
with ADOCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Update_Cloth_Sub_WJG_Qty :MainId');
Parameters.ParamByName('MainId').Value := Trim(FMainId);
ExecSQL;
end;
CDS_MJID.Delete;
end;
procedure TfrmClothGMInPut.Button3Click(Sender: TObject);
begin
try
frmSCPerson := TfrmSCPerson.Create(self);
with frmSCPerson do
begin
FlagStr := 'SCPerson';
if ShowModal = 1 then
begin
SCPerson.Text := frmSCPerson.FSDPerson;
end;
end;
finally
frmSCPerson.Free;
end;
end;
procedure TfrmClothGMInPut.JXPersonBtnClick(Sender: TObject);
begin
try
frmZDYHelp := TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag := 'JXPerson';
flagname := '<27><><EFBFBD><EFBFBD>';
if ShowModal = 1 then
begin
JXPerson.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmClothGMInPut.Button1Click(Sender: TObject);
begin
if CDS_MJID.IsEmpty then
Exit;
if CDS_MJID.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD>ش<EFBFBD><D8B4><EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
CDS_MJID.DisableControls;
with CDS_MJID do
begin
First;
while Locate('SSel', True, []) do
begin
PrintData(Trim(CDS_MJID.fieldbyname('MJID').AsString));
Edit;
FieldByName('SSel').Value := False;
Post;
end;
end;
CDS_MJID.EnableControls;
end;
end.