unit U_MJJYTH; interface uses Windows, Messages, SysUtils, strutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset, ADODB, DBClient, cxGridCustomPopupMenu, cxGridPopupMenu, ExtCtrls, ComCtrls, ToolWin, cxTextEdit, Buttons, cxSplitter, cxCheckBox, MovePanel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinDarkRoom, dxSkinOffice2013White, dxSkinSharpPlus, dxSkinSpringTime, dxSkinsDefaultPainters, dxSkinscxPCPainter, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSilver, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue; type TfrmMJJYTH = class(TForm) cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyle2: TcxStyle; cxGridPopupMenu1: TcxGridPopupMenu; DataSource1: TDataSource; Order_MJ: TClientDataSet; ADOQueryMain: TADOQuery; ADOCmd: TADOQuery; RMDB_Main: TRMDBDataSet; RM2: TRMGridReport; DataSource2: TDataSource; CDS_MJCD: TClientDataSet; DataSource3: TDataSource; CDS_MJID: TClientDataSet; Timer1: TTimer; ADOQueryPrint: TADOQuery; cxStyleRepository2: TcxStyleRepository; cxStyle3: TcxStyle; cxStyleRepository3: TcxStyleRepository; cxStyle4: TcxStyle; cxStyleRepository4: TcxStyleRepository; cxStyle5: TcxStyle; cxStyleRepository5: TcxStyleRepository; cxStyle6: TcxStyle; cxGridPopupMenu2: TcxGridPopupMenu; ADOQueryMainDSC: TADOQuery; RM3: TRMGridReport; ADOTmp: TADOQuery; Panel6: TPanel; Label16: TLabel; Label35: TLabel; Label24: TLabel; Label25: TLabel; Label3: TLabel; BTAdd: TButton; BTEdit: TButton; Edit7: TEdit; SMRK: TEdit; Label2: TLabel; Panel2: TPanel; SpeedButton13: TSpeedButton; SpeedButton14: TSpeedButton; SpeedButton15: TSpeedButton; PageControl1: TPageControl; TabSheet1: TTabSheet; Panel7: TPanel; Label5: TLabel; Label37: TLabel; MJLen: TEdit; BTPrint: TButton; GangNo: TEdit; Button5: TButton; Panel3: TPanel; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton5: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton7: TSpeedButton; SpeedButton8: TSpeedButton; SpeedButton9: TSpeedButton; SpeedButton10: TSpeedButton; SpeedButton11: TSpeedButton; SpeedButton12: TSpeedButton; TabSheet2: TTabSheet; TabSheet3: TTabSheet; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGangNo: TcxGridDBColumn; v3JYNo: TcxGridDBColumn; v3JYLen: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; ComboBox1: TComboBox; Panel1: TPanel; Label9: TLabel; Label6: TLabel; Label7: TLabel; Label11: TLabel; Label15: TLabel; Label30: TLabel; Label31: TLabel; Label32: TLabel; Label33: TLabel; JYLen: TEdit; JYKG: TEdit; JYPZ: TEdit; JYJZ: TEdit; Panel4: TPanel; SpeedButton16: TSpeedButton; SpeedButton17: TSpeedButton; SpeedButton18: TSpeedButton; SpeedButton19: TSpeedButton; SpeedButton20: TSpeedButton; SpeedButton21: TSpeedButton; SpeedButton22: TSpeedButton; SpeedButton23: TSpeedButton; SpeedButton24: TSpeedButton; SpeedButton25: TSpeedButton; SpeedButton26: TSpeedButton; SpeedButton27: TSpeedButton; cxGrid1: TcxGrid; TV2: TcxGridDBTableView; vJYNo: TcxGridDBColumn; cxGridDBJYLen: TcxGridDBColumn; v3JYKG: TcxGridDBColumn; v3JYJZ: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Panel8: TPanel; SpeedButton29: TSpeedButton; SpeedButton30: TSpeedButton; SpeedButton31: TSpeedButton; SpeedButton32: TSpeedButton; SpeedButton33: TSpeedButton; SpeedButton34: TSpeedButton; cxGrid2: TcxGrid; TV1: TcxGridDBTableView; cxGridDBGangNo: TcxGridDBColumn; cxGridDBSJZQty: TcxGridDBColumn; cxGridDBMQQty: TcxGridDBColumn; cxGridDBCQty: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; Button1: TButton; Button2: TButton; ComboBox2: TComboBox; ADOQuery1: TADOQuery; Button3: TButton; DataSource4: TDataSource; DataSource5: TDataSource; JY_CP: TClientDataSet; JY_HZ: TClientDataSet; Edit1: TEdit; Panel5: TPanel; SpeedButton28: TSpeedButton; SpeedButton35: TSpeedButton; SpeedButton36: TSpeedButton; SpeedButton37: TSpeedButton; SpeedButton38: TSpeedButton; SpeedButton39: TSpeedButton; cxGrid4: TcxGrid; TV4: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; cSJZQty: TcxGridDBColumn; cxGridLevel4: TcxGridLevel; DataSource6: TDataSource; DB_HZ: TClientDataSet; Panel9: TPanel; Label8: TLabel; ComboBox3: TComboBox; Label10: TLabel; Label12: TLabel; Edit2: TEdit; Label13: TLabel; Label14: TLabel; Label17: TLabel; XS: TEdit; Edit16: TEdit; Label47: TLabel; ComboBox4: TComboBox; Button4: TButton; Button6: TButton; ScrollBox1: TScrollBox; btn1: TSpeedButton; btn2: TSpeedButton; btn3: TSpeedButton; btn4: TSpeedButton; SpeedButton40: TSpeedButton; SpeedButton41: TSpeedButton; SpeedButton42: TSpeedButton; SpeedButton43: TSpeedButton; SpeedButton44: TSpeedButton; SpeedButton45: TSpeedButton; SpeedButton46: TSpeedButton; SpeedButton47: TSpeedButton; SpeedButton48: TSpeedButton; SpeedButton49: TSpeedButton; SpeedButton50: TSpeedButton; SpeedButton51: TSpeedButton; SpeedButton52: TSpeedButton; SpeedButton53: TSpeedButton; SpeedButton54: TSpeedButton; SpeedButton55: TSpeedButton; SpeedButton56: TSpeedButton; SpeedButton57: TSpeedButton; SpeedButton58: TSpeedButton; SpeedButton59: TSpeedButton; SpeedButton60: TSpeedButton; SpeedButton61: TSpeedButton; SpeedButton62: TSpeedButton; SpeedButton63: TSpeedButton; SpeedButton64: TSpeedButton; SpeedButton65: TSpeedButton; SpeedButton66: TSpeedButton; SpeedButton67: TSpeedButton; SpeedButton68: TSpeedButton; SpeedButton69: TSpeedButton; SpeedButton70: TSpeedButton; Button7: TButton; Button8: TButton; Label18: TLabel; Label1: TLabel; SpeedButton71: TSpeedButton; SpeedButton72: TSpeedButton; SpeedButton73: TSpeedButton; SpeedButton74: TSpeedButton; SpeedButton75: TSpeedButton; SpeedButton76: TSpeedButton; Label4: TLabel; SpeedButton77: TSpeedButton; SpeedButton78: TSpeedButton; SpeedButton79: TSpeedButton; SpeedButton80: TSpeedButton; SpeedButton81: TSpeedButton; SpeedButton82: TSpeedButton; Panel10: TPanel; SpeedButton83: TSpeedButton; SpeedButton84: TSpeedButton; SpeedButton85: TSpeedButton; SpeedButton86: TSpeedButton; SpeedButton87: TSpeedButton; SpeedButton88: TSpeedButton; SpeedButton89: TSpeedButton; SpeedButton90: TSpeedButton; SpeedButton91: TSpeedButton; SpeedButton92: TSpeedButton; SpeedButton93: TSpeedButton; SpeedButton94: TSpeedButton; SpeedButton95: TSpeedButton; SpeedButton96: TSpeedButton; SpeedButton97: TSpeedButton; SpeedButton98: TSpeedButton; SpeedButton99: TSpeedButton; SpeedButton100: TSpeedButton; SpeedButton101: TSpeedButton; SpeedButton102: TSpeedButton; SpeedButton103: TSpeedButton; SpeedButton104: TSpeedButton; SpeedButton105: TSpeedButton; SpeedButton106: TSpeedButton; SpeedButton107: TSpeedButton; SpeedButton108: TSpeedButton; SpeedButton109: TSpeedButton; SpeedButton110: TSpeedButton; SpeedButton111: TSpeedButton; SpeedButton112: TSpeedButton; SpeedButton113: TSpeedButton; SpeedButton114: TSpeedButton; SpeedButton115: TSpeedButton; SpeedButton116: TSpeedButton; SpeedButton117: TSpeedButton; SpeedButton118: TSpeedButton; SpeedButton119: TSpeedButton; SpeedButton120: TSpeedButton; SpeedButton121: TSpeedButton; SpeedButton122: TSpeedButton; SpeedButton123: TSpeedButton; SpeedButton124: TSpeedButton; SpeedButton125: TSpeedButton; SpeedButton126: TSpeedButton; SpeedButton127: TSpeedButton; SpeedButton128: TSpeedButton; SpeedButton129: TSpeedButton; SpeedButton130: TSpeedButton; SpeedButton131: TSpeedButton; SpeedButton132: TSpeedButton; SpeedButton133: TSpeedButton; SpeedButton134: TSpeedButton; SpeedButton135: TSpeedButton; SpeedButton136: TSpeedButton; SpeedButton137: TSpeedButton; SpeedButton138: TSpeedButton; SpeedButton139: TSpeedButton; SpeedButton140: TSpeedButton; SpeedButton141: TSpeedButton; SpeedButton142: TSpeedButton; SpeedButton143: TSpeedButton; SpeedButton144: TSpeedButton; SpeedButton145: TSpeedButton; SpeedButton146: TSpeedButton; Button9: TButton; Button10: TButton; SpeedButton147: TSpeedButton; SpeedButton148: TSpeedButton; ClientDataSet1: TClientDataSet; CPFlag: TEdit; Label20: TLabel; Label19: TRichEdit; Button11: TButton; Label21: TLabel; LBLen: TEdit; Tv3Column1: TcxGridDBColumn; Panel11: TPanel; Label22: TLabel; PS: TEdit; Label23: TLabel; Len1: TEdit; Label26: TLabel; Len2: TEdit; Label27: TLabel; Len3: TEdit; Label28: TLabel; Len4: TEdit; Label29: TLabel; Len5: TEdit; Label34: TLabel; Len6: TEdit; Button12: TButton; Label36: TLabel; Button13: TButton; Panel12: TPanel; Label38: TLabel; PP1: TEdit; Label39: TLabel; PP2: TEdit; Button14: TButton; Label40: TLabel; JYMF: TEdit; Label41: TLabel; JYKZ: TEdit; JYGH: TEdit; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure FormClick(Sender: TObject); procedure BTPrintClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure SpeedButton13Click(Sender: TObject); procedure cxGridDBColumn2PropertiesChange(Sender: TObject); procedure Button5Click(Sender: TObject); procedure SMRKKeyPress(Sender: TObject; var Key: Char); procedure MJstr3KeyPress(Sender: TObject; var Key: Char); procedure Label9Click(Sender: TObject); procedure JYJZExit(Sender: TObject); procedure JYJZChange(Sender: TObject); procedure JYKGChange(Sender: TObject); procedure Edit7Click(Sender: TObject); procedure JYJZKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); procedure SpeedButton14Click(Sender: TObject); procedure SpeedButton15Click(Sender: TObject); procedure PageControl1Change(Sender: TObject); procedure Button3Click(Sender: TObject); procedure GangNoClick(Sender: TObject); procedure SpeedButton29Click(Sender: TObject); procedure JYLenClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure TV2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure SpeedButton28Click(Sender: TObject); procedure Edit2Click(Sender: TObject); procedure JYLenChange(Sender: TObject); procedure Edit16Click(Sender: TObject); procedure TV4CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure Button4Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure btn1Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure SpeedButton83Click(Sender: TObject); procedure SpeedButton148Click(Sender: TObject); procedure CPFlagClick(Sender: TObject); procedure Button11Click(Sender: TObject); procedure Button12Click(Sender: TObject); procedure PSChange(Sender: TObject); procedure Button13Click(Sender: TObject); procedure Button14Click(Sender: TObject); private { Private declarations } FMainId, FSubId, FInt, FZHID, MD, FGuiZe: string; FOrdQty: Double; isCommopen, isCommopenDZC, IsJsMessage, IsCzMessage: boolean; procedure InitCDGridID(); procedure InitSub(MSubID: string); function SaveData(): Boolean; procedure PrtData(FMJID: string); procedure PrtDataMD(FMJID: string); procedure PrtDataJY(FMJID: string); function SaveDataMD(): Boolean; procedure OpenCom(DllName: string); procedure OpenComDZC(DllName: string); procedure CloseCom(DllName: string); function CLnum(fMjlen: string): double; procedure On1201(var Message: Tmessage); message 1201; procedure On1301(var Message: Tmessage); message 1301; procedure SSetEditDataADONew(yClientDataset: TADOQuery; mClientDataset: TADOQuery); procedure InitPerson(); function YFData(FFJYID: string): Boolean; public fmanage: string; LBID, JYID: string; //来布ID ISCP: Integer; //是否拆匹 { Public declarations } end; var frmMJJYTH: TfrmMJJYTH; newh, newh1: hwnd; implementation uses U_DataLink, U_Fun, U_ZDYHelp, U_iniParam, U_SCColor; {$R *.dfm} procedure TfrmMJJYTH.InitSub(MSubID: string); begin with ADOQuery1 do begin Close; sql.Clear; sql.add('select A.*,B.* '); sql.Add('from ML_OrderMainNew A '); sql.Add('inner join ML_OrderSubidNew B on B.NewMLID=A.NewMLID '); sql.Add('where B.NewSubid=''' + trim(MSubID) + ''''); // ShowMessage(sql.text); Open; end; if ADOQuery1.IsEmpty then begin SMRK.Text := ''; Application.MessageBox('没有该条码', '提示'); exit; end; FMainId := Trim(ADOQuery1.fieldbyname('NewMLID').AsString); FSubId := Trim(ADOQuery1.fieldbyname('NewSubid').AsString); FGuiZe := Trim(ADOQuery1.fieldbyname('CPBQGuiZe').AsString); FOrdQty := ADOQuery1.fieldbyname('Qty').AsFloat; Label24.Caption := Trim(ADOQuery1.fieldbyname('MLOrderNo').AsString); Label25.Caption := Trim(ADOQuery1.fieldbyname('MLColor').AsString); Label18.Caption := Trim(ADOQuery1.fieldbyname('MLColorNo').AsString); Label3.Caption := Trim(ADOQuery1.fieldbyname('MLHX').AsString); Label9.Caption := Trim(ADOQuery1.fieldbyname('QtyUnit').AsString); Label13.Caption := Trim(ADOQuery1.fieldbyname('Qty').AsString) + Trim(ADOQuery1.fieldbyname('QtyUnit').AsString); JYPZ.Text := Trim(ADOQuery1.fieldbyname('PiZhong').AsString); XS.Text := Trim(ADOQuery1.fieldbyname('XS').AsString); with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubId) + ''''); open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); Panel2.Visible := True; SMRK.Text := ''; end; procedure TfrmMJJYTH.SSetEditDataADONew(yClientDataset: TADOQuery; mClientDataset: TADOQuery); var i: integer; k: integer; mfieldName: string; begin if yClientDataset.IsEmpty then exit; k := 1; try mClientDataset.DisableControls; mClientDataset.Filtered := false; with mClientDataset do begin Append; for i := 0 to yClientDataset.FieldCount - 1 do begin mfieldName := trim(yClientDataset.fields[i].FieldName); fieldbyname(mfieldName).Value := yClientDataset.Fields[i].Value; end; post; inc(k); end; if not mClientDataset.IsEmpty then begin mClientDataset.First; end; finally mClientDataset.First; mClientDataset.EnableControls; end; end; function TfrmMJJYTH.CLnum(fMjlen: string): double; var i, m: integer; num1: double; begin i := strtoint(rightstr(fMjlen, 1)); m := strtoint(leftstr(fMjlen, length(fMjlen) - 2)); if (i >= 3) and (i < 8) then num1 := strtofloat(inttostr(m) + '.5') else if i >= 8 then num1 := m + 1 else num1 := m; result := num1; end; procedure TfrmMJJYTH.CloseCom(DllName: string); type TMyFunc = function(sCommName: PAnsiChar): HWND; stdcall; var Tf1: TMyFunc; Tp1: TFarProc; Th1: Thandle; begin Th1 := LoadLibrary(Pchar(trim(DllName))); if Th1 > 0 then begin try Tp1 := GetProcAddress(Th1, 'CommClose'); if Tp1 <> nil then begin Tf1 := TMyFunc(Tp1); newh1 := Tf1('Comm1'); end else begin end; finally // FreeLibrary(Th1); end; end else begin application.MessageBox(Pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMJJYTH.OpenCom(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: integer; IsMessage: integer): HWND; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin Th := LoadLibrary(Pchar(trim(DllName))); if Th > 0 then begin try Tp := GetProcAddress(Th, 'CommOpen'); if Tp <> nil then begin Tf := TMyFunc(Tp); newh := Tf(self.Handle, 'Comm1', 500, 1); if newh < 1 then begin application.MessageBox(Pchar('打开串口失败!'), '提示'); end else IsCommOpen := true; end else begin IsCommOpen := false; end; finally // FreeLibrary(Th); end; end else begin IsCommOpen := false; application.MessageBox(Pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMJJYTH.OpenComDZC(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: integer; IsMessage: integer): HWND; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin Th := LoadLibrary(Pchar(trim(DllName))); if Th > 0 then begin try Tp := GetProcAddress(Th, 'CommOpen'); if Tp <> nil then begin Tf := TMyFunc(Tp); newh := Tf(self.Handle, 'Comm1', 500, 1); if newh < 1 then begin application.MessageBox(Pchar('打开串口失败!'), '提示'); end else isCommopenDZC := true; end else begin isCommopenDZC := false; end; finally // FreeLibrary(Th); end; end else begin isCommopenDZC := false; application.MessageBox(Pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMJJYTH.FormDestroy(Sender: TObject); begin frmMJJYTH := nil; end; procedure TfrmMJJYTH.On1201(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if IsCzMessage then begin if trim(Edit2.Text) = '√' then begin JYJZ.Text := format('%.1f', [i1 / 100000]); end; end; end; procedure TfrmMJJYTH.On1301(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if IsJsMessage then begin if trim(Edit7.Text) = '√' then begin if PageControl1.TabIndex = 0 then begin MJLen.Text := floattostr(CLnum(format('%.1f', [i1 / 100000]))); if i2 = 0 then Label9.Caption := 'M' else Label9.Caption := 'Y'; end; if PageControl1.TabIndex = 2 then begin JYLen.Text := floattostr(CLnum(format('%.1f', [i1 / 100000]))); if i2 = 0 then Label9.Caption := 'M' else Label9.Caption := 'Y'; end; end; end; end; procedure TfrmMJJYTH.FormClose(Sender: TObject; var Action: TCloseAction); begin if isCommopen then begin closeCom(JCYDLL); end; Action := caFree; end; procedure TfrmMJJYTH.InitCDGridID(); begin with ADOQueryMain do begin Close; SQL.Clear; sql.Add('select A.*'); sql.Add(' from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and JTType=''' + Trim(label2.Caption) + ''''); sql.Add(' and Filler=''' + Trim(DName) + ''''); sql.Add(' and RKType=''未入库'' '); Open; end; SCreateCDS20(ADOQueryMain, CDS_MJID); SInitCDSData20(ADOQueryMain, CDS_MJID); end; procedure TfrmMJJYTH.FormShow(Sender: TObject); begin ReadINIFile(); if trim(Edit7.Text) = '√' then IsJsMessage := true; if Trim(Edit2.Text) = '√' then IsCzMessage := True; //IF trim(fmanage)<>'高权限' then begin OpenCom(JCYDLL); OpenComDZC(DllName); end; with ADOQuery1 do begin close; sql.Clear; sql.Add('select top 1 LBID '); sql.Add('from JTJY_New A where Filler=''' + Trim(DName) + ''' '); sql.Add('and isnull(LBID,'''') <> '''' order by Filltime desc'); open; end; if ADOQuery1.IsEmpty = False then begin LBID := Trim(ADOQuery1.FieldByName('LBID').asstring); end; SMRK.SetFocus; end; procedure TfrmMJJYTH.InitPerson(); var BB: array[0..100] of string; CC: array[0..100] of string; i, j, ZT: Integer; begin ZT := 0; if Copy(Trim(SMRK.Text), 1, 2) = 'ML' then begin with ADOTmp do begin Close; sql.Clear; sql.Add('select MLColor,MLColorNo,NewSubid from ML_OrderSubidNew where NewMLID=''' + Trim(SMRK.Text) + ''' '); //order by ZDYName Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('指示单二维码错误!', '提示', 0); SMRK.text := ''; Exit; end; with ADOTmp do begin First; i := 0; while not Eof do begin BB[i] := Trim(fieldbyname('MLColorNo').AsString) + #13 + Trim(fieldbyname('MLColor').AsString); CC[i] := Trim(fieldbyname('NewSubid').AsString); i := i + 1; Next; end; end; i := i - 1; if i > 35 then begin i := 35; end; for j := 0 to i do begin with ScrollBox1 do begin TSpeedButton(Controls[j]).Visible := True; TSpeedButton(Controls[j]).Caption := BB[j]; TSpeedButton(Controls[j]).Hint := CC[j]; end; end; end else begin if Application.MessageBox('是否要进行成品检验?', '是为成品检验,否为拆匹', 32 + 4) = IDYES then begin PS.text := ''; Len1.text := ''; Len2.text := ''; Len3.text := ''; Len4.text := ''; Len5.text := ''; Len6.text := ''; GangNo.text := ''; LBLen.text := ''; MJLen.text := ''; JYID := ''; PP1.text := ''; PP2.text := ''; ///////////////启用保存//////////////////// BTPrint.Enabled := true; Button11.Enabled := true; MJLen.Enabled := true; LBLen.Enabled := true; GangNo.Enabled := true; ///////////////启用保存//////////////////// FMainId := ''; FSubId := ''; Panel11.Visible := False; with ADOTmp do begin Close; sql.Clear; sql.Add('select A.MLColor,A.MLColorNo,A.NewSubid from ML_OrderSubidNew A '); sql.Add(' inner join JTJY_New B on A.NewSubid=B.NewSubid'); sql.Add(' where B.JYID=''' + Trim(SMRK.Text) + ''' '); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('条码错误!', '提示', 0); SMRK.text := ''; Exit; end; InitSub(Trim(ADOTmp.fieldbyname('NewSubid').AsString)); // with ADOTmp do // begin // First; // i := 0; // while not Eof do // begin // BB[i] := Trim(fieldbyname('MLColorNo').AsString) + #13 + Trim(fieldbyname('MLColor').AsString); // CC[i] := Trim(fieldbyname('NewSubid').AsString); // i := i + 1; // Next; // end; // end; // i := i - 1; // if i > 35 then // begin // i := 35; // end; // for j := 0 to i do // begin // with ScrollBox1 do // begin // TSpeedButton(Controls[j]).Visible := True; // TSpeedButton(Controls[j]).Caption := BB[j]; // TSpeedButton(Controls[j]).Hint := CC[j]; // end; // end; end else begin if (Copy(Trim(SMRK.Text), 1, 2) = 'MB') or (Copy(Trim(SMRK.Text), 1, 2) = 'DB') then begin with ADOTmp do begin Close; sql.Clear; sql.Add('select A.MLColor,A.MLColorNo,A.NewSubid,B.JYTYpe,B.GangNo,A.NewSubid,B.LBLen,B.JYLen from ML_OrderSubidNew A '); sql.Add(' inner join JTJY_New B on A.NewSubid=B.NewSubid'); sql.Add(' where B.JYID=''' + Trim(SMRK.Text) + ''' '); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('面布或者底布条码错误!', '提示', 0); SMRK.text := ''; Exit; end; ZT := 1; JYID := Trim(SMRK.Text); end else begin Application.MessageBox('只有面布或者底布能拆匹!', '提示', 0); SMRK.text := ''; Exit; end; // if ZT = 0 then // begin // with ADOTmp do // begin // First; // i := 0; // while not Eof do // begin // BB[i] := Trim(fieldbyname('MLColorNo').AsString) + #13 + Trim(fieldbyname('MLColor').AsString); // CC[i] := Trim(fieldbyname('NewSubid').AsString); // i := i + 1; // Next; // end; // end; // i := i - 1; // if i > 35 then // begin // i := 35; // end; // for j := 0 to i do // begin // with ScrollBox1 do // begin // TSpeedButton(Controls[j]).Visible := True; // TSpeedButton(Controls[j]).Caption := BB[j]; // TSpeedButton(Controls[j]).Hint := CC[j]; // end; // end; // end; if ZT = 1 then begin InitSub(Trim(ADOTmp.fieldbyname('NewSubid').AsString)); panel2.Visible := false; Label2.Caption := Trim(ADOTmp.fieldbyname('JYTYpe').AsString); GangNo.Text := Trim(ADOTmp.fieldbyname('GangNo').AsString); LBLen.Text := Trim(ADOTmp.fieldbyname('LBLen').AsString); MJLen.Text := Trim(ADOTmp.fieldbyname('JYLen').AsString); Label36.Caption := Trim(ADOTmp.fieldbyname('JYLen').AsString); ///////////////禁用保存//////////////////// BTPrint.Enabled := False; Button11.Enabled := False; MJLen.Enabled := False; LBLen.Enabled := False; GangNo.Enabled := False; ///////////////禁用保存//////////////////// if Label2.Caption = '底布' then begin MD := 'DB'; end else if Label2.Caption = '面布' then begin MD := 'MB'; end; PageControl1.TabIndex := 0; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''' + Trim(ADOTmp.fieldbyname('JYTYpe').AsString) + ''''); SQL.Add('group by A.GangNo,A.NewSubid'); // ShowMessage(sql.Text); open; end; SCreateCDS20(ADOQueryPrint, DB_HZ); SInitCDSData20(ADOQueryPrint, DB_HZ); with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(GangNo.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); // ShowMessage(sql.Text); Open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); Panel11.Visible := True; end; end; end; end; procedure TfrmMJJYTH.FormClick(Sender: TObject); begin FInt := '0'; end; function TfrmMJJYTH.SaveData(): Boolean; var maxno, FJYID, BZID, strsql: string; FMJLen: Double; FOrder, FWZ: Integer; begin if FInt = '1' then begin FJYID := ''; end; if FInt = '2' then begin FJYID := Trim(JY_CP.fieldbyname('JYID').AsString); end; try ADOCmd.Connection.BeginTrans; ///保存主表 with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where JYID=''' + Trim(FJYID) + ''''); Open; end; with ADOCmd do begin if IsEmpty then begin Append; if GetLSNo(ADOTmp, maxno, Trim(MD), 'JTJY_New', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!', '提示', 0); Button1.Enabled := true; Button2.Enabled := true; exit; end; FieldByName('Filler').Value := Trim(DName); end else begin maxno := Trim(FJYID); Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTmp); end; FieldByName('NewMLID').value := Trim(FMainId); FieldByName('NewSubid').value := Trim(FSubId); FieldByName('JYID').Value := Trim(maxno); FieldByName('RKType').Value := '已入库'; FieldByName('gangNo').Value := Trim(edit1.Text); FieldByName('JYLen').Value := Trim(JYLen.Text); FieldByName('JYKG').Value := StrToFloatDef(JYKG.Text, 0); FieldByName('JYPZ').Value := StrToFloatDef(JYPZ.Text, 0); FieldByName('JYJZ').Value := StrToFloatDef(JYJZ.Text, 0); FieldByName('XS').Value := StrToFloatDef(XS.Text, 0); FieldByName('PP1').Value := StrToFloatDef(PP1.Text, 0); FieldByName('PP2').Value := StrToFloatDef(PP2.Text, 0); FieldByName('JYType').Value := Trim(Label2.Caption); FieldByName('JYOrderNo').Value := Trim(label24.Caption); FieldByName('JYColHX').Value := Trim(label3.Caption); FieldByName('JYColor').Value := Trim(label25.Caption); FieldByName('JYUnit').Value := Trim(Label9.Caption); Post; end; if FInt = '1' then begin if Trim(FGuiZe) = '规则1' then begin if Trim(Label2.Caption) = '成品' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('update JTJY_New SET JYNo=1+isnull((select cast(max(X.JYNo) as int) from JTJY_New X '); sql.Add('where X.NewSubid=JTJY_New.NewSubid and X.JYID<>JTJY_New.JYID and X.JYType=''成品''),0) '); sql.Add('where JYID=''' + Trim(maxno) + ''''); execsql; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_JYID :JYID'); Parameters.ParamByName('JYID').Value := Trim(maxno); ExecSQL; end; end; end else begin with ADOCmd do begin Close; sql.Clear; sql.Add('update JTJY_New SET JYNo=1+isnull((select cast(max(X.JYNo) as int) from JTJY_New X '); sql.Add('where X.NewSubid=JTJY_New.NewSubid and X.JYType=JTJY_New.JYType '); SQL.Add('and X.GangNo=JTJY_New.GangNo and X.JYID<>JTJY_New.JYID),0) '); sql.Add('where JYID=''' + Trim(maxno) + ''''); execsql; end; end; if JY_CP.IsEmpty then begin with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JTJY_New where NewSubid=''' + trim(FSubId) + ''' and JYType=''' + trim(Label2.Caption) + ''''); SQL.Add(' and GangNo=''' + trim(edit1.Text) + ''''); open; end; SCreateCDS20(ADOCmd, JY_CP); SInitCDSData20(ADOCmd, JY_CP); end else begin with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JTJY_New where JYID=''' + trim(maxno) + ''''); open; end; SInitCDSData20(ADOCmd, JY_CP); end; JY_CP.Locate('JYID', Trim(maxno), []); end; if FInt = '2' then begin with JY_CP do begin edit; FieldByName('JYJZ').Value := Trim(JYJZ.Text); FieldByName('JYKG').Value := Trim(JYKG.Text); FieldByName('JYLen').Value := Trim(JYLen.Text); end; end; FJYID := Trim(maxno); //成品出入库 with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_Do_MLJYCRK ''' + Trim(maxno) + ''''); execsql; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_OrderSub :SubId'); Parameters.ParamByName('SubId').Value := Trim(FSubId); ExecSQL; end; ////////////////棉自动出库//////////////////// with ADOCmd do begin Close; sql.Clear; sql.Add(' select ZHID from ML_OrderZuHe where MLType=''棉'' and SSGS =''自己'' and NewMLID=''' + Trim(FMainId) + ''''); Open; end; if Trim(Label2.Caption) = '成品' then begin if ADOCmd.IsEmpty = false then begin with ADOCmd do begin Close; sql.Clear; sql.Add(' exec ZDCK_Mian :MainID,:SubId,:DName'); Parameters.ParamByName('MainID').Value := Trim(FMainId); Parameters.ParamByName('SubID').Value := Trim(FSubId); Parameters.ParamByName('DName').Value := Trim(DName); ExecSQL; end; end; end; ////////////////棉自动出库//////////////////// with ADOCmd do begin close; sql.Clear; sql.Add('select * '); sql.Add('from ML_OrderSubidNew A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add(' and isnull(JYQty,0)>(isnull(MBQty,0)*1.05)'); sql.Add(' and isnull(MBQty,0)>100 '); open; end; if ADOCmd.IsEmpty = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('成品数量超出上机布5%,不能打印!', '提示', 0); Exit; end; //更新棉&无纺布耗用 with ADOCmd do begin Close; sql.Clear; //实际 sql.Add('Update ML_OrderZuHe Set MLJYQty=(select sum(JYLen) from JTJY_New A where A.NewMLID=ML_OrderZuHe.NewMLID and A.JYType=''成品'') '); sql.Add(' where NewMLID=''' + Trim(FMainId) + ''''); sql.Add(' and isnull(MLName,'''')<>'''' and SSGS=''自己'' '); ExecSQL; end; //更新棉&无纺布耗用 if Label2.Caption = '退货' then begin if YFData(FJYID) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成退货数据失败!', '提示', 0); Exit; end; end; ADOCmd.Connection.CommitTrans; Result := True; except Result := False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; function TfrmMJJYTH.YFData(FFJYID: string): Boolean; var YFID, FFactoryName, FFactoryNo, FDate: string; begin Result := False; with ADOTmp do begin Close; sql.Clear; sql.Add('select A.*,B.*,FDate=getdate() from ML_OrderSubidNew A'); sql.Add('inner join ML_OrderMainNew B on A.NewMLID=B.NewMLID'); sql.Add(' where NewSubid=''' + Trim(FSubId) + ''''); Open; end; SCreateCDS20(ADOTmp, ClientDataSet1); SInitCDSData20(ADOTmp, ClientDataSet1); if Trim(ClientDataSet1.fieldbyname('MLPrice').AsString) = '' then begin Application.MessageBox('面料单价不能为空,请在指示单中补充单价信息!', '提示', 0); Result := False; end; FFactoryName := Trim(ClientDataSet1.fieldbyname('KHName').AsString); FFactoryNo := Trim(ClientDataSet1.fieldbyname('KHNO').AsString); FDate := Trim(FormatDateTime('yyyy-MM-dd', ClientDataSet1.fieldbyname('FDate').AsDateTime)); with ADOTmp do begin Close; sql.Clear; sql.Add('select * from YS_Money_CR where FactoryNo=' + quotedstr(Trim(FFactoryNo))); sql.Add(' and SubId=''' + Trim(FSubId) + ''''); sql.Add(' and CRTime=''' + Trim(FDate) + ''''); Open; end; YFID := Trim(ADOTmp.fieldbyname('YFID').AsString); if Trim(YFID) = '' then begin if GetLSNo(ADOCmd, YFID, 'YS', 'YS_Money_CR', 4, 1) = False then begin Application.MessageBox('取应收最大号失败!', '提示', 0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('select * from YS_Money_CR where YFID=''' + Trim(YFID) + ''''); Open; end; with ADOCmd do begin Append; FieldByName('YFID').Value := Trim(YFID); FieldByName('CRID').Value := -99999; FieldByName('Filler').Value := Trim(DName); FieldByName('SubId').Value := Trim(FSubId); FieldByName('CRType').Value := '应收款登记'; FieldByName('CRFlag').Value := '应收收'; FieldByName('ChkStatusP').Value := '未审核'; FieldByName('ChkStatusQ').Value := '未审核'; FieldByName('QtyFlag').Value := -1; FieldByName('FactoryName').Value := Trim(FFactoryName); FieldByName('FactoryNo').Value := Trim(FFactoryNo); FieldByName('CRTime').Value := StrToDate(FDate); FieldByName('YFType').Value := '自动生成'; FieldByName('Price').Value := ClientDataSet1.fieldbyname('MLPrice').Value; FieldByName('HSPrice').Value := ClientDataSet1.fieldbyname('MLPrice').Value; FieldByName('Note').Value := '退货'; FieldByName('QtyUnit').Value := Trim(ClientDataSet1.fieldbyname('QtyUnit').AsString); FieldByName('P_CodeName').Value := Trim(ClientDataSet1.fieldbyname('MLCodeName').AsString); FieldByName('BZType').Value := Trim(ClientDataSet1.fieldbyname('BZType').AsString); FieldByName('P_Color').Value := Trim(ClientDataSet1.fieldbyname('MLColor').AsString); FieldByName('P_HX').Value := Trim(ClientDataSet1.fieldbyname('MLHX').AsString); FieldByName('status').Value := '0'; Post; end; end; with ADOCmd do begin Close; sql.Clear; sql.Add('Update JTJY_New Set YFID=''' + Trim(YFID) + ''''); sql.Add(' where JYID=''' + Trim(FFJYID) + ''''); ExecSQL; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_THData :YFID'); Parameters.ParamByName('YFID').Value := Trim(YFID); ExecSQL; end; Result := True; end; function TfrmMJJYTH.SaveDataMD(): Boolean; var maxno, FJYID, BZID, strsql: string; FMJLen: Double; FOrder, FWZ: Integer; begin if FInt = '1' then begin FJYID := ''; end; if FInt = '2' then begin FJYID := Trim(Order_MJ.fieldbyname('JYID').AsString); end; //如果不是拆匹,则重新取一个来布ID if ISCP = 0 then begin if GetLSNo(ADOTmp, LBID, 'LB', 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; end; if Trim(LBID) = '' then begin Application.MessageBox('第一匹布不能直接进行拆匹!', '提示', 0); exit; end; try ADOCmd.Connection.BeginTrans; ///保存主表 with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where JYID=''' + Trim(FJYID) + ''''); Open; end; with ADOCmd do begin if IsEmpty then begin Append; if GetLSNo(ADOTmp, maxno, Trim(MD), 'JTJY_New', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!', '提示', 0); BTPrint.Enabled := true; Button5.Enabled := true; exit; end; FieldByName('Filler').Value := Trim(DName); end else begin maxno := Trim(FJYID); Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTmp); end; FieldByName('NewMLID').value := Trim(FMainId); FieldByName('NewSubid').value := Trim(FSubId); FieldByName('JYID').Value := Trim(maxno); FieldByName('RKType').Value := '未入库'; FieldByName('gangNo').Value := Trim(GangNo.Text); FieldByName('JYLen').Value := Trim(MJLen.Text); FieldByName('LBLen').Value := Trim(LBLen.Text); FieldByName('LBID').Value := Trim(LBID); FieldByName('JYKG').Value := 0; FieldByName('JYPZ').Value := 0; FieldByName('JYJZ').Value := 0; FieldByName('JYType').Value := Trim(Label2.Caption); FieldByName('JYOrderNo').Value := Trim(label24.Caption); FieldByName('JYColHX').Value := Trim(label3.Caption); FieldByName('JYColor').Value := Trim(label25.Caption); Post; end; if FInt = '1' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('update JTJY_New SET JYNo=1+isnull((select cast(max(X.JYNo) as int) from JTJY_New X '); sql.Add('where X.NewSubid=JTJY_New.NewSubid and X.JYType=JTJY_New.JYType '); SQL.Add('and X.GangNo=JTJY_New.GangNo and X.JYID<>JTJY_New.JYID),0) '); sql.Add('where JYID=''' + Trim(maxno) + ''''); execsql; end; if Order_MJ.IsEmpty then begin with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JTJY_New where NewSubid=''' + trim(FSubId) + ''' and JYType=''' + trim(Label2.Caption) + ''''); SQL.Add(' and GangNo=''' + trim(GangNo.Text) + ''''); open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); end else begin with ADOCmd do begin Close; sql.Clear; sql.Add('select * from JTJY_New where JYID=''' + trim(maxno) + ''''); open; end; SInitCDSData20(ADOCmd, Order_MJ); end; Order_MJ.Locate('JYID', Trim(maxno), []); end; if FInt = '2' then begin with Order_MJ do begin edit; FieldByName('GangNo').Value := Trim(GangNo.Text); FieldByName('JYLen').Value := Trim(MJLen.Text); end; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_OrderSub :SubId'); Parameters.ParamByName('SubId').Value := Trim(FSubId); ExecSQL; end; FJYID := Trim(maxno); ADOCmd.Connection.CommitTrans; Result := True; except Result := False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; procedure TfrmMJJYTH.BTPrintClick(Sender: TObject); var fPrintFile: string; mvalue: Double; i: Integer; begin BTPrint.Enabled := False; if (FMainId = '') or (FSubId = '') then begin BTPrint.Enabled := true; application.MessageBox('请扫描指示单', '提示'); exit; end; if Trim(GangNo.Text) = '' then begin Application.MessageBox('缸号不能为空!', '提示', 0); BTPrint.Enabled := true; Exit; end; if Trim(LBLen.Text) = '' then begin Application.MessageBox('来布长度需要输入大于0的数字', '提示', 0); BTPrint.Enabled := true; Exit; end; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select Sum(JYLen) MJLen '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''' + trim(Label2.Caption) + ''''); open; end; if FOrdQty * 1.5 < ADOQueryPrint.FieldByName('MJLen').AsFloat + strtofloat(MJLen.Text) then begin if Application.MessageBox('超过指示单数量的1.5倍,确定要提交吗', '提示', 1) = 2 then begin BTPrint.Enabled := true; Exit; end; end; if MJLen.Text = '' then begin application.MessageBox('长度不能为空', '提示信息', 0); BTPrint.Enabled := true; exit; end; if strtofloatdef(trim(MJLen.Text), 0) < 0.0 then begin application.MessageBox('长度不能小于0!', '提示信息', 0); BTPrint.Enabled := true; exit; end; FInt := '1'; ISCP := 0; //不是拆匹 if SaveDataMD() then begin MJLen.Text := ''; LBLen.Text := ''; PrtDataMD(Trim(Order_MJ.fieldbyname('JYID').AsString)); if Label2.Caption = '底布' then begin SpeedButton13.Click; end; if Label2.Caption = '面布' then begin SpeedButton14.Click; end; end; BTPrint.Enabled := true; MJLen.SetFocus; end; procedure TfrmMJJYTH.Button11Click(Sender: TObject); var fPrintFile: string; mvalue: Double; i: Integer; begin BTPrint.Enabled := False; if (FMainId = '') or (FSubId = '') then begin BTPrint.Enabled := true; application.MessageBox('请扫描指示单', '提示'); exit; end; if Trim(GangNo.Text) = '' then begin Application.MessageBox('缸号不能为空!', '提示', 0); BTPrint.Enabled := true; Exit; end; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select top 1 isnull(LBLen,0) AS LBLen '); sql.Add('from JTJY_New A where LBID=''' + Trim(LBID) + ''' '); sql.Add('order by LBLen desc'); open; end; if ADOQueryPrint.IsEmpty = False then begin LBLen.text := Trim(ADOQueryPrint.FieldByName('LBLen').asstring); end; if Trim(LBLen.Text) = '' then begin Application.MessageBox('来布长度需要输入大于0的数字', '提示', 0); BTPrint.Enabled := true; Exit; end; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select Sum(JYLen) MJLen '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''' + trim(Label2.Caption) + ''''); open; end; if FOrdQty * 1.5 < ADOQueryPrint.FieldByName('MJLen').AsFloat + strtofloat(MJLen.Text) then begin if Application.MessageBox('超过指示单数量的1.5倍,确定要提交吗', '提示', 1) = 2 then begin BTPrint.Enabled := true; Exit; end; end; if MJLen.Text = '' then begin application.MessageBox('长度不能为空', '提示信息', 0); BTPrint.Enabled := true; exit; end; if strtofloatdef(trim(MJLen.Text), 0) < 0.0 then begin application.MessageBox('长度不能小于0!', '提示信息', 0); BTPrint.Enabled := true; exit; end; FInt := '1'; ISCP := 1; //是拆匹 if SaveDataMD() then begin MJLen.Text := ''; LBLen.Text := ''; PrtDataMD(Trim(Order_MJ.fieldbyname('JYID').AsString)); if Label2.Caption = '底布' then begin SpeedButton13.Click; end; if Label2.Caption = '面布' then begin SpeedButton14.Click; end; end; BTPrint.Enabled := true; MJLen.SetFocus; end; procedure TfrmMJJYTH.PrtDataMD(FMJID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; i: Integer; begin if Trim(Edit16.Text) = '' then Exit; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('select A.*,B.*,C.*,ZH.*,ZHXHNo=ZH.XHNo '); sql.Add(',KHNameJC=(select KHNameJC from KH_Main KM where KM.KHNO=B.KHNO)'); sql.Add(',MBNO=(select top 1 X.MLCode from ML_OrderZuHe X where X.MLType =''面布'' and X.NewMLID =B.NewMLID)'); SQL.Add('from JTJY_New A '); SQL.Add('inner join ML_OrderMainNew B on B.NewMLID=A.NewMLID '); SQL.Add('inner join ML_OrderSubidNew C on C.NewSubid=A.NewSubid '); sql.Add('left join ML_OrderZuHe ZH on B.NewMLID=ZH.NewMLID'); sql.Add('where A.JYID=''' + trim(FMJID) + ''''); sql.Add(' order by ZH.XHNo'); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('JYID').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('条形码生成失败!', '提示信息', MB_ICONERROR); BTPrint.Enabled := true; Button5.Enabled := true; exit; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + trim(Label2.Caption) + '标签.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); //RM2.ShowReport; for i := 1 to StrToInt(ComboBox1.Text) do begin RM2.PrintReport; end; end else begin Application.MessageBox('没有找标签格式', '提示', 0); BTPrint.Enabled := true; Button5.Enabled := true; exit; end; end; procedure TfrmMJJYTH.PrtData(FMJID: string); var fPrintFile, BQName, FKHNO: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; i: Integer; begin if Trim(Edit16.Text) = '' then Exit; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('select A.*,B.*,C.*,CPBQName1=CPBQName '); sql.Add(',KHNameJC=(select KHNameJC from KH_Main KM where KM.KHNO=B.KHNO)'); SQL.Add('from JTJY_New A '); SQL.Add('inner join ML_OrderMainNew B on B.NewMLID=A.NewMLID '); SQL.Add('inner join ML_OrderSubidNew C on C.NewSubid=A.NewSubid '); sql.Add('where A.JYID=''' + trim(FMJID) + ''''); Open; end; BQName := Trim(ADOQueryPrint.fieldbyname('CPBQName1').AsString); FKHNO := Trim(ADOQueryPrint.fieldbyname('KHNO').AsString); if Trim(BQName) = '' then begin with ADOTmp do begin Close; sql.Clear; sql.Add('select Top 1* from ML_OrderMainNew where KHNO=''' + Trim(FKHNO) + ''' and isnull(CPBQName,'''')<>'''' '); sql.Add(' order by FillTime desc '); Open; end; BQName := Trim(ADOQueryPrint.fieldbyname('CPBQName').AsString); if Trim(BQName) = '' then begin BQName := '通用标签'; end; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('JYID').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('条形码生成失败!', '提示信息', MB_ICONERROR); Button1.Enabled := true; Button2.Enabled := true; exit; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + trim(BQName) + '.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); for i := 1 to StrToInt(ComboBox4.Text) do begin RM2.PrintReport; end; end else begin Application.MessageBox('没有找标签格式', '提示', 0); Button1.Enabled := true; Button2.Enabled := true; exit; end; end; procedure TfrmMJJYTH.PrtDataJY(FMJID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('exec P_Print_JY_Label '); sql.Add('@MJID=' + quotedstr(trim(FMJID))); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.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('条形码生成失败!', '提示信息', MB_ICONERROR); BTPrint.Enabled := true; exit; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\剪样标签.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); //Rm2.DefaultCopies:=strtointdef(trim(ComboBox1.Text),1); //RM2.ShowReport; RM2.PrintReport; end else begin Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ADOQueryPrint.fieldbyname('LBName').AsString)), '提示', 0); end; end; procedure TfrmMJJYTH.SpeedButton1Click(Sender: TObject); var fsj: string; begin fsj := Trim(TSpeedButton(Sender).Hint); if Trim(fsj) = '' then Exit; fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := fsj + Trim(TSpeedButton(Sender).Caption); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmMJJYTH.SpeedButton12Click(Sender: TObject); var fsj: string; begin fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); if Trim(fsj) = '' then Exit; TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := Copy(fsj, 1, Length(fsj) - 1); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmMJJYTH.SpeedButton13Click(Sender: TObject); var AA: array[0..100] of string; i, j: Integer; begin Label2.Caption := '底布'; MD := 'DB'; PageControl1.TabIndex := 0; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''底布'' '); SQL.Add('group by A.GangNo,A.NewSubid'); open; end; SCreateCDS20(ADOQueryPrint, DB_HZ); SInitCDSData20(ADOQueryPrint, DB_HZ); with DB_HZ do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('GangNo').AsString); i := i + 1; Next; end; end; if i < 12 then begin with Panel5 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end else begin with Panel5 do begin for j := 0 to 11 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; if DB_HZ.IsEmpty = False then begin with Panel10 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; MJLen.SetFocus; panel2.Visible := false; end; procedure TfrmMJJYTH.cxGridDBColumn2PropertiesChange(Sender: TObject); var fsj: string; begin fsj := Trim(Order_MJ.fieldbyname('SubId').AsString); Order_MJ.DisableControls; with Order_MJ do begin First; while not Eof do begin if Trim(Order_MJ.fieldbyname('SubId').AsString) <> fsj then begin Edit; FieldByName('SSel').Value := False; end; Next; end; end; Order_MJ.EnableControls; Order_MJ.Locate('SubId', fsj, []); end; procedure TfrmMJJYTH.Button5Click(Sender: TObject); begin PrtDataMD(Trim(Order_MJ.fieldbyname('JYID').AsString)); end; procedure TfrmMJJYTH.SMRKKeyPress(Sender: TObject; var Key: Char); var MSubID: string; begin if Key <> #13 then Exit; InitPerson(); if btn1.Visible = False then Exit; Label19.Visible := False; ScrollBox1.Visible := True; ScrollBox1.Left := 70; end; procedure TfrmMJJYTH.MJstr3KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Button1.SetFocus; end; end; procedure TfrmMJJYTH.Label9Click(Sender: TObject); begin if trim(Label9.Caption) = 'M' then begin Label9.Caption := 'Y'; end else begin Label9.Caption := 'M'; end; end; procedure TfrmMJJYTH.JYJZExit(Sender: TObject); begin if (trim(JYKG.Text) = '') and (trim(JYJZ.Text) = '') then exit; if (trim(JYKG.Text) = '') and (trim(JYPZ.Text) = '') then exit; if (trim(JYJZ.Text) = '') and (trim(JYPZ.Text) = '') then exit; if (trim(JYPZ.Text) = '') then exit; if (trim(JYJZ.Text) <> '') then begin JYKG.Text := floattostr(strtofloatdef(trim(JYPZ.Text), 0) + strtofloatdef(trim(JYJZ.Text), 0)); exit; end; end; procedure TfrmMJJYTH.JYJZChange(Sender: TObject); var FReal: Double; begin if Trim(JYJZ.Text) = '' then begin JYKG.Text := ''; Exit; end; if TryStrToFloat(JYJZ.Text, FReal) = False then Exit; if Trim(JYPZ.Text) <> '' then begin if TryStrToFloat(JYPZ.Text, FReal) = True then JYKG.Text := FloatToStr(StrToFloat(JYJZ.Text) + StrToFloat(JYPZ.Text)); end else begin JYKG.Text := JYJZ.Text; end; end; procedure TfrmMJJYTH.JYKGChange(Sender: TObject); var FReal: Double; begin if Trim(JYKG.Text) = '' then begin JYJZ.Text := ''; Exit; end; if TryStrToFloat(JYKG.Text, FReal) = False then Exit; if Trim(JYPZ.Text) <> '' then begin if TryStrToFloat(JYPZ.Text, FReal) = False then Exit; JYJZ.Text := FloatToStr(StrToFloat(JYKG.Text) - StrToFloat(JYPZ.Text)); end else begin JYJZ.Text := JYKG.Text; end; end; procedure TfrmMJJYTH.Edit7Click(Sender: TObject); begin if Trim(Edit7.Text) = '' then begin Edit7.Text := '√'; if not IsCommOpen then OpenCom(JCYDLL); IsJsMessage := true; end else begin Edit7.Text := ''; IsJsMessage := False; end; end; procedure TfrmMJJYTH.JYJZKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin BTPrint.Click; end; end; procedure TfrmMJJYTH.FormCreate(Sender: TObject); begin IsCommopen := false; IsJsMessage := false; IsCzMessage := false; end; procedure TfrmMJJYTH.SpeedButton14Click(Sender: TObject); var AA: array[0..100] of string; i, j: Integer; begin Label2.Caption := '面布'; MD := 'MB'; PageControl1.TabIndex := 0; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''面布'' '); SQL.Add('group by A.GangNo,A.NewSubid'); //ShowMessage(sql.Text); open; end; SCreateCDS20(ADOQueryPrint, DB_HZ); SInitCDSData20(ADOQueryPrint, DB_HZ); with DB_HZ do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('GangNo').AsString); i := i + 1; Next; end; end; if i < 12 then begin with Panel5 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end else begin with Panel5 do begin for j := 0 to 11 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; with Panel10 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; MJLen.SetFocus; panel2.Visible := false; end; procedure TfrmMJJYTH.SpeedButton15Click(Sender: TObject); var AA: array[0..100] of string; i, j: Integer; begin Label2.Caption := '成品'; if ADOQuery1.IsEmpty = False then begin Label19.Visible := True; Label19.text := ADOQuery1.fieldbyname('MLBZNote').AsString; end; MD := 'CP'; PageControl1.TabIndex := 2; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select AA.*,CQty=SJZQty-MQQty from (select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add(',MQQty=(select Sum(B.JYLen) from JTJY_New B where B.NewSubid=A.NewSubid '); sql.Add('and B.JYType=''成品'' and B.GangNo=A.GangNo)'); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''面布'' '); SQL.Add('group by A.GangNo,A.NewSubid) AA'); //ShowMessage(sql.Text); open; end; SCreateCDS20(ADOQueryPrint, JY_HZ); SInitCDSData20(ADOQueryPrint, JY_HZ); with JY_HZ do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('GangNo').AsString); i := i + 1; Next; end; end; if i < 12 then begin with Panel8 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end else begin with Panel8 do begin for j := 0 to 11 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; if JY_HZ.IsEmpty = False then begin with Panel10 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; JYLen.SetFocus; panel2.Visible := false; end; procedure TfrmMJJYTH.PageControl1Change(Sender: TObject); begin if not IsCommOpen then OpenCom(JCYDLL); IsJsMessage := true; end; procedure TfrmMJJYTH.Button3Click(Sender: TObject); begin close; end; procedure TfrmMJJYTH.GangNoClick(Sender: TObject); var i: Integer; begin with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmMJJYTH.SpeedButton29Click(Sender: TObject); var i: Integer; begin with Panel8 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Font.Color := clWindowText; end; end; end; TSpeedButton(Sender).Font.Color := clRed; Edit1.Text := TSpeedButton(Sender).Caption; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(Edit1.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); Open; end; SCreateCDS20(ADOCmd, JY_CP); SInitCDSData20(ADOCmd, JY_CP); end; procedure TfrmMJJYTH.JYLenClick(Sender: TObject); var i: Integer; begin with Panel4 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmMJJYTH.Button1Click(Sender: TObject); var fPrintFile: string; mvalue: Double; i: Integer; begin button1.Enabled := False; if (FMainId = '') or (FSubId = '') then begin button1.Enabled := true; application.MessageBox('请扫描指示单', '提示'); exit; end; if trim(Edit1.Text) = '' then begin button1.Enabled := true; application.MessageBox('缸号不能为空', '提示'); exit; end; if Trim(Label2.Caption) = '成品' then begin with ADOQueryPrint do begin close; sql.Clear; sql.Add('select Sum(JYLen) JYLen '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''' + trim(Label2.Caption) + ''''); open; end; if FOrdQty * 1.5 < ADOQueryPrint.FieldByName('JYLen').AsFloat + strtofloat(JYLen.Text) then begin if Application.MessageBox('超过指示单数量的1.5倍,确定要提交吗', '提示', 1) = 2 then begin button1.Enabled := true; Exit; end; end; end; if JYLen.Text = '' then begin application.MessageBox('长度不能为空', '提示信息', 0); button1.Enabled := true; exit; end; if Trim(JYPZ.Text) <> '' then begin if TryStrToFloat(JYPZ.Text, mvalue) = False then begin Application.MessageBox('皮重非法数字!', '提示', 0); Exit; end; end; if Trim(XS.Text) <> '' then begin if TryStrToFloat(XS.Text, mvalue) = False then begin Application.MessageBox('系数非法数字!', '提示', 0); Exit; end; end; if Trim(JYJZ.Text) <> '' then begin if TryStrToFloat(JYJZ.Text, mvalue) = False then begin Application.MessageBox('净重非法数字!', '提示', 0); Exit; end; end; if Trim(JYKG.Text) <> '' then begin if TryStrToFloat(JYKG.Text, mvalue) = False then begin Application.MessageBox('毛重非法数字!', '提示', 0); Exit; end; end; if strtofloatdef(trim(JYLen.Text), 0) < 0.0 then begin application.MessageBox('长度不能小于0!', '提示信息', 0); button1.Enabled := true; exit; end; FInt := '1'; if SaveData() then begin JYLen.Text := ''; JYJZ.Text := ''; JYKG.Text := ''; PP1.text := ''; PP2.text := ''; PrtData(Trim(JY_CP.fieldbyname('JYID').AsString)); end else begin Exit; end; if Trim(Label2.Caption) = '成品' then begin with ADOQueryPrint do begin close; sql.Clear; sql.Add('select AA.*,CQty=SJZQty-MQQty from (select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add(',MQQty=(select Sum(B.JYLen) from JTJY_New B where B.NewSubid=A.NewSubid '); sql.Add('and B.JYType=''成品'' and B.GangNo=A.GangNo) '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''面布'' '); SQL.Add('group by A.GangNo,A.NewSubid) AA'); //ShowMessage(sql.Text); open; end; SCreateCDS20(ADOQueryPrint, JY_HZ); SInitCDSData20(ADOQueryPrint, JY_HZ); end; button1.Enabled := true; JYLen.SetFocus; end; procedure TfrmMJJYTH.Button2Click(Sender: TObject); begin if JY_CP.IsEmpty then Exit; PrtData(Trim(JY_CP.fieldbyname('JYID').AsString)); end; procedure TfrmMJJYTH.TV2CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); var i: Integer; begin {with ADOTmp do begin close; sql.Clear; sql.Add('select * from JTJY_New where JYID=''' + Trim(JY_CP.fieldbyname('JYID').AsString) + ''''); Open; end; JYLen.Text := FloatToStr(ADOTmp.fieldbyname('JYLen').asfloat); JYPZ.Text := FloatToStr(ADOTmp.fieldbyname('JYPZ').asfloat); JYJZ.Text := FloatToStr(ADOTmp.fieldbyname('JYJZ').asfloat); JYKG.Text := FloatToStr(ADOTmp.fieldbyname('JYKG').asfloat); edit1.Text := Trim(ADOTmp.fieldbyname('GangNo').AsString); with Panel8 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin if TSpeedButton(Controls[i]).Caption = Trim(Edit1.Text) then begin TSpeedButton(Controls[i]).Font.Color := clRed; end else TSpeedButton(Controls[i]).Font.Color := clWindowText; end; end; end; } end; procedure TfrmMJJYTH.SpeedButton28Click(Sender: TObject); var i: Integer; begin with Panel5 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Font.Color := clWindowText; end; end; end; TSpeedButton(Sender).Font.Color := clRed; GangNo.Text := TSpeedButton(Sender).Caption; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(GangNo.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); Open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); end; procedure TfrmMJJYTH.Edit2Click(Sender: TObject); begin if Trim(Edit2.Text) = '' then begin Edit2.Text := '√'; if not isCommopenDZC then OpenComDZC(DllName); IsCzMessage := true; end else begin Edit2.Text := ''; IsCzMessage := False; end; end; procedure TfrmMJJYTH.JYLenChange(Sender: TObject); var FCD, FPZ, FJZ, FMZ, FXS: string; begin FCD := Trim(JYLen.Text); if Trim(FCD) = '' then begin FCD := '0'; end; FPZ := Trim(JYPZ.Text); if Trim(FPZ) = '' then begin FPZ := '0'; end; FXS := Trim(XS.Text); if Trim(FXS) = '' then begin FXS := '0'; end; if Trim(FXS) <> '' then begin JYJZ.Text := FloatToStr(StrToFloat(FCD) * StrToFloat(FXS)); JYKG.Text := FloatToStr(StrToFloat(FCD) * StrToFloat(FXS) + StrToFloat(FPZ)); end; end; procedure TfrmMJJYTH.Edit16Click(Sender: TObject); begin if Trim(Edit16.Text) = '' then begin Edit16.Text := '√'; end else begin Edit16.Text := ''; end; end; procedure TfrmMJJYTH.TV4CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin with ADOTmp do begin close; sql.Clear; sql.Add('select * from JTJY_New where NewSubId=''' + Trim(FSubId) + ''''); sql.Add(' and GangNo=''' + Trim(DB_HZ.fieldbyname('GangNo').AsString) + ''''); Open; end; SCreateCDS20(ADOTmp, Order_MJ); SInitCDSData20(ADOTmp, Order_MJ); end; procedure TfrmMJJYTH.Button4Click(Sender: TObject); var fPrintFile: string; i: Integer; begin if Trim(MJLen.Text) = '' then Exit; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('select MJLEN=' + MJLen.Text); Open; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\空标签.rmf'; if FileExists(fPrintFile) then begin RM2.LoadFromFile(fPrintFile); for i := 1 to StrToInt(ComboBox1.Text) do begin RM2.PrintReport; end; end else begin Application.MessageBox('没有找标签格式', '提示', 0); BTPrint.Enabled := true; Button5.Enabled := true; exit; end; end; procedure TfrmMJJYTH.Button6Click(Sender: TObject); var strsql: string; begin if Application.MessageBox('确定要作废数据吗?作废后数据不能恢复。', '提示', 32 + 4) <> IDYES then Exit; try ADOCmd.Connection.BeginTrans; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_MLCP_CR where MJID=' + quotedstr(Trim(Order_MJ.fieldbyname('JYID').AsString))); sql.Add('and CRFlag=''出库'' '); Open; end; if ADOTmp.RecordCount >= 1 then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('已出库不能删除!', '提示', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from JTJY_New where JYID=' + quotedstr(Trim(Order_MJ.fieldbyname('JYID').AsString))); sql.Add('and DATEDIFF(MI,filltime,GETDATE())<10 '); Open; end; if ADOTmp.IsEmpty then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('记录超时!', '提示', 0); Exit; end; with ADOCmd do begin Close; sql.Clear; sql.Add('delete JTJY_New where JYID=''' + Trim(Order_MJ.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_MLCP_CR where MJID=''' + Trim(Order_MJ.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_MLCP_KC where MJID=''' + Trim(Order_MJ.fieldbyname('JYID').AsString) + ''''); ExecSQL; end; strsql := '卷ID:' + trim(Order_MJ.FieldByName('JYID').AsString); with ADOCmd do begin Close; sql.Clear; sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('检验删除'))); sql.Add(',' + quotedstr(trim(strsql))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_OrderSub :SubId'); Parameters.ParamByName('SubId').Value := Trim(FSubId); ExecSQL; end; Order_MJ.Delete; ADOCmd.Connection.CommitTrans; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('删除失败!', '提示', 0); end; end; procedure TfrmMJJYTH.btn1Click(Sender: TObject); begin ScrollBox1.Visible := False; InitSub(TSpeedButton(Sender).Hint); end; procedure TfrmMJJYTH.Button8Click(Sender: TObject); var strsql, FYFID: string; begin if Application.MessageBox('确定要作废数据吗?作废后数据不能恢复。', '提示', 32 + 4) <> IDYES then Exit; try ADOCmd.Connection.BeginTrans; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_MLCP_CR where MJID=' + quotedstr(Trim(JY_CP.fieldbyname('JYID').AsString))); sql.Add('and CRFlag=''出库'' '); Open; end; if ADOTmp.RecordCount >= 1 then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('已出库不能删除!', '提示', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from JTJY_New where JYID=' + quotedstr(Trim(JY_CP.fieldbyname('JYID').AsString))); sql.Add('and DATEDIFF(MI,filltime,GETDATE())<10 '); Open; end; if ADOTmp.IsEmpty then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('记录超时!', '提示', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select * from JTJY_New where JYID=''' + Trim(JY_CP.fieldbyname('JYID').AsString) + ''''); Open; end; FYFID := Trim(ADOTmp.fieldbyname('YFID').AsString); with ADOCmd do begin Close; sql.Clear; sql.Add('delete JTJY_New where JYID=''' + Trim(JY_CP.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_MLCP_CR where MJID=''' + Trim(JY_CP.fieldbyname('JYID').AsString) + ''''); sql.Add('delete CK_MLCP_KC where MJID=''' + Trim(JY_CP.fieldbyname('JYID').AsString) + ''''); ExecSQL; end; if Trim(FYFID) <> '' then begin with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_THData :YFID'); Parameters.ParamByName('YFID').Value := Trim(FYFID); ExecSQL; end; end; strsql := '卷ID:' + trim(JY_CP.FieldByName('JYID').AsString); with ADOCmd do begin Close; sql.Clear; sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('检验删除'))); sql.Add(',' + quotedstr(trim(strsql))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_OrderSub :SubId'); Parameters.ParamByName('SubId').Value := Trim(FSubId); ExecSQL; end; //更新棉&无纺布耗用 with ADOCmd do begin Close; sql.Clear; //实际 sql.Add('Update ML_OrderZuHe Set MLJYQty=(select sum(JYLen) from JTJY_New A where A.NewMLID=ML_OrderZuHe.NewMLID and A.JYType=''成品'') '); sql.Add(' where NewMLID=''' + Trim(FMainId) + ''''); sql.Add(' and isnull(MLName,'''')<>'''' and SSGS=''自己'' '); ExecSQL; end; //更新棉&无纺布耗用 Order_MJ.Delete; ADOCmd.Connection.CommitTrans; except ADOCmd.Connection.RollbackTrans; Application.MessageBox('删除失败!', '提示', 0); end; end; procedure TfrmMJJYTH.Button7Click(Sender: TObject); var fPrintFile: string; i: Integer; begin if Trim(JYLen.Text) = '' then Exit; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('select MJLEN=' + JYLen.Text); // sql.Add(',JYKG=' + JYKG.Text); sql.Add(',JYKG=isnull(''' + JYKG.Text + ''','''')'); // sql.Add(',JYJZ=' + JYJZ.Text); sql.Add(',JYJZ=isnull(''' + JYJZ.Text + ''','''')'); sql.Add(',JYMF=isnull(''' + JYMF.Text + ''','''')'); sql.Add(',JYKZ=isnull(''' + JYKZ.Text + ''','''')'); sql.Add(',JYGH=isnull(''' + JYGH.Text + ''','''')'); // ShowMessage(sql.text); Open; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\空标签.rmf'; if FileExists(fPrintFile) then begin RM2.LoadFromFile(fPrintFile); for i := 1 to StrToInt(ComboBox1.Text) do begin RM2.PrintReport; end; end else begin Application.MessageBox('没有找标签格式', '提示', 0); BTPrint.Enabled := true; Button5.Enabled := true; exit; end; end; procedure TfrmMJJYTH.Button9Click(Sender: TObject); begin if SpeedButton83.Visible = False then Exit; if Panel2.Visible = True then Exit; Panel10.Visible := True; Panel10.Left := 5; end; procedure TfrmMJJYTH.SpeedButton83Click(Sender: TObject); var i: Integer; begin with Panel10 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Font.Color := clWindowText; end; end; end; TSpeedButton(Sender).Font.Color := clRed; if PageControl1.ActivePageIndex = 0 then begin GangNo.Text := TSpeedButton(Sender).Caption; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(GangNo.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); Open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); end else if PageControl1.ActivePageIndex = 2 then begin Edit1.Text := TSpeedButton(Sender).Caption; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(Edit1.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); Open; end; SCreateCDS20(ADOCmd, JY_CP); SInitCDSData20(ADOCmd, JY_CP); end; Panel10.Visible := False; end; procedure TfrmMJJYTH.SpeedButton148Click(Sender: TObject); var AA: array[0..100] of string; i, j: Integer; begin // Label2.Caption := '成品'; Label2.Caption := '退货'; if ADOQuery1.IsEmpty = False then begin Label19.Visible := True; Label19.text := ADOQuery1.fieldbyname('MLBZNote').AsString; end; MD := 'CP'; PageControl1.TabIndex := 2; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select AA.*,CQty=SJZQty-MQQty from (select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add(',MQQty=(select Sum(B.JYLen) from JTJY_New B where B.NewSubid=A.NewSubid '); sql.Add('and B.JYType=''成品'' and B.GangNo=A.GangNo)'); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''面布'' '); SQL.Add('group by A.GangNo,A.NewSubid) AA'); //ShowMessage(sql.Text); open; end; SCreateCDS20(ADOQueryPrint, JY_HZ); SInitCDSData20(ADOQueryPrint, JY_HZ); with JY_HZ do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('GangNo').AsString); i := i + 1; Next; end; end; if i < 12 then begin with Panel8 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end else begin with Panel8 do begin for j := 0 to 11 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; if JY_HZ.IsEmpty = False then begin with Panel10 do begin for j := 0 to i - 1 do begin if Controls[j] is TSpeedButton then begin TSpeedButton(Controls[j]).Visible := true; TSpeedButton(Controls[j]).Hint := AA[j]; TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; end; JYLen.SetFocus; panel2.Visible := false; end; procedure TfrmMJJYTH.CPFlagClick(Sender: TObject); begin if Trim(CPFlag.Text) = '' then begin CPFlag.Text := '√'; end else begin CPFlag.Text := ''; end; end; procedure TfrmMJJYTH.Button12Click(Sender: TObject); var MaxNo: string; begin if Trim(PS.text) = '' then begin Application.MessageBox('拆分匹数不能为空!', '提示', 0); Exit; end; if Trim(PS.text) = '1' then begin if Trim(len1.text) = '' then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else if Trim(PS.text) = '2' then begin if (Trim(len1.text) = '') or (Trim(len2.text) = '') then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else if Trim(PS.text) = '3' then begin if (Trim(len1.text) = '') or (Trim(len2.text) = '') or (Trim(len3.text) = '') then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else if Trim(PS.text) = '4' then begin if (Trim(len1.text) = '') or (Trim(len2.text) = '') or (Trim(len3.text) = '') or (Trim(len4.text) = '') then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else if Trim(PS.text) = '5' then begin if (Trim(len1.text) = '') or (Trim(len2.text) = '') or (Trim(len3.text) = '') or (Trim(len4.text) = '') or (Trim(len5.text) = '') then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else if Trim(PS.text) = '6' then begin if (Trim(len1.text) = '') or (Trim(len2.text) = '') or (Trim(len3.text) = '') or (Trim(len4.text) = '') or (Trim(len5.text) = '') or (Trim(len6.text) = '') then begin Application.MessageBox('长度输入错误!', '提示', 0); Exit; end; end else begin Application.MessageBox('匹数只能是1-6的数字!', '提示', 0); Exit; end; if Trim(PS.text) = '1' then begin if StrToFloatdef(Len1.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end else if Trim(PS.text) = '2' then begin if StrToFloatdef(Len1.Text, 0) + StrToFloatdef(Len2.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end else if Trim(PS.text) = '3' then begin if StrToFloatdef(Len1.Text, 0) + StrToFloatdef(Len2.Text, 0) + StrToFloatdef(Len3.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end else if Trim(PS.text) = '4' then begin if StrToFloatdef(Len1.Text, 0) + StrToFloatdef(Len2.Text, 0) + StrToFloatdef(Len3.Text, 0) + StrToFloatdef(Len4.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end else if Trim(PS.text) = '5' then begin if StrToFloatdef(Len1.Text, 0) + StrToFloatdef(Len2.Text, 0) + StrToFloatdef(Len3.Text, 0) + StrToFloatdef(Len4.Text, 0) + StrToFloatdef(Len5.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end else if Trim(PS.text) = '6' then begin if StrToFloatdef(Len1.Text, 0) + StrToFloatdef(Len2.Text, 0) + StrToFloatdef(Len3.Text, 0) + StrToFloatdef(Len4.Text, 0) + StrToFloatdef(Len5.Text, 0) + StrToFloatdef(Len6.Text, 0) < StrToFloatdef(Label36.Caption, 0) * 0.8 then begin Application.MessageBox('拆分长度与被拆分长度不能差太多!', '提示', 0); Exit; end; end; if GetLSNo(ADOTmp, LBID, 'LB', 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; if StrToFloatdef(Len1.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); sql.Add(',@MJLen=' + quotedstr(Trim(Len1.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; if StrToFloatdef(Len2.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); sql.Add(',@MJLen=' + quotedstr(Trim(Len2.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; if StrToFloatdef(Len3.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); sql.Add(',@MJLen=' + quotedstr(Trim(Len3.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; if StrToFloatdef(Len4.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); sql.Add(',@MJLen=' + quotedstr(Trim(Len4.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; if StrToFloatdef(Len5.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); sql.Add(',@MJLen=' + quotedstr(Trim(Len5.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; if StrToFloatdef(Len6.text, 0) > 0 then begin if GetLSNo(ADOTmp, MaxNo, MD, 'JTJY_New', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; with ADOQuery1 do begin Filtered := False; Close; sql.Clear; SQL.Add('exec P_JYCP '); sql.Add(' @JYID=' + quotedstr(Trim(MaxNo))); //现条码 sql.Add(',@LBID=' + quotedstr(Trim(LBID))); sql.Add(',@MJID=' + quotedstr(Trim(JYID))); //原条码 sql.Add(',@MJLen=' + quotedstr(Trim(Len6.text))); sql.Add(',@Filler=' + quotedstr(Trim(DName))); ExecSQL; end; PrtDataMD(MaxNo); end; /////// 删除原条码///////// with ADOQuery1 do begin Close; sql.Clear; sql.Add(' exec P_JYCP_Del'); sql.Add(' @JYID=' + quotedstr(Trim(JYID))); sql.Add(' ,@CPer=' + quotedstr(Trim(DName))); ExecSQL; end; /////// 删除原条码///////// with ADOCmd do begin Close; sql.Clear; sql.Add(' exec P_Update_OrderSub :SubId'); Parameters.ParamByName('SubId').Value := Trim(FSubId); ExecSQL; end; with ADOQueryPrint do begin close; sql.Clear; sql.Add('select A.GangNo,A.NewSubid,Sum(A.JYLen) SJZQty '); sql.Add('from JTJY_New A where NewSubid=''' + Trim(FSubid) + ''' '); sql.Add('and JYType=''底布'' '); SQL.Add('group by A.GangNo,A.NewSubid'); open; end; SCreateCDS20(ADOQueryPrint, DB_HZ); SInitCDSData20(ADOQueryPrint, DB_HZ); with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from JTJY_New where NewSubid=''' + Trim(FSubid) + ''''); sql.Add(' and GangNo=''' + Trim(GangNo.Text) + ''''); SQL.Add(' and JYType=''' + trim(Label2.Caption) + ''''); // ShowMessage(sql.Text); Open; end; SCreateCDS20(ADOCmd, Order_MJ); SInitCDSData20(ADOCmd, Order_MJ); PS.text := ''; Len1.text := ''; Len2.text := ''; Len3.text := ''; Len4.text := ''; Len5.text := ''; Len6.text := ''; GangNo.text := ''; LBLen.text := ''; MJLen.text := ''; JYID := ''; ///////////////启用保存//////////////////// BTPrint.Enabled := true; Button11.Enabled := true; MJLen.Enabled := true; LBLen.Enabled := true; GangNo.Enabled := true; ///////////////启用保存//////////////////// FMainId := ''; FSubId := ''; Panel11.Visible := False; end; procedure TfrmMJJYTH.PSChange(Sender: TObject); begin Label23.Visible := false; Len1.Visible := false; Label26.Visible := false; Len2.Visible := false; Label27.Visible := false; Len3.Visible := false; Label28.Visible := false; Len4.Visible := false; Label29.Visible := false; Len5.Visible := false; Label34.Visible := false; Len6.Visible := false; if Trim(PS.text) = '1' then begin Label23.Visible := True; Len1.Visible := True; end else if Trim(PS.text) = '2' then begin Label23.Visible := True; Len1.Visible := True; Label26.Visible := True; Len2.Visible := True; end else if Trim(PS.text) = '3' then begin Label23.Visible := True; Len1.Visible := True; Label26.Visible := True; Len2.Visible := True; Label27.Visible := True; Len3.Visible := True; end else if Trim(PS.text) = '4' then begin Label23.Visible := True; Len1.Visible := True; Label26.Visible := True; Len2.Visible := True; Label27.Visible := True; Len3.Visible := True; Label28.Visible := True; Len4.Visible := True; end else if Trim(PS.text) = '5' then begin Label23.Visible := True; Len1.Visible := True; Label26.Visible := True; Len2.Visible := True; Label27.Visible := True; Len3.Visible := True; Label28.Visible := True; Len4.Visible := True; Label29.Visible := True; Len5.Visible := True; end else if Trim(PS.text) = '6' then begin Label23.Visible := True; Len1.Visible := True; Label26.Visible := True; Len2.Visible := True; Label27.Visible := True; Len3.Visible := True; Label28.Visible := True; Len4.Visible := True; Label29.Visible := True; Len5.Visible := True; Label34.Visible := True; Len6.Visible := True; end; end; procedure TfrmMJJYTH.Button13Click(Sender: TObject); begin Panel12.Visible := true; end; procedure TfrmMJJYTH.Button14Click(Sender: TObject); begin Panel12.Visible := false; end; end.