unit u_info_price_managelistset; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dbcgrids, bsSkinCtrls, bsdbctrls, StdCtrls, Mask, DBCtrls, DB, ADODB; type Tfrm_info_price_managelistset = class(TForm) t_price_Detail: TADOQuery; t_price_Detail1: TDataSource; t_price_List_Detail1: TDataSource; t_price_List_Detail: TADOQuery; bsSkinPanel4: TbsSkinPanel; Label4: TLabel; bsSkinButton15: TbsSkinButton; bsSkinButton16: TbsSkinButton; DBEdit1: TDBEdit; bsSkinDBCheckRadioBox1: TbsSkinDBCheckRadioBox; bsSkinGroupBox1: TbsSkinGroupBox; DBCtrlGrid1: TDBCtrlGrid; Label1: TLabel; Label5: TLabel; DBEdit2: TDBEdit; bsSkinButton17: TbsSkinButton; bsSkinButton18: TbsSkinButton; bsSkinButton19: TbsSkinButton; bsSkinColorDialog1: TColorDialog; DBCheckBox1: TDBCheckBox; DBCheckBox2: TDBCheckBox; DBCheckBox3: TDBCheckBox; DBCheckBox4: TDBCheckBox; DBCheckBox5: TDBCheckBox; DBCheckBox6: TDBCheckBox; DBCheckBox7: TDBCheckBox; DBComboBoxGoods: TDBComboBox; bsSkinDBCheckRadioBox2: TbsSkinDBCheckRadioBox; DBEdit3: TDBEdit; Label2: TLabel; Label3: TLabel; DBText1: TDBText; DBEdit5: TDBEdit; DBEdit4: TDBEdit; Label6: TLabel; procedure bsSkinButton15Click(Sender: TObject); procedure DBEdit1Click(Sender: TObject); procedure bsSkinButton17Click(Sender: TObject); procedure bsSkinButton19Click(Sender: TObject); procedure bsSkinButton18Click(Sender: TObject); procedure bsSkinButton16Click(Sender: TObject); procedure t_price_List_DetailAfterInsert(DataSet: TDataSet); procedure t_price_DetailBeforeDelete(DataSet: TDataSet); procedure t_price_DetailAfterInsert(DataSet: TDataSet); procedure FormShow(Sender: TObject); procedure t_price_DetailBeforePost(DataSet: TDataSet); procedure t_price_List_DetailBeforeEdit(DataSet: TDataSet); procedure DBEdit5Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_info_price_managelistset: Tfrm_info_price_managelistset; implementation uses u_info_price_managelist, my_sys_function, u_data_share; {$R *.dfm} procedure Tfrm_info_price_managelistset.bsSkinButton15Click( Sender: TObject); var S:String; begin if t_price_Detail.State in [dsedit,dsinsert] then t_price_Detail.Post; if t_price_List_Detail.State in [dsedit,dsinsert] then t_price_List_Detail.Post; t_price_Detail.First; S:=''; if t_price_List_Detail['是否底价'] then begin while not t_price_Detail.Eof do begin if t_price_Detail['周一'] then S:=S+'一'; if t_price_Detail['周二'] then S:=S+'二'; if t_price_Detail['周三'] then S:=S+'三'; if t_price_Detail['周四'] then S:=S+'四'; if t_price_Detail['周五'] then S:=S+'五'; if t_price_Detail['周六'] then S:=S+'六'; if t_price_Detail['周日'] then S:=S+'日'; if S<>'' then if t_price_Detail.FieldByName('品名').AsString<>'' then S:=S+':'+t_price_Detail.FieldByName('品名').AsString+':'+t_price_Detail.FieldByName('运价').AsString+';' else S:=S+':'+t_price_Detail.FieldByName('运价').AsString+';' else if t_price_Detail.FieldByName('品名').AsString<>'' then S:=t_price_Detail.FieldByName('品名').AsString+':'+t_price_Detail.FieldByName('运价').AsString+';' else S:=t_price_Detail.FieldByName('运价').AsString+';'; t_price_Detail.Next; end; end else begin while not t_price_Detail.Eof do begin if t_price_Detail['周一'] then S:=S+'一'; if t_price_Detail['周二'] then S:=S+'二'; if t_price_Detail['周三'] then S:=S+'三'; if t_price_Detail['周四'] then S:=S+'四'; if t_price_Detail['周五'] then S:=S+'五'; if t_price_Detail['周六'] then S:=S+'六'; if t_price_Detail['周日'] then S:=S+'日'; if S<>'' then if t_price_Detail.FieldByName('品名').AsString<>'' then S:=S+':'+t_price_Detail.FieldByName('品名').AsString+':'+t_price_Detail.FieldByName('备注').AsString+';' else S:=S+':'+t_price_Detail.FieldByName('备注').AsString+';' else if t_price_Detail.FieldByName('品名').AsString<>'' then S:=t_price_Detail.FieldByName('品名').AsString+':'+t_price_Detail.FieldByName('备注').AsString+';' else S:=t_price_Detail.FieldByName('备注').AsString+';'; t_price_Detail.Next; end; S:='报'+S; end; frm_info_price_managelist.t_price_list.Edit; frm_info_price_managelist.t_price_list.fieldByName(t_price_List_Detail['字段']).asString:=S; frm_info_price_managelist.t_price_list.Post; Close; end; procedure Tfrm_info_price_managelistset.DBEdit1Click(Sender: TObject); begin if bsSkinColorDialog1.Execute then begin t_price_List_Detail.edit; t_price_List_Detail['颜色']:=ColorToString(bsSkinColorDialog1.Color); t_price_List_Detail.post; end; end; procedure Tfrm_info_price_managelistset.bsSkinButton17Click( Sender: TObject); begin t_price_Detail.Insert; end; procedure Tfrm_info_price_managelistset.bsSkinButton19Click( Sender: TObject); begin t_price_Detail.Delete; end; procedure Tfrm_info_price_managelistset.bsSkinButton18Click( Sender: TObject); begin if t_price_Detail.State in [dsedit,dsinSert] then t_price_Detail.Post; end; procedure Tfrm_info_price_managelistset.bsSkinButton16Click( Sender: TObject); begin t_price_Detail.Cancel; t_price_List_Detail.Cancel; close; end; procedure Tfrm_info_price_managelistset.t_price_List_DetailAfterInsert( DataSet: TDataSet); var cntrstr:String; begin // cntrstr:=RxDBLookupCombo4.DisplayValues[0]; { t_price_List_Detail.Close; t_price_List_Detail.SQL.Add('select * from t_price_List_Detail where 箱型='''+cntrstr+''' and 年份='+wwDBComboBox20.Text+' and 周次='+Edit1.Text+' AND 目的港代码='''+t_price_list['目的港代码']+''' and 字段='''+dxDBGrid1.FocusedField.FieldName+''''); t_price_List_Detail.Open; t_price_Detail.Open; t_price_List_Detail['年份']:=wwDBComboBox20.Text; t_price_List_Detail['周次']:=Edit1.Text; t_price_List_Detail['必须发布运价']:=1; t_price_List_Detail['箱型']:=cntrstr; t_price_List_Detail['目的港']:=t_price_list['目的港']; t_price_List_Detail['目的港代码']:=t_price_list['目的港代码']; t_price_List_Detail['颜色']:='clblack'; t_price_List_Detail['船公司']:=cntrstr; t_price_List_Detail['字段']:=cntrstr; } end; procedure Tfrm_info_price_managelistset.t_price_DetailBeforeDelete( DataSet: TDataSet); var aQuery:TADOQuery; begin if t_price_List_Detail['审核状态']='通过' then begin ShowMessage('已审核通过,无法修改'); Abort; end; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; sql.Add('Select * from t_ch_fee where 运价编号='+t_price_Detail.FieldByName('ID').AsString); Open; if not IsEmpty then begin MessageDlg('此运价已发布,不能删除此运价!',mtWarning,[mbOk],0); Abort; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_info_price_managelistset.t_price_DetailAfterInsert( DataSet: TDataSet); var aQuery3:TADOQuery; begin t_price_detail['LD_ID']:=t_price_List_Detail['LD_ID']; t_price_detail['运价']:=0; t_price_detail['周一']:=0; t_price_detail['周二']:=0; t_price_detail['周三']:=0; t_price_detail['周四']:=0; t_price_detail['周五']:=0; t_price_detail['周六']:=0; t_price_detail['周日']:=0; aQuery3:=CreateAdoQuery; try aQuery3.Close;aQuery3.SQL.Clear; aQuery3.SQL.Add('Select 星期 from t_vessel_plan where 年份='+t_price_List_Detail['年份']+' and 周次='+t_price_List_Detail['周次']+' and 船公司='''+t_price_List_Detail['船公司']+''''); aQuery3.Open; t_price_detail.Insert; aQuery3.First; while not aQuery3.Eof do begin if Trim(aQuery3['星期'])='一' then t_price_detail['周一']:=1; if Trim(aQuery3['星期'])='二' then t_price_detail['周二']:=1; if Trim(aQuery3['星期'])='三' then t_price_detail['周三']:=1; if Trim(aQuery3['星期'])='四' then t_price_detail['周四']:=1; if Trim(aQuery3['星期'])='五' then t_price_detail['周五']:=1; if Trim(aQuery3['星期'])='六' then t_price_detail['周六']:=1; if Trim(aQuery3['星期'])='日' then t_price_detail['周日']:=1; aQuery3.Next; end; t_price_detail.Post; finally FreeAndNil(aQuery3); end; end; procedure Tfrm_info_price_managelistset.FormShow(Sender: TObject); begin if frm_data_share.t_code_goods.Active then frm_data_share.t_code_goods.Open; frm_data_share.t_code_goods.First; DBComboBoxGoods.Items.Clear; while not frm_data_share.t_code_goods.Eof do begin DBComboBoxGoods.Items.Add(frm_data_share.t_code_goods.FieldByName('货物名称').AsString); frm_data_share.t_code_goods.Next; end; end; procedure Tfrm_info_price_managelistset.t_price_DetailBeforePost( DataSet: TDataSet); var S:String; begin if t_price_List_Detail['是否底价'] then begin if t_price_Detail['运价']=0 then begin ShowMessage('如果是底价,运价必须有值!'); Abort; end; end; if t_price_Detail['周一'] then S:=S+'一'; if t_price_Detail['周二'] then S:=S+'二'; if t_price_Detail['周三'] then S:=S+'三'; if t_price_Detail['周四'] then S:=S+'四'; if t_price_Detail['周五'] then S:=S+'五'; if t_price_Detail['周六'] then S:=S+'六'; if t_price_Detail['周日'] then S:=S+'日'; // t_price_Detail['备注']:=S; end; procedure Tfrm_info_price_managelistset.t_price_List_DetailBeforeEdit( DataSet: TDataSet); begin if t_price_List_Detail['审核状态']='通过' then begin ShowMessage('已审核通过,无法修改'); Abort; end; end; procedure Tfrm_info_price_managelistset.DBEdit5Change(Sender: TObject); begin if DBEdit5.Text='驳回' then begin Label6.Visible:=True; DBEdit4.Visible:=True; end else begin Label6.Visible:=false; DBEdit4.Visible:=false; end; end; end.