public MainDiscount(HomeDiscount form, OracleConnection con, bool newDC, bool existingDC, string filename, string folder, string user, string UR) { InitializeComponent(); //Get private variable home = form; ConnectionProd = con; FLAG_NEW = newDC; FLAG_EXISTING = existingDC; this.filename = filename; this.user = user; urNo = UR; outputPath = folder; }
private void ConnectDB() { Cursor.Current = Cursors.WaitCursor; string user = txtUser.Text; string password = txtPassword.Text; try { ConnectionProd = new OracleConnection(); string connString = "Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.19.193.20)(PORT = 1560))" + "(CONNECT_DATA = (SID = TEST03)));User Id=" + user + "; Password="******"; Min Pool Size=10; Max Pool Size =20"; //string connString = @"Data Source= (DESCRIPTION =(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 150.4.2.2)(PORT = 1521)) )" + // "(CONNECT_DATA =(SERVICE_NAME = TAPRD)));User ID=" + user + ";Password="******";"; ConnectionProd.ConnectionString = connString; ConnectionProd.Open(); if (ConnectionProd.State == ConnectionState.Open) { btnLogin.Enabled = false; if (FLAG_DISCOUNT == true) { HomeDiscount coverDiscount = new HomeDiscount(ConnectionProd, user); this.Hide(); coverDiscount.ShowDialog(); } else if (FLAG_HISPEED == true) { HomeHispeed coverHispeed = new HomeHispeed(ConnectionProd, user); this.Hide(); coverHispeed.ShowDialog(); } else { HomeVas coverVas = new HomeVas(ConnectionProd, user); this.Hide(); coverVas.Show(); } } else { btnLogin.Enabled = true; DialogResult result = MessageBox.Show("Please try again!!" + "\r\n" + "Cannot connect to database.", "Warning", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { Application.Exit(); } } } catch (Exception ex) { DialogResult result = MessageBox.Show("Please try again!! " + "\r\n" + "Connection database failed" + "\r\n" + ex.Message, "Confirmation", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { ConnectionProd.Close(); ConnectionProd.Dispose(); Application.Exit(); } } finally { Cursor.Current = Cursors.Default; } }