private void toolStripDeleteItemButton_Click(object sender, EventArgs e) { string idText = deleteIdTextBox.Text; int id = Int32.Parse(idText); posts postForDelete = db.posts.Where(it => it.id == id).Single(); db.posts.DeleteOnSubmit(postForDelete); db.SubmitChanges(); updatePostTableView(); deleteIdTextBox.Text = ""; }
private void toolStripAddItemButton_Click(object sender, EventArgs e) { string idText = postId.Text; int id = Int32.Parse(idText); string userIDT = postUserID.Text; int userID = Int32.Parse(userIDT); posts newPost = new posts(); newPost.id = id; newPost.header = postHeader.Text; newPost.short_topic = postShortTopic.Text; newPost.main_topic = postMainTopic.Text; newPost.user_id = userID; db.posts.InsertOnSubmit(newPost); db.SubmitChanges(); updatePostTableView(); clearInput(); }
private void saveToolStripButton_Click_1(object sender, EventArgs e) { string idText = postId.Text; int id = Int32.Parse(idText); int userId = 0; string userIdText = postUserID.Text; if (userIdText.Length > 0) { userId = Int32.Parse(userIdText); } posts postForUpdate = db.posts.Where(it => it.id == id).Single(); if (postHeader.Text.Length > 0) { postForUpdate.header = postHeader.Text; } if (postShortTopic.Text.Length > 0) { postForUpdate.short_topic = postShortTopic.Text; } if (postMainTopic.Text.Length > 0) { postForUpdate.main_topic = postMainTopic.Text; } if (postForUpdate.user_id != userId && userId > 0) { postForUpdate.user_id = userId; } db.SubmitChanges(); updatePostTableView(); }
private void detach_posts(posts entity) { this.SendPropertyChanging(); entity.users = null; }
private void attach_posts(posts entity) { this.SendPropertyChanging(); entity.users = this; }
partial void Deleteposts(posts instance);
partial void Updateposts(posts instance);
partial void Insertposts(posts instance);