public bool AddQuestionSubject(string q_obj_id , string q_dfn_id , int num , string q_sbj_name , double weight , string q_sbj_define , string q_sbj_desc , DateTime create_date , int create_user) { int affectedRow = 0; IDbConnection conn = DbAgentHelper.CreateDbConnection(); conn.Open(); IDbTransaction trx = conn.BeginTransaction(); try { Dac_KeyGens keyGen = new Dac_KeyGens(); string q_sbj_id = keyGen.GetCode(conn, trx, "EST_QUESTION_SUBJECT"); affectedRow = _questionsubject.Insert(conn , trx , q_sbj_id , q_obj_id , q_dfn_id , num , q_sbj_name , weight , q_sbj_define , q_sbj_desc , create_date , create_user); trx.Commit(); } catch (Exception ex) { trx.Rollback(); return(false); } finally { conn.Close(); } return((affectedRow > 0) ? true : false); }
public bool CopyQuestionObject(DataTable dataTable) { int affectedRow = 0; Dac_QuestionEstMaps questionEstMap = new Dac_QuestionEstMaps(); Dac_QuestionSubjects questionSubject = new Dac_QuestionSubjects(); Dac_QuestionItems questionItem = new Dac_QuestionItems(); Dac_QuestionDatas questionData = new Dac_QuestionDatas(); Dac_KeyGens keyGen = new Dac_KeyGens(); IDbConnection conn = DbAgentHelper.CreateDbConnection(); conn.Open(); IDbTransaction trx = conn.BeginTransaction(); try { //EST_QUESTION_OBJECT - 복사 foreach (DataRow dataRowDT in dataTable.Rows) { DataTable dtObj = _questionObject.Select(conn , trx , DataTypeUtility.GetValue(dataRowDT["EST_ID"]) , DataTypeUtility.GetValue(dataRowDT["Q_OBJ_ID"])).Tables[0]; DataTable dtEstMap = questionEstMap.Select(conn , trx , "" , DataTypeUtility.GetValue(dataRowDT["Q_OBJ_ID"])).Tables[0]; foreach (DataRow dataRowObj in dtObj.Rows) { string q_obj_id = keyGen.GetCode(conn , trx , "EST_QUESTION_OBJECT"); // 질의 그룹 등록 affectedRow += _questionObject.Insert(conn , trx , q_obj_id , "Copy of " + DataTypeUtility.GetValue(dataRowObj["Q_OBJ_NAME"]) , DataTypeUtility.GetValue(dataRowObj["Q_OBJ_TITLE"]) , DataTypeUtility.GetValue(dataRowObj["Q_OBJ_PREFACE"]) , DataTypeUtility.GetToDateTime(dataRowDT["DATE"]) , DataTypeUtility.GetToInt32(dataRowDT["USER"])); // 질의 매핑 등록 foreach (DataRow dataRowEstMap in dtEstMap.Rows) { affectedRow += questionEstMap.Insert(conn , trx , DataTypeUtility.GetValue(dataRowEstMap["EST_ID"]) , q_obj_id , DataTypeUtility.GetToDateTime(dataRowDT["DATE"]) , DataTypeUtility.GetToInt32(dataRowDT["USER"])); } DataTable dtSub = questionSubject.Select(conn , trx , "" , DataTypeUtility.GetValue(dataRowObj["Q_OBJ_ID"]) , "").Tables[0]; // 질의 제목 등록 foreach (DataRow dataRowSub in dtSub.Rows) { string q_sbj_id = keyGen.GetCode(conn , trx , "EST_QUESTION_SUBJECT"); affectedRow += questionSubject.Insert(conn , trx , q_sbj_id , q_obj_id , DataTypeUtility.GetValue(dataRowSub["Q_DFN_ID"]) , DataTypeUtility.GetToInt32(dataRowSub["NUM"]) , DataTypeUtility.GetValue(dataRowSub["Q_SBJ_NAME"]) , DataTypeUtility.GetToDouble(dataRowSub["WEIGHT"]) , DataTypeUtility.GetValue(dataRowSub["Q_SBJ_DEFINE"]) , DataTypeUtility.GetValue(dataRowSub["Q_SBJ_DESC"]) , DataTypeUtility.GetToDateTime(dataRowDT["DATE"]) , DataTypeUtility.GetToInt32(dataRowDT["USER"])); DataTable dtItem = questionItem.Select(conn , trx , "" , DataTypeUtility.GetValue(dataRowSub["Q_SBJ_ID"]) , DataTypeUtility.GetValue(dataRowObj["Q_OBJ_ID"])).Tables[0]; // 질의 항목 등록 foreach (DataRow dataRowItem in dtItem.Rows) { string q_itm_id = keyGen.GetCode(conn , trx , "EST_QUESTION_ITEM"); affectedRow += questionItem.Insert(conn , trx , q_itm_id , q_sbj_id , DataTypeUtility.GetToInt32(dataRowItem["NUM"]) , DataTypeUtility.GetValue(dataRowItem["Q_ITEM_NAME"]) , DataTypeUtility.GetToDouble(dataRowItem["POINT"]) , DataTypeUtility.GetValue(dataRowItem["COMMENT"]) , DataTypeUtility.GetValue(dataRowItem["SUBJECT_ITEM_YN"]) , DataTypeUtility.GetToDateTime(dataRowDT["DATE"]) , DataTypeUtility.GetToInt32(dataRowDT["USER"])); } } } } trx.Commit(); } catch (Exception ex) { trx.Rollback(); return(false); } finally { conn.Close(); } return((affectedRow > 0) ? true : false); }