Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox1.Text))
            {
                MessageBox.Show("You must enter the name of the movie!");
            }
            else
            {
                using (db = new DataClassesDataContext(c.connectionString))
                {
                    video v = new video();
                    v.name      = textBox1.Text;
                    v.status_id = 1;
                    v.type_id   = Int32.Parse((comboBox1.SelectedValue.ToString()));
                    v.year      = Convert.ToString(numericUpDown1.Value);
                    v.@new      = Int32.Parse((comboBox2.SelectedValue.ToString()));
                    v.data_add  = Convert.ToDateTime(DateTime.Now.ToShortDateString().ToString());



                    db.video.InsertOnSubmit(v);
                    try
                    {
                        db.SubmitChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        db.SubmitChanges();
                    }

                    MessageBox.Show("Great!");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/></param>
        /// <param name="e">The e<see cref="EventArgs"/></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox1.Text))
            {
                MessageBox.Show("You must enter the name of the movie!");
            }
            else
            {
                int videoID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

                using (db = new DataClassesDataContext(c.connectionString))
                {
                    var results = (
                        from v in db.video
                        where v.id == videoID
                        select v);

                    foreach (var res in results)
                    {
                        video v_now = db.video.Single(v => v.id == res.id);
                        v_now.name      = textBox1.Text;
                        v_now.type_id   = Int32.Parse((comboBox1.SelectedValue.ToString()));
                        v_now.year      = Convert.ToString(numericUpDown1.Value);
                        v_now.status_id = Int32.Parse((comboBox2.SelectedValue.ToString()));
                        v_now.data_edit = Convert.ToDateTime(DateTime.Now.ToShortDateString().ToString());
                        db.SubmitChanges();

                        dataGridView1.DataSource = db.v_video;
                        MessageBox.Show("Updated!");
                    }
                }

                /*  var count = (from r in db.rental
                 *             where r.video_id == videoID
                 *             select r).Count();
                 *
                 * if (count > 0)
                 * {
                 * }
                 */
            }
        }
Esempio n. 3
0
 private void detach_video(video entity)
 {
     this.SendPropertyChanging();
     entity.type = null;
 }
Esempio n. 4
0
 private void attach_video(video entity)
 {
     this.SendPropertyChanging();
     entity.type = this;
 }
Esempio n. 5
0
 partial void Deletevideo(video instance);
Esempio n. 6
0
 partial void Updatevideo(video instance);
Esempio n. 7
0
 partial void Insertvideo(video instance);