Beispiel #1
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            bool validate = !(Machine_txt.Text.Equals("") && User_text.Text.Equals("") && Password_txt.Text.Equals(""));

            if (validate)
            {
                InfoLogin info = new InfoLogin(Machine_txt.Text, Instance_txt.Text, User_text.Text, Password_txt.Text);
                try
                {
                    frmDatabaseList frm = new frmDatabaseList(info);
                    frm.MdiParent   = Owner;
                    DialogResult    = DialogResult.OK;
                    frm.WindowState = FormWindowState.Maximized;
                    frm.Show();
                }
                catch (Exception eb)
                {
                    MessageBox.Show("Login failed: " + eb.Message);
                }
                if (rbtnTestAcc.Checked && cbxSave.Checked)
                {
                    string saveAcc = String.Format("{0}:{1}:{2}:{3}",
                                                   Machine_txt.Text, Instance_txt.Text, User_text.Text, Password_txt.Text);
                    Properties.Settings.Default.test_login = saveAcc;
                    Properties.Settings.Default.Save();
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đủ thông tin đăng nhập");
            }
        }
Beispiel #2
0
        //Get List DBInfo
        private List <InfoDB> GetDBs(InfoLogin infoLogin)
        {
            List <InfoDB> list          = new List <InfoDB>();
            var           monitoring_db = Properties.Settings.Default.default_monitoring_dbname;
            string        connectString = attConnect[0] + infoLogin.Machine +
                                          attConnect[2] + infoLogin.User +
                                          attConnect[3] + infoLogin.Password;

            using (SqlConnection con = new SqlConnection(connectString))
            {
                con.Open();
                string query = String.Format(
                    @"SELECT s.datasource, ds.[catalog] , d.createdDate, d.brandname, d.domainname, s.[user],s.password
						FROM	[{0}].[dbo].[storage] as s,
								[{0}].[dbo].[domain_storage] as ds,                            
								[{0}].[dbo].[domain] as d
						WHERE S.ID = DS.storageid AND d.ID = ds.domainid AND s.[user] = '{1}'; "                        , monitoring_db, infoLogin.User);
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    using (SqlDataReader dbList = cmd.ExecuteReader())
                    {
                        while (dbList.Read())
                        {
                            InfoDB dB = new InfoDB();
                            dB.DataSource   = dbList["datasource"].ToString();
                            dB.Catalog      = dbList["catalog"].ToString();
                            dB.CreatedDate  = dbList["createdDate"].ToString();
                            dB.BrandName    = dbList["brandName"].ToString();
                            dB.DomainName   = dbList["domainName"].ToString();
                            dB.User         = dbList["user"].ToString();
                            dB.Password     = dbList["password"].ToString();
                            dB.UpdateChoice = false;
                            list.Add(dB);
                        }
                    }
                }
            }
            return(list);
        }
Beispiel #3
0
 public frmDatabaseList(InfoLogin info)
 {
     InitializeComponent();
     infoLogin = new InfoLogin(info.Machine, info.SeverName, info.User, info.Password);
     frm_GetListDB();
 }