public List <ListCompareTable> InportOriginData(DataTable dt) { List <ListCompareTable> listReturn = new List <ListCompareTable>(); try { Expression <Func <Td_kldm, bool> > where = (c => (c.DelFlag == false)); List <Td_kldm> list = GetRecord(where); foreach (DataRow dr in dt.Rows) { long ID = -1; long[] lID = list.Where(c => c.Name == dr["KLMC"].ToString()).Select(c => c.ID).ToArray(); if ((lID != null) && (lID.Length > 0)) { ID = lID[0]; } if (ID == -1)//目前库表中不存在 { Td_kldm model = new Td_kldm(); model.Name = dr["KLMC"].ToString(); model.Remark = dr["KLDM"].ToString(); model.Jbkl = dr["JBKL"].ToString(); try { model.Kscjbjxh = Convert.ToInt32(dr["KSCJBJXH"]); } catch { model.Kscjbjxh = 0; } string[] EditColumn = { "Name", "Remark", "Jbkl", "Kscjbjxh" }; long lNewID = SaveOneSimpleRecord(model, "kldmTable", EditColumn); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dr[0].ToString(); oneTable.lNewID = lNewID; listReturn.Add(oneTable); } else //目前库表中存在 { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dr["KLDM"].ToString(); oneTable.lNewID = ID; listReturn.Add(oneTable); } } return(listReturn); } catch (Exception e) { return(null); } }
/// <summary> /// 导入高考成绩,从17表的报名库中或12表的投档单中 /// </summary> /// <param name="dt"></param> /// <param name="dr"></param> /// <param name="lbmkID"></param> protected void InportGkcj(DataTable dt, List <BMKTable> BMK_list, List <ListCompareTable> CJXDM_list) { List <T_ksxkcj> listAll = new List <T_ksxkcj>(); foreach (DataRow dr in dt.Rows) { long lbmkID = GetBMKIDFromList(BMK_list, dr["KSH"].ToString()); if (lbmkID > 0) { for (int i = 0; i < dr.ItemArray.Length; i++) { string ColumnName = dt.Columns[i].ColumnName; if (ColumnName.Contains("GKCJX")) { T_ksxkcj model = new T_ksxkcj(); if (dr.ItemArray[i] != DBNull.Value) { try { model.Ddcj = Convert.ToDouble(dr.ItemArray[i]); } catch { } } if (model.Ddcj > 0) { string cjxdm = ColumnName.Replace("GKCJX", ""); model.RelationID = lbmkID; model.Kmdm = 0; model.KmdmOrigin = 0; ListCompareTable oneCompare = GetCompareList(CJXDM_list, cjxdm); if (oneCompare != null) { model.CjxdmOrigin = oneCompare.lOriginID; model.Cjxdm = oneCompare.lNewID; } model.Djff = 0; model.Cjlx = 2; listAll.Add(model); } } } } } AddRecords(listAll); }
public List <ListCompareTable> InportOriginData(DataTable dt, int nNowYear, long lProvinceID) { List <ListCompareTable> listReturn = new List <ListCompareTable>(); if (dt != null) { bool flag = false; OriginTableManage manOrigin = new OriginTableManage(); string[] mainColumns = { "ZYLBDM", "ZYLBMC" }; List <Td_zylbdm_Origin> OriginModels = manOrigin.InportSomeRowsOriginTable <Td_zylbdm_Origin>(dt, nNowYear, lProvinceID, mainColumns); for (int i = 0; i < OriginModels.Count; i++) { long lNowRelationID = OriginModels[i].RelationID; if (lNowRelationID == 0) //原始表中新加入的字段 { flag = true; Td_zylbdm zylbObj = IsExistType(OriginModels[i]); if (zylbObj == null) //如果在数据库中不存在,zylbdm表中需要增加该model { string OriginDM = OriginModels[i].DM; while (OriginDM.Length < 2) { OriginDM = "0" + OriginDM; } string sFirstCode = GetSubString(OriginDM, 0, 2); string sSecondCode = GetSubString(OriginDM, 2, 2); string sThirdCode = GetSubString(OriginDM, 4, 0); string sTypeName = OriginModels[i].MC; long lNewID = 0; Td_zylbdm model = new Td_zylbdm(); model.Code = OriginModels[i].DM; model.Name = sTypeName; model.JoinNames = model.Name; if (sSecondCode == "") //一级节点 { model.ParentIndex = -1; lNewID = SaveOneFirstTypeNode(model); } else if (sThirdCode == "") { lNewID = SaveOneSecondTypeNode(model, sFirstCode); } else { lNewID = SaveOneThirdTypeNode(model, sSecondCode, sFirstCode); } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); //修改原始表中相应的RelationID OriginModels[i].RelationID = lNewID; } else { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; if (zylbObj.DelFlag) { oneTable.lNewID = zylbObj.JoinID; OriginModels[i].RelationID = zylbObj.JoinID; } else { oneTable.lNewID = zylbObj.ID; OriginModels[i].RelationID = zylbObj.ID; } oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } else { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; oneTable.lNewID = lNowRelationID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } if (flag) { SaveManyRecords(OriginModels); } } return(listReturn); }
private T_bmk_Origin CreateNewModel(DataRow dr, int nYear, long GxID, long lProvinceID) { T_bmk_Origin bmk_model = new T_bmk_Origin(); bmk_model.Ksh = GetOneStrValue(dr, "KSH"); bmk_model.Zkzh = GetOneStrValue(dr, "ZKZH"); bmk_model.Xm = GetOneStrValue(dr, "XM"); //bmk_model.Xb = GetNowXB(GetOneStrValue(dr, "XBDM")); bmk_model.Csrq = Convert.ToDateTime(GetOneStrValue(dr, "CSNY", CosDataBase.DATE_TYPE)); bmk_model.YearCode = nYear; bmk_model.GxID = GxID; bmk_model.ProvinceID = lProvinceID; ListCompareTable oneCompare = GetCompareList(ZZMMDM_list, GetOneStrValue(dr, "ZZMMDM")); if (oneCompare != null) { bmk_model.ZzmmdmOrigin = oneCompare.lOriginID; bmk_model.Zzmmdm = oneCompare.lNewID; } oneCompare = GetCompareList(MZDM_list, GetOneStrValue(dr, "MZDM")); if (oneCompare != null) { bmk_model.MzdmOrigin = oneCompare.lOriginID; bmk_model.Mzdm = oneCompare.lNewID; } oneCompare = GetCompareList(XBDM_list, GetOneStrValue(dr, "XBDM")); if (oneCompare != null) { bmk_model.XbdmOrigin = oneCompare.lOriginID; bmk_model.Xbdm = oneCompare.lNewID; } bmk_model.Hkkh = GetOneStrValue(dr, "HKKH"); bmk_model.Hkdj = GetOneStrValue(dr, "HKDJ"); oneCompare = GetCompareList(XTDWDM_list, GetOneStrValue(dr, "XTDW")); if (oneCompare != null) { bmk_model.XtdwdmOrigin = oneCompare.lOriginID; bmk_model.Xtdwdm = oneCompare.lNewID; } //bmk_model.Sfzh = GetOneStrValue(dr, "SFZH"); //bmk_model.Jtdz = GetOneStrValue(dr, "JTDZ"); bmk_model.Zsyj = GetOneStrValue(dr, "ZSYJ"); //bmk_model.Kldm = GetMainListID(KLDM_list, GetOneStrValue(dr, "KLDM")); bmk_model.KldmOrigin = GetOriginListID(KLDM_list, GetOneStrValue(dr, "KLDM")); oneCompare = GetCompareList(KSLBDM_list, GetOneStrValue(dr, "KSLBDM")); if (oneCompare != null) { bmk_model.KslbdmOrigin = oneCompare.lOriginID; bmk_model.Kslbdm = oneCompare.lNewID; } oneCompare = GetCompareList(KSLXDM_list, GetOneStrValue(dr, "KSLXDM")); if (oneCompare != null) { bmk_model.KslxdmOrigin = oneCompare.lOriginID; bmk_model.Kslxdm = oneCompare.lNewID; } oneCompare = GetCompareList(BYLBDM_list, GetOneStrValue(dr, "BYLBDM")); if (oneCompare != null) { bmk_model.BylbdmOrigin = oneCompare.lOriginID; bmk_model.Bylbdm = oneCompare.lNewID; } oneCompare = GetCompareList(BYXXDM_list, GetOneStrValue(dr, "BYXXDM")); if (oneCompare != null) { bmk_model.ByxxdmOrigin = oneCompare.lOriginID; bmk_model.Byxxdm = oneCompare.lNewID; } oneCompare = GetCompareList(WYYZDM_list, GetOneStrValue(dr, "WYYZDM")); if (oneCompare != null) { bmk_model.WyyzdmOrigin = oneCompare.lOriginID; bmk_model.Wyyzdm = oneCompare.lNewID; } bmk_model.Kstz = GetKstz(GetOneStrValue(dr, "KSTZ"), false); bmk_model.KstzOrigin = GetKstz(GetOneStrValue(dr, "KSTZ"), true); oneCompare = GetCompareList(DQDM_list, GetOneStrValue(dr, "DQDM")); if (oneCompare != null) { bmk_model.DqdmOrigin = oneCompare.lOriginID; bmk_model.Dqdm = oneCompare.lNewID; } oneCompare = GetCompareList(ZJLXDM_list, GetOneStrValue(dr, "ZJLXDM")); if (oneCompare != null) { bmk_model.ZjlxdmOrigin = oneCompare.lOriginID; bmk_model.Zjlxdm = oneCompare.lNewID; } bmk_model.Zjhm = GetOneStrValue(dr, "ZJHM"); bmk_model.Xjh = GetOneStrValue(dr, "XJH"); bmk_model.Wyks = GetOneStrValue(dr, "WYKS"); bmk_model.Wytl = GetOneStrValue(dr, "WYTl"); bmk_model.Txdz = GetOneStrValue(dr, "TXDZ"); bmk_model.Yzbm = GetOneStrValue(dr, "YZBM"); bmk_model.Lxsj = GetOneStrValue(dr, "LXSJ"); bmk_model.Lxdh = GetOneStrValue(dr, "LXDH"); bmk_model.Sjr = GetOneStrValue(dr, "SJR"); bmk_model.Kstc = GetOneStrValue(dr, "KSTC"); bmk_model.Ksjlhcf = GetOneStrValue(dr, "KSJLHCF"); bmk_model.Sxpdkhyj = GetOneStrValue(dr, "SXPDKHYJ"); bmk_model.Kszg = GetKszg(GetOneStrValue(dr, "KSZG"), false); bmk_model.KszgOrigin = GetKszg(GetOneStrValue(dr, "KSZG"), true); oneCompare = GetCompareList(HJLBDM_list, GetOneStrValue(dr, "HJLBDM")); if (oneCompare != null) { bmk_model.HjlbdmOrigin = oneCompare.lOriginID; bmk_model.Hjlbdm = oneCompare.lNewID; } oneCompare = GetCompareList(CZLBDM_list, GetOneStrValue(dr, "CZLBDM")); if (oneCompare != null) { bmk_model.CzlbdmOrigin = oneCompare.lOriginID; bmk_model.Czlbdm = oneCompare.lNewID; } //bmk_model.Tag = GetOneStrValue(dr, "TAG"); bmk_model.Xkkm = GetKmxx(GetOneStrValue(dr, "XKKM"), false); bmk_model.XkkmOrigin = GetKmxx(GetOneStrValue(dr, "XKKM"), true); bmk_model.Skkm = GetKmxx(GetOneStrValue(dr, "SKKM"), false); bmk_model.SkkmOrigin = GetKmxx(GetOneStrValue(dr, "SKKM"), true); return(bmk_model); }
/// <summary> /// 导入基础数据表的公共函数 /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="T1"></typeparam> /// <param name="dataTable"></param> /// <param name="nYear"></param> /// <param name="lProvinceID"></param> /// <param name="keyword"></param> /// <param name="mainColumns"></param> /// <param name="moreColumns"></param> /// <param name="moreColumnTypes"></param> /// <returns></returns> public List <ListCompareTable> InportSimpleTableOriginData <T, T1>(DataTable dataTable, int nYear, long lProvinceID, string keyword, string[] mainColumns = null, string[] moreColumns = null, int[] moreColumnTypes = null) where T : class, new() where T1 : class, new() { List <ListCompareTable> listReturn = new List <ListCompareTable>(); try { if (dataTable != null) { DataView dataView = dataTable.DefaultView; if (mainColumns == null) { mainColumns = new string[2]; mainColumns[0] = dataTable.Columns[0].ColumnName; mainColumns[1] = dataTable.Columns[1].ColumnName; } DataTable dt = dataView.ToTable(true, mainColumns[0], mainColumns[1]); List <T1> OriginModels = InportSomeRowsOriginTable <T1>(dt, nYear, lProvinceID, mainColumns, moreColumns, moreColumnTypes); TableStatusManage statusManage = new TableStatusManage(); for (int i = 0; i < dt.Rows.Count; i++) { long lNowRelationID = Convert.ToInt64(OriginModels[i].GetType().GetProperty("RelationID").GetValue(OriginModels[i], null)); if (lNowRelationID == 0) //原始表中新加入的字段 { long lNewID = 0; T obj = getOneMainRecord <T>(dt.Rows[i][1].ToString()); if (obj == null) //目前主表中不存在 { while (!statusManage.BeginUpdate <T>()) { Random ra = new Random(); Thread.Sleep(ra.Next(100, 1000)); } obj = getOneMainRecord <T>(dt.Rows[i][1].ToString()); if (obj == null) //还是不存在 { int num = 4; if (moreColumns != null) { num = num + moreColumns.Length; } string[] EditColumns = new string[num]; EditColumns[0] = "Name"; EditColumns[1] = "Remark"; EditColumns[2] = "Code"; EditColumns[3] = "JoinNames"; if (moreColumns != null) { for (int j = 0; j < moreColumns.Length; j++) { EditColumns[j + 4] = moreColumns[j]; } } T model = new T(); model.GetType().GetProperty("Name").SetValue(model, dt.Rows[i][1].ToString(), null); model.GetType().GetProperty("Code").SetValue(model, dt.Rows[i][0].ToString(), null); model.GetType().GetProperty("JoinNames").SetValue(model, dt.Rows[i][1].ToString(), null); if ((dt.Columns.Count > 2) && (dt.Columns[2].ColumnName == "BZ")) { model.GetType().GetProperty("Remark").SetValue(model, dt.Rows[i][2].ToString(), null); } model = ArrangeMoreColumns(moreColumns, moreColumnTypes, dt.Rows[i], model); lNewID = SaveOneSimpleRecord(model, keyword, EditColumns); statusManage.EndUpdate <T>(); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i][0].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = Convert.ToInt64(OriginModels[i].GetType().GetProperty("ID").GetValue(OriginModels[i], null)); listReturn.Add(oneTable); } else //主表中存在了 { statusManage.EndUpdate <T>(); lNewID = Convert.ToInt64(obj.GetType().GetProperty("ID").GetValue(obj, null)); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i][0].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = Convert.ToInt64(OriginModels[i].GetType().GetProperty("ID").GetValue(OriginModels[i], null)); listReturn.Add(oneTable); } } else //目前主表中存在 { lNewID = Convert.ToInt64(obj.GetType().GetProperty("ID").GetValue(obj, null)); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i][0].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = Convert.ToInt64(OriginModels[i].GetType().GetProperty("ID").GetValue(OriginModels[i], null)); listReturn.Add(oneTable); } //不管存在与否,都需修改原始表中相应的RelationID //string[] EditColumn = { "RelationID" }; OriginModels[i].GetType().GetProperty("RelationID").SetValue(OriginModels[i], lNewID, null); //SaveOneRecord(OriginModels[i], EditColumn); } else //原始表中已有相关字段,直接取用 { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i][0].ToString(); oneTable.lNewID = lNowRelationID; oneTable.lOriginID = Convert.ToInt64(OriginModels[i].GetType().GetProperty("ID").GetValue(OriginModels[i], null)); listReturn.Add(oneTable); } } SaveManyRecords(OriginModels); } return(listReturn); } catch (Exception e) { return(null); } }
public List <ListCompareTable> InportOriginData(DataTable dt, int nYear, long lProvinceID, string[] mainColumns) { DataTable datatable = ShrinkDataTable(dt, lProvinceID); //先把其他省份的去掉 System.Data.DataView dv = datatable.DefaultView; dv.Sort = "DQDM Asc"; DataTable dt2 = dv.ToTable(true); List <ListCompareTable> listReturn = new List <ListCompareTable>(); OriginTableManage man = new OriginTableManage(); List <Td_dqdm_Origin> OriginModels = man.InportSomeRowsOriginTable <Td_dqdm_Origin>(dt, nYear, lProvinceID, mainColumns); List <Td_dqdm> Models = GetAllLeafNodes <Td_dqdm>(lProvinceID); //TableStatusManage statusManage = new TableStatusManage(); 地区代码,认为每个省份的数据库无重复 bool flag = true; //记录有无修改 for (int i = 0; i < OriginModels.Count; i++) { long lNowRelationID = Convert.ToInt64(OriginModels[i].RelationID); if (lNowRelationID == 0) //原始表中新加入的字段 { flag = false; Td_dqdm dqObj = IsExistRegion(OriginModels[i], Models); if (dqObj == null) //如果区域在数据库中不存在,dqdm表中需要增加该区域 { string sFirstCode, sSecondCode, sThirdCode; if ((OriginModels[i].DM.Length >= 2) && (IsNumeric(OriginModels[i].DM))) { sFirstCode = OriginModels[i].DM.Substring(0, 2); } else { sFirstCode = "00"; } if ((OriginModels[i].DM.Length >= 4) && (IsNumeric(OriginModels[i].DM))) { sSecondCode = OriginModels[i].DM.Substring(2, 2); } else { sSecondCode = "00"; } if ((OriginModels[i].DM.Length >= 6) && (IsNumeric(OriginModels[i].DM))) { sThirdCode = OriginModels[i].DM.Substring(4, 2); } else { sThirdCode = "00"; } long lNewID = 0; Td_dqdm model = new Td_dqdm(); model.Code = OriginModels[i].DM; model.Name = OriginModels[i].MC; model.JoinNames = OriginModels[i].MC; if (sThirdCode == "00") //二级节点 (不可能增加一级节点) { model.TheOrder = Convert.ToInt16(sSecondCode); model.ParentIndex = lProvinceID; } else //三级节点 { string sParentCode = sFirstCode + sSecondCode + "00"; Td_dqdm nowCity = null; List <Td_dqdm> listHere = Models.Where(c => c.Code == sParentCode).ToList(); if ((listHere == null) || (listHere.Count == 0)) //二级节点不存在 { nowCity = new Td_dqdm(); nowCity.ParentIndex = lProvinceID; nowCity.Code = sParentCode; nowCity.TheOrder = Convert.ToInt16(sSecondCode); nowCity.Name = "市辖区/县"; AddOneTreeNode(nowCity); } else { nowCity = listHere[0]; } model.TheOrder = Convert.ToInt16(sThirdCode); model.ParentIndex = nowCity.ID; } lNewID = AddOneTreeNode(model); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); OriginModels[i].RelationID = lNewID; } else { string sRegionName = OriginModels[i].MC; if (dqObj.Code == null) { dqObj.Code = OriginModels[i].DM; string[] EditColumn = { "Code" }; SaveOneRecord(dqObj, EditColumn); } if (sRegionName != dqObj.Name) { if (!dqObj.JoinNames.Split(CosValue.SPLITOPERATOR1).Contains(sRegionName)) { dqObj.JoinNames = dqObj.JoinNames + CosValue.SPLITOPERATOR1 + sRegionName; string[] EditColumn = { "JoinNames" }; SaveOneRecord(dqObj, EditColumn); } } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; if (dqObj.DelFlag) { oneTable.lNewID = dqObj.JoinID; OriginModels[i].RelationID = dqObj.JoinID; } else { oneTable.lNewID = dqObj.ID; OriginModels[i].RelationID = dqObj.ID; } oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } else { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = OriginModels[i].DM; oneTable.lNewID = lNowRelationID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } if (!flag) { SaveManyRecords(OriginModels); } return(listReturn); }
public List <ListCompareTable> InportOriginData(DataTable dt, int nNowYear, long lProvinceID, long lGxID) { List <ListCompareTable> listReturn = new List <ListCompareTable>(); List <T_tddw_Origin> OriginModels = InportSomeTddwOriginTable(dt, nNowYear, lProvinceID); TableStatusManage statusManage = new TableStatusManage(); for (int i = 0; i < dt.Rows.Count; i++) { //T_tddw_Origin OriginModel = InportOneTddwOriginTable(dr, nNowYear, lProvinceID); long lNowRelationID = Convert.ToInt64(OriginModels[i].RelationID); if (lNowRelationID != 0) //原始表中已经存在,直接取用 { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i]["TDDWDM"].ToString(); oneTable.lNewID = lNowRelationID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } else { long lNewID = 0; T_tddw obj = getOneMainRecord(lGxID, OriginModels[i]); string MC = GetOneStrValue(dt.Rows[i], "TDDWMC"); if (obj == null) //目前主表中不存在 { while (!statusManage.BeginUpdate <T_tddw>()) { Random ra = new Random(); Thread.Sleep(ra.Next(100, 1000)); } obj = getOneMainRecord(lGxID, OriginModels[i]); if (obj == null) //还是不存在 { T_tddw model = new T_tddw(); model.Name = MC; model.Code = GetOneStrValue(dt.Rows[i], "TDDWDM"); model.Remark = GetOneStrValue(dt.Rows[i], "BZ"); ListCompareTable oneCompare = GetCompareList(PCDM_list, GetOneStrValue(dt.Rows[i], "PCDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.PcdmOrigin = oneCompare.lOriginID; model.Pcdm = oneCompare.lNewID; } oneCompare = GetCompareList(KLDM_list, GetOneStrValue(dt.Rows[i], "KLDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.KldmOrigin = oneCompare.lOriginID; model.Kldm = oneCompare.lNewID; } oneCompare = GetCompareList(JHXZDM_list, GetOneStrValue(dt.Rows[i], "JHXZDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.JhxzdmOrigin = oneCompare.lOriginID; model.Jhxzdm = oneCompare.lNewID; } oneCompare = GetCompareList(JHLBDM_list, GetOneStrValue(dt.Rows[i], "JHLBDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.JhlbdmOrigin = oneCompare.lOriginID; model.Jhlbdm = oneCompare.lNewID; } model.Csmbh = GetOneStrValue(dt.Rows[i], "CSMBH"); model.Tag = GetOneStrValue(dt.Rows[i], "TAG"); model.GxID = lGxID; model.JoinNames = model.Name; string[] EditColumns = { "Name", "Code", "Remark", "PcdmOrigin", "Pcdm", "KldmOrigin", "Kldm", "JhxzdmOrigin", "Jhxzdm", "JhlbdmOrigin", "Jhlbdm", "Csmbh", "Tag", "GxID", "JoinNames" }; lNewID = SaveOneSimpleRecord(model, "tddwTable", EditColumns); statusManage.EndUpdate <T_tddw>(); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = GetOneStrValue(dt.Rows[i], "TDDWDM"); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } else { if (obj.DelFlag) { lNewID = obj.JoinID; } else { lNewID = obj.ID; } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = GetOneStrValue(dt.Rows[i], "TDDWDM"); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } else //目前主表中存在 { if (obj.DelFlag) { lNewID = obj.JoinID; } else { lNewID = obj.ID; } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = GetOneStrValue(dt.Rows[i], "TDDWDM"); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } ////不管存在与否,都需修改原始表中相应的RelationID string[] EditColumn = { "RelationID" }; OriginModels[i].GetType().GetProperty("RelationID").SetValue(OriginModels[i], lNewID, null); SaveOneRecord(OriginModels[i], EditColumn); } } return(listReturn); }
public List <ListCompareTable> InportOriginData(DataTable dt, int nNowYear, long lProvinceID, long lParentDepartmentID, long GxID) { List <ListCompareTable> listReturn = new List <ListCompareTable>(); if (dt != null) { List <Td_zydh_Origin> OriginModels = InportSomeRowsOriginTable <Td_zydh_Origin>(dt, nNowYear, lProvinceID); TableStatusManage statusManage = new TableStatusManage(); for (int i = 0; i < dt.Rows.Count; i++) { //先导入原始表 long lNowRelationID = Convert.ToInt64(OriginModels[i].RelationID); if (lNowRelationID != 0) //原始表中已经存在,直接取用 { ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i]["ZYDH"].ToString(); oneTable.lNewID = OriginModels[i].RelationID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } else { long lNewID = 0; Td_zydh obj = getOneMainRecord(lParentDepartmentID, OriginModels[i]); if (obj == null) //目前主表中不存在 { while (!statusManage.BeginUpdate <Td_zydh>()) { Random ra = new Random(); Thread.Sleep(ra.Next(100, 1000)); } obj = getOneMainRecord(lParentDepartmentID, OriginModels[i]); if (obj == null) //还是不存在 { Td_zydh model = new Td_zydh(); model.Name = GetOneStrValue(dt.Rows[i], "ZYMC"); model.Code = GetOneStrValue(dt.Rows[i], "ZYDH"); model.Remark = GetOneStrValue(dt.Rows[i], "BZ"); ListCompareTable oneCompare = GetCompareList(CCDM_list, GetOneStrValue(dt.Rows[i], "CCDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.CcdmOrigin = oneCompare.lOriginID; model.Ccdm = oneCompare.lNewID; } oneCompare = GetCompareList(KLDM_list, GetOneStrValue(dt.Rows[i], "KLDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.KldmOrigin = oneCompare.lOriginID; model.Kldm = oneCompare.lNewID; } string sXzdm = GetXzdm(dt.Rows[i]); oneCompare = GetCompareList(XZDM_list, sXzdm); if (oneCompare != null) { model.XzdmOrigin = oneCompare.lOriginID; model.Xzdm = oneCompare.lNewID; } oneCompare = GetCompareList(ZYLBDM_list, GetOneStrValue(dt.Rows[i], "ZYLBDM", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.ZylbdmOrigin = oneCompare.lOriginID; model.Zylbdm = oneCompare.lNewID; } model.Zkfx = GetOneStrValue(dt.Rows[i], "ZKFX"); model.Tjsxbz = GetOneStrValue(dt.Rows[i], "TJSXBZ"); model.Sfks = Convert.ToBoolean(GetOneStrValue(dt.Rows[i], "SFKZ", CosDataBase.BOOLEAN_TYPE)); model.Sfbz = Convert.ToInt32(GetOneStrValue(dt.Rows[i], "Sfbz", CosDataBase.INT_TYPE)); model.Bxdd = GetOneStrValue(dt.Rows[i], "BXDD"); model.Wyyz = GetOneStrValue(dt.Rows[i], "WYYZ"); model.ParentDepartmentID = lParentDepartmentID; model.GxID = GxID; model.JoinNames = model.Name; string[] EditColumns = { "Name", "Code", "Remark", "CcdmOrigin", "Ccdm", "KldmOrigin", "Kldm", "XzdmOrigin", "Xzdm", "ZylbdmOrigin", "Zylbdm", "Zkfx", "Tjsxbz", "Sfks","Sfbz","Bxdd", "Wyyz", "ParentDepartmentID", "GxID", "JoinNames" }; lNewID = SaveOneSimpleRecord(model, "zydhTable", EditColumns); statusManage.EndUpdate <Td_zydh>(); ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i]["ZYDH"].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } else //目前主表中存在 { if (obj.DelFlag) { lNewID = obj.JoinID; } else { lNewID = obj.ID; } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i]["ZYDH"].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } } else //目前主表中存在 { if (obj.DelFlag) { lNewID = obj.JoinID; } else { lNewID = obj.ID; } ListCompareTable oneTable = new ListCompareTable(); oneTable.sOldID = dt.Rows[i]["ZYDH"].ToString(); oneTable.lNewID = lNewID; oneTable.lOriginID = OriginModels[i].ID; listReturn.Add(oneTable); } ////不管存在与否,都需修改原始表中相应的RelationID string[] EditColumn = { "RelationID" }; OriginModels[i].RelationID = lNewID; SaveOneRecord(OriginModels[i], EditColumn); } } } return(listReturn); }
public List <BMKTable> InportOriginData(DataTable dt, OleDbConnection con, string sNowPath, int nYear, long lProvinceID, long GxID) { bool IsOldData = VeiryOldData(dt); //检查是不是12库 bmkTableManage bmkMan = new bmkTableManage(); if (IsOldData) { dt.Columns["ZXDM"].ColumnName = "BYXXDM"; //和17表保持一致,改名 dt.Columns["ZXMC"].ColumnName = "BYXXMC"; dt.Columns["TDDW"].ColumnName = "TDDWDM"; dt.Columns["SFZH"].ColumnName = "ZJHM"; //身份证号->证件号码 dt.Columns["JTDZ"].ColumnName = "TXDZ"; //家庭地址->通讯地址 dt.Columns["YXDRCJ"].ColumnName = "YXDYCJ"; //院校导入成绩->院校定义成绩 dt.Columns["LQFS"].ColumnName = "LQLXDM"; //录取方式->录取类型代码 dt.Columns["BH"].ColumnName = "TDDBH"; //编号->投档单编号 bmkMan.InitAllFoundDataList(con, sNowPath, dt, nYear, lProvinceID); bmkMan.BYLBDM_list = BYLBDM_list; bmkMan.CJXDM_list = CJXDM_list; bmkMan.CZLBDM_list = CZLBDM_list; bmkMan.DQDM_list = DQDM_list; bmkMan.HJLBDM_list = HJLBDM_list; bmkMan.KLDM_list = KLDM_list; bmkMan.KMDM_list = KMDM_list; bmkMan.KSLBDM_list = KSLBDM_list; bmkMan.KSLXDM_list = KSLXDM_list; bmkMan.KSTZDM_list = KSTZDM_list; bmkMan.KSZGDM_list = KSZGDM_list; bmkMan.MZDM_list = MZDM_list; bmkMan.WYYZDM_list = WYYZDM_list; bmkMan.ZJLXDM_list = ZJLXDM_list; bmkMan.XTDWDM_list = XTDWDM_list; bmkMan.ZZMMDM_list = ZZMMDM_list; bmkMan.XBDM_list = XBDM_list; //bmkMan.BYXXDM_list = BYXXDM_list; BMK_list = bmkMan.AddSomeNewStudents(dt, nYear, GxID, lProvinceID); } List <T_tdd> tddList = new List <T_tdd>(); foreach (DataRow dr in dt.Rows) { long lbmkID = GetBMKIDFromList(BMK_list, dr["KSH"].ToString()); if (lbmkID != 0) { //Expression<Func<T_tdd, bool>> where = (c => c.RelationID == lbmkID && c.DelFlag == false); //long lID = ExistOneRecord(where); //List<T_tdd> list = GetRecord(where); //if ((list == null) || (list.Count == 0)) //一条报名库记录对应一条投档单记录 //if (lID == 0) { T_tdd tdd_model = new T_tdd(); tdd_model.RelationID = lbmkID; tdd_model.Ljzyh = GetOneStrValue(dr, "LJZYH"); tdd_model.TddwOrigin = GetOriginListID(TDDW_list, GetOneStrValue(dr, "TDDWDM")); tdd_model.PcdmOrigin = GetOriginListID(PCDM_list, GetOneStrValue(dr, "PCDM")); tdd_model.KldmOrigin = GetOriginListID(KLDM_list, GetOneStrValue(dr, "KLDM")); tdd_model.JhxzdmOrigin = GetOriginListID(JHXZDM_list, GetOneStrValue(dr, "JHXZDM")); tdd_model.JhlbdmOrigin = GetOriginListID(JHLBDM_list, GetOneStrValue(dr, "JHLBDM")); ListCompareTable oneCompare = GetCompareList(TDLXDM_list, GetOneStrValue(dr, "TDLXDM")); if (oneCompare != null) { tdd_model.TdlxdmOrigin = oneCompare.lOriginID; tdd_model.Tdlxdm = oneCompare.lNewID; } tdd_model.Tdsj = Convert.ToDateTime(GetOneStrValue(dr, "TDSJ", CosDataBase.DATETIME_TYPE)); tdd_model.Cj = Convert.ToDouble(GetOneStrValue(dr, "CJ", CosDataBase.FLOAT_TYPE)); tdd_model.Tzcj = Convert.ToDouble(GetOneStrValue(dr, "TZCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Tdcj = Convert.ToDouble(GetOneStrValue(dr, "TDCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Zgf = Convert.ToDouble(GetOneStrValue(dr, "ZGF", CosDataBase.FLOAT_TYPE)); tdd_model.Yxdycj = Convert.ToDouble(GetOneStrValue(dr, "YXDYCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Zyytjzcj = Convert.ToDouble(GetOneStrValue(dr, "ZYYTJZCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Zyytfjcj = Convert.ToDouble(GetOneStrValue(dr, "ZYYTFJCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Ytzy = GetMainListID(ZYDH_list, GetOneStrValue(dr, "YTZY")); tdd_model.Lqzy = GetMainListID(ZYDH_list, GetOneStrValue(dr, "LQZY")); tdd_model.Lqsj = Convert.ToDateTime(GetOneStrValue(dr, "LQSJ", CosDataBase.DATE_TYPE)); oneCompare = GetCompareList(TDYYDM_list, GetOneStrValue(dr, "TDYYDM")); if (oneCompare != null) { tdd_model.TdyydmOrigin = oneCompare.lOriginID; tdd_model.Tdyydm = oneCompare.lNewID; } tdd_model.Zyhg = Convert.ToBoolean(GetOneStrValue(dr, "ZYHG", CosDataBase.BOOLEAN_TYPE)); tdd_model.Tjhg = Convert.ToBoolean(GetOneStrValue(dr, "TJHG", CosDataBase.BOOLEAN_TYPE)); tdd_model.Xkkmhg = Convert.ToBoolean(GetOneStrValue(dr, "XKKMHG", CosDataBase.BOOLEAN_TYPE)); tdd_model.Skkmhg = Convert.ToBoolean(GetOneStrValue(dr, "SKKMHG", CosDataBase.BOOLEAN_TYPE)); tdd_model.Lqxh = GetOneStrValue(dr, "LQXH"); tdd_model.Tddbh = GetOneStrValue(dr, "TDDBH"); tdd_model.Xzbh = GetOneStrValue(dr, "XZBH"); tdd_model.Tddzt = GetOneStrValue(dr, "TDDZT"); tdd_model.Sdbz = GetOneStrValue(dr, "SDBZ"); tdd_model.Remark = GetOneStrValue(dr, "BZ"); oneCompare = GetCompareList(ZYTZDM_list, GetOneStrValue(dr, "ZYTZDM")); if (oneCompare != null) { tdd_model.ZytzOrigin = oneCompare.lOriginID; tdd_model.Zytz = oneCompare.lNewID; } tdd_model.Zycj = Convert.ToDouble(GetOneStrValue(dr, "ZYCJ", CosDataBase.FLOAT_TYPE)); tdd_model.Zycjtfpw = Convert.ToInt16(GetOneStrValue(dr, "ZYCJTFPW", CosDataBase.INT_TYPE)); oneCompare = GetCompareList(ZYTJLXDM_list, GetOneStrValue(dr, "ZYTJLXDM")); if (oneCompare != null) { tdd_model.ZytjlxdmOrigin = oneCompare.lOriginID; tdd_model.Zytjlxdm = oneCompare.lNewID; } tdd_model.Kslsczbz = GetOneStrValue(dr, "KSLSCZBZ"); oneCompare = GetCompareList(LQFSDM_list, GetOneStrValue(dr, "LQLXDM")); if (oneCompare != null) { tdd_model.LqfsOrigin = oneCompare.lOriginID; tdd_model.Lqfs = oneCompare.lNewID; } tdd_model.Kszt = GetOneStrValue(dr, "KSZT"); tdd_model.Zyzytj = Convert.ToBoolean(GetOneStrValue(dr, "ZYZYTJ", CosDataBase.BOOLEAN_TYPE)); tdd_model.Dxtj = Convert.ToBoolean(GetOneStrValue(dr, "DXTJ", CosDataBase.BOOLEAN_TYPE)); tdd_model.Zytjfc = Convert.ToBoolean(GetOneStrValue(dr, "Zytjfc", CosDataBase.BOOLEAN_TYPE)); tdd_model.TjjldmOrigin = GetOriginListID(TJJLDM_list, GetOneStrValue(dr, "TJJLDM")); tddList.Add(tdd_model); } } } AddRecords(tddList); if (IsOldData) { //下面处理高考成绩(12库) InportGkcj(dt, BMK_list, CJXDM_list); //下面处理志愿信息(12库) InportZyk(dt, BMK_list); } return(BMK_list); }
public List <T_jhk> InportOriginData(DataTable dt, int nNowYear, long lProvinceID, long lParentDepartmentID, long lGxID, out List <ListCompareTable> old12ZYDH_list) { BuildZYDH(dt, nNowYear, lProvinceID, lParentDepartmentID, lGxID, out old12ZYDH_list); if (dt.Columns.Contains("JHXZ")) { dt.Columns["JHXZ"].ColumnName = "JHXZDM"; //和17表保持一致,改名 } if (dt.Columns.Contains("TDDW")) { dt.Columns["TDDW"].ColumnName = "TDDWDM"; //和17表保持一致,改名 } ArrayList names = new ArrayList(); ArrayList values = new ArrayList(); names.Add("DelFlag"); values.Add(false); names.Add("ProvinceID"); values.Add(lProvinceID); names.Add("YearCode"); values.Add(nNowYear); //names.Add("ParentDepartmentID"); values.Add(lParentDepartmentID); names.Add("GxID"); values.Add(lGxID); Expression <Func <T_jhk, bool> > where = GetAndLambdaExpression <T_jhk>(names, values); List <T_jhk> list = GetRecord(where); //取出主表中相关所有字段 List <T_jhk> listAdd = new List <T_jhk>(); foreach (DataRow dr in dt.Rows) { if (!ExistJH(dr, list)) //如果是不存在的计划 { T_jhk model = new T_jhk(); model.ProvinceID = lProvinceID; model.YearCode = nNowYear; model.ParentDepartmentID = lParentDepartmentID; model.GxID = lGxID; model.PcdmOrigin = GetOriginListID(PCDM_list, GetOneStrValue(dr, "PCDM", CosDataBase.LONGINT_TYPE)); //model.Pcdm = GetMainListID(PCDM_list, GetOneStrValue(dr, "PCDM", CosDataBase.LONGINT_TYPE)); model.KldmOrigin = GetOriginListID(KLDM_list, GetOneStrValue(dr, "KLDM", CosDataBase.LONGINT_TYPE)); //model.Jhxzdm = GetMainListID(JHXZDM_list, GetOneStrValue(dr, "JHXZDM", CosDataBase.LONGINT_TYPE)); model.JhxzdmOrigin = GetOriginListID(JHXZDM_list, GetOneStrValue(dr, "JHXZDM", CosDataBase.LONGINT_TYPE)); //model.Jhlbdm = GetMainListID(JHLBDM_list, GetOneStrValue(dr, "JHLBDM", CosDataBase.LONGINT_TYPE)); model.JhlbdmOrigin = GetOriginListID(JHLBDM_list, GetOneStrValue(dr, "JHLBDM", CosDataBase.LONGINT_TYPE)); model.TddwdmOrigin = GetOriginTddw(dr); model.Tddwdm = GetTddw(dr); ListCompareTable oneCompare = GetCompareList(ZKLXDM_list, GetOneStrValue(dr, "ZKLX", CosDataBase.LONGINT_TYPE)); if (oneCompare != null) { model.ZklxdmOrigin = oneCompare.lOriginID; model.Zklxdm = oneCompare.lNewID; } oneCompare = GetCompareList(ZYDH_list, GetOneStrValue(dr, "ZYDH")); if (oneCompare != null) { model.ZydhOrigin = oneCompare.lOriginID; model.Zydh = oneCompare.lNewID; } model.Jhrs = Convert.ToInt32(GetOneStrValue(dr, "JHRS", CosDataBase.INT_TYPE)); model.Jhzxs = Convert.ToInt32(GetOneStrValue(dr, "JHZXS", CosDataBase.INT_TYPE)); model.Sfsf = Convert.ToBoolean(GetOneStrValue(dr, "SFSF", CosDataBase.BOOLEAN_TYPE)); model.Ytces = Convert.ToInt32(GetOneStrValue(dr, "YTCES", CosDataBase.INT_TYPE)); model.Yxxh = Convert.ToInt32(GetOneStrValue(dr, "YXXH", CosDataBase.INT_TYPE)); model.Bz = GetOneStrValue(dr, "BZ"); listAdd.Add(model); //AddOneRecord(model); } } AddRecords(listAdd); list.AddRange(listAdd); return(list); }