Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            RestaurantDBDataContext rb = new RestaurantDBDataContext();

            int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

            Restaurant r = rb.Restaurants.FirstOrDefault(s => s.id == id);

            rb.Restaurants.DeleteOnSubmit(r);

            rb.SubmitChanges();

            bindgridview();
        }
Example #2
0
        private void insert_Click(object sender, EventArgs e)
        {
            db = new RestaurantDBDataContext();

            r = new Restaurant();

            r.id    = int.Parse(idbox.Text);
            r.name  = namebox.Text;
            r.rooms = int.Parse(roombox.Text);
            r.city  = citybox.Text;

            db.Restaurants.InsertOnSubmit(r);
            db.SubmitChanges();
            bindgridview();
        }
Example #3
0
        private void update_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                RestaurantDBDataContext rb = new RestaurantDBDataContext();

                int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value);

                Restaurant rr = rb.Restaurants.FirstOrDefault(s => s.id == id);

                rr.id    = int.Parse(idbox.Text.ToString());
                rr.name  = namebox.Text.ToString();
                rr.city  = citybox.Text.ToString();
                rr.rooms = int.Parse(roombox.Text.ToString());

                rb.SubmitChanges();

                bindgridview();
            }
            else
            {
                MessageBox.Show(" SELECT SOMETHING BUDDY ");
            }
        }
Example #4
0
 public void bindgridview()
 {
     db = new RestaurantDBDataContext();
     dataGridView1.DataSource = db.Restaurants;
 }