492 lines
13 KiB
ObjectPascal
492 lines
13 KiB
ObjectPascal
unit U_MJEdit_other;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, DBClient, ADODB,
|
||
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxClasses, cxControls, cxGridCustomView, cxGrid, StdCtrls, ExtCtrls,
|
||
ComCtrls, ToolWin, cxButtonEdit;
|
||
|
||
type
|
||
TfrmMJEdit_other = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
ToolButton2: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
MJID: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
tv2CDType: TcxGridDBColumn;
|
||
tv2CDWZ: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
Tv2CDQty: TcxGridDBColumn;
|
||
Tv2CDReason: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
ADOTmp: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Order_MJ: TClientDataSet;
|
||
ToolButton1: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
Label2: TLabel;
|
||
MJMaoZ: TEdit;
|
||
Label4: TLabel;
|
||
M: TLabel;
|
||
Label6: TLabel;
|
||
MJLen: TEdit;
|
||
RadioGroup1: TRadioGroup;
|
||
Ma: TLabel;
|
||
Label7: TLabel;
|
||
MJQty1: TEdit;
|
||
Label5: TLabel;
|
||
Label8: TLabel;
|
||
MJFK: TEdit;
|
||
Label9: TLabel;
|
||
Label10: TLabel;
|
||
Label3: TLabel;
|
||
Label11: TLabel;
|
||
MJSJKZ: TEdit;
|
||
ToolButton4: TToolButton;
|
||
Label13: TLabel;
|
||
MJQty2: TEdit;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure MJIDKeyPress(Sender: TObject; var Key: Char);
|
||
procedure tv2CDTypePropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure tv2CDWZPropertiesEditValueChanged(Sender: TObject);
|
||
procedure v2Column2PropertiesEditValueChanged(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
function SaveData():Boolean;
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmMJEdit_other: TfrmMJEdit_other;
|
||
|
||
implementation
|
||
uses
|
||
U_Fun,U_ZDYHelp,U_DataLink;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmMJEdit_other.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmMJEdit_other:=nil;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.MJIDKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key=#13 then
|
||
begin
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select A.*,AOrddefstr3=(select AOrddefstr3 from JYOrder_Sub_AnPai B where B.APID=A.APID), ');
|
||
sql.Add('AOrddefstr2=(select AOrddefstr2 from JYOrder_Sub_AnPai B where B.APID=A.APID) from WFB_MJJY1 A');
|
||
sql.Add(' where A.MJID='''+Trim(MJID.Text)+'''');
|
||
Open;
|
||
end;
|
||
if ADOTmp.IsEmpty then
|
||
begin
|
||
MJID.Text:='';
|
||
Label2.Caption:='';
|
||
Label2.Visible:=False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
MJMaoZ.Text:=Trim(ADOTmp.fieldbyname('MJMaoZ').AsString);
|
||
MJLen.Text:=Trim(ADOTmp.fieldbyname('MJLen').AsString);
|
||
MJQty1.Text:=Trim(ADOTmp.fieldbyname('MJQty1').AsString);
|
||
MJQty2.Text:=Trim(ADOTmp.fieldbyname('MJQty2').AsString);
|
||
MJFK.Text:=Trim(ADOTmp.fieldbyname('MJFK').AsString);
|
||
MJSJKZ.Text:=Trim(ADOTmp.fieldbyname('MJSJKZ').AsString);
|
||
M.Caption:=Trim(Trim(ADOTmp.fieldbyname('MJTypeOther').AsString));
|
||
Ma.Caption:=Trim(Trim(ADOTmp.fieldbyname('MJStr1').AsString));
|
||
if Trim(m.Caption)='' then
|
||
begin
|
||
m.Caption:=Trim(ADOTmp.fieldbyname('AOrddefstr3').AsString);
|
||
end;
|
||
if Trim(Ma.Caption)='' then
|
||
begin
|
||
Ma.Caption:=Trim(ADOTmp.fieldbyname('AOrddefstr2').AsString);
|
||
end;
|
||
if Trim(Trim(ADOTmp.fieldbyname('MJType').AsString))='<27><>Ʒ' then
|
||
begin
|
||
RadioGroup1.ItemIndex:=0
|
||
end else
|
||
if Trim(Trim(ADOTmp.fieldbyname('MJType').AsString))='<27><>Ʒ' then
|
||
begin
|
||
RadioGroup1.ItemIndex:=1;
|
||
end else
|
||
if Trim(Trim(ADOTmp.fieldbyname('MJType').AsString))='<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
RadioGroup1.ItemIndex:=2;
|
||
end;
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from WFB_MJJY_CD1 A where A.MJID='''+Trim(MJID.Text)+'''');
|
||
Open;
|
||
end;
|
||
Label2.Caption:=Trim(MJID.Text);
|
||
Label2.Visible:=True;
|
||
MJID.Text:='';
|
||
SCreateCDS20(ADOTmp,Order_MJ);
|
||
SInitCDSData20(ADOTmp,Order_MJ);
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.tv2CDTypePropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='WFBCD';
|
||
flagname:='<27>õ<EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
Self.Order_MJ.Edit;
|
||
Self.Order_MJ.FieldByName('CDName').value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.tv2CDWZPropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue,CDBeg,CDEnd:string;
|
||
FFReal:Double;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CDBeg').Value:=mvalue;
|
||
Post;
|
||
end;
|
||
CDBeg:=Trim(Order_MJ.fieldbyname('CDBeg').AsString);
|
||
CDEnd:=Trim(Order_MJ.fieldbyname('CDEnd').AsString);
|
||
if (Trim(CDBeg)<>'') and (Trim(CDEnd)<>'') then
|
||
begin
|
||
if TryStrToFloat(CDBeg,FFReal) and TryStrToFloat(CDBeg,FFReal) then
|
||
begin
|
||
if StrToFloat(CDEnd)<StrToFloat(CDBeg) then
|
||
begin
|
||
Application.MessageBox('<27><>ֹλ<D6B9><CEBB>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CDQty').Value:=StrToFloat(CDEnd)-StrToFloat(CDBeg);
|
||
Post;
|
||
end;
|
||
end else
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.v2Column2PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue,CDBeg,CDEnd:string;
|
||
FFReal:Double;
|
||
begin
|
||
mvalue:=TcxTextEdit(Sender).EditingText;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CDEnd').Value:=mvalue;
|
||
Post;
|
||
end;
|
||
CDBeg:=Trim(Order_MJ.fieldbyname('CDBeg').AsString);
|
||
CDEnd:=Trim(Order_MJ.fieldbyname('CDEnd').AsString);
|
||
if (Trim(CDBeg)<>'') and (Trim(CDEnd)<>'') then
|
||
begin
|
||
if TryStrToFloat(CDBeg,FFReal) and TryStrToFloat(CDBeg,FFReal) then
|
||
begin
|
||
if StrToFloat(CDEnd)<StrToFloat(CDBeg) then
|
||
begin
|
||
Application.MessageBox('<27><>ֹλ<D6B9><CEBB>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with Order_MJ do
|
||
begin
|
||
Edit;
|
||
FieldByName('CDQty').Value:=StrToFloat(CDEnd)-StrToFloat(CDBeg);
|
||
Post;
|
||
end;
|
||
end else
|
||
begin
|
||
Application.MessageBox('<27>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption)='' then Exit;
|
||
Order_MJ.Append;
|
||
Order_MJ.Post;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption)='' then Exit;
|
||
if Order_MJ.IsEmpty then Exit;
|
||
if Trim(Order_MJ.fieldbyname('MCID').AsString)<>'' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete WFB_MJJY_CD1 where MCID='''+Trim(Order_MJ.fieldbyname('MCID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_MJ.Delete;
|
||
end;
|
||
function TfrmMJEdit_other.SaveData():Boolean;
|
||
var
|
||
maxno:String;
|
||
FFreal:Double;
|
||
begin
|
||
try
|
||
ADOCmd.Connection.BeginTrans;
|
||
///<2F><><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>
|
||
with Order_MJ do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(Order_MJ.fieldbyname('MCID').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOTmp,maxno,'MC','WFB_MJJY_CD1',5,1)=False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
maxno:=Trim(Order_MJ.fieldbyname('MCID').AsString);
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from WFB_MJJY_CD1 ');
|
||
sql.Add(' where MCID='''+Trim(maxno)+'''');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if Trim(Order_MJ.fieldbyname('MCID').AsString)='' then
|
||
Append
|
||
else
|
||
Edit;
|
||
FieldByName('MJId').Value:=Trim(Label2.Caption);
|
||
FieldByName('MCID').Value:=Trim(maxno);
|
||
SSetSaveDataCDSNew(ADOCmd,Tv2,Order_MJ,'WFB_MJJY_CD1',0);
|
||
Post;
|
||
end;
|
||
|
||
Order_MJ.Edit;
|
||
Order_MJ.FieldByName('MCID').Value:=Trim(maxno);
|
||
Order_MJ.FieldByName('MJID').Value:=Trim(Label2.Caption);
|
||
Next;
|
||
end;
|
||
end;
|
||
if Trim(MJMaoZ.Text)<>'' then
|
||
begin
|
||
if TryStrToFloat(MJMaoZ.Text,FFreal)=False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if Trim(MJLen.Text)<>'' then
|
||
begin
|
||
if TryStrToFloat(MJLen.Text,FFreal)=False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD>ȷǷ<C8B7><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if Trim(MJSJKZ.Text)<>'' then
|
||
begin
|
||
if TryStrToFloat(MJSJKZ.Text,FFreal)=False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD>طǷ<D8B7><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
if Trim(MJQty2.Text)<>'' then
|
||
begin
|
||
if TryStrToFloat(MJQty2.Text,FFreal)=False then
|
||
begin
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate WFB_MJJY1 Set MJTypeOther='''+Trim(M.Caption)+'''');
|
||
sql.Add(',MJStr1='''+Trim(Ma.Caption)+'''');
|
||
if Trim(MJLen.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJLen='+Trim(MJLen.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJLen=0');
|
||
end;
|
||
if Trim(MJQty1.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJQty1='+Trim(MJQty1.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJQty1=0');
|
||
end;
|
||
if Trim(MJQty2.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJQty2='+Trim(MJQty2.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJQty2=0');
|
||
end;
|
||
if Trim(MJFK.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJFK='+Trim(MJFK.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJFK=0');
|
||
end;
|
||
if Trim(MJMaoZ.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJMaoZ='+Trim(MJMaoZ.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJMaoZ=0');
|
||
end;
|
||
if Trim(MJSJKZ.Text)<>'' then
|
||
begin
|
||
sql.Add(',MJSJKZ='+Trim(MJSJKZ.Text));
|
||
end else
|
||
begin
|
||
sql.Add(',MJSJKZ=0');
|
||
end;
|
||
if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
sql.Add(',MJType=''<27><>Ʒ'' ');
|
||
end else
|
||
if RadioGroup1.ItemIndex=1 then
|
||
begin
|
||
sql.Add(',MJType=''<27><>Ʒ'' ');
|
||
end else
|
||
if RadioGroup1.ItemIndex=2 then
|
||
begin
|
||
sql.Add(',MJType=''<27><><EFBFBD><EFBFBD>'' ');
|
||
end;
|
||
sql.Add(' where MJID='''+Trim(Label2.Caption)+'''');
|
||
|
||
ExecSQL;
|
||
end;
|
||
ADOCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
Result:=False;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if Trim(Label2.Caption)='' then Exit;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27><>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>',Tv2,'Ⱦ<><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27><>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>',Tv2,'Ⱦ<><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmMJEdit_other.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
with ADOTmp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from CK_BanCP_CR1 where MJID='''+Trim(Label2.Caption)+'''');
|
||
Open;
|
||
end;
|
||
if ADOTmp.IsEmpty=False then
|
||
begin
|
||
Application.MessageBox('<27>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>ɾ<EFBFBD><C9BE>!','<27><>ʾ',0);
|
||
Exit;
|
||
end else
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ָܻ<DCBB><D6B8><EFBFBD>','<27><>ʾ',32+4)=IDYES then
|
||
begin
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete WFB_MJJY1 where MJID='''+Trim(Label2.Caption)+'''');
|
||
sql.Add('delete WFB_MJJY_CD1 where MJID='''+Trim(Label2.Caption)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Label2.Caption:='';
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
end.
|