unit u_info_plan_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, BusinessSkinForm,DateUtils; type Tfrm_info_plan_add = class(TForm) bsSkinGroupBox1: TbsSkinGroupBox; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinCheckRadioBox3: TbsSkinCheckRadioBox; bsSkinGroupBox2: TbsSkinGroupBox; Notebook1: TbsSkinNotebook; wwDBDateTimePicker1: TwwDBDateTimePicker; Label1: TLabel; Label2: TLabel; Edit1: TEdit; Edit3: TEdit; Label3: TLabel; Edit2: TEdit; Edit4: TEdit; Label4: TLabel; Edit5: TEdit; Label5: TLabel; Edit6: TEdit; bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; Edit7: TEdit; Label6: TLabel; Label7: TLabel; Edit8: TEdit; Label8: TLabel; Label9: TLabel; procedure bsSkinCheckRadioBox1Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure Edit6Change(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure Edit1Change(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_info_plan_add: Tfrm_info_plan_add; implementation uses u_main, my_sys_function, u_info_plan_individual; {$R *.dfm} procedure Tfrm_info_plan_add.bsSkinCheckRadioBox1Click(Sender: TObject); begin Notebook1.PageIndex:=0; wwDBDateTimePicker1.Date:=DATE; end; procedure Tfrm_info_plan_add.FormShow(Sender: TObject); begin Notebook1.PageIndex:=0; wwDBDateTimePicker1.Date:=DATE; end; procedure Tfrm_info_plan_add.bsSkinCheckRadioBox2Click(Sender: TObject); begin Notebook1.PageIndex:=1; Edit7.text:=inttostr(YearOf(Date)); Edit1.Text:=inttostr(WeekofYear(Date)); end; procedure Tfrm_info_plan_add.bsSkinCheckRadioBox3Click(Sender: TObject); begin Notebook1.PageIndex:=2; Edit8.text:=inttostr(YearOf(Date)); Edit6.Text:=inttostr(MonthOf(Date)); end; procedure Tfrm_info_plan_add.Edit6Change(Sender: TObject); begin if (Edit6.Text='')or(Edit8.Text='') then begin Edit4.Text:=''; Edit5.Text:=''; exit; end; try strtoint(Edit6.Text); strtoint(Edit8.Text); except Edit4.Text:=''; Edit5.Text:=''; exit; end; if (strtoint(Edit6.Text)<1)or(strtoint(Edit6.Text)>12) or (strtoint(Edit8.text)<2006)or(strtoint(Edit8.text)>2020) then begin Edit4.Text:=''; Edit5.Text:=''; exit; end; IF(strtoint(Edit6.Text)=12) THEN BEGIN Edit4.Text:=Edit8.text+'-'+Edit6.Text+'-'+'01'; Edit5.Text:=datetostr(strtodatetime(inttostr(strtoint(Edit8.text)+1)+'-'+'01'+'-'+'01')-1); END ELSE begin Edit4.Text:=Edit8.text+'-'+Edit6.Text+'-'+'01'; Edit5.Text:=datetostr(strtodatetime(Edit8.text+'-'+inttostr(strtoint(Edit6.Text)+1)+'-'+'01')-1); end; end; procedure Tfrm_info_plan_add.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_info_plan_add.Edit1Change(Sender: TObject); begin if (Edit7.text='')or(Edit1.text='') then begin Edit3.text:=''; Edit2.text:=''; exit; end; try strtoint(Edit7.text); strtoint(Edit1.text); except Edit3.text:=''; Edit2.text:=''; exit; end; if (strtoint(Edit7.text)<2006)or(strtoint(Edit7.text)>2020) or (strtoint(Edit1.text)<1) or(strtoint(Edit1.text)>54) then begin Edit3.text:=''; Edit2.text:=''; exit; end; Edit3.text:=datetostr(dayofW(Edit7.text,strtoint(Edit1.Text))); Edit2.text:=datetostr(dayofW(Edit7.text,strtoint(Edit1.Text))+6); end; procedure Tfrm_info_plan_add.bsSkinButton1Click(Sender: TObject); var i:integer; begin if bsSkinCheckRadioBox1.checked then begin if wwDBDateTimePicker1.text='' then begin showmessage('请输入计划执行的日期!!'); exit; end; end; if bsSkinCheckRadioBox2.checked then begin if Edit1.text='' then begin showmessage('请输入计划执行的日期!!'); exit; end; end; if bsSkinCheckRadioBox3.checked then begin if Edit6.text='' then begin showmessage('请输入计划执行的日期!!'); exit; end; end; try modify_all:=true; frm_info_plan_individual.t_info_plan.insert; frm_info_plan_individual.t_info_plan['计划状态']:='录入状态'; if bsSkinCheckRadioBox1.checked then begin frm_info_plan_individual.t_info_plan['计划周期']:=wwDBDateTimePicker1.text; frm_info_plan_individual.t_info_plan['年']:=inttostr(yearof(wwDBDateTimePicker1.date)); frm_info_plan_individual.t_info_plan['计划类型']:='天计划'; frm_info_plan_individual.t_info_plan.post; frm_info_plan_individual.t_info_plan_detail.insert; frm_info_plan_individual.t_info_plan_detail['计划类型']:='其它计划'; frm_info_plan_individual.t_info_plan_detail['执行日期']:=wwDBDateTimePicker1.date; frm_info_plan_individual.t_info_plan_detail['是否完成']:=0; frm_info_plan_individual.t_info_plan_detail['录入人']:=employee; frm_info_plan_individual.t_info_plan_detail.post; end; if bsSkinCheckRadioBox2.checked then begin frm_info_plan_individual.t_info_plan['计划周期']:='第'+Edit1.text+'周'; frm_info_plan_individual.t_info_plan['年']:=Edit7.text; frm_info_plan_individual.t_info_plan['计划类型']:='周计划'; frm_info_plan_individual.t_info_plan.post; for i:=0 to round(strtodate(Edit2.text)-strtodate(Edit3.text)) do begin frm_info_plan_individual.t_info_plan_detail.insert; frm_info_plan_individual.t_info_plan_detail['计划类型']:='其它计划'; frm_info_plan_individual.t_info_plan_detail['执行日期']:=strtodate(Edit3.text)+i; frm_info_plan_individual.t_info_plan_detail['是否完成']:=0; frm_info_plan_individual.t_info_plan_detail['录入人']:=employee; frm_info_plan_individual.t_info_plan_detail.post; end; end; if bsSkinCheckRadioBox3.checked then begin frm_info_plan_individual.t_info_plan['计划周期']:=Edit6.text+'月'; frm_info_plan_individual.t_info_plan['年']:=Edit8.text; frm_info_plan_individual.t_info_plan['计划类型']:='月计划'; frm_info_plan_individual.t_info_plan.post; for i:=0 to round(strtodate(Edit5.text)-strtodate(Edit4.text)) do begin frm_info_plan_individual.t_info_plan_detail.insert; frm_info_plan_individual.t_info_plan_detail['计划类型']:='其它计划'; frm_info_plan_individual.t_info_plan_detail['执行日期']:=strtodate(Edit4.text)+i; frm_info_plan_individual.t_info_plan_detail['是否完成']:=0; frm_info_plan_individual.t_info_plan_detail['录入人']:=employee; frm_info_plan_individual.t_info_plan_detail.post; end; end; close; finally modify_all:=false; end; end; end.