MainForm.cs
上传用户:abcs8778
上传日期:2022-08-03
资源大小:2093k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- using Microsoft.AnalysisServices.AdomdClient;
- namespace BookSellPredict
- {
- public partial class MainForm : Form
- {
- protected SqlConnection _connDatabase;
- protected AdomdConnection _connAnalysis;
- public MainForm()
- {
- InitializeComponent();
- }
- private void MainForm_Load(object sender, EventArgs e)
- {
- _connDatabase = new SqlConnection("Data Source=(local); Initial Catalog=BookSell; Integrated Security=true");
- _connAnalysis = new AdomdConnection("Data Source=(local); Initial Catalog=BookSellAnalysis;");
- try
- {
- _connDatabase.Open();
- _connAnalysis.Open();
- }
- catch (Exception exp)
- {
- MessageBox.Show("数据连接错误:" + exp.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- this.Close();
- }
- }
- private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (_connDatabase != null && _connDatabase.State != ConnectionState.Closed)
- _connDatabase.Close();
- if (_connAnalysis != null && _connAnalysis.State != ConnectionState.Closed)
- _connAnalysis.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- CustomerAnalysisForm frm1 = new CustomerAnalysisForm(_connDatabase, _connAnalysis);
- frm1.ShowDialog();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- BookAnalysisForm frm1 = new BookAnalysisForm(_connDatabase, _connAnalysis);
- frm1.ShowDialog();
- }
- }
- }