Пример #1
0
        public ActionResult GetInsProduct()
        {
            int id = DoRequest.GetFormInt("id");

            List <InsProItem>  InfoProlist  = new List <InsProItem>();
            List <InsTypeItem> InfoTypelist = new List <InsTypeItem>();
            var resp = QueryInsProduct.Do(id);

            //if (resp != null && resp.Body != null&& resp.Body.ins_pro_list != null && resp.Body.ins_type_list != null)
            //{
            InfoProlist  = resp.Body.insproduct_list;
            InfoTypelist = resp.Body.instype_list;
            //}
            return(Json(new { error = false, datapro = InfoProlist, datatype = InfoTypelist }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult PostInsuranceProductData()
        {
            int                id = DoRequest.GetFormInt("id");
            string             itemproidstring  = DoRequest.GetFormString("proids").Trim();
            string             itemtypeidstring = DoRequest.GetFormString("typeids").Trim();
            List <InsProItem>  oldproitems      = new List <InsProItem>();
            List <InsTypeItem> oldtypeitems     = new List <InsTypeItem>();
            var                res = QueryInsProduct.Do(id);

            if (res != null && res.Body != null)
            {
                if (res.Body.insproduct_list != null)
                {
                    oldproitems = res.Body.insproduct_list;
                }
                if (res.Body.instype_list != null)
                {
                    oldtypeitems = res.Body.instype_list;
                }
            }
            List <int> oldproids = new List <int>();

            string[] itemproids = itemproidstring.Split(',');

            List <int> itemproids2 = new List <int>();

            string delids = "";
            string addids = "";

            foreach (InsProItem item in oldproitems)
            {
                oldproids.Add(Convert.ToInt32(item.product_id));
            }

            int _count = 0;

            //新增的proID
            if (!itemproidstring.Equals(""))
            {
                for (int i = 0; i < itemproids.Length; i++)
                {
                    itemproids2.Add(Utils.StrToInt(itemproids[i], 0));
                    if (!oldproids.Contains(Utils.StrToInt(itemproids[i], 0)))
                    {
                        if (_count > 0)
                        {
                            addids += ",";
                        }
                        addids += Utils.StrToInt(itemproids[i], 0);
                        _count++;
                    }
                }
            }
            #region
            //List<InsProItem> sitems = new List<InsProItem>();
            //for (int i = 0; i < itemproids2.Count; i++)
            //{
            //    InsProItem sitem = new InsProItem();
            //    sitem.id = "0";
            //    sitem.product_id = itemproids2[i].ToString();
            //    if (oldproids.Contains(itemproids2[i]))
            //    {
            //        foreach (InsProItem item in oldproitems)
            //        {
            //            if (item.product_id == itemproids2[i].ToString())
            //                sitem.id = item.id;
            //        }
            //    }
            //    sitems.Add(sitem);
            //}
            #endregion
            _count = 0;
            ////删除的proID "add_proids":"50178,60935,,,,,,,,"
            foreach (InsProItem item in oldproitems)
            {
                if (!itemproids2.Contains(Convert.ToInt32(item.product_id)))
                {
                    if (_count == 0)
                    {
                        delids = item.product_id.ToString();
                    }
                    else
                    {
                        delids = delids + "," + item.product_id;
                    }
                    _count++;
                }
            }
            List <int> oldtypeids   = new List <int>();
            string[]   itemtypeids  = itemtypeidstring.Split(',');
            List <int> itemtypeids2 = new List <int>();
            string     deltypeids   = "";
            string     addtypeids   = "";
            foreach (InsTypeItem item in oldtypeitems)
            {
                oldtypeids.Add(Convert.ToInt32(item.product_type_id));
            }
            _count = 0;
            //新增的typeID
            //"addtypeids":"7816220116123818845848"
            if (!itemtypeidstring.Equals(""))
            {
                for (int i = 0; i < itemtypeids.Length; i++)
                {
                    itemtypeids2.Add(Utils.StrToInt(itemtypeids[i], 0));
                    if (!oldtypeids.Contains(Utils.StrToInt(itemtypeids[i], 0)))
                    {
                        if (_count > 0)
                        {
                            addtypeids += ",";
                        }
                        addtypeids += Utils.StrToInt(itemtypeids[i], 0);
                        _count++;
                    }
                }
            }
            _count = 0;
            //删除的typeID
            foreach (InsTypeItem item in oldtypeitems)
            {
                if (!itemtypeids2.Contains(Convert.ToInt32(item.product_type_id)))
                {
                    if (_count == 0)
                    {
                        deltypeids = item.product_type_id.ToString();
                    }
                    else
                    {
                        deltypeids = deltypeids + "," + item.product_type_id;
                    }
                    _count++;
                }
            }
            int returnVal = -1;
            var res1      = OpInsProductInfo.Do(id, addids, delids, addtypeids, deltypeids);
            if (res1 != null && res1.Header != null && res1.Header.Result != null && res1.Header.Result.Code != null)
            {
                returnVal = Utils.StrToInt(res1.Header.Result.Code, -1);
            }
            if (returnVal == 0)
            {
                return(Json(new { error = false, message = "操作成功" }));
            }
            return(Json(new { error = true, message = "操作失败" }));
        }