示例#1
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata, string table)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.Base_blend_web bc = new Sql.Base_blend_web();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                ////代码                           //名字
                //string code = stringList[0]; string name = stringList[1];
                ////是否启用                                         //备注
                //string enabled = stringList[2] == "是" ? "1" : "0"; string remark = stringList[3];

                ////启用日期
                //string startdate = json_formdata.Value<string>("STARTDATE");
                ////停用日期
                //string enddate = json_formdata.Value<string>("ENDDATE");

                //string formdata = "{\"CODE\":\"" + code + "\",\"NAME\":\"" + name + "\",\"ENABLED\":\"" + enabled + "\",\"REMARK\":\"" + remark + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\"}";
                string  formdata = sw.importValue(json_formdata, table, stringList);
                JObject json     = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bc.check_repeat(table, json) > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bc.insertTable(table, json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
示例#2
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata, string table)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.Base_blend_web bc = new Sql.Base_blend_web();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                string  formdata = sw.importValue(json_formdata, table, stringList);
                JObject json     = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bc.check_repeat(table, json) > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bc.insertTable(table, json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
示例#3
0
        public Dictionary <int, List <int> > upload_base_recorddetails(string newfile, string fileName, string action,
                                                                       JObject json_formdata, string recordinfoid)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.busi_RecordInfor bc = new Sql.busi_RecordInfor();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            try
            {
                for (int i = 0; i < dtExcel.Rows.Count; i++)
                {
                    for (int j = 0; j < dtExcel.Columns.Count; j++)
                    {
                        stringList.Add(dtExcel.Rows[i][j].ToString());
                    }

                    //项号
                    if (i == 8)
                    {
                    }
                    RecordDetailEn detail  = new RecordDetailEn(stringList, json_formdata);
                    string         jsonStr = JsonConvert.SerializeObject(detail);
                    JObject        json    = (JObject)JsonConvert.DeserializeObject(jsonStr);

                    if (bc.check_repeat_record_details(json, recordinfoid).Rows.Count > 0)
                    {
                        errorlines.Add(i + 2);
                    }
                    else
                    {
                        int f = bc.insert_record_details(recordinfoid, json);
                        if (f > 0)
                        {
                            count = count + 1;
                        }
                        else
                        {
                            errorlines.Add(i + 2);
                        }
                    }
                    stringList.Clear();
                }
                successinsert.Add(count);
                returndic.Add(1, successinsert);
                returndic.Add(2, errorlines);
            }
            catch (Exception ex)
            {
            }
            return(returndic);
        }
示例#4
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            Sql.busi_RecordInfor bc = new Sql.busi_RecordInfor();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                //备案号                           //账册属性
                string code = stringList[0]; string BOOKATTRIBUTE = stringList[1];
                //规格型号启用
                string ISMODEL = stringList[6] == "是" ? "1" : "0";
                //是否启用
                string ENABLED = stringList[7] == "是" ? "1" : "0";
                //BUSIUNIT
                string BUSIUNIT = stringList[2];
                //RECEIVEUNIT
                string RECEIVEUNIT = stringList[3];
                //TRADE
                string TRADE = stringList[4];
                //EXEMPTING
                string EXEMPTING = stringList[5];
                //remark
                string REMARK = stringList[8];

                //启用日期
                string startdate = json_formdata.Value <string>("STARTDATE");
                //停用日期
                string enddate = json_formdata.Value <string>("ENDDATE");

                string formdata = "{\"CODE\":\"" + code + "\",\"BOOKATTRIBUTE\":\"" + BOOKATTRIBUTE + "\",\"ENABLED\":\"" + ENABLED + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\",\"ISMODEL\":\"" + ISMODEL + "\"," +
                                  "\"BUSIUNIT\":\"" + BUSIUNIT + "\",\"RECEIVEUNIT\":\"" + RECEIVEUNIT + "\",\"TRADE\":\"" + TRADE + "\",\"EXEMPTING\":\"" + EXEMPTING + "\",\"REMARK\":\"" + REMARK + "\"}";
                //string formdata = sw.importValue(json_formdata, table, stringList);
                JObject json = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bc.check_sys_recordinfo(json).Tables[0].Rows.Count > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bc.insert_sys_recordinfo(json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
示例#5
0
        private void export(string table)
        {
            string strWhere        = string.Empty;
            string combo_ENABLED_S = Request["combo_ENABLED_S"];

            if (combo_ENABLED_S == "null")
            {
                combo_ENABLED_S = String.Empty;
            }
            if (!string.IsNullOrEmpty(Request["CODE_S"]))
            {
                strWhere = strWhere + " and t1.Code like '%" + Request["CODE_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(Request["CNNAME_S"]))
            {
                strWhere = strWhere + " and t1.name like '%" + Request["CNNAME_S"] + "%'";
            }
            if (!string.IsNullOrEmpty(combo_ENABLED_S))
            {
                strWhere = strWhere + " and t1.enabled='" + combo_ENABLED_S + "'";
            }
            switch (table)
            {
            case "base_insplicense":
            case "base_inspinvoice":
            case "base_booksdata":
                strWhere = string.Empty;
                strWhere = Getexport(table);
                break;
            }
            if (table == "base_booksdata")
            {
                strWhere = strWhere + " order by t1.trade asc";
            }
            else
            {
                strWhere = strWhere + " order by t1.code asc";
            }

            Sql.Base_blend_web           bc = new Sql.Base_blend_web();
            Switch_helper_Base_blend_web sc = new Switch_helper_Base_blend_web();
            DataTable    dt   = bc.ExportTable(table, strWhere);
            HSSFWorkbook book = sc.createExcel(dt, table);

            try
            {
                // 输出Excel
                string filename = sc.get_excelname(table) + ".xls";
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Server.UrlEncode(filename)));
                Response.Clear();

                MemoryStream ms = new MemoryStream();
                book.Write(ms);
                Response.BinaryWrite(ms.GetBuffer());
                Response.End();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#6
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            //Sql.busi_RecordInfor bc = new Sql.busi_RecordInfor();
            //Sql.busi_SpecialHsConvernet bsh = new Sql.busi_SpecialHsConvernet();
            Sql.busi_UnitConvert bu = new Sql.busi_UnitConvert();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                //计量单位1
                string UNITNAME1 = stringList[0];
                string UNITCODE1 = bu.getUnitName(UNITNAME1).Rows[0]["CODE"].ToString();
                //计量单位2
                string UNITNAME2 = stringList[1];
                string UNITCODE2 = bu.getUnitName(UNITNAME2).Rows[0]["CODE"].ToString();
                //转换率
                string CONVERTRATE = stringList[2];
                //是否启用
                string ENABLED = stringList[3] == "是" ? "1" : "0";
                //备注
                string REMARK = stringList[4];
                //启用日期
                string startdate = json_formdata.Value <string>("STARTDATE");
                //停用日期
                string enddate = json_formdata.Value <string>("ENDDATE");

                string formdata = "{\"UNITCODE1\":\"" + UNITCODE1 + "\",\"UNITCODE2\":\"" + UNITCODE2 + "\",\"ENABLED\":\"" + ENABLED + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\"," +
                                  "\"CONVERTRATE\":\"" + CONVERTRATE + "\",\"REMARK\":\"" + REMARK + "\"}";
                JObject json = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bu.check_repeat(json).Rows.Count > 0 || string.IsNullOrEmpty(json.Value <string>("UNITCODE1")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bu.insert_table(json);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }
示例#7
0
        public Dictionary <int, List <int> > upload_base_company(string newfile, string fileName, string action,
                                                                 JObject json_formdata)
        {
            Base_Company_Method          bcm = new Base_Company_Method();
            Switch_helper_Base_blend_web sw  = new Switch_helper_Base_blend_web();
            DataTable     dtExcel            = bcm.GetExcelData_Table(Server.MapPath(newfile), 0);
            List <string> stringList         = new List <string>();

            //记住发生错误的行数
            List <int> errorlines = new List <int>();

            //记住插入成功的个数
            int count = 0;

            //Sql.busi_RecordInfor bc = new Sql.busi_RecordInfor();
            Sql.busi_SpecialHsConvernet bsh = new Sql.busi_SpecialHsConvernet();
            //插入成功的个数(返回放入dictionary)
            List <int> successinsert = new List <int>();
            //返回值
            Dictionary <int, List <int> > returndic = new Dictionary <int, List <int> >();

            for (int i = 0; i < dtExcel.Rows.Count; i++)
            {
                for (int j = 0; j < dtExcel.Columns.Count; j++)
                {
                    stringList.Add(dtExcel.Rows[i][j].ToString());
                }
                //商品HS编码                           //附加码
                string CODE = stringList[0]; string EXTRACODE = stringList[1];
                //是否启用
                string ENABLED = stringList[5] == "是" ? "1" : "0";
                //商品名称
                string NAME = stringList[2];
                //类型
                string TYPE = stringList[3];
                //国家
                string COUNTRY = stringList[4];
                //备注
                string REMARK = stringList[6];
                //启用日期
                string startdate = json_formdata.Value <string>("STARTDATE");
                //停用日期
                string enddate = json_formdata.Value <string>("ENDDATE");

                string formdata = "{\"CODE\":\"" + CODE + "\",\"EXTRACODE\":\"" + EXTRACODE + "\",\"ENABLED\":\"" + ENABLED + "\",\"STARTDATE\":\"" + startdate + "\",\"ENDDATE\":\"" + enddate + "\"," +
                                  "\"NAME\":\"" + NAME + "\",\"TYPE\":\"" + TYPE + "\",\"COUNTRY\":\"" + COUNTRY + "\",\"REMARK\":\"" + REMARK + "\"}";
                JObject json = (JObject)JsonConvert.DeserializeObject(formdata);
                if (bsh.check_repeat(json).Rows.Count > 0 || string.IsNullOrEmpty(json.Value <string>("CODE")))
                {
                    errorlines.Add(i + 2);
                }
                else
                {
                    bsh.inser_specialhsconvert(json, COUNTRY);
                    count = count + 1;
                }
                stringList.Clear();
            }
            successinsert.Add(count);
            returndic.Add(1, successinsert);
            returndic.Add(2, errorlines);
            return(returndic);
        }