예제 #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");
     }
 }
예제 #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);
        }
예제 #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);
            }
예제 #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();
        }
예제 #5
0
 private void LoadDataBase()
 {
     try
     {
         Database_Connector.OpenConnection();
         Database.FillDataSet();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
예제 #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);
        }
예제 #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();
        }
예제 #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);
         }
     }
 }
예제 #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
        }
예제 #10
0
 private void Main_Menu_FormClosed(object sender, FormClosedEventArgs e)
 {
     Database_Connector.CloseConnection();
 }