public override string UpdateCUPE(CupeQuestionStringData cupeQuestion) { CLIENT client = ClientDataControl.Client.EntityObject as CLIENT; try { CUPE cupe = (from ent in client.CUPE where ent.CUPEQUESTION.NAME.TrimEnd() == cupeQuestion.OriginalQuestionText select ent).Single(); cupe.NAME = cupeQuestion.QuestionText; cupe.COMMODITY = cupeQuestion.ChoiceA; cupe.UTILITY = cupeQuestion.ChoiceB; cupe.PARTNER = cupeQuestion.ChoiceC; cupe.ENABLER = cupeQuestion.ChoiceD; if (cupe.NAME.TrimEnd() != cupe.CUPEQUESTION.NAME.TrimEnd()) { CUPEQUESTION cupeQuestionEnt; if(!GetCUPEQuestion(cupe.NAME.TrimEnd(), out cupeQuestionEnt)) { cupeQuestionEnt = new CUPEQUESTION(); cupeQuestionEnt.NAME = cupe.NAME; cupeQuestionEnt.COMMODITY = cupe.COMMODITY; cupeQuestionEnt.UTILITY = cupe.UTILITY; cupeQuestionEnt.PARTNER = cupe.PARTNER; cupeQuestionEnt.ENABLER = cupe.ENABLER; cupeQuestionEnt.INTWENTY = cupeQuestionEnt.INTEN = "N"; } cupe.CUPEQUESTION = cupeQuestionEnt; cupeQuestion.OriginalQuestionText = cupeQuestionEnt.NAME.TrimEnd(); } } catch { MessageBox.Show("Failed to update CUPE: " + cupeQuestion.QuestionText, "Error"); } return cupeQuestion.OriginalQuestionText; }
public override bool AddCupeQuestion(CupeQuestionStringData cupeQuestion) { if ((from ent in dbo.CUPEQUESTION where ent.NAME.TrimEnd() == cupeQuestion.QuestionText select ent).Count() != 0) { MessageBox.Show("Error adding question: Question already exists", "Error"); return false; } CUPEQUESTION cupeQuestionEnt = new CUPEQUESTION(); cupeQuestionEnt.NAME = cupeQuestion.QuestionText; cupeQuestionEnt.COMMODITY = cupeQuestion.ChoiceA; cupeQuestionEnt.UTILITY = cupeQuestion.ChoiceB; cupeQuestionEnt.PARTNER = cupeQuestion.ChoiceC; cupeQuestionEnt.ENABLER = cupeQuestion.ChoiceD; cupeQuestionEnt.INTWENTY = cupeQuestionEnt.INTEN = "N"; dbo.AddToCUPEQUESTION(cupeQuestionEnt); return true; }
/// <summary> /// Deprecated Method for adding a new object to the CUPEQUESTION EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCUPEQUESTION(CUPEQUESTION cUPEQUESTION) { base.AddObject("CUPEQUESTION", cUPEQUESTION); }
public bool GetCUPEQuestion(string cqName, out CUPEQUESTION cupeQuestion) { try { cupeQuestion = (from ent in dbo.CUPEQUESTION where ent.NAME.TrimEnd() == cqName select ent).Single(); } catch { cupeQuestion = null; return false; } return true; }
/// <summary> /// Create a new CUPEQUESTION object. /// </summary> /// <param name="cUPEQUESTIONID">Initial value of the CUPEQUESTIONID property.</param> public static CUPEQUESTION CreateCUPEQUESTION(global::System.Int32 cUPEQUESTIONID) { CUPEQUESTION cUPEQUESTION = new CUPEQUESTION(); cUPEQUESTION.CUPEQUESTIONID = cUPEQUESTIONID; return cUPEQUESTION; }