public void LoadQAndA(string id, string type) { StudioMResource.QandAForSupplier qa; StudioMQandA.Clear(); client = new SQSAdminServiceClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint); DataSet ds = client.SQSAdmin_StudioM_LoadStudioMAttributeForClusterOrGroup(id, type, DefaultStateID.ToString()); client.Close(); foreach (DataRow dr in ds.Tables[0].Rows) { qa = new StudioMResource.QandAForSupplier(); qa.SupplierBrandID = int.Parse(dr["idStudioMSupplier"].ToString()); qa.SupplierBrandName = dr["SupplierName"].ToString(); qa.QuestionID = int.Parse(dr["idTemplateQuestion"].ToString()); qa.QuestionText = dr["Question"].ToString(); if (bool.Parse(dr["mandatory"].ToString())) { qa.Mandatory = true; } else { qa.Mandatory = false; } qa.AnswerType = dr["AnswerType"].ToString(); qa.AnswerID = int.Parse(dr["idTemplateAnswer"].ToString()); qa.AnswerText = dr["Answer"].ToString(); StudioMQandA.Add(qa); } }
public void AddStudioMAttributes(StudioMResource.QandAForSupplier qa, int index) { bool dul = false; foreach (var item in StudioMQandA) { if (item.SupplierBrandID == qa.SupplierBrandID && item.QuestionID == qa.QuestionID && item.AnswerID == qa.AnswerID) { dul = true; break; } } if (!dul) { if (index == -1) // add to the bottom { StudioMQandA.Add(qa); } else { StudioMQandA.Insert(index, qa); } } }
public void RemoveStudioMAttributes(StudioMResource.QandAForSupplier qa) { StudioMQandA.Remove(qa); }