Ejemplo n.º 1
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            //Check Data Version
            try
            {
                SetConfig();
                ConnectDB.dbconnection = "Data Source=" + ddlServer.Text + ";Initial Catalog="
                                         + ddlDatabase.Text + ";User ID=" + ConnectDB.Userdb + ";Password="******";";
                //+ ";Connection Timeout=" + ConnectDB.ConnectDB.Timeout + ";"; //Integrated Security=SSPI; Connection Timeout=1800
                ConnectDB.user         = txtUser.Text;
                ConnectDB.server       = ddlServer.Text;
                ConnectDB.dbname       = ddlDatabase.Text;
                ClassLib.Classlib.User = ConnectDB.user;

                ////OpenSqlConnection(); //Test Connection time out
                if (checkVr())
                {
                    //ConnectDB.ConnectDB.server = cboServer.Text;
                    //ConnectDB.ConnectDB.dbname = cboDatabase.Text;

                    this.Hide();
                    this.ShowInTaskbar = false;
                    Mainfrom rad = new Mainfrom();
                    rad.Show();
                }
            }
            //catch { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //    dbclass.getDb.A00_ErrorLog(this.Name, ex.ToString(), ConnectDB.ConnectDB.user);
            }
        }
Ejemplo n.º 2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            //Check Data Version

            try
            {
                SetConfig();
                ConnectDB.dbconnection = "Data Source=" + ddlServer.Text + ";Initial Catalog="
                                         + ddlDatabase.Text + ";User ID=" + txtUserDb.Text + ";Password="******";";
                ConnectDB.server = ddlServer.Text;
                ConnectDB.dbname = ddlDatabase.Text;
                ConnectDB.Userdb = txtUserDb.Text;
                ConnectDB.PassDb = txtPassDb.Text;

                Properties.Settings.Default["dbStockControlConnectionString1"] = ConnectDB.dbconnection;
                ConnectDB.user         = txtUser.Text;
                ConnectDB.server       = ddlServer.Text;
                ConnectDB.dbname       = ddlDatabase.Text;
                ClassLib.Classlib.User = ConnectDB.user;

                Report.CRRReport.ServerName = ddlServer.Text;
                Report.CRRReport.DbName     = ddlDatabase.Text;
                Report.CRRReport.dbUser     = ConnectDB.Userdb;
                Report.CRRReport.dbPass     = ConnectDB.PassDb;


                ////OpenSqlConnection(); //Test Connection time out
                if (checkVr())
                {
                    //ConnectDB.ConnectDB.server = cboServer.Text;
                    //ConnectDB.ConnectDB.dbname = cboDatabase.Text;

                    this.Hide();
                    this.ShowInTaskbar = false;
                    Mainfrom rad = new Mainfrom();
                    rad.Show();
                }
            }
            //catch { }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //    dbclass.getDb.A00_ErrorLog(this.Name, ex.ToString(), ConnectDB.ConnectDB.user);
            }
        }
Ejemplo n.º 3
0
 private void radButton1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!txtUserID.Text.Equals("") && !txtPassword.Text.Equals(""))
         {
             using (DataClasses1DataContext db = new DataClasses1DataContext())
             {
                 tb_User ur = db.tb_Users.Where(u => u.UserID == txtUserID.Text && u.Password == txtPassword.Text && u.Active == true).FirstOrDefault();
                 if (ur != null)
                 {
                     dbClss.UserID = txtUserID.Text;
                     this.Hide();
                     tb_UserMachine um = db.tb_UserMachines.Where(m => m.MachineName == Environment.MachineName).FirstOrDefault();
                     if (um != null)
                     {
                         db.tb_UserMachines.DeleteOnSubmit(um);
                         db.SubmitChanges();
                     }
                     tb_UserMachine nw = new tb_UserMachine();
                     nw.MachineName = Environment.MachineName;
                     nw.UserID      = txtUserID.Text.Trim();
                     db.tb_UserMachines.InsertOnSubmit(nw);
                     db.SubmitChanges();
                     Mainfrom main = new Mainfrom();
                     main.ShowDialog();
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("User or Password Invalid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         else
         {
             MessageBox.Show("User or Password Empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }