示例#1
0
        private string submitaction(JsonArrayParse jp)
        {
            JsonObjectCollection collection = new JsonObjectCollection();
            string flag  = "1";
            int    level = 1;

            try
            {
                //if (jp.getValue("Parent") != "")
                //{
                //    Business.Base.BusinessRegion parent = new project.Business.Base.BusinessRegion();
                //    parent.load(jp.getValue("Parent"), user.Entity.AccID);
                //    level = parent.Entity.Level;
                //}

                Business.Base.BusinessRegion bc = new project.Business.Base.BusinessRegion();
                if (jp.getValue("tp") == "update")
                {
                    bc.load(jp.getValue("id"), user.Entity.AccID);
                    bc.Entity.RegionName = jp.getValue("RegionName");
                    //bc.Entity.Parent = jp.getValue("Parent");
                    bc.Entity.Level = level;
                    int r = bc.Save("update");
                    if (r <= 0)
                    {
                        flag = "2";
                    }
                }
                else
                {
                    Data      obj = new Data();
                    DataTable dt  = obj.ExecuteDataSet("select 1 from Base_Region where RegionNo=N'" + jp.getValue("RegionNo") + "' and AccID='" + user.Entity.AccID + "'").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        flag = "3";
                    }
                    else
                    {
                        bc.Entity.RegionNo   = jp.getValue("RegionNo");
                        bc.Entity.RegionName = jp.getValue("RegionName");
                        //bc.Entity.Parent = jp.getValue("Parent");
                        bc.Entity.Level = level;
                        bc.Entity.AccID = user.Entity.AccID;
                        int r = bc.Save("insert");
                        if (r <= 0)
                        {
                            flag = "2";
                        }
                    }
                }
            }
            catch { flag = "2"; }

            collection.Add(new JsonStringValue("type", "submit"));
            collection.Add(new JsonStringValue("flag", flag));
            collection.Add(new JsonStringValue("liststr", createList()));

            return(collection.ToString());
        }