示例#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();
        }