示例#1
0
	/// <summary>
	/// Создает общий шаблон для таблицы
	/// </summary>
	/// <param name="Parent">Родительская форма</param>
	/// <param name="Table">Исходная таблица</param>
	public static void CreateTemplate(BankLab Parent, DataGridView Table) 
	{
		Excel.Application ExcelApp;
		ExcelApp = new Excel.Application();
		ResFile Maket = new ResFile(bl_res_doc.Resource1.Maket, AppDomain.CurrentDomain.BaseDirectory + "~tmp.xlsx");
		Maket.CreateFile();
		Parent.CurrentProgressBar.SetProgressBarValue(35);
		ExcelApp.Workbooks.Open(Maket.FileName);
		Parent.CurrentProgressBar.SetProgressBarValue(50);
		Table.Columns.Add("Year", ExcelApp.Cells[1, 1].Value);
		Table.ColumnCount = 19;
		Parent.CurrentProgressBar.SetProgressBarValue(60);
		for (int i = 1; i <= 18; i++) {
			Table.Columns[i].Name = "X" + i.ToString();
			Table.Columns[i].HeaderText = ExcelApp.Cells[1, i + 1].Value;
			Table.Columns[i].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
		}
		Parent.CurrentProgressBar.SetProgressBarValue(90);
		SetTablePropertyToCreateTamplate(Table);
		Parent.CurrentSideBar.AddTables();
		ExcelApp.Workbooks.Close();
		ExcelApp.Quit();
		Maket.FreeFile();
		Parent.CurrentMenu.ChangeMenuItemsEnable(true);
	}
示例#2
0
		public ParamForm(BankLab parent, DataGridView dataTable)
		{
			InitializeComponent();
			Parent = parent;
			CurrentDataTable = dataTable;
			ShowParametrForm(CurrentDataTable);
		}
示例#3
0
	/// <summary>
	/// Импортирует Excell документ в таблицу
	/// </summary>
	/// <param name="Parent">Родительская форма</param>
	/// <param name="Table">Таблица назначения</param>
	/// <returns></returns>
	public static int ImportExcelFile(BankLab Parent, DataGridView Table) 
	{
		String FileName = Parent.ShowOpenDialog("Файлы Excel (*.xls; *.xlsx)|*.xls;*.xlsx");
		if (FileName == String.Empty) {
			Parent.CurrentProgressBar.HideProgressBar();
			return 0;
		}
		Excel.Application ExcelApp = new Excel.Application();
		ExcelApp.Workbooks.Open(FileName);
		Table.Visible = false;
		Parent.CurrentProgressBar.SetProgressBarValue(10);
		Table = Parent.CurrentDataTable.ReinitializeDataTable();
		ExcelFunctions.CreateTemplate(Parent, Table);
		for (int i = 0; i < ExcelApp.Sheets[1].UsedRange.Rows.Count - 1; i++) {
			Table.Rows.Add();
			for (int j = 1; j <= 18; j++) {
				Table.Rows[i].Cells[j].Value = ExcelApp.Cells[i + 2, j + 1].Value;
			}
		}
		Parent.CurrentProgressBar.SetProgressBarValue(90);
		Parent.CurrentDataTable.FillTableIntervalColumnByFirstYear(Convert.ToInt32(ExcelApp.Cells[2, 1].value));
		Table.Visible = true;
		ExcelApp.Workbooks.Close();
		ExcelApp.Quit();
		Parent.CurrentProgressBar.SetProgressBarValue(100);
		return 1;
	}
示例#4
0
	public save_form(BankLab parent, DataGridView datatable)
	{
		InitializeComponent();
		Parent = parent;
		DataTable = datatable;
		ShowCurrentTableName();
	}
示例#5
0
	public RegressionForm(BankLab parent, ParamForm selectColumnsForm, DataGridView regressionTable)
	{
		InitializeComponent();
		Parent = parent;
		SelectColumnsForm = selectColumnsForm;
		RegressionTable = regressionTable;
		DefaultHeight = title_label.Height + ButtonPanel.Height;
	}
示例#6
0
	public year_form(BankLab parent, bool create)
	{
		InitializeComponent();
		Create = create;
		Parent = parent;
		this.start_year_edit.KeyDown += DelegateButtonsDown;
		this.end_year_edit.KeyDown += DelegateButtonsDown;
	}
示例#7
0
	public coefficient_form(BankLab parent, int index)
	{
		InitializeComponent();
		this.DoubleBuffered = true;
		Parent = parent;
		DefaultHeight = title_label.Height + sub_main_menu.Height + statusStrip1.Height;
		Index = index;
	}
示例#8
0
	public DataBaseEditor(BankLab parent)
	{
		InitializeComponent();
  		Parent = parent;
		this.FormClosing += CloseDataBaseEditorFormDelegate;
	}
示例#9
0
	public static DataGridView StartRegression(bool[] SelectedColumns, BankLab Parent)
	{
			Excel.Application ExApp = GetExcelAppWithAddIn(); 
			int ColumnsCount = ExportColumnsToExcel(ExApp, SelectedColumns, Parent);
			string MacrosCode =
				"Sub reg()\r\n" +
				"Application.Run \"ATPVBAEN.XLAM!Regress\", ActiveSheet.Range(\"$A$1:$A$" + Parent.CurrentCoefficientForm.GetCoefficientTable().RowCount.ToString() + "\"), _\r\n" +
				"ActiveSheet.Range(\"$B$1:$" + (char)((int)'A' + ColumnsCount - 2) + "$" + Parent.CurrentCoefficientForm.GetCoefficientTable().RowCount.ToString() + "\"), False, True, , \"\", False, False, False _\r\n" +
				", False, , False\r\n" +
				"End Sub\r\n";
			AddMacros(ExApp, MacrosCode);
			ExApp.Run("reg");
			DataGridView ResTable = ReadResulFromExcel(ExApp, false);
			ExApp.Workbooks[1].Close(false);
			ExApp.Workbooks.Close();
			ExApp.Quit();
			return ResTable;
	}
示例#10
0
	private static int ExportColumnsToExcel(Excel.Application exApp, bool[] SelectedColumns, BankLab Parent)
	{
		DataGridView Table = Parent.CurrentCoefficientForm.GetCoefficientTable();
		int CurColumn = 1;
		for (int i = 1; i < Table.ColumnCount; i++) {
			if (SelectedColumns[i - 1]) {
				exApp.Cells[1, CurColumn] = Table.Columns[i].HeaderText;
				for (int j = 1; j < Table.RowCount; j++) {
					exApp.Cells[j + 1, CurColumn].Value = Table.Rows[j].Cells[i].Value;
				}
				CurColumn++;
			}
		}
		return CurColumn;
	}
示例#11
0
	public forecast_form(BankLab parent)
	{
		InitializeComponent();
		Parent = parent;
	}
示例#12
0
	public open_form(BankLab parent, DataGridView dataTable)
	{
		InitializeComponent();
		Parent = parent;
		DataTable = dataTable;
	}
示例#13
0
	public OptimizationForm(BankLab parent)
	{
		InitializeComponent();
		Parent = parent;
	}