Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DafestyEntities ctx = new DafestyEntities();
            Movie           mv  = ctx.Movies1.Where(x => x.VideoCode == 400).First();

            ctx.Movies1.Remove(mv);
            ctx.SaveChanges();
            MessageBox.Show("Successfully Deleted");
        }
Example #2
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            int             code = Convert.ToInt32(tbFind.Text);
            DafestyEntities ctx  = new DafestyEntities();
            Movie           mv   = ctx.Movies1.Where(x => x.VideoCode == code).First();

            tbMovieTitle.Text = mv.MovieTitle;
            tbGenre.Text      = mv.Genre;
            tbVideoCode.Text  = mv.VideoCode.ToString();
            tbRentalCost.Text = mv.RentalCost.ToString();
        }
Example #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int             code = Convert.ToInt32(tbVideoCode.Text);
            DafestyEntities ctx  = new DafestyEntities();
            Movie           mv   = ctx.Movies1.Where(x => x.VideoCode == code).First();

            mv.MovieTitle = tbMovieTitle.Text;
            mv.Genre      = tbGenre.Text;
            mv.RentalCost = float.Parse(tbRentalCost.Text);
            ctx.SaveChanges();
            MessageBox.Show("Update is successful");
            Reset();
        }
Example #4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            DafestyEntities ctx = new DafestyEntities();
            Movie           mv  = new Movie();
            Producer        pd  = ctx.Producers.Where(x => x.ProducerID == "Warner").First();

            //int code = Convert.ToInt16(tbVideoCode.Text);
            mv.VideoCode  = 400;
            mv.MovieTitle = "Sully";
            mv.Genre      = "Darama";
            mv.ProducerID = pd.ProducerID;
            mv.RentalCost = 2.50f;
            mv.Rating     = "U";
            mv.TotalStock = 4;
            ctx.Movies1.Add(mv);
            ctx.SaveChanges();
            MessageBox.Show("Record is successfully inserted");
        }