private void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DGridAppNames.SelectedItem == null)
                {
                    throw new Exception("No APP was selected.");
                }

                if (string.IsNullOrEmpty(TxtAppName.Text) || string.IsNullOrWhiteSpace(TxtAppName.Text))
                {
                    throw new Exception("APP Name cannot be empty.");
                }

                var _X = TxtMSI.Text;
                if (string.IsNullOrEmpty(_X) == false && string.IsNullOrWhiteSpace(_X) == false)
                {
                    var ext = System.IO.Path.GetExtension(_X).ToLower();
                    if (ext.Equals(".msi") == false && ext.Equals(".exe") == false)
                    {
                        TxtMSI.Focus();
                        TxtMSI.SelectAll();
                        throw new Exception("Check Installer's filename extension.");
                    }
                }

                _X = TxtEXE.Text;
                if (string.IsNullOrEmpty(_X) == false && string.IsNullOrWhiteSpace(_X) == false)
                {
                    var ext = System.IO.Path.GetExtension(_X).ToLower();
                    if (ext.Equals(".msi") == false && ext.Equals(".exe") == false)
                    {
                        TxtEXE.Focus();
                        TxtEXE.SelectAll();
                        throw new Exception("Check Installer's filename extension.");
                    }
                }


                if (MessageBox.Show("Update APP?", "Apps Center", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    Classes.MySQL A = new Classes.MySQL();
                    A.stored_procedure_with_params("Apps_Update");
                    A.cmd.Parameters.AddWithValue("@_APPNAME", TxtAppName.Text);
                    A.cmd.Parameters.AddWithValue("@_PATH_EXECUTABLE", TxtPathExe.Text);
                    A.cmd.Parameters.AddWithValue("@_LATEST_VERSION", TxtLatestVersion.Text);
                    A.cmd.Parameters.AddWithValue("@_PATH_LATEST_INSTALLER", TxtPathInstaller.Text);
                    A.cmd.Parameters.AddWithValue("@_MSI", TxtMSI.Text);
                    A.cmd.Parameters.AddWithValue("@_EXE", TxtEXE.Text);
                    A.cmd.Parameters.AddWithValue("@_COMPANY", (string.IsNullOrEmpty(CboPublishTo.Text) || CboPublishTo.Text.Equals("any", StringComparison.OrdinalIgnoreCase)) ? "" : CboPublishTo.Text);
                    A.cmd.Parameters.AddWithValue("@_OLD_APPNAME", (DGridAppNames.SelectedItem as AppName)._App);
                    A.rdr = A.cmd.ExecuteReader();

                    if (A.rdr.RecordsAffected == 1)
                    {
                        MessageBox.Show("APP Updated!", "Apps Center", MessageBoxButton.OK, MessageBoxImage.Information);
                        REFRESH();
                    }
                    else
                    {
                        throw new Exception("Failed updating APP!");
                    }

                    A.conn.Close(); A.conn.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "Apps Center", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            finally
            {
            }
        }
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(TxtAppName.Text) == false)
                {
                    var _X = TxtMSI.Text.ToLower();
                    //MessageBox.Show("Extension : " + System.IO.Path.GetExtension(_X));
                    if (string.IsNullOrEmpty(_X) == false && string.IsNullOrWhiteSpace(_X) == false)
                    {
                        if (System.IO.Path.GetExtension(_X).Contains("msi") == false)
                        {
                            TxtMSI.SelectAll();
                            throw new Exception("Check Installer's filename extension.");
                        }
                    }

                    _X = TxtEXE.Text.ToLower();
                    //MessageBox.Show("Extension : " + System.IO.Path.GetExtension(_X));
                    if (string.IsNullOrEmpty(_X) == false && string.IsNullOrWhiteSpace(_X) == false)
                    {
                        if (System.IO.Path.GetExtension(_X).Contains("exe") == false)
                        {
                            TxtEXE.SelectAll();
                            throw new Exception("Check Installer's filename extension.");
                        }
                    }

                    if (MessageBox.Show("Add new App?", "Apps Center", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        Classes.MySQL A = new Classes.MySQL();
                        A.stored_procedure_with_params("Apps_Insert");
                        A.cmd.Parameters.AddWithValue("@_APPNAME", TxtAppName.Text);
                        A.cmd.Parameters.AddWithValue("@_PATH_EXECUTABLE", TxtPathExe.Text);
                        A.cmd.Parameters.AddWithValue("@_LATEST_VERSION", TxtLatestVersion.Text);
                        A.cmd.Parameters.AddWithValue("@_PATH_LATEST_INSTALLER", TxtPathInstaller.Text);
                        A.cmd.Parameters.AddWithValue("@_MSI", TxtMSI.Text);
                        A.cmd.Parameters.AddWithValue("@_EXE", TxtEXE.Text);
                        A.cmd.Parameters.AddWithValue("@_COMPANY", (string.IsNullOrEmpty(CboPublishTo.Text) || CboPublishTo.Text.Equals("any", StringComparison.OrdinalIgnoreCase)) ? "" : CboPublishTo.Text);
                        A.rdr = A.cmd.ExecuteReader();

                        if (A.rdr.RecordsAffected == 1)
                        {
                            MessageBox.Show("New APP added!", "Apps Center", MessageBoxButton.OK, MessageBoxImage.Information);
                            REFRESH();
                        }
                        else
                        {
                            throw new Exception("Failed adding new APP!");
                        }

                        A.conn.Close(); A.conn.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "Apps Center", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            finally
            {
            }
        }