public static void DeleteKnot(int knotId) { Knots knot = db.Knots.Where(k => k.id.Equals(knotId)).Single(); Guides guide = db.Guides.Where(g => g.id.Equals(knot.guide_id)).Single(); db.Knots.DeleteOnSubmit(knot); db.Guides.DeleteOnSubmit(guide); db.SubmitChanges(); MessageBox.Show("Узел <" + knot.name + "> успешно удален", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static void UpdateKnot(int knotId, string knotName, string knotComment, Binary knotBinary, string guideComment, Binary guideBinary, int typeId) { Knots knot = db.Knots.Where(k => k.id.Equals(knotId)).Single(); Guides guide = db.Guides.Where(g => g.id.Equals(knot.guide_id)).Single(); knot.name = knotName; knot.comment = knotComment; knot.image = knotBinary; knot.type_id = typeId; guide.comment = guideComment; guide.image = guideBinary; db.SubmitChanges(); MessageBox.Show("Данные об узле <" + knotName + ">, успешно изменены.", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static void InsertKnot(string knotName, string knotComment, Binary knotBinary, string guideComment, Binary guideBinary, int typeId) { bool exist = db.Knots.Where(k => k.name.Equals(knotName)).Any(); if (exist != true) { Guides newGuide = new Guides { comment = guideComment, image = guideBinary }; db.Guides.InsertOnSubmit(newGuide); db.SubmitChanges(); Guides guide = db.Guides.ToList().Last(); Knots newKnot = new Knots { name = knotName, comment = knotComment, image = knotBinary, type_id = typeId, guide_id = guide.id }; db.Knots.InsertOnSubmit(newKnot); db.SubmitChanges(); MessageBox.Show("Новый узел <" + knotName + "> успешно добавлен.", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Узел с названием <" + knotName + "> уже существует.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void detach_Knots(Knots entity) { this.SendPropertyChanging(); entity.Types = null; }
private void attach_Knots(Knots entity) { this.SendPropertyChanging(); entity.Types = this; }
partial void DeleteKnots(Knots instance);
partial void UpdateKnots(Knots instance);
partial void InsertKnots(Knots instance);