public static List<TestPrivilege> BuildPrivilegeFromDataBaseData(string idPerson) { List<TestPrivilege> priveleges = new List<TestPrivilege>(); using (NpgsqlConnection connection = Global.GetSqlConnection()) { string findPriviledge = "SELECT * FROM public.priviledge WHERE id_person = '" + idPerson + "'"; NpgsqlCommand person = new NpgsqlCommand(findPriviledge, connection); using (NpgsqlDataReader contactReader = person.ExecuteReader()) { while (contactReader.Read()) { //что делать с DateSpecified? Privilege priv = new Privilege(); if (contactReader["date_start"] != DBNull.Value) priv.StartDate = Convert.ToDateTime(contactReader["date_start"]); if (contactReader["date_end"] != DBNull.Value) priv.EndDate = Convert.ToDateTime(contactReader["date_end"]); TestPrivilege privilege = new TestPrivilege(priv); if (contactReader["id_priviledge_code"] != DBNull.Value) privilege.privilegeType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(contactReader["id_priviledge_code"])); priveleges.Add(privilege); } } } return (priveleges.Count != 0) ? priveleges : null; }
static public List <TestPrivilege> BuildPrivilegeFromDataBaseData(string idPerson) { List <TestPrivilege> priveleges = new List <TestPrivilege>(); using (NpgsqlConnection connection = Global.GetSqlConnection()) { string findPriviledge = "SELECT * FROM public.priviledge WHERE id_person = '" + idPerson + "'"; NpgsqlCommand person = new NpgsqlCommand(findPriviledge, connection); using (NpgsqlDataReader contactReader = person.ExecuteReader()) { while (contactReader.Read()) { //что делать с DateSpecified? Privilege priv = new Privilege(); if (contactReader["date_start"] != DBNull.Value) { priv.StartDate = Convert.ToDateTime(contactReader["date_start"]); } if (contactReader["date_end"] != DBNull.Value) { priv.EndDate = Convert.ToDateTime(contactReader["date_end"]); } TestPrivilege privilege = new TestPrivilege(priv); if (contactReader["id_priviledge_code"] != DBNull.Value) { privilege.privilegeType = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(contactReader["id_priviledge_code"])); } priveleges.Add(privilege); } } } return((priveleges.Count != 0) ? priveleges : null); }
static public TestPatient BuildPatientFromDataBaseData(string idPerson, string MIS) { TestPatient patient = new TestPatient(); patient.addreses = TestAddress.BuildAdressesFromDataBaseData(idPerson); patient.contacts = TestContact.BuildContactsFromDataBaseData(idPerson); patient.documents = TestDocument.BuildDocumentsFromDataBaseData(idPerson); patient.jobs = TestJob.BuildJobFromDataBaseData(idPerson); patient.privileges = TestPrivilege.BuildPrivilegeFromDataBaseData(idPerson); patient.person = TestPerson.BuildPersonFromDataBaseData(idPerson, MIS); return(patient); }
public void FindMismatch(TestPrivilege b) { if (b.privilege != null) { if (this.privilege.EndDate != b.privilege.EndDate) { Global.errors3.Add("Несовпадение EndDate TestPrivilege"); } if (this.privilege.StartDate != b.privilege.StartDate) { Global.errors3.Add("Несовпадение StartDate TestPrivilege"); } if (Global.GetLength(this.privilegeType) != Global.GetLength(b.privilegeType)) { Global.errors3.Add("Несовпадение IdPrivilageType TestPrivilege"); } } }
public override bool Equals(Object obj) { TestPrivilege p = obj as TestPrivilege; if (p == null) { return(false); } if ((this.privilege.EndDate != p.privilege.EndDate) && (this.privilege.StartDate != p.privilege.StartDate) && Global.IsEqual(this.privilegeType, p.privilegeType)) { return(true); } else { this.FindMismatch(p); Global.errors3.Add("несовпадение TestPrivilege"); return(false); } }
public void FindMismatch(TestPrivilege b) { if (b.privilege != null) { if (this.privilege.EndDate != b.privilege.EndDate) Global.errors3.Add("Несовпадение EndDate TestPrivilege"); if (this.privilege.StartDate != b.privilege.StartDate) Global.errors3.Add("Несовпадение StartDate TestPrivilege"); if (Global.GetLength(this.privilegeType) != Global.GetLength(b.privilegeType)) Global.errors3.Add("Несовпадение IdPrivilageType TestPrivilege"); } }