コード例 #1
0
        public ActionResult OrgInfo_AddEdit()
        {
            string          ID         = Request["ID"]._ToStrTrim();
            string          ParentID   = Request["ParentID"]._ToStrTrim();
            List <retValue> resultList = new List <retValue>();

            //如果修改则传ID,新增则传上级ID
            if (!string.IsNullOrEmpty(ID))
            {
                retValue ret = new retValue();
                ret.result = true;
                ret.data   = "修改";
                resultList.Add(ret);
                BLL.OrgInfoBLL _OrgInfoBLL = new OrgInfoBLL();
                ret = _OrgInfoBLL.GetOrgByPK(ID._ToInt32());
                resultList.Add(ret);
                ViewData.Model = resultList;
            }
            else if (!string.IsNullOrEmpty(ParentID))
            {
                retValue ret = new retValue();
                ret.result = false;
                ret.data   = ParentID;
                resultList.Add(ret);
                ViewData.Model = resultList;
            }
            else
            {
                ViewData.Model = null;
            }
            return(View());
        }
コード例 #2
0
        public ActionResult OrgInfo_AddEdits(string str)
        {
            retValue ret = new retValue();

            BLL.OrgInfoBLL _BLL = new OrgInfoBLL();
            JObject        o    = null;

            if (!string.IsNullOrEmpty(str))
            {
                o = JObject.Parse(str);

                string    ID      = o["ID"]._ToStrTrim();
                string    NAME    = o["Name"]._ToStrTrim();
                string    OrgCode = o["OrgCode"]._ToStrTrim();
                string    Address = o["Address"]._ToStrTrim();
                UserModel user    = Session["UserModel"] as UserModel;
                //新增
                if (string.IsNullOrEmpty(ID))
                {
                    string Province         = o["Province"]._ToStrTrim();
                    string CompanyCity      = o["CompanyCity"]._ToStrTrim();
                    string CompanyUnderCity = o["CompanyUnderCity"]._ToStrTrim();
                    string CompanyUnderArea = o["CompanyUnderArea"]._ToStrTrim();
                    string OrgID            = "";
                    if (Province._ToInt32() > 0)
                    {
                        OrgID = Province;
                    }
                    if (CompanyCity._ToInt32() > 0)
                    {
                        OrgID = CompanyCity;
                    }
                    if (CompanyUnderCity._ToInt32() > 0)
                    {
                        OrgID = CompanyUnderCity;
                    }
                    if (CompanyUnderArea._ToInt32() > 0)
                    {
                        OrgID = CompanyUnderArea;
                    }
                    int level = 0;
                    ret = _BLL.GetOrgByPK(OrgID._ToInt32());
                    if (ret.result)
                    {
                        level = ((DataTable)ret.data).Rows[0]["Level"]._ToInt32() + 1;
                    }
                    if (user.Level > level)
                    {
                        ret.result = false;
                        ret.reason = "您不能添加当前级别的机构";
                    }
                    else
                    {
                        ret = _BLL.insert(NAME, Address, OrgCode, OrgID._ToInt32(), level);
                    }
                }
                //更新
                else
                {
                    int level = 0;
                    ret = _BLL.GetOrgByPK(ID._ToInt32());
                    if (ret.result)
                    {
                        level = ((DataTable)ret.data).Rows[0]["Level"]._ToInt32();

                        if (user.Level > level)
                        {
                            ret.result = false;
                            ret.reason = "您不能更新当前级别的机构";
                        }
                        else
                        {
                            ret = _BLL.update(ID._ToInt32(), NAME, OrgCode, Address);
                        }
                    }
                }
            }
            var js = JsonConvert.SerializeObject(ret);

            return(Json(js, JsonRequestBehavior.AllowGet));
        }