コード例 #1
0
        public HttpResponseBase SaveFunction()
        {
            Function function = new Function();
            string json = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["RowId"]))
                {
                    function.RowId = Convert.ToInt32(Request.Form["RowId"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["child_only"]))
                {
                    function.FunctionType = 3;
                }
                else
                {
                    function.FunctionType = Convert.ToInt32(Request.Form["Type"] ?? "1");
                }
                if (!string.IsNullOrEmpty(Request.Form["Group"]))
                {
                    function.FunctionGroup = Request.Form["Group"];
                }
                if (!string.IsNullOrEmpty(Request.Form["Name"]))
                {
                    function.FunctionName = Request.Form["Name"];
                }
                if (!string.IsNullOrEmpty(Request.Form["Code"]))
                {
                    function.FunctionCode = Request.Form["Code"];
                }
                if (!string.IsNullOrEmpty(Request.Form["IconCls"]))
                {
                    function.IconCls = Request.Form["IconCls"];
                }
                if (!string.IsNullOrEmpty(Request.Form["Remark"]))
                {
                    function.Remark = Request.Form["Remark"];
                }
                if (!string.IsNullOrEmpty(Request.Form["TopValue"]))
                {
                    function.TopValue = Convert.ToInt32(Request.Form["TopValue"]);
                }
                if (!string.IsNullOrEmpty(Request.Form["IsEdit"]))
                {

                    function.IsEdit = int.Parse(Request.Form["IsEdit"]);
                }//edit by wwei0216w

                function.Kuser = (Session["caller"] as Caller).user_email;

                functionMgr = new FunctionMgr(connectionString);
                if (function.RowId != 0)
                {
                    if (functionMgr.Update(function) > 0)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
                else
                {
                    if (functionMgr.Save(function) > 0)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
            }
            catch (Exception ex)
            {
                json = "{success:false}";
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }