1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_LabelMachine.Entity;
- namespace UAS_LabelMachine
- {
- public partial class ChangeMaster : Form
- {
- DataHelper dh = SystemInf.dh;
- SqliteDBHelper sdh;
- DataTable Masterdt;
- public ChangeMaster()
- {
- InitializeComponent();
- }
- private void ChangeMaster_Load(object sender, EventArgs e)
- {
- Masterdt = (DataTable)dh.ExecuteSql("select ma_function,ms_pwd,ma_user from master ", "select");
- MasterCombox.DisplayMember = "ma_function";
- MasterCombox.ValueMember = "ma_user";
- MasterCombox.DataSource = Masterdt;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string Ms_Pwd = "";
- for (int i = 0; i < Masterdt.Rows.Count; i++)
- {
- if (MasterCombox.SelectedValue == Masterdt.Rows[i]["ma_user"])
- Ms_Pwd = Masterdt.Rows[i]["ms_pwd"].ToString();
- }
- //切换至用户选择的数据源
- string ConnectionString = "Connection Timeout=0;Pooling=false;Password=" + Ms_Pwd + ";User ID=" + MasterCombox.SelectedValue.ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + SystemInf.IP + ")(PORT=" + DataHelper.OraclePort + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
- DataHelper.DBConnectionString = ConnectionString;
- //设置当前账套
- SystemInf.Master = MasterCombox.SelectedValue.ToString();
- SystemInf.sdh = sdh = new SqliteDBHelper(SystemInf.Master + ".db3");
- SystemInf.MasterName = MasterCombox.Text;
- //设置了Connection,重新执行构造函数,重置数据库连接
- dh = new DataHelper();
- Close();
- }
- }
- }
|