public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action, JObject json_formdata, string yearid) { Base_Company_Method bcm = new Base_Company_Method(); DataTable dtExcel = bcm.GetExcelData_Table(Server.MapPath(newfile), 0); Sql.decl_HS by = new Sql.decl_HS(); //判断是否有重复的ciq代码 //excel中得到的数据是:CIQ代码,CIQ中文名,启用情况,备注 List <string> insert_base_hscode = new List <string>(); //记住成功插入的条数 int countsuccess = 0; //记住失败的行数 List <int> errorlines = new List <int>(); //记住成功的个数 List <int> successInts = new List <int>(); //返回值 Dictionary <int, List <int> > retundDictionary = new Dictionary <int, List <int> >(); for (int i = 0; i < dtExcel.Rows.Count; i++) { for (int j = 0; j < dtExcel.Columns.Count; j++) { insert_base_hscode.Add(dtExcel.Rows[i][j].ToString()); } //hs编码 //附加码 string HSCODE = insert_base_hscode[0]; string EXTRACODE = insert_base_hscode[1]; //商品名称 //申报要素 string NAME = insert_base_hscode[2]; string ELEMENTS = insert_base_hscode[3]; //法定单位 //第二单位 string LEGALUNIT = insert_base_hscode[4]; string SECONDUNIT = insert_base_hscode[5]; //海关监管 string CUSTOMREGULATORY = insert_base_hscode[6]; //商检监管 string INSPECTIONREGULATORY = insert_base_hscode[7]; //一般税率 string GENERALRATE = insert_base_hscode[8]; //最惠税率 string FAVORABLERATE = insert_base_hscode[9]; //增值税率 string VATRATE = insert_base_hscode[10]; //出口退税率 string EXPORTREBATRATE = insert_base_hscode[11]; //暂定税率 string TEMPRATE = insert_base_hscode[12]; //消费税率 string CONSUMERATE = insert_base_hscode[13]; //出口税率 string EXPORTRATE = insert_base_hscode[14]; //最高价格 string TOPPRICE = insert_base_hscode[15]; //最低价格 string LOWPRICE = insert_base_hscode[16]; //特殊标志 string SPECIALMARK = insert_base_hscode[17]; //启用情况 string ENABLED = insert_base_hscode[18] == "是" ? "1" : "0"; //备注 string REMARK = insert_base_hscode[19]; //启用日期 string startdate = json_formdata.Value <string>("STARTDATE"); //停用日期 string enddate = json_formdata.Value <string>("ENDDATE"); string formdata = "{\"HSCODE\":\"" + HSCODE + "\",\"NAME\":\"" + NAME + "\",\"LEGALUNIT\":\"" + LEGALUNIT + "\",\"EXTRACODE\":\"" + EXTRACODE + "\",\"ELEMENTS\":\"" + ELEMENTS + "\",\"CUSTOMREGULATORY\":\"" + CUSTOMREGULATORY + "\",\"INSPECTIONREGULATORY\":\"" + INSPECTIONREGULATORY + "\",\"ENABLED\":\"" + ENABLED + "\"," + "\"REMARK\":\"" + REMARK + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\"," + "\"SECONDUNIT\":\"" + SECONDUNIT + "\",\"GENERALRATE\":\"" + GENERALRATE + "\",\"FAVORABLERATE\":\"" + FAVORABLERATE + "\"," + "\"VATRATE\":\"" + VATRATE + "\",\"EXPORTREBATRATE\":\"" + EXPORTREBATRATE + "\",\"TEMPRATE\":\"" + TEMPRATE + "\"," + "\"CONSUMERATE\":\"" + CONSUMERATE + "\",\"EXPORTRATE\":\"" + EXPORTRATE + "\",\"TOPPRICE\":\"" + TOPPRICE + "\"," + "\"LOWPRICE\":\"" + LOWPRICE + "\",\"SPECIALMARK\":\"" + SPECIALMARK + "\"}"; JObject json = (JObject)JsonConvert.DeserializeObject(formdata); if (by.check_repeat_base_insphs(json, yearid).Rows.Count > 0 || string.IsNullOrEmpty(HSCODE) || string.IsNullOrEmpty(NAME)) { errorlines.Add(i + 2); } else { by.insert_base_insphs(json, yearid); countsuccess = countsuccess + 1; } insert_base_hscode.Clear(); } successInts.Add(countsuccess); retundDictionary.Add(1, successInts); retundDictionary.Add(2, errorlines); return(retundDictionary); }
public void MaintainSave(string formdata) { Base_Codename_Method bcm = new Base_Codename_Method(); string yearid = Request["ID"]; //从前端获取值 JObject json = (JObject)JsonConvert.DeserializeObject(formdata); string response = String.Empty; Sql.decl_HS by = new Sql.decl_HS(); if (string.IsNullOrEmpty(json.Value <string>("ID"))) { if (json.Value <string>("ENABLED") == "1") { //查询是否有重复值 DataTable dt = by.check_repeat_base_insphs(json, yearid); if (dt.Rows.Count > 0) { //当数据有重复时success返回值为4 response = "{\"success\":\"4\"}"; } else { int i = by.insert_base_insphs(json, yearid); response = "{\"success\":" + (i > 0 ? "true" : "false") + "}"; } } else { int i = by.insert_base_insphs(json, yearid); response = "{\"success\":" + (i > 0 ? "true" : "false") + "}"; } } else { if (json.Value <string>("ENABLED") == "1") { DataTable dt = by.check_repeat_base_insphs_update(json, yearid); //判断是否有重复值 if (dt.Rows.Count > 0) { //当数据有重复时success返回值为4 response = "{\"success\":\"4\"}"; } else { //获取修改之前的记录 DataTable getChanges = by.Before_Change(json); int i = by.update_base_insphs(json, yearid); if (i > 0) { //获取修改的内容 string content = bcm.getChangeHsCode2(getChanges, json); by.saveChangeBaseHsCode(json, content); response = "{\"success\":" + (i > 0 ? "true" : "false") + "}"; } } } else { //获取修改之前的记录 DataTable getChanges = by.Before_Change(json); int i = by.update_base_insphs(json, yearid); if (i > 0) { //获取修改的内容 string content = bcm.getChangeHsCode2(getChanges, json); by.saveChangeBaseHsCode(json, content); response = "{\"success\":" + (i > 0 ? "true" : "false") + "}"; } } } Response.Write(response); Response.End(); }