Ejemplo n.º 1
0
    protected void btnAddGenre_click(object sender, EventArgs e) //To ADD NEW GENRE
    {
        int    genreCount = 0;
        string connString = ConfigurationManager.ConnectionStrings["UserDetailsConnectionString"].ConnectionString;

        using (SqlConnection connect = new SqlConnection(connString))
        {
            using (SqlCommand cmd = new SqlCommand("SELECT count(*) from tblGenre where Genre='" + tbxGenreName.Text + "'"))
            {
                cmd.Connection = connect;
                connect.Open();
                genreCount = Convert.ToInt32(cmd.ExecuteScalar());
            }
        }
        if (genreCount == 0 && tbxGenreName.Text != "")
        {
            Genres objGenres = new Genres();
            objGenres.Genre = tbxGenreName.Text.Trim();

            objGenres.AddGenre(objGenres);
            Response.Redirect("AddSkills.aspx");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('New Genre added.')", true);
        }
        else if (tbxGenreName.Text != "")
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('This Genre is already added.')", true);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Enter Name of Genre.')", true);
        }
        //Response.Redirect("AddSkills.aspx");
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Checking genre's input and sending it to the database
        /// </summary>
        /// <returns>True if genre sent to DB, otherwise false</returns>
        private bool AddItemGenre()
        {
            GenreAddViewModel viewmodel = (GenreAddViewModel)DataContext;
            Genre             genre     = viewmodel.MyGenre;

            if (string.IsNullOrEmpty(genre.Name))
            {
                MessageBox.Show("Name cannnot be empty.");
                return(false);
            }
            foreach (var g in Genres.GenresList)
            {
                if (g.Name == genre.Name)
                {
                    MessageBox.Show("Genre already exists!");
                    return(false);
                }
            }
            try
            {
                int id = MSAConnectionDB.SaveGenreToDB(genre);
                genre.GenreId = id;
                Genres.AddGenre(genre);
                ActivateMainWindow();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            return(true);
        }
Ejemplo n.º 3
0
    protected void btnAddGenre_click(object sender, EventArgs e) //To ADD NEW GENRE
    {
        Genres objGenres = new Genres();

        objGenres.Genre = tbxGenreName.Text.Trim();

        objGenres.AddGenre(objGenres);
    }
Ejemplo n.º 4
0
    protected void AddGenreButton_Click(object sender, EventArgs e)
    {
        NewGenreTextBox.Visible = true;

        if (NewGenreTextBox.Text.Trim() != "")
        {
            Genre g1 = new Genre(0, NewGenreTextBox.Text.Trim());

            Genres.AddGenre(g1);

            NewGenreTextBox.Text    = "";
            NewGenreTextBox.Visible = false;

            GenresListBox.DataSource     = Genres.GetAllGenres();
            GenresListBox.DataTextField  = "Genre";
            GenresListBox.DataValueField = "GenreID";
            GenresListBox.DataBind();
        }
    }