示例#1
0
        public void save(string formdata)
        {
            JObject json = (JObject)JsonConvert.DeserializeObject(formdata);

            Sql.RelaHSCCIQ bcsql = new Sql.RelaHSCCIQ();
            //禁用人
            string stopman = "";
            //返回重复结果
            string repeat = "";
            //返回前端的值
            string response = "";

            if (json.Value <string>("ENABLED") == "1")
            {
                stopman = "";
            }
            else
            {
                FormsIdentity identity  = HttpContext.Current.User.Identity as FormsIdentity;
                string        userName  = identity.Name;
                JObject       json_user = Extension.Get_UserInfo(userName);
                stopman = (string)json_user.GetValue("ID");
            }

            //插入
            if (String.IsNullOrEmpty(json.Value <string>("ID")))
            {
                List <int> retunRepeat = bcsql.CheckRepeat(json.Value <string>("ID"), json.Value <string>("HSCODE"), json.Value <string>("CIQCODE"));
                repeat = bcsql.Check_Repeat(retunRepeat);
                if (repeat == "")
                {
                    //insert数据向表base_company当是5时插入成功
                    bcsql.insert_rela_hs_ciq(json, stopman);
                    repeat = "5";
                }
            }
            else
            {
                //更新
                List <int> retunRepeat = bcsql.CheckRepeat(json.Value <string>("ID"), json.Value <string>("HSCODE"), json.Value <string>("CIQCODE"));
                repeat = bcsql.Check_Repeat(retunRepeat);
                if (repeat == "")
                {
                    //insert数据向表base_company当是5时插入成功
                    DataTable dt = bcsql.LoadDataById(json.Value <string>("ID"));
                    int       i  = bcsql.update_rela_hs_ciq(json, stopman);
                    if (i > 0)
                    {
                        bcsql.insert_base_alterrecord(json, dt);
                    }
                    repeat = "5";
                }
            }

            response = "{\"success\":\"" + repeat + "\"}";

            Response.Write(response);
            Response.End();
        }
示例#2
0
        public Dictionary <int, List <int> > upload_RelaHSCIQ(string newfile, string fileName, string action, JObject json_formdata)
        {
            Sql.RelaHSCCIQ bc      = new Sql.RelaHSCCIQ();
            DataTable      dtExcel = GetExcelData_Table(Server.MapPath(newfile), 0);
            //DataTable dtExcel = GetExcelData_Table(newfile, 0);
            List <string> stringList = new List <string>();
            //停用人
            string stopman = "";

            //存放成功信息
            List <int> repeatListsuccess = new List <int>();
            //存放失败条数
            List <int> repeatListerror = new List <int>();
            //记住insert成功的条数
            int count = 0;
            //返回信息
            Dictionary <int, List <int> > dcInts = 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 HSCODE = stringList[0];
                //CIQ
                string CIQCODE = stringList[1];

                string REMARK = stringList[2];
                //string ENABLED = stringList[4] == "是" ? "1" : "0";
                string ENABLED = "1";
                //维护人
                string CREATEMANNAME = json_formdata.Value <string>("CREATEMANNAME");
                //启用时间
                string STARTDATE = json_formdata.Value <string>("STARTDATE") == "" ? DateTime.MinValue.ToShortDateString() : json_formdata.Value <string>("STARTDATE");

                //停用日期
                string ENDDATE = json_formdata.Value <string>("ENDDATE") == ""
                    ? DateTime.MaxValue.ToShortDateString()
                    : json_formdata.Value <string>("ENDDATE");

                if (ENABLED == "1")
                {
                    stopman = "";
                }
                else
                {
                    FormsIdentity identity  = HttpContext.Current.User.Identity as FormsIdentity;
                    string        userName  = identity.Name;
                    JObject       json_user = Extension.Get_UserInfo(userName);
                    stopman = (string)json_user.GetValue("ID");
                }
                //导入判断条件
                List <int> inlist       = bc.CheckRepeat("", HSCODE, CIQCODE);
                string     check_repeat = bc.Check_Repeat(inlist);

                if (check_repeat == "")
                {
                    bc.insert_rela_hs_ciq_excel(HSCODE, CIQCODE, ENABLED, REMARK, stopman, STARTDATE, ENDDATE);
                    count = count + 1;
                }
                else
                {
                    repeatListerror.Add(i + 2);
                }

                //清除
                stringList.Clear();
            }
            repeatListsuccess.Add(count);
            dcInts.Add(1, repeatListsuccess);
            dcInts.Add(2, repeatListerror);
            return(dcInts);
        }