public ImportResult ImportDataSPFL(string codeFile) { Dictionary <string, object> dictionary; ImportResult result = new ImportResult(); XmlDocument document = new XmlDocument(); try { document.Load(codeFile); XmlNode documentElement = document.DocumentElement; if ((documentElement.Attributes["id"].Value != "spbm") && (documentElement.Attributes["id"].Value != "SPBM")) { throw new Exception("导入税收分类编码文件格式不正确!"); } } catch { throw new Exception("导入税收分类编码文件格式不正确!"); } string innerText = document.GetElementsByTagName("MWJY")[0].InnerText; string text1 = document.GetElementsByTagName("COUNT")[0].InnerText; string str = string.Empty; XmlNodeList elementsByTagName = document.GetElementsByTagName("BBH"); if ((elementsByTagName == null) || (elementsByTagName.Count < 1)) { throw new Exception("导入税收分类编码版本号异常!"); } string maxBMBBBH = this.GetMaxBMBBBH(); string s = elementsByTagName[0].InnerText; if (float.Parse(maxBMBBBH) >= float.Parse(s)) { throw new Exception("导入文件中税收分类编码版本号过低,系统不允许导入!"); } List <string> sqlID = new List <string>(); List <Dictionary <string, object> > listSPFL = new List <Dictionary <string, object> >(); XmlNodeList list6 = document.GetElementsByTagName("BMXX"); for (int i = 0; i < list6.Count; i++) { dictionary = new Dictionary <string, object>(); XmlNodeList childNodes = list6[i].ChildNodes; if (childNodes != null) { dictionary.Add("BMB_BBH", s); foreach (XmlNode node2 in childNodes) { switch (node2.Name) { case "SPBM": { dictionary.Add("HBBM", node2.InnerText); str = str + node2.InnerText; string bM = this.GetBM(node2.InnerText); dictionary.Add("BM", bM); dictionary.Add("SJBM", this.GetSJBM(bM)); continue; } case "SPMC": { dictionary.Add("MC", node2.InnerText); continue; } case "SM": { dictionary.Add("SM", node2.InnerText); continue; } case "ZZSSL": { dictionary.Add("SLV", node2.InnerText); str = str + node2.InnerText; continue; } case "GJZ": { dictionary.Add("GJZ", node2.InnerText); continue; } case "HZX": { dictionary.Add("HZX", node2.InnerText); continue; } case "BB": { dictionary.Add("BBH", node2.InnerText); continue; } case "KYZT": { dictionary.Add("KYZT", node2.InnerText); continue; } case "ZZSTSGL": { dictionary.Add("ZZSTSGL", node2.InnerText); str = str + node2.InnerText; continue; } case "ZZSZCYJ": { dictionary.Add("ZZSZCYJ", node2.InnerText); continue; } case "ZZSTSNRDM": { dictionary.Add("ZZSTSNRDM", node2.InnerText); continue; } case "XFSGL": { dictionary.Add("XFSGL", node2.InnerText); continue; } case "XFSZCYJ": { dictionary.Add("XFSZCYJ", node2.InnerText); continue; } case "XFSTSNRDM": { dictionary.Add("XFSTSNRDM", node2.InnerText); continue; } case "TJJBM": { dictionary.Add("TJJBM", node2.InnerText); continue; } case "HGJCKSPPM": { dictionary.Add("HGJCKSPPM", node2.InnerText); continue; } case "QYSJ": { dictionary.Add("QYSJ", node2.InnerText); continue; } case "GDQJZSJ": { dictionary.Add("GDQJZSJ", node2.InnerText); continue; } case "GXSJ": { if (node2.InnerText.Trim().Length <= 8) { break; } dictionary.Add("GXSJ", DateTime.Parse(node2.InnerText)); continue; } default: { continue; } } DateTime time = DateTime.ParseExact(node2.InnerText, "yyyyMMdd", CultureInfo.CurrentCulture, DateTimeStyles.AllowWhiteSpaces); dictionary.Add("GXSJ", time); } sqlID.Add("aisino.Fwkp.Bmgl.BMSPFL.ReplaceSPFL"); listSPFL.Add(dictionary); } } if ((listSPFL != null) && (listSPFL.Count > 1)) { listSPFL = this.HandleWJJD(listSPFL); } XmlNodeList list8 = document.GetElementsByTagName("ZZSYHZC"); if ((list8 != null) && (list8.Count > 1)) { //Dictionary<string, object> dictionary2; //dictionary2 = new Dictionary<string, object> { // "aisino.Fwkp.Bmgl.BMSPFL.DeleteYHZC", // dictionary2 //}; foreach (XmlNode node3 in list8) { dictionary = new Dictionary <string, object>(); XmlNodeList list9 = node3.ChildNodes; if ((list9 != null) && (list9.Count >= 1)) { dictionary = new Dictionary <string, object>(); foreach (XmlNode node4 in list9) { string name = node4.Name; if (name != null) { if (!(name == "YHZCMC")) { if (name == "SL") { goto Label_06B5; } } else { dictionary.Add("Yhzcmc", node4.InnerText); str = str + node4.InnerText; } } continue; Label_06B5: dictionary.Add("SLv", node4.InnerText); str = str + node4.InnerText; } sqlID.Add("aisino.Fwkp.Bmgl.BMSPFL.InsertYHZC"); listSPFL.Add(dictionary); } } } str = str + "0123456789"; string str6 = this.UserMd5(str); DAL.BMSPFLManager manager = new DAL.BMSPFLManager(); if (!(str6 == innerText)) { throw new Exception("密文校验失败!"); } if (!manager.UpdateSPFLTable(sqlID, listSPFL, false)) { throw new Exception("税收分类编码导入失败!"); } this.checkspspfl(); this.checkclspfl(); this.checkfyxmspfl(); new SPFLService().UpdateBMBBBH(s); MessageBoxHelper.Show("税收分类编码导入成功!", "正确", MessageBoxButtons.OK, MessageBoxIcon.None); result.ImportTable = "税收分类编码.DB"; return(result); }
public void AutoImportDatabase(string codeFile) { Dictionary <string, object> dictionary; XmlDocument document = new XmlDocument(); document.Load(codeFile); string innerText = document.GetElementsByTagName("MWJY")[0].InnerText; string text1 = document.GetElementsByTagName("COUNT")[0].InnerText; string str = string.Empty; XmlNodeList elementsByTagName = document.GetElementsByTagName("BBH"); if (elementsByTagName != null) { int count = elementsByTagName.Count; } string maxBMBBBH = this.GetMaxBMBBBH(); string s = elementsByTagName[0].InnerText; float.Parse(s); float.Parse(maxBMBBBH); List <string> sqlID = new List <string>(); List <Dictionary <string, object> > listSPFL = new List <Dictionary <string, object> >(); XmlNodeList list6 = document.GetElementsByTagName("BMXX"); for (int i = 0; i < list6.Count; i++) { dictionary = new Dictionary <string, object>(); XmlNodeList childNodes = list6[i].ChildNodes; if (childNodes != null) { dictionary.Add("BMB_BBH", s); foreach (XmlNode node in childNodes) { switch (node.Name) { case "SPBM": { dictionary.Add("HBBM", node.InnerText); str = str + node.InnerText; string bM = this.GetBM(node.InnerText); dictionary.Add("BM", bM); dictionary.Add("SJBM", this.GetSJBM(bM)); continue; } case "SPMC": { dictionary.Add("MC", node.InnerText); continue; } case "SM": { dictionary.Add("SM", node.InnerText); continue; } case "ZZSSL": { dictionary.Add("SLV", node.InnerText); str = str + node.InnerText; continue; } case "GJZ": { dictionary.Add("GJZ", node.InnerText); continue; } case "HZX": { dictionary.Add("HZX", node.InnerText); continue; } case "BB": { dictionary.Add("BBH", node.InnerText); continue; } case "KYZT": { dictionary.Add("KYZT", node.InnerText); continue; } case "ZZSTSGL": { dictionary.Add("ZZSTSGL", node.InnerText); str = str + node.InnerText; continue; } case "ZZSZCYJ": { dictionary.Add("ZZSZCYJ", node.InnerText); continue; } case "ZZSTSNRDM": { dictionary.Add("ZZSTSNRDM", node.InnerText); continue; } case "XFSGL": { dictionary.Add("XFSGL", node.InnerText); continue; } case "XFSZCYJ": { dictionary.Add("XFSZCYJ", node.InnerText); continue; } case "XFSTSNRDM": { dictionary.Add("XFSTSNRDM", node.InnerText); continue; } case "TJJBM": { dictionary.Add("TJJBM", node.InnerText); continue; } case "HGJCKSPPM": { dictionary.Add("HGJCKSPPM", node.InnerText); continue; } case "QYSJ": { dictionary.Add("QYSJ", node.InnerText); continue; } case "GDQJZSJ": { dictionary.Add("GDQJZSJ", node.InnerText); continue; } case "GXSJ": { if (node.InnerText.Trim().Length <= 8) { break; } dictionary.Add("GXSJ", DateTime.Parse(node.InnerText)); continue; } default: { continue; } } DateTime time = DateTime.ParseExact(node.InnerText, "yyyyMMdd", CultureInfo.CurrentCulture, DateTimeStyles.AllowWhiteSpaces); dictionary.Add("GXSJ", time); } sqlID.Add("aisino.Fwkp.Bmgl.BMSPFL.ReplaceSPFL"); listSPFL.Add(dictionary); } } if ((listSPFL != null) && (listSPFL.Count > 1)) { listSPFL = this.HandleWJJD(listSPFL); } XmlNodeList list8 = document.GetElementsByTagName("ZZSYHZC"); if ((list8 != null) && (list8.Count > 1)) { //Dictionary<string, object> dictionary2; //dictionary2 = new Dictionary<string, object> { // "aisino.Fwkp.Bmgl.BMSPFL.DeleteYHZC", // dictionary2 //}; foreach (XmlNode node2 in list8) { dictionary = new Dictionary <string, object>(); XmlNodeList list9 = node2.ChildNodes; if ((list9 != null) && (list9.Count >= 1)) { dictionary = new Dictionary <string, object>(); foreach (XmlNode node3 in list9) { string name = node3.Name; if (name != null) { if (!(name == "YHZCMC")) { if (name == "SL") { goto Label_0634; } } else { dictionary.Add("Yhzcmc", node3.InnerText); str = str + node3.InnerText; } } continue; Label_0634: dictionary.Add("SLv", node3.InnerText); str = str + node3.InnerText; } sqlID.Add("aisino.Fwkp.Bmgl.BMSPFL.InsertYHZC"); listSPFL.Add(dictionary); } } } str = str + "0123456789"; string str6 = this.UserMd5(str); DAL.BMSPFLManager manager = new DAL.BMSPFLManager(); if ((str6 == innerText) && manager.UpdateSPFLTable(sqlID, listSPFL, false)) { new SPFLService().UpdateBMBBBH(s); } }