public bool setAccusation(int _AccuselID, string _AccusedAvatar, int _AccusedID) { Accusation_Table At = new Accusation_Table(); At.MemberID = Viewbag.member.MemberID; // At.MemberID = 3; At.AccuseID = _AccuselID + 1; At.AccusedAvatar = _AccusedAvatar; At.AccusedID = _AccusedID.ToString(); DE.Accusation_Table.Add(At); DE.SaveChanges(); if (_AccusedAvatar == "0") { Recipe_Table q = (from n in DE.Recipe_Table where n.RecipeID == _AccusedID select n).FirstOrDefault(); q.DisVisible = true; } else if (_AccusedAvatar == "1") { CommentSection_Table q = (from n in DE.CommentSection_Table where n.CommentID == _AccusedID select n).FirstOrDefault(); q.DisVisible = true; } DE.SaveChanges(); return(true); }
private void button2_Click(object sender, EventArgs e) { int get_select = Convert.ToInt32(dataGridView1.CurrentRow.Cells["AccusedID"].Value); int get_select_Accusation = Convert.ToInt32(dataGridView1.CurrentRow.Cells["AccusationRightID"].Value); Recipe_Table q = (from n in DE.Recipe_Table where n.RecipeID == get_select select n).FirstOrDefault(); q.DisVisible = false; DE.SaveChanges(); var q2 = (from n in DE.Accusation_Table where n.AccusationRightID == get_select_Accusation select n).FirstOrDefault(); q2.ProgressID = 1; DE.SaveChanges(); var result = (from n in DE.Recipe_Table where n.RecipeID == get_select select new { n.RecipeID, n.RecipeName, n.DisVisible }); dataGridView2.DataSource = result.ToList(); }
private void btn_delete_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("確定刪除?", "系統提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { Recipe_Table table = Delicious.Recipe_Table.First(r => r.MemberID == memberData.MemberID); table.DeleteOrNot = false; Delicious.SaveChanges(); MessageBox.Show("刪除成功"); this.Close(); } catch (Exception) { MessageBox.Show("刪除失敗,請聯絡管理員"); } } }
private void btn_Save_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("確認新增?", "通知", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { var Recipe = new Recipe_Table() { MemberID = Viewbag.member.MemberID, Picture = RecipeByte, RecipeName = tb_RecipeName.Text, RecipeCategoryID = cb_CategoryName.SelectedIndex + 1, ForHowMany = Convert.ToInt32(tb_howmany.Text), TimeNeed = Convert.ToInt32(tb_Time.Text) * 60, RecipeDescription = tb_RecipeDescription.Text, Video = tb_Video.Text, PostTime = DateTime.Now, ShareLink = "https://www.youtube.com/watch?v=072tU1tamd0", DeleteOrNot = false, DisVisible = false }; Delicious.Recipe_Table.Add(Recipe); Delicious.SaveChanges(); var NowRecipeID = (from A in Delicious.Recipe_Table select A.RecipeID).Max(); for (int i = 0; i < ID_List.Count; i++) { var Ingredient = new Ingredient_Record_Table() { IngredientID = ID_List[i], RecipeID = NowRecipeID, Unt = Unt_List[i], IngredientAmountForUse = ForUse_List[i], }; Delicious.Ingredient_Record_Table.Add(Ingredient); } Delicious.SaveChanges(); for (int i = 0; i < Step.Count; i++) { var AddStep = new Steps_Table() { RecipeID = NowRecipeID, StepsNumber = i + 1, Steps = Step[i], Picture = Img[i] }; Delicious.Steps_Table.Add(AddStep); } Delicious.SaveChanges(); MessageBox.Show("新增成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { return; } } catch (Exception) { MessageBox.Show("新增失敗", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); } }