public void Load() { if (this.Id != null) { try { using (VisitMgtDataContext vmdc = new VisitMgtDataContext()) { visit_card vc = vmdc.visit_card.Single(q => q.c_id == this.Id); this.Desc = vc.c_desc; this.availiable = (bool)vc.c_avaliable; this.Type = (VisitMgt.CardType)vc.c_type; } } catch (Exception ex) { throw new Exception("获取访客卡信息失败", ex); } } }
public void save() { try { using (VisitMgtDataContext vmdc = new VisitMgtDataContext()) { visit_card vc = new visit_card { c_id = this.Id, c_desc = this.Desc, c_avaliable = this.availiable, c_type = (int)this.Type }; vmdc.visit_card.InsertOnSubmit(vc); } } catch (Exception ex) { throw new Exception("更新访客卡失败", ex); } }