public string deleteKnowledgePoint(string kpId)
 {
     KnowledgePointTableAdapter kpta = new KnowledgePointTableAdapter();
     KnowledgePointAssetRelationTableAdapter assetAdapter = new KnowledgePointAssetRelationTableAdapter();
     try
     {
         kpta.DeleteKPById(Convert.ToInt16(kpId));
         assetAdapter.DeleteRelationByKnowledgePointId(Convert.ToInt16(kpId));
         return "success";
     }
     catch {
         return "error";
     }
 }
        public string updateKnowledgePoint(KnowledgePoint updatedKnowledgePoint)
        {
            KnowledgePointTableAdapter kpAdapter = new KnowledgePointTableAdapter();
            //check knowledge point exist
            if (kpAdapter.GetKnowledgePointById(updatedKnowledgePoint.id).Count > 0)
            {
                int success = kpAdapter.UpdateKnowledgePoint(updatedKnowledgePoint.name, (int)(updatedKnowledgePoint.priority), updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime(updatedKnowledgePoint.createDate), Convert.ToDateTime(updatedKnowledgePoint.modifiedDate), Convert.ToInt32(updatedKnowledgePoint.courseId), updatedKnowledgePoint.id);
                if (success == 0)
                {
                    return "Failed in update the details";
                }
            }
            else
            {
                //int success = kpAdapter.InsertNewKnowledgePoint(updatedKnowledgePoint.name, (int)updatedKnowledgePoint.priority, updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime("1/1/1753 12:00:00"), Convert.ToDateTime("1/1/1753 12:00:00"), Convert.ToInt32(updatedKnowledgePoint.courseId));
                int success = kpAdapter.InsertNewKnowledgePoint(updatedKnowledgePoint.name, (int)updatedKnowledgePoint.priority, updatedKnowledgePoint.posX, updatedKnowledgePoint.posY, Convert.ToDateTime(updatedKnowledgePoint.createDate), Convert.ToDateTime(updatedKnowledgePoint.modifiedDate), Convert.ToInt32(updatedKnowledgePoint.courseId));
                if (success == 0)
                {
                    return "Failed in add the details";
                }
            }
            KnowledgePointParentChildRelationTableAdapter relationAdapter = new KnowledgePointParentChildRelationTableAdapter();
            var updateTable = updatedKnowledgePoint.parentsKnowledgePointsId;

            relationAdapter.DeleteAllByChildId(updatedKnowledgePoint.id);

            for (int j = 0; j < updateTable.Count; j++)
            {
                relationAdapter.InsertNewRelation(updatedKnowledgePoint.id, updateTable[j]);
            }
            KnowledgePointAssetRelationTableAdapter assetAdapter = new KnowledgePointAssetRelationTableAdapter();

            assetAdapter.DeleteRelationByKnowledgePointId(updatedKnowledgePoint.id);
            for (int j = 0; j < updatedKnowledgePoint.assets.Count; j++)
            {
                assetAdapter.InsertNewAssetRelation(updatedKnowledgePoint.id, updatedKnowledgePoint.assets[j].id, updatedKnowledgePoint.assets[j].start, updatedKnowledgePoint.assets[j].end);
            }
            AssetTableAdapter ata = new AssetTableAdapter();
            for (int j = 0; j < updatedKnowledgePoint.messageBox.messageList.Count; j++)
            {
                assetAdapter.InsertNewAssetRelation(updatedKnowledgePoint.id, ata.GetIdByAssetName(updatedKnowledgePoint.messageBox.messageList[j].messageId.ToString())[0].Id, -1, -1);
            }
            return "Success";
        }