unit MAINFORM;
interface
uses
Business.System, Business.Model, Business.Forms, Business.Data,
Business.System.SysUtils, Business.Forms.Dialogs, Justep.Tools.Pim,
Business.System.DateUtils;
type
TMAINFORM = class(TForm)
FuncBroker: TFuncBroker;
ControlBar: TControlBar;
DataNavigator: TDataNavigator;
DataSetBGFTCXSJJ: TSQLDataSet;
DataSourceAment: TDataSource;
FIELD_BGFTCXSJJ_project_id: TUserDataField;
FIELD_BGFTCXSJJ_FYLB: TLookupCalcField;
FIELD_BGFTCXSJJ_YFTJE: TLookupCalcField;
FIELD_BGFTCXSJJ_WFTJE: TExprCalcField;
DataSetCKYBGFTJESJJ: TSQLDataSet;
DataSourceYft: TDataSource;
FIELD_BGFTCXSJJ_XMBH: TLookupCalcField;
DataSetBrokerContractInvoice: TDataSetBroker;
InfoBrokerContract: TInfoBroker;
DataSetHTFK: TSQLDataSet;
DataSourceContractPayments: TDataSource;
DataSetBrokerContractPayments: TDataSetBroker;
DataSetBrokerInvestFinish: TDataSetBroker;
DataSetBrokerSjfk: TDataSetBroker;
DataSetBrokerHTTZXXGL: TDataSetBroker;
Panel1: TPanel;
PageControl: TPageControl;
TabSheetList: TTabSheet;
DocViewHTTZGL_HTTZ: TDocView;
TabSheetInfo: TTabSheet;
DocViewHTTZGL_HTXXBDJL: TDocView;
TabSheetContractApp: TTabSheet;
TabSheetChange: TTabSheet;
TabSheetContractPlanPayment: TTabSheet;
TabSheetInvoice: TTabSheet;
TabSheetPayment: TTabSheet;
Panel6: TPanel;
GroupBox5: TGroupBox;
TabSheetInvestFinish: TTabSheet;
Panel11: TPanel;
GroupBox6: TGroupBox;
ControlBar2: TControlBar;
Button4: TButton;
Panel5: TPanel;
DocViewHTTZGL_HTBG: TDocView;
Panel16: TPanel;
GroupBox10: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
DataEdit4: TDataEdit;
DataEdit5: TDataEdit;
DataEdit6: TDataEdit;
Panel18: TPanel;
GroupBox2: TGroupBox;
Panel19: TPanel;
DataGrid3: TDataGrid;
Panel20: TPanel;
DataGrid4: TDataGrid;
ControlBar3: TControlBar;
Panel21: TPanel;
Label4: TLabel;
Month: TComboBox;
Label5: TLabel;
Year: TComboBox;
Label6: TLabel;
ButtonSelectMonth: TButton;
ButtonSelectYear: TButton;
ButtonAddUp: TButton;
ControlBar4: TControlBar;
Panel2: TPanel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
ButtonTotalFinish: TButton;
ButtonYearFinish: TButton;
ButtonMonthFihish: TButton;
MonthFinish: TComboBox;
YearFinish: TComboBox;
Panel22: TPanel;
DataGrid5: TDataGrid;
DataGrid5voucher_id: TDataGridColumn;
DataGrid5WCJE: TDataGridColumn;
DataGrid5BCWCZHTB___: TDataGridColumn;
DataGrid5zy: TDataGridColumn;
TabSheetAffix: TTabSheet;
TabSheetContractFastenerPrepay: TTabSheet;
Panel24: TPanel;
GroupBox11: TGroupBox;
DataSetBrokerContractFastenerPrepay: TDataSetBroker;
ControlBar5: TControlBar;
ButtonSelectPaymentPlay: TButton;
DataSetBrokerPaymentPlan: TDataSetBroker;
DocViewApp: TDocView;
DocViewPayPlan: TDocView;
DataGrid4payment_type: TDataGridColumn;
DataGrid4value: TDataGridColumn;
DataGrid4voucher_id: TDataGridColumn;
DataGrid4day: TDataGridColumn;
DataGrid4zy: TDataGridColumn;
DataGrid4BCFKZHTB: TDataGridColumn;
InfoBrokerVoucherInfo: TInfoBroker;
DataGrid3contract_id: TDataGridColumn;
DataGrid3date: TDataGridColumn;
DataGrid3invoice_sort_id: TDataGridColumn;
DataGrid3name: TDataGridColumn;
DataGrid3no: TDataGridColumn;
DataGrid3note: TDataGridColumn;
DataGrid3value: TDataGridColumn;
DataGrid3rec_peo: TDataGridColumn;
DataGrid3rec_date: TDataGridColumn;
DataGrid3hand_peo: TDataGridColumn;
DataGrid3HTH: TDataGridColumn;
ControlBar1: TControlBar;
Panel3: TPanel;
ButtonAddInvoice: TButton;
ButtonEditInvoice: TButton;
ButtonDelInvoice: TButton;
DocView2: TDocView;
Label10: TLabel;
DataEdit1: TDataEdit;
Label11: TLabel;
DataEdit2: TDataEdit;
Panel4: TPanel;
DataGrid7: TDataGrid;
DataGrid7CONTRACT_NO: TDataGridColumn;
DataGrid7CONTRACT_NAME: TDataGridColumn;
DataGrid7FASTENER_DATE: TDataGridColumn;
DataGrid7FASTENER_MONEY: TDataGridColumn;
DataGrid7REMARK: TDataGridColumn;
TabSheetProjectFile: TTabSheet;
Panel7: TPanel;
Panel8: TPanel;
Panel9: TPanel;
ControlBar6: TControlBar;
Panel12: TPanel;
Label17: TLabel;
SelectFile: TButton;
EditId: TEdit;
Button1: TButton;
GroupBox1: TGroupBox;
Panel10: TPanel;
DataGrid1: TDataGrid;
DataSetBrokerPrjectFile: TDataSetBroker;
DataSetBrokerFileType: TDataSetBroker;
DataGrid1no: TDataGridColumn;
DataGrid1name: TDataGridColumn;
Button2: TButton;
DataSetBrokerSelectFileType: TDataSetBroker;
EditType: TEdit;
InfoBrokerConstructVise: TInfoBroker;
InfoBrokerMeetingSummary: TInfoBroker;
procedure PageControlChange(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure ButtonSelectMonthClick(Sender: TObject);
procedure ButtonSelectYearClick(Sender: TObject);
procedure ButtonAddUpClick(Sender: TObject);
procedure ButtonMonthFihishClick(Sender: TObject);
procedure ButtonYearFinishClick(Sender: TObject);
procedure ButtonTotalFinishClick(Sender: TObject);
// procedure DataEdit24Change(Sender: TObject);
procedure BizFormShow(Sender: TObject);
procedure ButtonSelectPaymentPlayClick(Sender: TObject);
procedure ButtonAddInvoiceClick(Sender: TObject);
procedure ButtonEditInvoiceClick(Sender: TObject);
procedure ButtonDelInvoiceClick(Sender: TObject);
procedure DataNavigatorBeforeAction(Sender: TObject; var Accept: Boolean);
procedure DataGrid4MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure DataGrid4DblClick(Sender: TObject);
procedure DataGrid5DblClick(Sender: TObject);
procedure DataGrid5MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure PageControlChanging(Sender: TObject; var AllowChange: Boolean);
procedure SelectFileClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure DataGrid1Click(Sender: TObject);
procedure DataGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
private
FDataSetBrokerContractApp: TDataSetBroker;
FDataSetBrokerContractInvoice: TDataSetBroker;
function GetYear: string;
function GetMonth: string;
function GetYearFinish: string;
function GetMonthFinish: string;
function GetNowYear: string;
function GetNowMonth: string;
procedure EditableNavigator(Editable: Boolean);
function GetFirstVisiblePageIndex: Integer;
public
procedure ButtonSelectFileTypeClick;
procedure ButtonSelectMeetingSummary;
{public declarations}
end;
implementation
//------------------------------ 事件处理函数 --------------------------------
uses InfoVoucherInformation, ContractMgr,InfoConstructVise,InfoMeetingSummary;
procedure TMAINFORM.EditableNavigator(Editable: Boolean);
begin
DataNavigator.Enabled := Editable;
end;
function TMAINFORM.getYear: string;
begin
Result := Year.Text;
end;
function TMAINFORM.getMonth: string;
begin
Result := month.Text;
end;
function TMAINFORM.GetYearFinish: string;
begin
Result := YearFinish.Text;
end;
function TMAINFORM.GetMonthFinish: string;
begin
Result := MonthFinish.Text;
end;
function TMAINFORM.GetNowYear: string;
begin
Result :=IntToStr(Trunc(YearOf(Date())));
end;
function TMAINFORM.GetNowMonth: string;
begin
Result :=IntToStr(Trunc(MonthOf(Date())));
end;
procedure TMAINFORM.PageControlChange(Sender: TObject);
var
lID: String;
lYear: String;
lMonth: String;
lYears: String;
lMonths: String;
lDataContractAppSet: TBizDataSet;
lDataContractPlanPaymentSet: TBizDataSet;
begin
// if pageControl.TabIndex=1 then
DocViewHTTZGL_HTTZ.SetFocus;
//工程文件
if TabSheetProjectFile.Visible then
begin
EditableNavigator(False);
end;
//合同台帐
if TabSheetList.Visible then
begin
EditableNavigator(True);
end;
//合同信息
if TabSheetInfo.Visible then
begin
EditableNavigator(True);
end;
//合同分摊
if TabSheetContractApp.Visible then
begin
EditableNavigator(False);
ContractMgr.TContractApp(DocViewApp.Doc).ShowByContract(
DataSetBrokerHTTZXXGL.DataSet.FieldByName('id').AsInteger);
end;
//合同附件
if TabSheetAffix.Visible then
begin
EditableNavigator(False);
end;
//合同变更
if TabSheetChange.Visible then
begin
EditableNavigator(False);
end;
//合同发票
if TabSheetInvoice.Visible then
begin
EditableNavigator(False);
DataSetBrokerContractInvoice.DataSet.Open;
end;
//扣回预付款
if TabSheetContractFastenerPrepay.Visible then
begin
EditableNavigator(False);
DataSetBrokerContractFastenerPrepay.DataSet.Open ;
end;
if TabSheetPayment.Visible then
begin
EditableNavigator(False);
Year.ItemIndex := YearFinish.Items.IndexOf(GetNowYear);
Month.ItemIndex := MonthFinish.Items.IndexOf(GetNowMonth);
lID := InfoBrokerContract.Info.DataSetByID('HTTZXXGL').FieldByName('id').AsString;
with TSQLDataSet(DataSetBrokerContractPayments.DataSet) do
begin
//DataSetBrokerContractPayments.DataSet.Close;
// TSQLDataSet(DataSetBrokerContractPayments.DataSet).SQL.Text :=
// 'select p.*,h.day,v.zy,year(h.day)as fyear ,month(h.day) as fmonth from PMVOUCHER_DISASSEMBLE p left outer join voucher_head h on '
// +'p.voucher_id=h.pz_id left outer join voucher v on v.pz_id=p.voucher_id and flh=dispart_no where p.contract_id='''+lID+''' order by year(h.day),month(h.day)';
// DataSetBrokerContractPayments.DataSet.Open;
DataSetBrokerContractPayments.DataSet.Close;
TSQLDataSet(DataSetBrokerContractPayments.DataSet).SQL.Text :=
'SELECT p.*, h.day, v.zy,year(h.day)as fyear ,month(h.day) as fmonth,isnull(contract.total_value,0.00) as contract_totalValue, '
+' (CASE isnull(contract.total_value,0.00) WHEN 0.00 THEN 0.00 ELSE (p.value/isnull(contract.total_value,0.00))*100 END) as 比例 '
+' FROM PMVOUCHER_DISASSEMBLE p left outer JOIN voucher_head h ON p.voucher_id = h.pz_id left outer JOIN voucher v ON v.pz_id = p.voucher_id and flh = dispart_no '
+' left join(SELECT CONTRACT.id,CONTRACT.no,CONTRACT.CONTRACT_VALUE,c1.bg_value as 变更金额,CONTRACT.CONTRACT_VALUE+c1.bg_value as total_value '
+' FROM CONTRACT left join (SELECT top 10000 CONTRACT.id,SUM(COALESCE(CONTRACT_AMENDMENT.amendment_value,0.00)) '
+' AS bg_value,CONTRACT_AMENDMENT.contract_id FROM CONTRACT LEFT OUTER JOIN CONTRACT_AMENDMENT ON CONTRACT.id = CONTRACT_AMENDMENT.contract_id '
+' GROUP BY CONTRACT.id,CONTRACT_AMENDMENT.contract_id) c1 on CONTRACT.id=c1.id) contract '
+' on contract.id=p.contract_id where p.contract_id='''+lID+''' ORDER BY h.DAY';
DataSetBrokerContractPayments.DataSet.Open;
end;
end;
//投资完成
if TabSheetInvestFinish.Visible then
begin
EditableNavigator(false);
YearFinish.ItemIndex :=YearFinish.Items.IndexOf(GetNowYear);
MonthFinish.ItemIndex :=MonthFinish.Items.IndexOf(GetNowMonth);
lID:=InfoBrokerContract.Info.DataSetByID('HTTZXXGL').FieldByName('id').AsString;
with TSQLDataSet(DataSetBrokerInvestFinish.DataSet) do
begin
DataSetBrokerInvestFinish.DataSet.Close;
TSQLDataSet(DataSetBrokerInvestFinish.DataSet).SQL.Text :=
//'select i.*,(isnull(i.lend_value,0)-isnull(i.payment_value,0))as 完成金额,h.day,v.zy from Ivvoucher_disassemble i left outer join voucher_head h on '
// +'i.voucher_id=h.pz_id left outer join voucher v on v.pz_id=i.voucher_id and flh=dispart_no '
//+' where i.contract_id='''+lID+''' ';
'select i.*,(isnull(i.lend_value,0)-isnull(i.budget_value,0)) as 完成金额,h.day,v.zy,(CASE isnull(contract.total_value,0.00) '
+' WHEN 0.00 THEN 0.00 ELSE ((isnull(i.lend_value,0)-isnull(i.budget_value,0)) /isnull(contract.total_value,0.00))*100 END) as 比例 '
+' from Ivvoucher_disassemble i left outer join voucher_head h on i.voucher_id=h.pz_id left outer join voucher v on v.pz_id=i.voucher_id and flh=dispart_no '
+' left join (SELECT CONTRACT.id,CONTRACT.no,CONTRACT.CONTRACT_VALUE,c1.bg_value as 变更金额,CONTRACT.CONTRACT_VALUE+c1.bg_value as total_value '
+' FROM CONTRACT left join (SELECT top 10000 CONTRACT.id,SUM(COALESCE(CONTRACT_AMENDMENT.amendment_value,0.00)) AS bg_value,CONTRACT_AMENDMENT.contract_id '
+' FROM CONTRACT LEFT OUTER JOIN CONTRACT_AMENDMENT ON CONTRACT.id = CONTRACT_AMENDMENT.contract_id GROUP BY CONTRACT.id,CONTRACT_AMENDMENT.contract_id) c1 on CONTRACT.id=c1.id '
+' ) contract on contract.id=i.contract_id where i.contract_id='''+lID+''' ORDER BY h.PZ_ID';
DataSetBrokerInvestFinish.DataSet.Open;
end;
end;
//付款计划
if TabSheetContractPlanPayment.Visible then
begin
EditableNavigator(True);
ContractMgr.TPaymentPlan(DocViewPayPlan.Doc).ShowByContract(
DataSetBrokerHTTZXXGL.DataSet.FieldByName('id').AsInteger);
end;
end; |