unit U_MaDanManageWWBAK; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxCheckBox, cxButtonEdit, cxDropDownEdit, BtnEdit, cxGridBandedTableView, cxGridDBBandedTableView, cxContainer, cxTextEdit, cxMemo, cxRichEdit, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu; type TfrmMaDanManageWWBAK = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBFind: TToolButton; TBClose: TToolButton; Panel1: TPanel; Label3: TLabel; OrderNo: TEdit; ScrollBox3: TScrollBox; ScrollBox4: TScrollBox; ScrollBox6: TScrollBox; Panel7: TPanel; Label13: TLabel; cxGrid5: TcxGrid; Tv5: TcxGridDBTableView; cxGridDBColumn8: TcxGridDBColumn; cxGridDBColumn9: TcxGridDBColumn; cxGridLevel4: TcxGridLevel; v5Column1: TcxGridDBColumn; v5Column2: TcxGridDBColumn; v5Column3: TcxGridDBColumn; v5Column4: TcxGridDBColumn; v5Column5: TcxGridDBColumn; v5Column7: TcxGridDBColumn; Panel2: TPanel; Label1: TLabel; v5Column8: TcxGridDBColumn; Panel3: TPanel; Label2: TLabel; Panel5: TPanel; Label9: TLabel; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; v2Column1: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; v2Column2: TcxGridDBColumn; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1Column4: TcxGridDBColumn; v1SOrddefstr1: TcxGridDBColumn; v1PRTColor: TcxGridDBColumn; v1Column1: TcxGridDBColumn; v1PRTOrderQty: TcxGridDBColumn; v1OrderUnit: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; Panel4: TPanel; Label12: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label25: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Label18: TLabel; DLYDate: TDateTimePicker; MPRTCodeName: TEdit; MPRTSpec: TEdit; MPRTCF: TEdit; MPRTMF: TEdit; MPRTKZ: TEdit; MPRTKZNote: TEdit; LiDanPerson: TEdit; ScrollBox1: TScrollBox; Panel8: TPanel; Button1: TButton; Button2: TButton; Button3: TButton; Panel6: TPanel; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn11: TcxGridDBColumn; cxGridDBColumn14: TcxGridDBColumn; cxGridDBColumn12: TcxGridDBColumn; Tv3Column1: TcxGridDBColumn; Tv3Column2: TcxGridDBColumn; Tv3Column3: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; cxGrid4: TcxGrid; Tv6: TcxGridDBBandedTableView; cxGridDBBandedColumn1: TcxGridDBBandedColumn; cxGridDBBandedColumn2: TcxGridDBBandedColumn; cxGridLevel3: TcxGridLevel; Tv6Column1: TcxGridDBBandedColumn; Tv6Column2: TcxGridDBBandedColumn; v6Column1: TcxGridDBBandedColumn; v6Column2: TcxGridDBBandedColumn; v6Column3: TcxGridDBBandedColumn; v3Column1: TcxGridDBColumn; v6Column4: TcxGridDBBandedColumn; v6Column5: TcxGridDBBandedColumn; v6Column6: TcxGridDBBandedColumn; v6Column8: TcxGridDBBandedColumn; v6Column9: TcxGridDBBandedColumn; v6Column10: TcxGridDBBandedColumn; Edit1: TEdit; CDS_OrderNo: TClientDataSet; DS_OrderNo: TDataSource; cxGrid6: TcxGrid; TvOrdeNo: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; cxGridDBColumn10: TcxGridDBColumn; cxGrid4Level1: TcxGridLevel; ADOQuery1: TADOQuery; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; ClientDataSet1: TClientDataSet; DataSource1: TDataSource; ClientDataSet2: TClientDataSet; DataSource2: TDataSource; ClientDataSet5: TClientDataSet; DataSource5: TDataSource; v3Column2: TcxGridDBColumn; v3Column3: TcxGridDBColumn; ClientDataSet3: TClientDataSet; DataSource3: TDataSource; v5Column9: TcxGridDBColumn; Button4: TButton; Button5: TButton; Button6: TButton; v6Column11: TcxGridDBBandedColumn; v6Column12: TcxGridDBBandedColumn; v6Column14: TcxGridDBBandedColumn; ClientDataSet6: TClientDataSet; DataSource6: TDataSource; v6Column7: TcxGridDBBandedColumn; v1Column2: TcxGridDBColumn; Label4: TLabel; PFGenDanPerson: TEdit; MPRTCode: TEdit; MPRTGY: TEdit; v1Column5: TcxGridDBColumn; v1Column3: TcxGridDBColumn; v1Column6: TcxGridDBColumn; v1Column7: TcxGridDBColumn; cxGridPopupMenu1: TcxGridPopupMenu; cxGridPopupMenu2: TcxGridPopupMenu; cxGridPopupMenu3: TcxGridPopupMenu; cxGridPopupMenu4: TcxGridPopupMenu; cxGridPopupMenu5: TcxGridPopupMenu; v3Column4: TcxGridDBColumn; v3Column5: TcxGridDBColumn; v6Column13: TcxGridDBBandedColumn; v6Column15: TcxGridDBBandedColumn; Button7: TButton; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure TvOrdeNoDblClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure v2Column2PropertiesEditValueChanged(Sender: TObject); procedure v5Column8PropertiesEditValueChanged(Sender: TObject); procedure Tv3Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure v6Column8PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v6Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v6Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v1Column2PropertiesEditValueChanged(Sender: TObject); procedure Tv6MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Tv3MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormShow(Sender: TObject); procedure Button7Click(Sender: TObject); private { Private declarations } FMainId,SParameters1:String; procedure InitGrid(); public { Public declarations } end; var frmMaDanManageWWBAK: TfrmMaDanManageWWBAK; implementation uses U_DataLink,U_RTFun, U_GYSList; {$R *.dfm} procedure TfrmMaDanManageWWBAK.FormDestroy(Sender: TObject); begin frmMaDanManageWWBAK:=nil; end; procedure TfrmMaDanManageWWBAK.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmMaDanManageWWBAK.TBCloseClick(Sender: TObject); begin WriteCxGrid('Tv1',Tv1,'外围码单'); WriteCxGrid('Tv2',Tv2,'外围码单'); WriteCxGrid('Tv3',Tv3,'外围码单'); WriteCxGrid('Tv5',Tv5,'外围码单'); WriteCxBandedGrid('Tv6',Tv6,'外围码单'); close; end; procedure TfrmMaDanManageWWBAK.OrderNoChange(Sender: TObject); var mvalue:String; begin mvalue:=Trim(OrderNo.Text); if Length(Trim(mvalue))<2 then begin cxGrid6.Visible:=False; Exit; end; mvalue:='%'+Trim(mvalue)+'%'; with ADOQuery1 do begin Close; sql.Clear; sql.Add('select OrderNo,MPRTCodeName,A.MainId from JYOrder_Main A'); sql.Add(' where A.orderno like :orderno '); //sql.Add(' and A.MainId in(select MainId from JYOrder_Sub B where B.Mainid=A.MainId and B.subId in(select OrdSubId from Contract_Cloth_LL))'); Parameters.ParamByName('orderno').Value:=mvalue; Open; end; SCreateCDS20(ADOQuery1,CDS_OrderNo); SInitCDSData20(ADOQuery1,CDS_OrderNo); if CDS_OrderNo.IsEmpty then cxGrid6.Visible:=False else cxGrid6.Visible:=True; end; procedure TfrmMaDanManageWWBAK.TvOrdeNoDblClick(Sender: TObject); var fsj:String; begin OrderNo.Text:=CDS_OrderNo.fieldbyname('OrderNo').AsString; cxGrid6.Visible:=False; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.* '); sql.Add(' from JYOrder_Main A'); sql.Add(' where Orderno='''+Trim(OrderNo.Text)+''''); Open; end; SCSHData(ADOQueryTemp,Panel4,2); MPRTCode.Text:=Trim(ADOQueryTemp.fieldbyname('MPRTCode').AsString); FMainId:=Trim(ADOQueryTemp.fieldbyname('MainId').AsString); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_Process where MainId='''+Trim(FMainId)+''''); Open; end; with ADOQueryTemp do begin First; while not Eof do begin with ADOQuery1 do begin Close; sql.Clear; sql.Add('select AA=dbo.F_Get_Order_SubStr(:PSID,''PFGenDanPerson'')'); Parameters.ParamByName('PSID').Value:=Trim(ADOQueryTemp.fieldbyname('PSID').AsString); open; end; if Trim(fsj)='' then begin fsj:=Trim(ADOQueryTemp.fieldbyname('PSName').AsString)+':'+Trim(ADOQuery1.fieldbyname('AA').AsString); end else fsj:=fsj+' '+Trim(ADOQueryTemp.fieldbyname('PSName').AsString)+':'+Trim(ADOQuery1.fieldbyname('AA').AsString); Next; end; end; PFGenDanPerson.Text:=Trim(fsj); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.*,B.PRTHX,B.PRTColorNo,B.PRTColor,B.PRTOrdQty,B.OrderUnit,B.ColorNote,JP.PSName '); sql.Add(' from JYOrder_PCS_Sub A'); sql.Add(' inner join JYOrder_Process JP on A.PSID=JP.PSID'); sql.Add(' left join JYOrder_Sub B on A.SubId=B.SubId'); sql.Add(' where A.MainId='''+Trim(FMainId)+''''); Open; end; SCreateCDS20(ADOQueryTemp,ClientDataSet1); SInitCDSData20(ADOQueryTemp,ClientDataSet1); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from Contract_Main A inner join Contract_Sub B on A.MainId=B.MainId '); sql.Add(' where A.ConNo like '''+'%'+Trim(OrderNo.Text)+'%'+''''); Open; end; SCreateCDS20(ADOQueryTemp,ClientDataSet5); SInitCDSData20(ADOQueryTemp,ClientDataSet5); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_Process where MainId='''+Trim(FMainId)+''''); Open; end; SCreateCDS20(ADOQueryTemp,ClientDataSet2); SInitCDSData20(ADOQueryTemp,ClientDataSet2); InitGrid(); end; procedure TfrmMaDanManageWWBAK.InitGrid(); var FPSID,FOrdSubId,FConSubId,FPFID:String; begin if ClientDataSet2.Locate('SSel',True,[])=True then begin FPSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString); end else begin FPSID:=''; end; if ClientDataSet5.Locate('SSel',True,[])=True then begin FConSubId:=Trim(ClientDataSet5.fieldbyname('SubId').AsString); end else begin FConSubId:=''; end; if ClientDataSet1.Locate('SSel',True,[])=True then begin FOrdSubId:=Trim(ClientDataSet1.fieldbyname('SubId').AsString); FPFID:=Trim(ClientDataSet1.fieldbyname('PFID').AsString); end else begin FOrdSubId:=''; FPFID:=''; end; with ADOQuery1 do begin Close; sql.Clear; sql.Add('select A.*,B.PSName OrdPSName,C.ConNo,C.FactoryNoName,D.Price,JS.PRTHX,JS.PRTColor,JS.PRTColorNo,JS.ColorNote '); sql.Add(' from JYOrder_Main_MD A'); sql.Add(' inner join JYOrder_Process B on A.PSID=B.PSID'); sql.Add(' inner join JYOrder_PCS_Sub JPS on A.PFID=JPS.PFID '); sql.Add(' left join JYOrder_Sub JS on A.OrdSubId=JS.SubId'); sql.Add(' inner join Contract_Main C on A.ConMainid=C.MainID'); sql.Add(' inner join Contract_Sub D on A.ConSubid=D.SubID'); sql.Add(' where A.ORDMainId='''+Trim(FMainId)+''''); if Trim(FPSID)<>'' then begin sql.Add(' and A.PSID='''+Trim(FPSID)+''''); end; if Trim(FConSubId)<>'' then begin sql.Add(' and A.ConSubID='''+Trim(FConSubId)+''''); end; if Trim(FOrdSubId)<>'' then begin sql.Add(' and A.OrdSubID='''+Trim(FOrdSubId)+''''); end; if Trim(FPFID)<>'' then begin sql.Add(' and A.PFID='''+Trim(FPFID)+''''); end; if Trim(SParameters1)<>'高权限' then begin SQL.Add(' and A.Filler='''+Trim(DName)+''''); end; sql.Add(' and A.MDType=''外围'' '); SQL.Add(' and isnull(CKName,'''')<>''调节仓库'' '); Open; end; SCreateCDS20(ADOQuery1,ClientDataSet3); SInitCDSData20(ADOQuery1,ClientDataSet3); with ADOQuery1 do begin Close; sql.Clear; sql.Add('select A.*,B.PSName OrdPSName,C.ConNo,C.FactoryNoName,D.Price,JS.PRTHX,JS.PRTColor,JS.PRTColorNo,JS.ColorNote '); sql.Add(' from JYOrder_Main_MD A'); sql.Add(' inner join JYOrder_Process B on A.PSID=B.PSID'); sql.Add(' inner join JYOrder_PCS_Sub JPS on A.PFID=JPS.PFID '); sql.Add(' left join JYOrder_Sub JS on A.OrdSubId=JS.SubId'); sql.Add(' inner join Contract_Main C on A.ConMainid=C.MainID'); sql.Add(' inner join Contract_Sub D on A.ConSubid=D.SubID'); sql.Add(' where A.ORDMainId='''+Trim(FMainId)+''''); if Trim(FPSID)<>'' then begin sql.Add(' and A.PSID='''+Trim(FPSID)+''''); end; if Trim(FConSubId)<>'' then begin sql.Add(' and A.ConSubID='''+Trim(FConSubId)+''''); end; if Trim(FOrdSubId)<>'' then begin sql.Add(' and A.OrdSubID='''+Trim(FOrdSubId)+''''); end; if Trim(FPFID)<>'' then begin sql.Add(' and A.PFID='''+Trim(FPFID)+''''); end; if Trim(SParameters1)<>'高权限' then begin SQL.Add(' and A.Filler='''+Trim(DName)+''''); end; sql.Add(' and A.MDType=''外围'' '); SQL.Add(' and isnull(A.CKName,'''')=''调节仓库'' '); Open; end; SCreateCDS20(ADOQuery1,ClientDataSet6); SInitCDSData20(ADOQuery1,ClientDataSet6); end; procedure TfrmMaDanManageWWBAK.Button1Click(Sender: TObject); begin if Trim(FMainId)='' then begin Application.MessageBox('没有选择订单!','提示',0); Exit; end; if ClientDataSet5.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择加工合同!','提示',0); Exit; end; if ClientDataSet2.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择生产流程!','提示',0); Exit; end; if ClientDataSet1.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择安排信息!','提示',0); Exit; end; with ClientDataSet3 do begin Append; ClientDataSet5.Locate('SSel',True,[]); ClientDataSet2.Locate('SSel',True,[]); ClientDataSet1.Locate('SSel',True,[]); FieldByName('ConNo').Value:=ClientDataSet5.fieldbyname('ConNo').Value; FieldByName('FactoryNo').Value:=ClientDataSet1.fieldbyname('FactoryNo').Value; FieldByName('FactoryName').Value:=ClientDataSet1.fieldbyname('FactoryName').Value; FieldByName('FactoryNoName').Value:=ClientDataSet5.fieldbyname('FactoryNoName').Value; FieldByName('Price').Value:=ClientDataSet5.fieldbyname('Price').Value; FieldByName('PSName').Value:=ClientDataSet2.fieldbyname('PSName').Value; FieldByName('QtyUnit').Value:=ClientDataSet5.fieldbyname('C_Unit').Value; FieldByName('Filler').Value:=Trim(DName); FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp); FieldByName('PRTHX').Value:=ClientDataSet1.fieldbyname('PRTHX').Value; FieldByName('PRTColorNo').Value:=ClientDataSet1.fieldbyname('PRTColorNo').Value; Post; end; end; procedure TfrmMaDanManageWWBAK.v2Column2PropertiesEditValueChanged( Sender: TObject); var PSID:String; Mvalue:Boolean; begin Mvalue:=TcxCheckBox(Sender).EditingValue; PSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString); with ClientDataSet2 do begin while ClientDataSet2.Locate('SSel',True,[])=True do begin Edit; FieldByName('SSel').Value:=False; Post; end; ClientDataSet2.Locate('PSID',PSID,[]); Edit; FieldByName('SSel').Value:=Mvalue; Post; end; with ADOQuery1 do begin Close; sql.Clear; sql.Add('select A.*,B.PRTHX,B.PRTColorNo,B.PRTColor,B.PRTOrdQty,B.OrderUnit,B.ColorNote,JP.PSName '); sql.Add(' from JYOrder_PCS_Sub A'); sql.Add(' inner join JYOrder_Process JP on A.PSID=JP.PSID'); sql.Add(' left join JYOrder_Sub B on A.SubId=B.SubId'); if Mvalue=True then sql.Add('where A.PSID='''+Trim(ClientDataSet2.fieldbyname('PSID').AsString)+'''') else sql.Add(' where A.MainId='''+Trim(FMainId)+''''); Open; end; SCreateCDS20(ADOQuery1,ClientDataSet1); SInitCDSData20(ADOQuery1,ClientDataSet1); InitGrid(); end; procedure TfrmMaDanManageWWBAK.v5Column8PropertiesEditValueChanged( Sender: TObject); var PSID:String; Mvalue:Boolean; begin Mvalue:=TcxCheckBox(Sender).EditingValue; PSID:=Trim(ClientDataSet5.fieldbyname('SubID').AsString); with ClientDataSet5 do begin while ClientDataSet5.Locate('SSel',True,[])=True do begin Edit; FieldByName('SSel').Value:=False; Post; end; ClientDataSet5.Locate('SubID',PSID,[]); Edit; FieldByName('SSel').Value:=Mvalue; Post; end; InitGrid(); end; procedure TfrmMaDanManageWWBAK.Tv3Column1PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmGYSList:=TfrmGYSList.Create(Application); with frmGYSList do begin if ShowModal=1 then begin with Self.ClientDataSet3 do begin Edit; FieldByName('FromFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ; FieldByName('FromFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString); //Post; end; end; end; finally frmGYSList.Free; end; end; procedure TfrmMaDanManageWWBAK.Button3Click(Sender: TObject); var maxno,ConMainId,ConSubId,PSID,OrdSubId,PFID:string; begin if ClientDataSet3.IsEmpty then Exit; if Trim(ClientDataSet3.FieldByName('MDId').AsString)='' then begin if ClientDataSet5.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择加工合同!','提示',0); Exit; end; if ClientDataSet2.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择生产流程!','提示',0); Exit; end; if ClientDataSet1.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择安排信息!','提示',0); Exit; end; end; if Trim(SParameters1)='高权限' then begin if Application.MessageBox('确定要保存数据吗?','提示',32+4)<>IDYES then Exit; end else begin if Application.MessageBox('确定要保存数据吗?数据保存后将不能修改!','提示',32+4)<>IDYES then Exit; end; //ClientDataSet1.Locate('SSel',True,[]); ConMainId:=Trim(ClientDataSet5.fieldbyname('MainId').AsString); ConSubId:=Trim(ClientDataSet5.fieldbyname('SubId').AsString); PSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString); OrdSubId:=Trim(ClientDataSet1.fieldbyname('SubId').AsString); PFID:=Trim(ClientDataSet1.fieldbyname('PFID').AsString); if Trim(ClientDataSet3.fieldbyname('ConMainId').AsString)<>'' then begin ConMainId:=Trim(ClientDataSet3.fieldbyname('ConMainId').AsString); end; if Trim(ClientDataSet3.fieldbyname('ConSubId').AsString)<>'' then begin ConSubId:=Trim(ClientDataSet3.fieldbyname('ConSubId').AsString); end; if Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString)<>'' then begin OrdSubId:=Trim(ClientDataSet3.fieldbyname('OrdSubId').AsString); end; if Trim(ClientDataSet3.fieldbyname('PSID').AsString)<>'' then begin PSID:=Trim(ClientDataSet3.fieldbyname('PSID').AsString); end; if Trim(ClientDataSet3.fieldbyname('PFID').AsString)<>'' then begin PFID:=Trim(ClientDataSet3.fieldbyname('PFID').AsString); end; try ADOQueryCmd.Connection.BeginTrans; ClientDataSet3.DisableControls; with ClientDataSet3 do begin First; while not Eof do begin if Trim(SParameters1)<>'高权限' then begin if Trim(ClientDataSet3.fieldbyname('MDID').AsString)<>'' then begin Next; Continue; end; end; if Trim(ClientDataSet3.fieldbyname('MDId').AsString)='' then begin if GetLSNo(ADOQueryCmd,maxno,'','JYOrder_Main_MD',4,1)=False then begin ClientDataSet3.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取码单流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(ClientDataSet3.fieldbyname('MDId').AsString); end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from JYOrder_Main_MD where MDID='''+Trim(ClientDataSet3.fieldbyname('MDId').AsString)+''''); Open; end; with ADOQueryCmd do begin if Trim(ClientDataSet3.fieldbyname('MDId').AsString)='' then begin Append; FieldByName('Filler').Value:=Trim(DName); end else begin Edit; FieldByName('Editer').Value:=Trim(DName); FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTemp); end; FieldByName('MDID').Value:=Trim(maxno); FieldByName('OrdMainID').Value:=Trim(FMainId); FieldByName('ConMainID').Value:=Trim(ConMainId); FieldByName('ConSubID').Value:=Trim(ConSubId); FieldByName('OrdSubId').Value:=Trim(OrdSubId); FieldByName('PSID').Value:=Trim(PSID); FieldByName('PFID').Value:=Trim(PFID); FieldByName('MDType').Value:='外围'; RTSetSaveDataCDS(ADOQueryCmd,Tv3,ClientDataSet3,'JYOrder_Main_MD',2); FieldByName('MDNO').Value:='MD'+Trim(maxno); FieldByName('FactoryNo').Value:=Trim(ClientDataSet3.fieldbyname('FactoryNo').AsString); FieldByName('FromFactoryNo').Value:=Trim(ClientDataSet3.fieldbyname('FromFactoryNo').AsString); Post; end; Edit; FieldByName('MDID').Value:=Trim(maxno); FieldByName('MDNO').Value:='MD'+Trim(maxno); FieldByName('OrdMainID').Value:=Trim(FMainId); FieldByName('ConMainID').Value:=Trim(ConMainId); FieldByName('ConSubID').Value:=Trim(ConSubId); FieldByName('OrdSubId').Value:=Trim(OrdSubId); FieldByName('PSID').Value:=Trim(PSID); FieldByName('PFID').Value:=Trim(PFID); Post; Next; end; end; ADOQueryCmd.Connection.CommitTrans; ClientDataSet3.EnableControls; except ClientDataSet3.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('保存异常!','提示',0); end; end; procedure TfrmMaDanManageWWBAK.FormCreate(Sender: TObject); begin SParameters1:=Trim(DParameters1); end; procedure TfrmMaDanManageWWBAK.Button2Click(Sender: TObject); begin if ClientDataSet3.IsEmpty then Exit; if Trim(ClientDataSet3.fieldbyname('MDID').AsString)<>'' then begin if Trim(SParameters1)<>'高权限' then begin Application.MessageBox('已保存的数据不能删除!','提示',0); Exit; end; if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete JYOrder_Main_MD where MDID='''+Trim(ClientDataSet3.fieldbyname('MDID').AsString)+''''); ExecSQL; end; end; ClientDataSet3.Delete; end; procedure TfrmMaDanManageWWBAK.Button4Click(Sender: TObject); begin if Trim(FMainId)='' then begin Application.MessageBox('没有选择订单!','提示',0); Exit; end; if ClientDataSet5.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择加工合同!','提示',0); Exit; end; if ClientDataSet2.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择生产流程!','提示',0); Exit; end; if ClientDataSet1.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择安排信息!','提示',0); Exit; end; with ClientDataSet6 do begin Append; ClientDataSet5.Locate('SSel',True,[]); ClientDataSet2.Locate('SSel',True,[]); ClientDataSet1.Locate('SSel',True,[]); FieldByName('ConNo').Value:=ClientDataSet5.fieldbyname('ConNo').Value; FieldByName('FactoryNo').Value:=ClientDataSet1.fieldbyname('FactoryNo').Value; FieldByName('FactoryName').Value:=ClientDataSet1.fieldbyname('FactoryName').Value; FieldByName('FactoryNoName').Value:=ClientDataSet5.fieldbyname('FactoryNoName').Value; FieldByName('Price').Value:=ClientDataSet5.fieldbyname('Price').Value; FieldByName('PSName').Value:=ClientDataSet2.fieldbyname('PSName').Value; FieldByName('QtyUnit').Value:=ClientDataSet5.fieldbyname('C_Unit').Value; FieldByName('Filler').Value:=Trim(DName); FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp); FieldByName('PRTHX').Value:=ClientDataSet1.fieldbyname('PRTHX').Value; FieldByName('PRTColorNo').Value:=ClientDataSet1.fieldbyname('PRTColorNo').Value; Post; end; end; procedure TfrmMaDanManageWWBAK.Button5Click(Sender: TObject); begin if ClientDataSet6.IsEmpty then Exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_Main_MD where MDID='''+Trim(ClientDataSet6.fieldbyname('MDID').AsString)+''''); Open; end; if Trim(ADOQueryTemp.fieldbyname('CRFlag').asstring)='入库' then begin Application.MessageBox('已经入库不能删除数据!','提示',0); Exit; end; if Trim(ClientDataSet6.fieldbyname('MDID').AsString)<>'' then begin if Trim(SParameters1)<>'高权限' then begin Application.MessageBox('已保存的数据不能删除!','提示',0); Exit; end; if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete JYOrder_Main_MD where MDID='''+Trim(ClientDataSet6.fieldbyname('MDID').AsString)+''''); ExecSQL; end; end; ClientDataSet6.Delete; end; procedure TfrmMaDanManageWWBAK.Button6Click(Sender: TObject); var maxno,ConMainId,ConSubId,PSID,OrdSubId,PFID:string; begin if ClientDataSet6.IsEmpty then Exit; if Trim(ClientDataSet6.FieldByName('MDId').AsString)='' then begin if ClientDataSet5.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择加工合同!','提示',0); Exit; end; if ClientDataSet2.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择生产流程!','提示',0); Exit; end; if ClientDataSet1.Locate('SSel',True,[])=False then begin Application.MessageBox('没有选择安排信息!','提示',0); Exit; end; end; if Trim(SParameters1)='高权限' then begin if Application.MessageBox('确定要保存数据吗?','提示',32+4)<>IDYES then Exit; end else begin if Application.MessageBox('确定要保存数据吗?数据保存后将不能修改!','提示',32+4)<>IDYES then Exit; end; //if Application.MessageBox('确定要保存数据吗?','提示',32+4)<>IDYES then Exit; //ClientDataSet1.Locate('SSel',True,[]); ConMainId:=Trim(ClientDataSet5.fieldbyname('MainId').AsString); ConSubId:=Trim(ClientDataSet5.fieldbyname('SubId').AsString); PSID:=Trim(ClientDataSet2.fieldbyname('PSID').AsString); OrdSubId:=Trim(ClientDataSet1.fieldbyname('SubId').AsString); PFID:=Trim(ClientDataSet1.fieldbyname('PFID').AsString); if Trim(ClientDataSet6.fieldbyname('ConMainId').AsString)<>'' then begin ConMainId:=Trim(ClientDataSet6.fieldbyname('ConMainId').AsString); end; if Trim(ClientDataSet6.fieldbyname('ConSubId').AsString)<>'' then begin ConSubId:=Trim(ClientDataSet6.fieldbyname('ConSubId').AsString); end; if Trim(ClientDataSet6.fieldbyname('OrdSubId').AsString)<>'' then begin OrdSubId:=Trim(ClientDataSet6.fieldbyname('OrdSubId').AsString); end; if Trim(ClientDataSet6.fieldbyname('PSID').AsString)<>'' then begin PSID:=Trim(ClientDataSet6.fieldbyname('PSID').AsString); end; if Trim(ClientDataSet6.fieldbyname('PFID').AsString)<>'' then begin PFID:=Trim(ClientDataSet6.fieldbyname('PFID').AsString); end; try ADOQueryCmd.Connection.BeginTrans; ClientDataSet6.DisableControls; with ClientDataSet6 do begin First; while not Eof do begin if Trim(SParameters1)<>'高权限' then begin if Trim(ClientDataSet6.fieldbyname('MDID').AsString)<>'' then begin Next; Continue; end; end; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_Main_MD where MDID='''+Trim(ClientDataSet6.fieldbyname('MDID').AsString)+''''); Open; end; if Trim(ADOQueryTemp.fieldbyname('CRFlag').AsString)='入库' then begin Next; Continue; end; if Trim(ClientDataSet6.fieldbyname('MDId').AsString)='' then begin if GetLSNo(ADOQueryCmd,maxno,'','JYOrder_Main_MD',4,1)=False then begin ClientDataSet6.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取码单流水号失败!','提示',0); Exit; end; end else begin maxno:=Trim(ClientDataSet6.fieldbyname('MDId').AsString); end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from JYOrder_Main_MD where MDID='''+Trim(ClientDataSet6.fieldbyname('MDId').AsString)+''''); Open; end; with ADOQueryCmd do begin if Trim(ClientDataSet6.fieldbyname('MDId').AsString)='' then begin Append; FieldByName('Filler').Value:=Trim(DName); end else begin Edit; FieldByName('Editer').Value:=Trim(DName); FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTemp); end; FieldByName('MDID').Value:=Trim(maxno); FieldByName('OrdMainID').Value:=Trim(FMainId); FieldByName('ConMainID').Value:=Trim(ConMainId); FieldByName('ConSubID').Value:=Trim(ConSubId); FieldByName('OrdSubId').Value:=Trim(OrdSubId); FieldByName('PSID').Value:=Trim(PSID); FieldByName('PFID').Value:=Trim(PFID); FieldByName('MDType').Value:='外围'; RTSetSaveDataCDSBand(ADOQueryCmd,Tv6,ClientDataSet6,'JYOrder_Main_MD',2); FieldByName('MDNO').Value:='MD'+Trim(maxno); FieldByName('FactoryNo').Value:=Trim(ClientDataSet6.fieldbyname('FactoryNo').AsString); FieldByName('FromFactoryNo').Value:=Trim(ClientDataSet6.fieldbyname('FromFactoryNo').AsString); FieldByName('ToFactoryNo').Value:=Trim(ClientDataSet6.fieldbyname('FromFactoryNo').AsString); FieldByName('DutyFactoryNo').Value:=Trim(ClientDataSet6.fieldbyname('FromFactoryNo').AsString); FieldByName('CKName').Value:='调节仓库'; Post; end; Edit; FieldByName('MDID').Value:=Trim(maxno); FieldByName('MDNO').Value:='MD'+Trim(maxno); FieldByName('OrdMainID').Value:=Trim(FMainId); FieldByName('ConMainID').Value:=Trim(ConMainId); FieldByName('ConSubID').Value:=Trim(ConSubId); FieldByName('OrdSubId').Value:=Trim(OrdSubId); FieldByName('PSID').Value:=Trim(PSID); FieldByName('PFID').Value:=Trim(PFID); Post; Next; end; end; ADOQueryCmd.Connection.CommitTrans; ClientDataSet6.EnableControls; except ClientDataSet6.EnableControls; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('保存异常!','提示',0); end; end; procedure TfrmMaDanManageWWBAK.v6Column8PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmGYSList:=TfrmGYSList.Create(Application); with frmGYSList do begin if ShowModal=1 then begin with Self.ClientDataSet6 do begin Edit; FieldByName('FromFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ; FieldByName('FromFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString); //Post; end; end; end; finally frmGYSList.Free; end; end; procedure TfrmMaDanManageWWBAK.v6Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmGYSList:=TfrmGYSList.Create(Application); with frmGYSList do begin if ShowModal=1 then begin with Self.ClientDataSet6 do begin Edit; FieldByName('DutyFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ; FieldByName('DutyFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString); //Post; end; end; end; finally frmGYSList.Free; end; end; procedure TfrmMaDanManageWWBAK.v6Column14PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); begin try frmGYSList:=TfrmGYSList.Create(Application); with frmGYSList do begin if ShowModal=1 then begin with Self.ClientDataSet6 do begin Edit; FieldByName('ToFactoryNo').Value:=Trim(frmGYSList.Order_Main.fieldbyname('ZKID').AsString) ; FieldByName('ToFactoryName').Value:=Trim(frmGYSList.Order_Main.fieldbyname('KHNameJC').AsString); //Post; end; end; end; finally frmGYSList.Free; end; end; procedure TfrmMaDanManageWWBAK.v1Column2PropertiesEditValueChanged( Sender: TObject); var PFID:String; Mvalue:Boolean; begin Mvalue:=TcxCheckBox(Sender).EditingValue; PFID:=Trim(ClientDataSet1.fieldbyname('PFID').AsString); with ClientDataSet1 do begin while ClientDataSet1.Locate('SSel',True,[])=True do begin Edit; FieldByName('SSel').Value:=False; Post; end; ClientDataSet1.Locate('PFID',PFID,[]); Edit; FieldByName('SSel').Value:=Mvalue; Post; end; InitGrid(); end; procedure TfrmMaDanManageWWBAK.Tv6MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin {with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from JYOrder_Main_MD where MDID='''+Trim(ClientDataSet6.fieldbyname('MDID').AsString)+''''); Open; end;} if ClientDataSet6.IsEmpty then Exit; if Trim(ClientDataSet6.fieldbyname('CRFlag').asstring)='入库' then begin Tv6.OptionsSelection.CellSelect:=False; end else begin Tv6.OptionsSelection.CellSelect:=True; end; if Trim(SParameters1)='高权限' then Exit; if Trim(ClientDataSet6.fieldbyname('MDID').asstring)<>'' then begin Tv6.OptionsSelection.CellSelect:=False; end else begin Tv6.OptionsSelection.CellSelect:=True; end; end; procedure TfrmMaDanManageWWBAK.Tv3MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(SParameters1)='高权限' then Exit; if ClientDataSet3.IsEmpty then Exit; if Trim(ClientDataSet3.fieldbyname('MDID').asstring)<>'' then begin Tv3.OptionsSelection.CellSelect:=False; end else begin Tv3.OptionsSelection.CellSelect:=True; end; end; procedure TfrmMaDanManageWWBAK.FormShow(Sender: TObject); begin ReadCxGrid('Tv1',Tv1,'外围码单'); ReadCxGrid('Tv2',Tv2,'外围码单'); ReadCxGrid('Tv3',Tv3,'外围码单'); ReadCxGrid('Tv5',Tv5,'外围码单'); ReadCxBandedGrid('Tv6',Tv6,'外围码单'); end; procedure TfrmMaDanManageWWBAK.Button7Click(Sender: TObject); begin WriteCxGrid('Tv1',Tv1,'外围码单'); WriteCxGrid('Tv2',Tv2,'外围码单'); WriteCxGrid('Tv3',Tv3,'外围码单'); WriteCxGrid('Tv5',Tv5,'外围码单'); WriteCxBandedGrid('Tv6',Tv6,'外围码单'); close; end; end.