예제 #1
0
파일: Form2.cs 프로젝트: szafirow/RentalApp
        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!");
                }
            }
        }
예제 #2
0
파일: Form3.cs 프로젝트: szafirow/RentalApp
        /// <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)
                 * {
                 * }
                 */
            }
        }
예제 #3
0
 private void detach_video(video entity)
 {
     this.SendPropertyChanging();
     entity.type = null;
 }
예제 #4
0
 private void attach_video(video entity)
 {
     this.SendPropertyChanging();
     entity.type = this;
 }
예제 #5
0
 partial void Deletevideo(video instance);
예제 #6
0
 partial void Updatevideo(video instance);
예제 #7
0
 partial void Insertvideo(video instance);