private ShiftAssociationCollection createShiftAssociation(DataTable lineTable, String association) { ShiftAssociationCollection Association = new ShiftAssociationCollection(); for (int i = 0; i < lineTable.Rows.Count; i++) { Association.Add(new ShiftAssociationInfo((int)lineTable.Rows[i]["id"], (string)lineTable.Rows[i]["description"], (association.ToCharArray())[i] == '0' ? false : true)); } return Association; }
public void createAssociation(Contact c, String lineTag, string shiftTag, string departmentTag, string escalationTag) { SqlConnection con = new SqlConnection(conStr); con.Open(); String qry; qry = String.Empty; qry = @"SELECT * FROM lines"; SqlCommand cmd = new SqlCommand(qry, con); SqlDataReader dr = cmd.ExecuteReader(); DataTable lineTable = new DataTable(); lineTable.Load(dr); dr.Close(); qry = @"SELECT * FROM shift"; cmd = new SqlCommand(qry, con); dr = cmd.ExecuteReader(); DataTable shiftTable = new DataTable(); shiftTable.Load(dr); dr.Close(); qry = @"SELECT * FROM departments"; cmd = new SqlCommand(qry, con); dr = cmd.ExecuteReader(); DataTable departmentTable = new DataTable(); departmentTable.Load(dr); dr.Close(); qry = @"SELECT * FROM escalation"; cmd = new SqlCommand(qry, con); dr = cmd.ExecuteReader(); DataTable escalationTable = new DataTable(); escalationTable.Load(dr); dr.Close(); cmd.Dispose(); LineAssociationCollection lineAssociation = new LineAssociationCollection(); for (int i = 0; i < lineTable.Rows.Count; i++) { lineAssociation.Add(new LineAssociationInfo((int)lineTable.Rows[i]["id"], (string)lineTable.Rows[i]["description"], (lineTag.ToCharArray())[i] == '0' ? false : true)); } c.LineAssociation = lineAssociation; ShiftAssociationCollection shiftAssociation = new ShiftAssociationCollection(); for (int i = 0; i < shiftTable.Rows.Count; i++) { shiftAssociation.Add(new ShiftAssociationInfo((int)shiftTable.Rows[i]["id"], (string)shiftTable.Rows[i]["description"], (shiftTag.ToCharArray())[i] == '0' ? false : true)); } c.ShiftAssociation = shiftAssociation; DepartmentAssociationCollection departmentAssociation = new DepartmentAssociationCollection(); for (int i = 0; i < departmentTable.Rows.Count; i++) { departmentAssociation.Add(new DepartmentAssociationInfo((int)departmentTable.Rows[i]["id"], (string)departmentTable.Rows[i]["description"], (departmentTag.ToCharArray())[i] == '0' ? false : true)); } c.DepartmentAssociation = departmentAssociation; EscalationAssociationCollection escalationAssociation = new EscalationAssociationCollection(); for (int i = 0; i < escalationTable.Rows.Count; i++) { escalationAssociation.Add(new EscalationAssociationInfo((int)escalationTable.Rows[i]["id"], (string)escalationTable.Rows[i]["description"], (escalationTag.ToCharArray())[i] == '0' ? false : true)); } c.EscalationAssociation = escalationAssociation; con.Close(); con.Dispose(); }
private ShiftAssociationCollection createShiftAssociation(DataTable lineTable, String association) { ShiftAssociationCollection Association = new ShiftAssociationCollection(); SqlConnection con = new SqlConnection(conStr); con.Open(); SqlCommand cmd; String qry; qry = String.Empty; qry = @"SELECT * FROM shift"; cmd = new SqlCommand(qry, con); SqlDataReader dr = cmd.ExecuteReader(); DataTable shiftTable = new DataTable(); shiftTable.Load(dr); dr.Close(); for (int i = 0; i < shiftTable.Rows.Count; i++) { Association.Add(new ShiftAssociationInfo((int)shiftTable.Rows[i]["id"], (string)lineTable.Rows[i]["description"], (association.ToCharArray())[i] == '0' ? false : true)); } return Association; }