2025-03-27 15:05:14 +08:00

96 lines
2.6 KiB
C#

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 Oracle.ManagedDataAccess.Client;
namespace InventoryTool
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
dbip.Focus();
}
private string serverip = "";
private string connname = "";
private string serverport = "";
private string user = "";
private string pass = "";
public string Serverip
{
get { return serverip; }
set { Serverip = value; }
}
public string Connname
{
get { return connname; }
set { Connname = value; }
}
public string Serverport
{
get { return serverport; }
set { Serverport = value; }
}
public string User
{
get { return user; }
set { User = value; }
}
public string Pass
{
get { return pass; }
set { Pass = value; }
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string connString = "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = " + dbip.Text + ")(PORT = " + dbport.Text + "))(CONNECT_DATA = (SERVICE_NAME = " + conname.Text + "))); User Id = " + dbuser.Text + "; Password=" + dbpass.Text + ";";
OracleConnection conn = new OracleConnection(connString);
conn.Open();
conn.Close();
MessageBox.Show("连接成功");
}
catch (Exception ex)
{
MessageBox.Show("连接失败!\r\n" + ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
if (this.dbip.Text != "")
{
serverip = this.dbip.Text;
connname = this.conname.Text;
serverport = this.dbport.Text;
user = this.dbuser.Text;
pass = this.dbpass.Text;
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
MessageBox.Show("请输入服务器IP地址");
dbip.Focus();
}
}
catch (Exception ex)
{
}
}
}
}