#if !defined(AFX_DOCCREATEDLG_H__04160A50_397F_11D4_B939_D448B2198C5A__INCLUDED_)
#define AFX_DOCCREATEDLG_H__04160A50_397F_11D4_B939_D448B2198C5A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DocCreateDlg.h : header file
#include <apl_gui.h>
#include "apl_api.h"

#include "aplCharactView.h"
#include "aplApprovalView.h"
#include "aplDocsView.h"
#include "aplAccessView.h"
#include "aplEntryView.h"
#include "resource.h"
#include "afxdtctl.h"
#include "afxwin.h"

#include "DocFormatListsDlg.h"

class CDocCreateDlg;

class CaplDblclickEdit : public CEdit
{
public:
	CaplDblclickEdit(){m_parent=0;};
// 	virtual ~CaplDblclickEdit();
	//{{AFX_MSG(CaplDblclickEdit)
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	//}}AFX_MSG

	CDocCreateDlg* m_parent;

	DECLARE_MESSAGE_MAP()
	DECLARE_DYNCREATE(CaplDblclickEdit)
};
//
/////////////////////////////////////////////////////////////////////////////
// CDocCreateDlg dialog

class CaplEntryView;

class CDocCreateDlg : public CaplResizableDialog
{
// Construction
public:
	CDocCreateDlg(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(CDocCreateDlg)
	enum { IDD = IDD_CREATE_DOC };
	CComboBox	m_format_ctrl;
	
	// новые атрибуты карточки документа
	CComboBox	m_dkvd;
	CComboBox	m_kdvzohi;
	CComboBox	m_struct_kind;

	CEdit m_of_list;
	CaplDblclickEdit m_of_lists;
	CButton m_autent;

	//CEdit m_doc_sheets;
	//CEdit m_doc_format;
	//CEdit m_doc_litera;
	//CEdit m_doc_total_sheets;

	CString m_sDkvd;
	CString m_sKdvzohi;
	CString m_sStructKind;
	CString m_sOfList;
	CString m_sOfLists;
	CString m_sOfListsA4;
	CString m_sRevDate;
	CaplTAggr<SMapListDescr*,SMapListDescr*,APLAGGR_LIST_OR_AUTOKILLREF> m_list_num_lists;

	int m_nAutent;

	CRect m_rect_of_listB,m_rect_of_listsB,m_rect_statis_of_listB;
	CRect m_rect_of_listM,m_rect_of_listsM,m_rect_statis_of_listM;

	//CString m_sDocSheets;
	//CString m_sDocTotalSheets;
	//CString m_sDocLitera;
	//CString m_sDocFormat;

	CString m_sPart;
	int m_nInclude;

	CButton	m_doc_name_chg_btn;
	CButton	m_doc_id_chg_btn;
	CaplButton	m_bPropsProps;
	CaplButton	m_bPropsDel;
	CaplButton	m_bPropsAdd;
	CaplTabCtrl	m_Tab;
	BOOL	m_save_to_db;
	BOOL	m_set_ro;
	CaplButton	m_cancel_btn;
	CaplButton	m_ok_btn;
	CEdit	m_doc_id_ctrl;
	CButton	m_browse_file_btn;
	CButton	m_context_sel;
	CButton	m_save_to_db_ctrl;
	CButton	m_set_ro_btn;
	CComboBox	m_doc_type_ctrl;
	CEdit	m_context_names;
	CEdit	m_doc_descr_ctrl;
	CEdit	m_doc_name_ctrl;
	CEdit	m_doc_rel_src_ctrl;
	CEdit	m_doc_rev_descr_ctrl;
	CEdit	m_doc_rev_file_ctrl;
	CEdit	m_dt_text;
	CEdit	m_edit_rev_id;
	CEdit	m_file_size_ctrl;
	CEdit	m_label_ctrl;
	CStatic	m_st_contexts;
	CStatic	m_st_name;
	CStatic	m_st_rel_src;
	CString	m_doc_descr;
	CString	m_doc_id;
	CString	m_doc_name;
	CString	m_doc_rel_src;
	CString	m_doc_rev_descr;
	CString	m_doc_rev_file;
	CString	m_doc_rev_id;
	CString	m_file_size_str;
	CString	m_label;
	CString	m_format;
	//}}AFX_DATA

	int m_prev_format_pos;

	CaplAPI *m_api;
	
	// массив значений реквизита для дальнейшего присоединения к версии документа создания 
	aplExtent m_aeEntryToCreate;	

	CaplInstance *m_doc, *m_rev, *m_dt;
	bool m_show_contexts, m_context_changed, m_doc_ref_ro, m_bWFstateReadOnly;
	aplExtent m_rel_contexts;
	CString m_rel_src;

	CaplInstance *m_doc_po_from; // Автор
	aplExtent m_doc_recitients;  // Получатели

	CStringArray m_sel_doc_types_names;

	CString			m_csAccessString;

	// прежние значения
	CString m_sOldId;
	CString m_sOldName;
	CString m_sOldDescr;
	CaplInstance *m_ciOldType;
	CaplEntryView *m_pEntryView;

	void CalcMultiFormatsA4SheetsCount();
	
protected:
	CBitmap m_name_bmp;
	int m_nEntryTabPos;

	// предотвращаем потерю модальности после диалога с бочками из aplSocketTransport
	CaplParentWndProcesser m_pwp;

	BOOL	SetAnchors(void);
	BOOL	ValidateData(void);
	BOOL	SaveData(void);
	BOOL	ChangeDocEntries(bool bOkFunc);
	CaplInstance*	PutEntryVal(CaplInstance *ciRev, CaplInstance *ciEntryVal, CString sValue, CString sCardField, CaplInstance *ciEntry);
	bool	CheckEntry(aplExtent &aeEntriesVal, CaplInstance *ciRev);		

	BOOL			InitViews(void);

	void			ChangeViewBtnsState(BOOL bDis,BOOL bHide);
	void			CreateEntryVal(CString sCardField, CString sValue);
	bool			RebuildEntryList(CaplInstance *ciDocType);
	CaplInstance*	GetLastEntryVal(CaplInstance *ciRev, CString sCardField);
	bool			LoadEntriesInfo();
	void			KDVZOHIandAut();
	int				Find(CString sText, CString sSub);
	void			CutSpaceBeforCode(int nPos);
	void			FormatFileSize(__int64 size);
	bool			VerIsActive();

	void  InsertFormats(); // заполняет возможные значения поля формат

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDocCreateDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	
	// Generated message map functions
	//{{AFX_MSG(CDocCreateDlg)
	afx_msg void OnBrowseFile();
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	afx_msg void OnStName();
	afx_msg void OnSelContext();
	afx_msg void OnSelDocType();
	afx_msg void OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBPropsAdd();
	afx_msg void OnBPropsDel();
	afx_msg void OnBPropsProps();
	afx_msg void OnDocIdChange();
	afx_msg void OnDocNameChange();
	virtual void OnCancel();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnStnClickedTDocType();
	afx_msg void OnEnChangeLabel();
	afx_msg void OnCbnSelchangeKdvzohi();		
	afx_msg void OnEnChangeOfList();
	afx_msg void OnEnChangeOfLists();
	afx_msg void OnCbnSelchangedFormat();
	afx_msg void OnEnChangeLitera();
	afx_msg void OnCbnSelchangeFormat();
	CDateTimeCtrl m_rev_date_ctrl;
	COleDateTime m_dt_rev_date;
	CEdit m_crc_ctrl;
	CButton m_crc_check_btn;
	afx_msg void OnBnClickedCrcCheck();
	void CalcA4SheetsCount();
	bool TestMultiFormat();
	CaplDblclickEdit m_lists_a4_ctrl;
//	afx_msg void OnCbnCloseupFormat();
	afx_msg void OnCbnEditchangeFormat();
	CEdit m_inv_num_ctrl;
	afx_msg void OnBnClickedSelDocFrom();
	afx_msg void OnBnClickedSelDocTo();
	CEdit m_from_ctrl;
	CEdit m_to_ctrl;
	CButton m_sel_fom_ctrl;
	CButton m_sel_to_ctrl;
	CDateTimeCtrl m_doc_date_treb_ctrl;
	CComboBox m_doc_srocn_ctrl;
	CDateTimeCtrl m_doc_date_isp_plan_ctrl;
	CDateTimeCtrl m_doc_date_isp_fact_ctrl;
	afx_msg void OnBnClickedDelDocFrom();
	CButton m_del_fom_ctrl;
	CDateTimeCtrl m_doc_date_ctrl;
	CString m_litera;
	CComboBox m_litera_ctrl;
	void DblclkListsFormats();
	CButton m_lists_select_btn;
	afx_msg void OnBnClickedOfListsSelect();
	CaplButton m_view_btn;
	afx_msg void OnBnClickedDocView();
	CStatic m_statis_of_list;
	CButton m_del_from_disk_btn;
	BOOL m_del_from_disk;
	afx_msg void OnBnClickedSaveToDb();
	afx_msg void OnDropFiles(HDROP hDropInfo);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DOCCREATEDLG_H__04160A50_397F_11D4_B939_D448B2198C5A__INCLUDED_)
