private string UpdateData_Two(insert_Step_Two item) { string USERNO; using (Hr_RegisterDataContext bx = new Hr_RegisterDataContext()) { try { var str = (from xx in bx.STEP_TWOs where xx.USERNO == item.USERNO select xx).FirstOrDefault(); bx.STEP_TWOs.DeleteOnSubmit(str); bx.SubmitChanges(); //ts.Complete(); } catch (Exception ex) { throw new ArgumentException( $"{ex.Message} "); } } //} return(USERNO = item.USERNO); }
public IEnumerable <RetName> Regis_Step_Two(insert_Step_Two item) { List <RetName> results = new List <RetName>(); try { using (Hr_RegisterDataContext bx = new Hr_RegisterDataContext()) { var str = (from xx in bx.STEP_TWOs where xx.USERNO == item.USERNO select xx).FirstOrDefault(); string USERNO; int Status; if (str == null) { USERNO = InsertData_Two(item); Status = 1; } else { USERNO = UpdateData_Two(item); USERNO = InsertData_Two(item); Status = 2; } RetName res = new RetName(); res.status = "S"; if (Status == 1) { res.message = "Insert success"; } else if (Status == 2) { res.message = "Update success"; } res.USERNO = USERNO; results.Add(res); } } catch (Exception ex) { RetName res = new RetName(); res.status = "F"; res.message = ex.Message; results.Add(res); } return(results.ToArray()); }
public IEnumerable <insert_Step_Two> Back_Three_To_Two(RetName item) { //string strSQL = "SELECT POSITION,FULLNAME_TH FROM STEP_ONE"; List <insert_Step_Two> results = new List <insert_Step_Two>(); try { using (Hr_RegisterDataContext bx = new Hr_RegisterDataContext()) { var str = (from xx in bx.STEP_TWOs where xx.USERNO == item.USERNO select xx).FirstOrDefault(); insert_Step_Two res = new insert_Step_Two(); res.USERNO = str.USERNO; res.MARITAL = str.MARITAL; res.CHILDEN = str.CHILDEN; res.SPOUSE_NAME = str.SPOUSE_NAME; res.SPOUSE_AGE = str.SPOUSE_AGE; res.SPOUSE_OCCUPATION = str.SPOUSE_OCCUPATION; res.SPOUSE_OFFICE = str.SPOUSE_OFFICE; res.SPOUSE_PHONE = str.SPOUSE_PHONE; res.EMERGENCY = str.EMERGENCY; res.EMERGENCY_ROW1 = str.EMERGENCY_ROW1; res.EMERGENCY_ROW2 = str.EMERGENCY_ROW2; res.EMERGENCY_RELATIONSHIP = str.EMERGENCY_RELATIONSHIP; res.EMERGENCY_PHONE = str.EMERGENCY_PHONE; //res._WORKDATE = DateTime.Now.AddYears(543); results.Add(res); } } catch (Exception ex) { insert_Step_One res = new insert_Step_One(); res._USERNO = ex.Message; //results.Add(res); } return(results.ToArray()); }
private string InsertData_Two(insert_Step_Two item) { string USERNO; using (TransactionScope ts = new TransactionScope()) { using (Hr_RegisterDataContext bx = new Hr_RegisterDataContext()) { try { var Step_Two = new STEP_TWO(); Step_Two.USERNO = item.USERNO; USERNO = item.USERNO; Step_Two.MARITAL = item.MARITAL; Step_Two.CHILDEN = item.CHILDEN; Step_Two.SPOUSE_NAME = item.SPOUSE_NAME; Step_Two.SPOUSE_AGE = item.SPOUSE_AGE; Step_Two.SPOUSE_OCCUPATION = item.SPOUSE_OCCUPATION; Step_Two.SPOUSE_OFFICE = item.SPOUSE_OFFICE; Step_Two.SPOUSE_PHONE = item.SPOUSE_PHONE; Step_Two.EMERGENCY = item.EMERGENCY; Step_Two.EMERGENCY_ROW1 = item.EMERGENCY_ROW1; Step_Two.EMERGENCY_ROW2 = item.EMERGENCY_ROW2; Step_Two.EMERGENCY_RELATIONSHIP = item.EMERGENCY_RELATIONSHIP; Step_Two.EMERGENCY_PHONE = item.EMERGENCY_PHONE; Step_Two.FLAG = 0; bx.STEP_TWOs.InsertOnSubmit(Step_Two); bx.SubmitChanges(); ts.Complete(); } catch (Exception ex) { throw new ArgumentException( $"{ex.Message} "); } } } return(USERNO); }
public IEnumerable <ViewSummary> Summary(RetName item) { List <ViewSummary> results = new List <ViewSummary>(); ViewSummary summary = new ViewSummary(); string USERNO = item.USERNO; //List<insert_Step_One> One = new List<insert_Step_One>(); try { using (Hr_RegisterDataContext bx = new Hr_RegisterDataContext()) { var str_one = (from xx in bx.STEP_ONEs where xx.USERNO == USERNO select xx).FirstOrDefault(); insert_Step_One res_one = new insert_Step_One(); res_one._USERNO = str_one.USERNO; res_one._POSITION = str_one.POSITION; res_one._FULLNAME_TH = str_one.FULLNAME_TH; res_one._NICKNAME_TH = str_one.NICKNAME_TH; res_one._FULLNAME_EN = str_one.FULLNAME_EN; res_one._NICKNAME_EN = str_one.NICKNAME_EN; res_one._PEOPLEID = str_one.PEOPLEID; res_one._ZONE = str_one.ZONE; res_one._PROVINCE_BIRTH = str_one.PROVINCE_BIRTH; res_one._BIRTHDATE = DateTime.Parse(str_one.BIRTHDATE.ToString()); res_one._AGE = str_one.AGE; res_one._WEIGHT = str_one.WEIGHT; res_one._HEIGHT = str_one.HEIGHT; res_one._ADDR_ROW1 = str_one.ADDR_ROW1; res_one._ADDR_ROW2 = str_one.ADDR_ROW2; res_one._ADDR_ROW3 = str_one.ADDR_ROW3; res_one._ADDR_HOME1 = str_one.ADDR_HOME1; res_one._ADDR_HOME2 = str_one.ADDR_HOME2; res_one._ADDR_HOME3 = str_one.ADDR_HOME3; res_one._ADDR_TEL = str_one.ADDR_TEL; res_one._ADDR_MOBILE = str_one.ADDR_MOBILE; res_one._ADDR_EMAIL = str_one.ADDR_EMAIL; res_one._ADDR_PHOTO = str_one.ADDR_PHOTO; summary.Step_One = res_one; //------------------------------------------------------------------------------------------------- var str_two = (from xx in bx.STEP_TWOs where xx.USERNO == USERNO select xx).FirstOrDefault(); insert_Step_Two res_two = new insert_Step_Two(); res_two.USERNO = str_two.USERNO; res_two.STARTING_DATE = DateTime.Parse(str_two.STARTING_DATE.ToString()); res_two.MARITAL = str_two.MARITAL; res_two.CHILDEN = str_two.CHILDEN; res_two.SPOUSE_NAME = str_two.SPOUSE_NAME; res_two.SPOUSE_AGE = str_two.SPOUSE_AGE; res_two.SPOUSE_OCCUPATION = str_two.SPOUSE_OCCUPATION; res_two.SPOUSE_OFFICE = str_two.SPOUSE_OFFICE; res_two.SPOUSE_PHONE = str_two.SPOUSE_PHONE; res_two.EMERGENCY = str_two.EMERGENCY; res_two.EMERGENCY_ROW1 = str_two.EMERGENCY_ROW1; res_two.EMERGENCY_ROW2 = str_two.EMERGENCY_ROW2; res_two.EMERGENCY_RELATIONSHIP = str_two.EMERGENCY_RELATIONSHIP; res_two.EMERGENCY_PHONE = str_two.EMERGENCY_PHONE; summary.Step_Two = res_two; //------------------------------------------------------------------------------------------------- var str_three_detail = (from xx in bx.STEP_THREE_DETAILs where xx.USERNO == USERNO select xx).FirstOrDefault(); Step_Three_DETAIL res_three_detail = new Step_Three_DETAIL(); res_three_detail.CURRENTLY_STUDY = str_three_detail.CURRENTLY_STUDY; res_three_detail.STUDY_NAME = str_three_detail.STUDY_NAME; res_three_detail.STUDY_MAJOR = str_three_detail.STUDY_MAJOR; res_three_detail.HOBBY_ROW1 = str_three_detail.HOBBY_ROW1; res_three_detail.HOBBY_ROW2 = str_three_detail.HOBBY_ROW2; res_three_detail.HOBBY_ROW3 = str_three_detail.HOBBY_ROW3; res_three_detail.HOBBY_ROW4 = str_three_detail.HOBBY_ROW4; summary.Detail = res_three_detail; //------------------------------------------------------------------------------------------------- var str_three_eduction = (from xx in bx.STEP_THREE_EDUCTIONs where xx.USERNO == USERNO select xx); List <Step_Three_EDUCTION> res_three_Eduction = new List <Step_Three_EDUCTION>(); foreach (var item_Edu in str_three_eduction) { Step_Three_EDUCTION Eduction = new Step_Three_EDUCTION(); Eduction.EDUCATION_LV = item_Edu.EDUCATION_LV; Eduction.EDUCATION_NAME = item_Edu.EDUCATION_NAME; Eduction.DEGREE = item_Edu.DEGREE; Eduction.S_YEAR = item_Edu.S_YEAR; Eduction.E_YEAR = item_Edu.E_YEAR; Eduction.GPA = decimal.Parse(item_Edu.GPA.ToString()); Eduction.MAJOR = item_Edu.MAJOR; res_three_Eduction.Add(Eduction); } summary.Eduction = res_three_Eduction; //------------------------------------------------------------------------------------------------- var str_three_employment = (from xx in bx.STEP_THREE_EMPLOYMENTs where xx.USERNO == USERNO select xx); List <Step_Three_EMPLOYMENT> res_three_Employment = new List <Step_Three_EMPLOYMENT>(); foreach (var item_Emp in str_three_employment) { Step_Three_EMPLOYMENT Employment = new Step_Three_EMPLOYMENT(); Employment.COMPANY_NAME = item_Emp.COMPANY_NAME; Employment.S_DATE = item_Emp.S_DATE; Employment.E_DATE = item_Emp.E_DATE; Employment.POSITION = item_Emp.POSITION; Employment.SALARY = item_Emp.SALARY; Employment.DETAIL = item_Emp.DETAIL; Employment.LEAVING = item_Emp.LEAVING; res_three_Employment.Add(Employment); } summary.Employment = res_three_Employment; //------------------------------------------------------------------------------------------------- var str_three_language = (from xx in bx.STEP_THREE_LANGUAGEs where xx.USERNO == USERNO select xx); List <Step_Three_LANGUAGE> res_three_Language = new List <Step_Three_LANGUAGE>(); foreach (var item_lan in str_three_language) { Step_Three_LANGUAGE Language = new Step_Three_LANGUAGE(); Language.LANGUAGE = item_lan.LANGUAGE; Language.SPEAKING = item_lan.SPEAKING; Language.READING = item_lan.READING; Language.WRITING = item_lan.WRITING; res_three_Language.Add(Language); } summary.Language = res_three_Language; //------------------------------------------------------------------------------------------------- var str_three_training = (from xx in bx.STEP_THREE_TRAININGs where xx.USERNO == USERNO select xx); List <Step_Three_TRAINING> res_three_Training = new List <Step_Three_TRAINING>(); foreach (var item_Tra in str_three_training) { Step_Three_TRAINING Training = new Step_Three_TRAINING(); Training.DATE = DateTime.Parse(item_Tra.DATE.ToString()); Training.COURSE = item_Tra.COURSE; Training.INSTITUTION = item_Tra.INSTITUTION; Training.S_DATE = DateTime.Parse(item_Tra.S_DATE.ToString()); Training.E_DATE = DateTime.Parse(item_Tra.E_DATE.ToString()); res_three_Training.Add(Training); } summary.Training = res_three_Training; //------------------------------------------------------------------------------------------------- var str_four = (from xx in bx.STEP_FOURs where xx.USERNO == USERNO select xx); List <Step_Four> res_four = new List <Step_Four>(); foreach (var item_Four in str_four) { Step_Four Four = new Step_Four(); Four.Q_ID = item_Four.Q_ID; Four.CHOOSE = item_Four.CHOOSE; Four.DETAIL_ROW1 = item_Four.DETAIL_ROW1; Four.DETAIL_ROW2 = item_Four.DETAIL_ROW2; Four.DETAIL_ROW3 = item_Four.DETAIL_ROW3; res_four.Add(Four); } summary.Step_Four = res_four; //------------------------------------------------------------------------------------------------- results.Add(summary); } } catch (Exception ex) { insert_Step_One res = new insert_Step_One(); res._USERNO = ex.Message; //results.Add(res); } return(results.ToArray()); }