Esempio n. 1
0
 private void VerifyPasswords()
 {
     if (Database_Connector.GetUserIdByUsernameAndPassword(Main.user.Username, Controls["TB_currentPassword"].Text) == 0)
     {
         Controls["TB_currentPassword"].Text = "";
         Controls["TB_newPassword"].Text     = "";
         Controls["TB_confirmPassword"].Text = "";
         throw new Exception("PASSWORD_INVALID");
     }
     else if (Controls["TB_newPassword"].Text == String.Empty || Controls["TB_confirmPassword"].Text == String.Empty)
     {
         throw new Exception("PASSWORD_EMPTY");
     }
     else if (Controls["TB_currentPassword"].Text == Controls["TB_newPassword"].Text)
     {
         Controls["TB_newPassword"].Text     = "";
         Controls["TB_confirmPassword"].Text = "";
         throw new Exception("PASSWORD_SAME");
     }
     else if (Controls["TB_newPassword"].Text != Controls["TB_confirmPassword"].Text)
     {
         Controls["TB_confirmPassword"].Text = "";
         throw new Exception("PASSWORD_NOT_MATCHING");
     }
 }
Esempio n. 2
0
        private void ImportFromIMDB()
        {
            string URL = tb_Url.Text;
            string id;
            int    IndexIDStart;
            int    IndexIDEnd;

            IndexIDStart = URL.IndexOf("/title/") + 7;
            if (IndexIDStart == -1)
            {
                throw new Exception("IMDB_ID_NOT_FOUND");
            }

            IndexIDEnd = URL.IndexOf("/", IndexIDStart);

            if (IndexIDEnd == -1 && URL.IndexOf("tt") == 0)
            {
                id = URL;
            }
            else if (IndexIDEnd != -1)
            {
                id = URL.Substring(IndexIDStart, IndexIDEnd - IndexIDStart);
            }
            else
            {
                throw new Exception("ID_FORMAT_INVALID");
            }

            MovieObject movie = Database_Connector.GetFromIMDB(id);

            movie.Category = CategoryObject.GetCategoryID(GetSelectedCategory());

            Database_Connector.Insert.Movie(movie);
        }
Esempio n. 3
0
            /// <summary>
            ///
            ///
            /// Comment : If the user doesn't have the settings, insert them.
            /// </summary>
            /// <returns></returns>
            public static string LanguageSetting()
            {
                string value = null;

                OracleConnection conn_  = Database_Connector.GetConnection();
                string           select = "SELECT value FROM user_settings WHERE user_id=:userid AND key=:keyp";
                OracleCommand    cmd    = new OracleCommand(select, conn_);

                cmd.Parameters.Add(new OracleParameter("userid", Main.user.ID.ToString()));
                cmd.Parameters.Add(new OracleParameter("keyp", "Language"));

                OracleDataReader dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    value = Convert.ToString(dr["value"]);
                }
                else
                {
                    // Insert default value here.
                    value = Settings.Default.Language;
                    //Insert.LanguageSetting(Settings.Default.Language);
                }
                conn_.Close();

                return(value);
            }
Esempio n. 4
0
        private static void GetDBData(string TableName, string SelectSQL)
        {
            OracleDataAdapter DataAdapter = new OracleDataAdapter(new OracleCommand(SelectSQL, Database_Connector.GetConnection()));

            DataAdapter.Fill(DS, TableName);
            Database_Connector.CloseConnection();
        }
Esempio n. 5
0
 private void LoadDataBase()
 {
     try
     {
         Database_Connector.OpenConnection();
         Database.FillDataSet();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Esempio n. 6
0
        public bool Login(string username, string plainPassword)
        {
            if (LoggedIn)
            {
                throw new Exception("User already logged-in.");
            }

            Username = username;
            UserID   = Database_Connector.GetUserIdByUsernameAndPassword(username, plainPassword);

            if (UserID > 0)
            {
                LoggedIn = true;

                LoadSettings();
                LoadPermissions();

                return(true);
            }
            return(false);
        }
Esempio n. 7
0
        private void Load(int Userid)
        {
            string select = "SELECT PERMISSION FROM USER_PERMISSIONS where USER_ID=:userid " +
                            "UNION ALL SELECT PERMISSION FROM USER_GROUPS inner join GROUP_PERMISSIONS " +
                            "on USER_GROUPS.GROUP_ID=GROUP_PERMISSIONS.GROUP_ID where USER_GROUPS.USER_ID=:userid";

            OracleCommand cmd = new OracleCommand(select, Database_Connector.GetConnection());

            OracleParameter uid = new OracleParameter("userid", OracleDbType.Int32);

            uid.Value = Userid;

            cmd.Parameters.Add(uid);
            OracleDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                UserPermissions.Add(dr["PERMISSION"].ToString().ToLower());
            }

            Database_Connector.CloseConnection();
        }
Esempio n. 8
0
 private void bt_Finish_Click(object sender, EventArgs e)
 {
     if (Modify)
     {
         try
         {
             Database_Connector.Update.User(userId, tb_Username.Text, tb_Name.Text, tb_LastName.Text);
             if ((tb_Password.Text != String.Empty || tb_ConfPassword.Text != String.Empty))
             {
                 PasswordValid();
                 Database_Connector.Update.UserPassword(userId, tb_Password.Text);
             }
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         try
         {
             if (tb_Username.Text.Equals(string.Empty))
             {
                 throw new Exception("USERNAME_EMPTY");
             }
             PasswordValid();
             Database_Connector.AddUser(tb_Username.Text, tb_Password.Text, tb_Name.Text, tb_LastName.Text);
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Esempio n. 9
0
        private void LoadSettings()
        {
            //Settings.Default["Language"] = Database_Connector.Select.LanguageSetting();

            /* Fonction to load ALL SETTINGS */
            OracleConnection conn_  = Database_Connector.GetConnection();
            string           select = "SELECT key, value FROM user_settings WHERE user_id=:userid";
            OracleCommand    cmd    = new OracleCommand(select, conn_);

            cmd.Parameters.Add(new OracleParameter("userid", Main.user.ID.ToString()));

            OracleDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                string key   = Convert.ToString(dr["key"]);
                string value = Convert.ToString(dr["value"]);

                Settings.Default[key] = value;
            }
            conn_.Close();

            // Load into Main
        }
Esempio n. 10
0
 private void Main_Menu_FormClosed(object sender, FormClosedEventArgs e)
 {
     Database_Connector.CloseConnection();
 }