// // 选不同的单据,显示不同的明细... procedure TForm1.GridSelChanged(Sender: TObject); begin ShowDetailList; end;
// // 显示业务单据列表的过程... procedure TForm1.ShowLeaseList; var i: integer; Lease: TLease; begin DetailGrid.RowCount:=0; if assigned(LeaseList) then FreeAndNil(LeaseList); LeaseList:=TLeaseList.ReadFromDB(Mba,'','LeaseId Desc'); if LeaseList=nil then begin Grid.RowCount:=0; ShowMessage('从服务器读取租赁业务单列表失败!'); exit; end; Grid.BeginUpdate; Grid.RowCount:=LeaseList.Count; for i := 0 to LeaseList.Count-1 do begin Lease:=TLease(LeaseList.Items[i]); Grid.Cells[0,i]:=Lease.f_LeaseId; Grid.Cells[1,i]:=Lease.f_CustomerName; Grid.Cells[2,i]:=Lease.f_CreateDate; Grid.Cells[3,i]:=Lease.f_CreaterName; end; Grid.EndUpdate; if Grid.RowCount>0 then ShowDetailList; end;
// // 显示租赁明细记录... procedure TForm1.ShowDetailList; var Lease: TLease; i: integer; Detail: TLeaseDetail; begin if Grid.Selected<0 then exit; Lease:=TLease(LeaseList.Items[Grid.Selected]); Lease.LoadAppertains(Mba); if Lease.f_LeaseDetail_List=nil then exit; DetailGrid.BeginUpdate; DetailGrid.RowCount:=Lease.f_LeaseDetail_List.Count; for i := 0 to Lease.f_LeaseDetail_List.Count-1 do begin Detail:=TLeaseDetail(Lease.f_LeaseDetail_List.Items[i]); DetailGrid.Cells[0,i]:=Detail.f_BuildingId; DetailGrid.Cells[1,i]:=Detail.f_BuildingName; DetailGrid.Cells[2,i]:=Detail.f_BeginDate; DetailGrid.Cells[3,i]:=Detail.f_EndDate; end; DetailGrid.EndUpdate; end;
// // 连接/断开服务器... procedure TForm1.Button2Click(Sender: TObject); begin if Button2.Text='连接' then begin if mbconn.connect then begin Button2.Text:='断开'; ShowLeaseList; end else ShowMessage('连接应用服务器失败!'); end else begin mbconn.disconnect; Grid.RowCount:=0; DetailGrid.RowCount:=0; Button2.Text:='连接'; end; end;
// // 新建租赁业务单... procedure TForm1.Button1Click(Sender: TObject); begin Form2.mode:=1; Form2.show; end;
// // 修改所选租赁业务单... procedure TForm1.Button5Click(Sender: TObject); begin if grid.Selected<0 then exit; Form2.mode:=2; Form2.LeaseId:=grid.Cells[0,grid.Selected]; Form2.show; end;
// // 退出... procedure TLoginForm.Button3Click(Sender: TObject); begin Close; end;
// // 初始化... procedure TLoginForm.FormCreate(Sender: TObject); begin edit1.Text:=''; edit2.text:=''; end;
// // 连接服务器... procedure TLoginForm.Button1Click(Sender: TObject); begin mainform.LazConn.Host:=mainform.s_ServerIpAddress; mainform.LazConn.Port:=mainform.s_ServerPort; if not mainform.LazConn.Connect then begin application.MessageBox('对不起,连接服务器失败,请重设通信参数后再试!','操作提示',mb_ok+mb_iconinformation); exit; end; hide; mainform.WindowState:=wsMaximized; mainform.timer1.enabled:=true; mainform.show; end;
// // 配置参数... procedure TLoginForm.Button2Click(Sender: TObject); var Parcel: TLazParcel; begin configform.Edit1.Text:=mainform.s_ServerIpAddress; configform.Edit2.Text:=inttostr(mainform.s_ServerPort); configform.ShowModal; if configform.execute then begin mainform.s_ServerIpAddress:=configform.ip; mainform.s_ServerPort:=configform.port; Parcel:=TLazParcel.Create; Parcel.PutstringGoods('ServerIpAddress',configform.ip); Parcel.PutIntegerGoods('ServerPort',configform.port); Parcel.SaveToFile(mainform.s_defaultdir+extractfilename(application.exename)+'.par'); FreeAndNil(Parcel); end; end;