You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

690 lines
21 KiB
Plaintext

11 months ago
unit u_op_ctn_add;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl,
dxDBGrid, DB, ADODB, StdCtrls, DBCtrls, wwdbdatetimepicker, wwdbedit,
Wwdotdot, Wwdbcomb, Mask, RxLookup, ComCtrls, bsSkinTabs, wwdblook,
Grids, Wwdbigrd, Wwdbgrid, DBGridEh, Menus, dxDBTLCl, dxGrClms, DBCtrlsEh;
type
Tfrm_op_ctn_add = class(TForm)
Panel1: TPanel;
bsSkinButton7: TbsSkinButton;
bsSkinButton6: TbsSkinButton;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
t_op_addctn: TADOQuery;
t_op_addctn1: TDataSource;
t_op_ctnmg_detail: TADOQuery;
t_op_ctnmg_detail1: TDataSource;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet2: TbsSkinTabSheet;
bsSkinPanel2: TbsSkinPanel;
bsSkinPanel1: TbsSkinPanel;
Label10: TLabel;
Label5: TLabel;
Label8: TLabel;
Label6: TLabel;
Label2: TLabel;
Label27: TLabel;
bsSkinButton44: TbsSkinButton;
wwDBDateTimePicker1: TwwDBDateTimePicker;
wwDBDateTimePicker2: TwwDBDateTimePicker;
RxDBLookupCombo6: TRxDBLookupCombo;
Edit1: TEdit;
Edit3: TEdit;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column1: TdxDBGridColumn;
dxDBGrid1Column2: TdxDBGridColumn;
dxDBGrid1Column3: TdxDBGridColumn;
dxDBGrid1Column7: TdxDBGridColumn;
dxDBGrid1Column8: TdxDBGridColumn;
dxDBGrid1Column9: TdxDBGridColumn;
dxDBGrid1Column10: TdxDBGridColumn;
Label4: TLabel;
Label7: TLabel;
Label9: TLabel;
Label15: TLabel;
Label20: TLabel;
Label1: TLabel;
Label3: TLabel;
DBEdit1: TDBEdit;
RxDBLookupCombo2: TRxDBLookupCombo;
DBMemo1: TDBMemo;
DBEdit2: TDBEdit;
wwDBDateTimePicker5: TwwDBDateTimePicker;
wwDBDateTimePicker3: TwwDBDateTimePicker;
bsSkinGroupBox1: TbsSkinGroupBox;
wwDBGrid1: TwwDBGrid;
wwDBComboBox1: TwwDBComboBox;
wwDBLookupComboctn: TwwDBLookupCombo;
bsSkinPanel3: TbsSkinPanel;
bsSkinButton3: TbsSkinButton;
bsSkinButton8: TbsSkinButton;
bsSkinButton10: TbsSkinButton;
bsSkinButton11: TbsSkinButton;
wwDBLookupCombo3: TwwDBLookupCombo;
wwDBLookupCombo1: TwwDBLookupCombo;
t_op_ctnmg_status: TADOQuery;
wwDBComboBox3: TwwDBComboBox;
Label11: TLabel;
dxDBGrid1Column11: TdxDBGridColumn;
Label12: TLabel;
wwDBComboBox2: TwwDBComboBox;
bsSkinGroupBox2: TbsSkinGroupBox;
bsSkinSplitter1: TbsSkinSplitter;
bsSkinPanel5: TbsSkinPanel;
Label13: TLabel;
Label14: TLabel;
Label16: TLabel;
Label18: TLabel;
bsSkinButton12: TbsSkinButton;
Edit4: TEdit;
RxDBLookupCombo9: TRxDBLookupCombo;
Edit6: TEdit;
RxDBLookupCombo4: TRxDBLookupCombo;
dxDBGrid2: TdxDBGrid;
dxDBGridColumn1: TdxDBGridColumn;
dxDBGridColumn2: TdxDBGridColumn;
dxDBGridColumn3: TdxDBGridColumn;
dxDBGridColumn4: TdxDBGridColumn;
dxDBGridColumn5: TdxDBGridColumn;
dxDBGridColumn6: TdxDBGridColumn;
dxDBGridColumn7: TdxDBGridColumn;
dxDBGrid2Column8: TdxDBGridColumn;
dxDBGrid2Column9: TdxDBGridCheckColumn;
dxDBGrid2Column10: TdxDBGridColumn;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
t_ctn_detail: TADOQuery;
t_ctn_detail1: TDataSource;
RxDBLookupCombo1: TRxDBLookupCombo;
Label17: TLabel;
Label19: TLabel;
DBNumberEditEh1: TDBNumberEditEh;
bsSkinButton13: TbsSkinButton;
bsSkinButton14: TbsSkinButton;
dxDBGrid1Column12: TdxDBGridColumn;
procedure bsSkinButton5Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure bsSkinButton7Click(Sender: TObject);
procedure bsSkinButton6Click(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
procedure bsSkinButton44Click(Sender: TObject);
procedure t_op_ctnmg_detailBeforeInsert(DataSet: TDataSet);
procedure dxDBGrid1DblClick(Sender: TObject);
procedure t_op_addctnBeforePost(DataSet: TDataSet);
procedure t_op_ctnmg_detailAfterInsert(DataSet: TDataSet);
procedure t_op_ctnmg_detailBeforePost(DataSet: TDataSet);
procedure wwDBLookupComboctnChange(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure bsSkinButton8Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure bsSkinButton11Click(Sender: TObject);
procedure t_op_addctnBeforeDelete(DataSet: TDataSet);
procedure t_op_ctnmg_detailBeforeEdit(DataSet: TDataSet);
procedure t_op_ctnmg_detailAfterPost(DataSet: TDataSet);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure t_op_addctnAfterInsert(DataSet: TDataSet);
procedure bsSkinButton12Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure bsSkinButton13Click(Sender: TObject);
procedure bsSkinButton14Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_op_ctn_add: Tfrm_op_ctn_add;
implementation
uses u_main, my_sys_function, u_data_share;
{$R *.dfm}
procedure Tfrm_op_ctn_add.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_op_ctn_add.FormShow(Sender: TObject);
begin
if not frm_data_share.v_code_port.Active then
frm_data_share.v_code_port.open;
t_op_addctn.open;
t_op_ctnmg_detail.Close;
t_op_ctnmg_detail.Open;
end;
procedure Tfrm_op_ctn_add.bsSkinButton7Click(Sender: TObject);
begin
if not t_op_addctn.Bof then
t_op_addctn.Prior;
end;
procedure Tfrm_op_ctn_add.bsSkinButton6Click(Sender: TObject);
begin
if not t_op_addctn.eof then
t_op_addctn.next;
end;
procedure Tfrm_op_ctn_add.bsSkinButton1Click(Sender: TObject);
begin
t_op_addctn.Insert;
bsSkinPageControl1.ActivePageIndex:=1;
end;
procedure Tfrm_op_ctn_add.bsSkinButton2Click(Sender: TObject);
begin
table_post(t_op_ctnmg_detail);
table_post(t_op_addctn);
end;
procedure Tfrm_op_ctn_add.bsSkinButton4Click(Sender: TObject);
begin
table_delete(t_op_addctn);
end;
procedure Tfrm_op_ctn_add.bsSkinButton44Click(Sender: TObject);
var
ctnstr:string;
begin
ctnstr:='';
t_op_ctnmg_detail.Close;
t_op_addctn.close;
t_op_addctn.SQL.clear;
t_op_addctn.SQL.add('select * from t_op_addctn where 1=1 ');
if Edit3.Text<>'' then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B5A5>='+''''+edit3.text+'''');
if wwDBDateTimePicker1.text<>''then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>>='+''''+wwDBDateTimePicker1.text+'''');
if wwDBDateTimePicker2.text<>''then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><='+''''+wwDBDateTimePicker2.text+'''');
if RxDBLookupCombo6.DisplayValue<>'' then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD><EFBFBD>乫˾='+''''+RxDBLookupCombo6.DisplayValues[1]+'''');
if wwDBLookupCombo1.text<>'' then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>='+''''+wwDBLookupCombo1.text+'''');
if wwDBComboBox3.Text<>'' then
t_op_addctn.SQL.add(' and <20><><EFBFBD><EFBFBD>='+''''+wwDBComboBox3.text+'''');
if Edit1.Text<>'' then
ctnstr:=ctnstr+' and <20><><EFBFBD><EFBFBD>='+''''+edit1.Text+'''';
if ctnstr<>'' then
t_op_addctn.SQL.add(' and id in (select addctnid from t_op_ctnmg_detail where 1=1 '+ctnstr+')');
t_op_addctn.SQL.add(' order by id');
t_op_addctn.open;
t_op_ctnmg_detail.open;
if Edit1.Text<>'' then
t_op_ctnmg_detail.Locate('<27><><EFBFBD><EFBFBD>',Edit1.Text,[]);
end;
procedure Tfrm_op_ctn_add.t_op_ctnmg_detailBeforeInsert(DataSet: TDataSet);
begin
if t_op_addctn.State in [dsedit,dsinsert] then t_op_addctn.Post;
if t_op_addctn.IsEmpty then begin
ShowMessage('<27><><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B5A5>');
Exit;
end;
end;
procedure Tfrm_op_ctn_add.dxDBGrid1DblClick(Sender: TObject);
begin
bsSkinPageControl1.ActivePageIndex:=1;
end;
procedure Tfrm_op_ctn_add.t_op_addctnBeforePost(DataSet: TDataSet);
begin
table_before_post(t_op_addctn,'<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>');
table_before_post(t_op_addctn,'<27><><EFBFBD><EFBFBD><EFBFBD>乫˾');
table_before_post(t_op_addctn,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>');
table_before_post(t_op_addctn,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>');
table_before_post(t_op_addctn,'<27><><EFBFBD><EFBFBD>');
if t_op_addctn.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B5A5>').AsString='' then
t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4B5A5>']:=get_no(date,'MC');
end;
procedure Tfrm_op_ctn_add.t_op_ctnmg_detailAfterInsert(DataSet: TDataSet);
function getMaxNo:Integer;
var
aQuery:TADOQuery;
stno:Integer;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('select addno from t_op_ctnmg_detail where addctnid='+t_op_addctn.fieldbyname('id').AsString+' order by addno');
open;
if IsEmpty then
result:=1
else begin
First;
stno:=0;
while not Eof do begin
if (fieldbyname('addno').AsInteger=(stno+1)) then
stno:=fieldbyname('addno').AsInteger;
Next;
end;
Result:=stno+1;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
begin
t_op_ctnmg_detail['addctnid']:=t_op_addctn['id'];
t_op_ctnmg_detail['addno']:=getMaxNo;
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'];
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>״̬']:='<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>';
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=get_id;
t_op_ctnmg_detail['<27><>ǰ״̬']:='<27><><EFBFBD><EFBFBD>';
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=False;
t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>̬']:=t_op_addctn['<27><><EFBFBD><EFBFBD>'];
t_op_ctnmg_detail['<27><>̬ʱ<CCAC><CAB1>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>'];
t_op_ctnmg_detail['<27><>ǰ<EFBFBD>ص<EFBFBD>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>'];
t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>վ']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD>䳡վ'];
end;
procedure Tfrm_op_ctn_add.t_op_ctnmg_detailBeforePost(DataSet: TDataSet);
function isadd:Boolean;
var
aQuery:TADOQuery;
begin
result:=True;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
close;SQL.Clear;
sql.Add('select count(*) as ct from t_op_ctnmg_detail where <20><><EFBFBD><EFBFBD>='''+t_op_ctnmg_detail.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString+'''');
sql.Add(' and ctnid<>'+t_op_ctnmg_detail.fieldbyname('ctnid').AsString);
sql.Add(' and (<28><>ǰ<EFBFBD><C7B0>̬=''<27><><EFBFBD><EFBFBD>'' or <20><>ǰ<EFBFBD><C7B0>̬=''<27><><EFBFBD><EFBFBD>'')');
Open;
if IsEmpty then
else
if FieldByName('ct').AsInteger>=1 then
result:=false;
end;
finally
end;
end;
begin
// table_before_post(t_op_ctnmg_detail,'<27><><EFBFBD><EFBFBD>');
table_before_post(t_op_ctnmg_detail,'<27><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>');
table_before_post(t_op_ctnmg_detail,'<27><><EFBFBD><EFBFBD>');
table_before_post(t_op_ctnmg_detail,'<27><>ǰ<EFBFBD><C7B0>̬');
table_before_post(t_op_ctnmg_detail,'<27><>̬ʱ<CCAC><CAB1>');
table_before_post(t_op_ctnmg_detail,'<27><>ǰ<EFBFBD>ص<EFBFBD>');
table_before_post(t_op_ctnmg_detail,'<27><>ǰ״̬');
end;
procedure Tfrm_op_ctn_add.wwDBLookupComboctnChange(Sender: TObject);
begin
if (t_op_ctnmg_detail.State=dsedit)or(t_op_ctnmg_detail.State=dsinsert) then
begin
if frm_data_share.t_code_ctn.Locate('<27><><EFBFBD><EFBFBD>',wwDBLookupComboctn.text,[]) then
begin
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=frm_data_share.t_code_ctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ'];
end
else
begin
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:='';
end;
end;
end;
procedure Tfrm_op_ctn_add.bsSkinButton3Click(Sender: TObject);
begin
t_op_ctnmg_detail.Append;
end;
procedure Tfrm_op_ctn_add.bsSkinButton8Click(Sender: TObject);
begin
table_post(t_op_ctnmg_detail);
end;
procedure Tfrm_op_ctn_add.bsSkinButton10Click(Sender: TObject);
var
aQuery:TADOQuery;
i:integer;
str_list:Tstringlist;
begin
if t_op_ctnmg_detail.isempty then
exit;
if application.MessageBox('<27><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?','<27><><EFBFBD><EFBFBD>:',MB_OKCANCEL)<>IDOK then
exit;
aQuery:=CreateAdoQuery;
if wwDBGrid1.SelectedList.Count>=1 then
begin
try
t_op_ctnmg_detail.DisableControls;
str_list:=Tstringlist.create;
for i:=0 to wwDBGrid1.SelectedList.Count-1 do
begin
t_op_ctnmg_detail.GotoBookmark(pointer(wwDBGrid1.SelectedList[i]));
str_list.Add(t_op_ctnmg_detail.fieldbyname('ctnID').asstring);
end;
for i:=0 to str_list.Count-1 do
begin
if t_op_ctnmg_detail.locate('ctnID',str_list[i],[]) then
begin
with aQuery do
begin
close;sql.Clear;
sql.add('select count(*) as ct from t_op_ctnmg_detail where returnid='+str_list[i]);
open;
if IsEmpty then begin
end else begin
if FieldByName('ct').AsInteger=0 then
else begin
close;
sql.text:='update t_op_ctnmg_detail set returnid=0 where returnid='+str_list[i];
ExecSQL;
end;
end;
end;
t_op_ctnmg_detail.Delete;
end;
end;
finally
str_list.free;
t_op_ctnmg_detail.EnableControls;
end;
end
else
begin
with aQuery do
begin
close;sql.Clear;
sql.add('select count(*) as ct from t_op_ctnmg_detail where returnid='+t_op_ctnmg_detail.fieldbyname('ctnid').AsString);
open;
if IsEmpty then begin
end else begin
if FieldByName('ct').AsInteger=0 then
else begin
close;
sql.text:='update t_op_ctnmg_detail set returnid=0 where returnid='+t_op_ctnmg_detail.fieldbyname('ctnid').AsString;
ExecSQL;
end;
end;
end;
t_op_ctnmg_detail.delete;
end;
t_op_ctnmg_detail.Refresh;
{
try
with aQuery do
begin
close;sql.Clear;
sql.add('select count(*) as ct from t_op_ctnmg_detail where returnid='+t_op_ctnmg_detail.fieldbyname('ctnid').AsString);
open;
if IsEmpty then begin
end else begin
if FieldByName('ct').AsInteger=0 then
else begin
close;
sql.text:='update t_op_ctnmg_detail set returnid=0 where returnid='+t_op_ctnmg_detail.fieldbyname('ctnid').AsString;
ExecSQL;
end;
end;
end;
finally
table_delete(t_op_ctnmg_detail);
FreeAndNil(aQuery);
end;
}
try
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_op_ctn_add.bsSkinButton11Click(Sender: TObject);
begin
table_Cancel(t_op_ctnmg_detail);
end;
procedure Tfrm_op_ctn_add.t_op_addctnBeforeDelete(DataSet: TDataSet);
begin
if not t_op_ctnmg_detail.IsEmpty then begin
MessageDlg('<27><><EFBFBD>ڼ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>',mtWarning,[mbok],0);
Abort;
end;
end;
procedure Tfrm_op_ctn_add.t_op_ctnmg_detailBeforeEdit(DataSet: TDataSet);
begin
if not ((t_op_ctnmg_detail.FieldByName('<27><>ǰ<EFBFBD><C7B0>̬').AsString='<27><><EFBFBD><EFBFBD>') or (t_op_ctnmg_detail.FieldByName('<27><>ǰ<EFBFBD><C7B0>̬').AsString='') or (t_op_ctnmg_detail.FieldByName('<27><>ǰ<EFBFBD><C7B0>̬').AsString='<27><><EFBFBD><EFBFBD>')) then begin
MessageDlg('<27><>ǰ<EFBFBD><C7B0>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ģ<DEB8>',mtWarning,[mbok],0);
Abort;
end;
end;
procedure Tfrm_op_ctn_add.t_op_ctnmg_detailAfterPost(DataSet: TDataSet);
begin
t_op_ctnmg_status.Close;
t_op_ctnmg_status.SQL.text:='select * from t_op_ctnmg_status where (<28><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>=''<27><><EFBFBD><EFBFBD>'' or <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>=''<27><><EFBFBD><EFBFBD>'') and ctnid='''+t_op_ctnmg_detail.fieldbyname('ctnid').AsString+'''';
t_op_ctnmg_status.open;
if t_op_ctnmg_status.IsEmpty then begin
t_op_ctnmg_status.Insert;
t_op_ctnmg_status['ctnid']:=t_op_ctnmg_detail['ctnid'];
t_op_ctnmg_status['<27><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>̬'];
t_op_ctnmg_status['<27><>̬ʱ<CCAC><CAB1>']:=t_op_ctnmg_detail['<27><>̬ʱ<CCAC><CAB1>'];
t_op_ctnmg_status['״̬']:=t_op_ctnmg_detail['<27><>ǰ״̬'];
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>']:=t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>'];
t_op_ctnmg_status['<27><>ע']:=t_op_ctnmg_detail['<27><>ע'];
t_op_ctnmg_status['<27>ص<EFBFBD>']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD>ص<EFBFBD>'];
t_op_ctnmg_status['<27><>վ']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>վ'];
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>Ա']:=employee;
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>']:=date;
t_op_ctnmg_status.post;
end else begin
t_op_ctnmg_status.Edit;
t_op_ctnmg_status['<27><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>̬'];
t_op_ctnmg_status['<27><>̬ʱ<CCAC><CAB1>']:=t_op_ctnmg_detail['<27><>̬ʱ<CCAC><CAB1>'];
t_op_ctnmg_status['״̬']:=t_op_ctnmg_detail['<27><>ǰ״̬'];
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>']:=t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>'];
t_op_ctnmg_status['<27><>ע']:=t_op_ctnmg_detail['<27><>ע'];
t_op_ctnmg_status['<27>ص<EFBFBD>']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD>ص<EFBFBD>'];
t_op_ctnmg_status['<27><>վ']:=t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>վ'];
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>Ա']:=employee;
t_op_ctnmg_status['<27><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>']:=date;
t_op_ctnmg_status.post;
end;
t_op_ctnmg_detail.Requery();
end;
procedure Tfrm_op_ctn_add.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
table_post(t_op_ctnmg_detail);
table_post(t_op_addctn);
savereggrid(dxdbgrid1,caption);
frm_op_ctn_add.Hide;
frm_op_ctn_add.ManualFloat(frm_op_ctn_add.BoundsRect );
frm_main.freeTabs('frm_op_ctn_add');
action:=cafree;
frm_op_ctn_add:=nil;
end;
procedure Tfrm_op_ctn_add.t_op_addctnAfterInsert(DataSet: TDataSet);
begin
t_op_addctn['¼<><C2BC><EFBFBD><EFBFBD>']:=employee;
t_op_addctn['¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Date;
t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>']:=Date;
t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>']:=Date;
t_op_addctn['<27><><EFBFBD><EFBFBD>']:='<27><><EFBFBD><EFBFBD>';
end;
procedure Tfrm_op_ctn_add.bsSkinButton12Click(Sender: TObject);
var
ctnstr:string;
begin
ctnstr:='';
t_ctn_detail.close;
t_ctn_detail.SQL.clear;
t_ctn_detail.SQL.add('select * from t_op_ctnmg_detail where (<28><>ǰ<EFBFBD><C7B0>̬=''<27><><EFBFBD><EFBFBD>'' or <20><>ǰ<EFBFBD><C7B0>̬=''<27><><EFBFBD><EFBFBD>'') and ((returnid is null) or (returnid=0))');
if Edit4.Text<>'' then
ctnstr:=ctnstr+' and <20><><EFBFBD><EFBFBD>='+''''+edit4.Text+'''';
if RxDBLookupCombo9.DisplayValue<>'' then
ctnstr:=ctnstr+' and <20><>ǰ<EFBFBD>ص<EFBFBD>='+''''+RxDBLookupCombo9.DisplayValue+'''';
if Edit6.Text<>'' then
ctnstr:=ctnstr+' and <20><>ǰ<EFBFBD><C7B0>վ='+''''+edit6.Text+'''';
if RxDBLookupCombo4.DisplayValue<>'' then
ctnstr:=ctnstr+' and <20><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>='+''''+RxDBLookupCombo4.DisplayValues[0]+'''';
if ctnstr<>'' then
t_ctn_detail.SQL.add(ctnstr);
t_ctn_detail.SQL.add(' order by ctnid');
t_ctn_detail.open;
end;
procedure Tfrm_op_ctn_add.N1Click(Sender: TObject);
var
i:Integer;
begin
if t_op_addctn.State in [dsedit,dsinsert] then t_op_addctn.Post;
if not t_op_ctnmg_detail.Active then t_op_ctnmg_detail.Open;
try
t_ctn_detail.DisableControls;
for i:=0 to dxDBGrid2.SelectedCount-1 do
begin
t_ctn_detail.GotoBookmark(pointer(dxDBGrid2.selectedrows[i]));
t_op_ctnmg_detail.Insert;
t_op_ctnmg_detail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring:=t_ctn_detail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring;
t_op_ctnmg_detail.fieldbyname('<27><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>').asstring:=t_ctn_detail.fieldbyname('<27><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>').asstring;
t_op_ctnmg_detail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring:=t_ctn_detail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring;
t_op_ctnmg_detail.post;
t_ctn_detail.Edit;
t_ctn_detail['returnid']:=t_op_ctnmg_detail['ctnid'];
t_ctn_detail.Post;
end;
finally
t_ctn_detail.Requery();
t_ctn_detail.EnableControls;
end;
end;
procedure Tfrm_op_ctn_add.bsSkinButton13Click(Sender: TObject);
begin
table_Cancel(t_op_addctn);
end;
procedure Tfrm_op_ctn_add.bsSkinButton14Click(Sender: TObject);
function getMaxNo:Integer;
var
aQuery:TADOQuery;
stno:Integer;
begin
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('select addno from t_op_ctnmg_detail where addctnid='+t_op_addctn.fieldbyname('id').AsString+' order by addno');
open;
if IsEmpty then
result:=1
else begin
First;
stno:=0;
while not Eof do begin
if (fieldbyname('addno').AsInteger=(stno+1)) then
stno:=fieldbyname('addno').AsInteger;
Next;
end;
Result:=stno+1;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
var i,CtnCount :integer;
begin
if MessageDlg('ȷʵҪ<CAB5><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
exit;
CtnCount:=t_op_addctn.FieldByName('<27><><EFBFBD><EFBFBD>').AsInteger;
if t_op_addctn.FieldByName('<27><><EFBFBD><EFBFBD>').AsString='' then
begin
ShowMessage('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>');
exit;
end;
if CtnCount>=1 then
begin
for i:=0 to CtnCount-1 do
begin
t_op_ctnmg_detail.Append;
t_op_ctnmg_detail['addctnid']:=t_op_addctn['id'];
t_op_ctnmg_detail['addno']:=getMaxNo;
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'];
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>״̬']:='<27><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>';
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=get_id;
t_op_ctnmg_detail['<27><>ǰ״̬']:='<27><><EFBFBD><EFBFBD>';
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=False;
t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>̬']:=t_op_addctn['<27><><EFBFBD><EFBFBD>'];
t_op_ctnmg_detail['<27><>̬ʱ<CCAC><CAB1>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>'];
t_op_ctnmg_detail['<27><>ǰ<EFBFBD>ص<EFBFBD>']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>'];
t_op_ctnmg_detail['<27><>ǰ<EFBFBD><C7B0>վ']:=t_op_addctn['<27><><EFBFBD><EFBFBD><EFBFBD>䳡վ'];
t_op_ctnmg_detail.FieldByName('<27><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>').AsString:=t_op_addctn.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
if frm_data_share.t_code_ctn.Locate('<27><><EFBFBD><EFBFBD>',t_op_ctnmg_detail.FieldByName('<27><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>').AsString,[]) then
begin
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:=frm_data_share.t_code_ctn['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ'];
end
else
begin
t_op_ctnmg_detail['<27><><EFBFBD><EFBFBD>']:='';
end;
t_op_ctnmg_detail.Post;
end;
end
else
begin
end;
end;
end.