public void Delete() { try { using (VisitMgtDataContext vmdc = new VisitMgtDataContext()) { visitor_cert vc = vmdc.visitor_cert.Single(q => q.cert_id == CertID); vmdc.visitor_cert.DeleteOnSubmit(vc); vmdc.SubmitChanges(); } } }
public void Save() { try { using (VisitMgtDataContext vmdc = new VisitMgtDataContext()) { visitor_cert vc = new visitor_cert { cert_id = this.CertID, cert_host = this.Host.Id, cert_name = this.Name, cert_type = this.CertType.TypeCode, cert_code = this.CertCode, cert_exipred = this.ExpiredDate }; vmdc.visitor_cert.InsertOnSubmit(vc); } } catch (Exception ex) { throw new Exception("保存证件失败", ex); } }
public Cert(Guid id) { try { using (VisitMgtDataContext vmdc = new VisitMgtDataContext()) { visitor_cert vc = vmdc.visitor_cert.Single(q => q.cert_id == id); this.CertID = id; this.Host = new Visitor((int)vc.cert_host); this.Name = vc.cert_name; this.CertType = new CertType(vc.cert_type); this.CertCode = vc.cert_code; if (vc.cert_exipred != null) { this.ExpiredDate = (DateTime)vc.cert_exipred; } } } catch (Exception ex) { throw new Exception("获取证件失败", ex); } }