protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // int movieId = Convert.ToInt32(Session["movieId"]);
            int movieId = Convert.ToInt32(Session[ddlMovie.SelectedValue]);

            try
            {
                if (ddlMovie.SelectedValue != "Seçiniz")
                {
                    field.movieId = Convert.ToInt32(ddlMovie.SelectedValue);
                }
                field.movieYear = Convert.ToDateTime(datepicker.Text);
                //field.director = txtDirector.Text;
                field.movieId    = Convert.ToInt32(ddlMovie.SelectedValue);
                field.directorId = Convert.ToInt32(ddlDirectors.SelectedValue);

                bl.UpdateMovie(field);
                bl.UpdateDirector(field);
                Session["selectedmovieid"] = 0;
                if (FileUpload1.HasFile)
                {
                    field.imageData = "~/Uploads/" + FileUpload1.FileName.ToString();
                    bl.updateImage(field);
                    //ddlMovie.ClearSelection();
                    //listType.Items.Clear();
                    //datepicker.Text = "";
                    //ddlDirectors.ClearSelection();
                    //listActors.Items.Clear();
                    Response.Redirect("Movies.aspx");
                }
                for (int i = 0; i < chktype.Items.Count; i++)
                {
                    if (chktype.Items[i].Selected)
                    {
                        bl.InsertType(field, Convert.ToInt32(chktype.Items[i].Value));
                    }
                }
                for (int i = 0; i < chkboxActors.Items.Count; i++)
                {
                    if (chkboxActors.Items[i].Selected)
                    {
                        bl.InsertActors(field, Convert.ToInt32(chkboxActors.Items[i].Value));
                    }
                }

                // Response.Write("<script>alert('"+ddlMovie.SelectedItem.Text+" was Updated Successfullyxcd!')</script>");
                Response.Redirect("Movies.aspx");
            }
            catch (Exception ex)
            {
                lblmessage.Text = ex.ToString();
            }
        }
Beispiel #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            field.text = txttype.Text;
            bl.InsertType(field);
            DataAccess dal = new DataAccess();
            SqlCommand cmd = dal.Query("sp_ListTypes");

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataSet ds = new DataSet();

            da.Fill(ds);

            listType.DataSource     = ds.Tables[0];
            listType.DataValueField = "typeId";
            listType.DataTextField  = "type";
            listType.DataBind();

            DataBind();

            txttype.Text = "";
            field.text   = "";
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                field.movieName = txtName.Text;
                field.movieYear = Convert.ToDateTime(datepicker.Text);
                field.movieId   = bl.InsertMovieRT(field);

                for (int i = 0; i < chkbox.Items.Count; i++)
                {
                    if (chkbox.Items[i].Selected)
                    {
                        bl.InsertType(field, Convert.ToInt32(chkbox.Items[i].Value));
                    }
                }
                for (int i = 0; i < rbDirectors.Items.Count; i++)
                {
                    if (rbDirectors.Items[i].Selected)
                    {
                        bl.InsertDirectors(field.movieId, Convert.ToInt32(rbDirectors.Items[i].Value));
                    }
                }
                for (int i = 0; i < chkactors.Items.Count; i++)
                {
                    if (chkactors.Items[i].Selected)
                    {
                        bl.InsertActors(field, Convert.ToInt32(chkactors.Items[i].Value));
                    }
                }
                if (FileUpload1.HasFile)
                {
                    try
                    {
                        FileUpload1.SaveAs(Server.MapPath("~/Uploads/" +
                                                          FileUpload1.FileName));
                        // field.imageData = "C:\\Users\\Betul\\Desktop\\moviesSon\\Uploads\\" +
                        // FileUpload1.FileName.ToString();
                        // lblmessage.Text = "File name: " + FileUpload1.PostedFile.FileName + "<br>" + FileUpload1.PostedFile.ContentLength + " kb<br>" +
                        //   "Content type: " +  FileUpload1.PostedFile.ContentType;
                        lblmessage.Text = "~/Uploads/" + FileUpload1.FileName.ToString();

                        string image = field.imageData = lblmessage.Text;
                        //Image1.ImageUrl = image;
                        bl.InsertImageData(field);
                    }
                    catch (Exception ex)
                    {
                        lblmessage.Text = "ERROR: " + ex.Message.ToString();
                    }
                }
                else
                {
                    lblmessage.Text = "You have not specified a file.";
                }

                chkbox.ClearSelection();
                rbDirectors.ClearSelection();
                chkactors.ClearSelection();
                txtName.Text    = "";
                datepicker.Text = "";


                Response.Redirect("Movies.aspx");
            }

            catch (Exception ex)
            {
                lblmessage.Text = "ERROR: " + ex.Message.ToString();
            }
        }