public ActionResult Index(ProStoredProcedure proSP)
        {
            ViewBag.Title = "Home Page";

            ViewBag.Name = "";
            if (!string.IsNullOrWhiteSpace(proSP.Name))
            {
                ViewBag.Name = proSP.Name;
            }
            ViewBag.EXECUTE = "";
            if (!string.IsNullOrWhiteSpace(proSP.Execute))
            {
                ViewBag.EXECUTE = proSP.Execute;
            }
            ViewBag.content = "";
            if (!string.IsNullOrWhiteSpace(proSP.Content))
            {
                ViewBag.content = proSP.Content;
            }
            ViewBag.remark = "";
            if (!string.IsNullOrWhiteSpace(proSP.Remark))
            {
                ViewBag.remark = proSP.Remark;
            }
            ViewBag.tags = "";
            if (!string.IsNullOrWhiteSpace(proSP.Tags))
            {
                ViewBag.tags = proSP.Tags;
            }

            ViewBag.AJAXparams = getAJAXparams(proSP);

            return(View());
        }
Example #2
0
        // GET api/values/5
        public object Get(int id)
        {
            Exception          exception = null;
            ProStoredProcedure proSP     = null;

            using (SQLPro db = new SQLPro())
            {
                try
                {
                    proSP = db.ProStoredProcedure.Find(id);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }

            if (exception == null && proSP != null)
            {
                return(proSP);
            }
            else
            {
                return(exception);
            }
        }
Example #3
0
        // PUT api/values/5
        public object Put([FromBody] ProStoredProcedure proSPNew)
        {
            proSPNew.Name    = proSPNew.Name.Trim();
            proSPNew.Execute = proSPNew.Execute.Trim();

            Exception exception = null;

            DateTime dNow = DateTime.Now;

            using (SQLPro db = new SQLPro())
            {
                try
                {
                    ProStoredProcedure proSP = db.ProStoredProcedure.Find(proSPNew.Id);

                    if (proSP != null)
                    {
                        if (!string.IsNullOrEmpty(proSPNew.Name))
                        {
                            proSP.Name = proSPNew.Name;
                        }
                        if (!string.IsNullOrEmpty(proSPNew.Execute))
                        {
                            proSP.Execute = proSPNew.Execute;
                        }
                        if (!string.IsNullOrEmpty(proSPNew.Content))
                        {
                            proSP.Content = proSPNew.Content;
                        }
                        if (!string.IsNullOrEmpty(proSPNew.Remark))
                        {
                            proSP.Remark = proSPNew.Remark;
                        }
                        if (!string.IsNullOrEmpty(proSPNew.Tags))
                        {
                            proSP.Tags = proSPNew.Tags;
                        }
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }

            if (exception == null)
            {
                return(new { msg = "COMMIT" });
            }
            else
            {
                return(exception);
            }
        }
Example #4
0
        // POST api/values
        public object Post([FromBody] ProStoredProcedure proSP)
        {
            if (proSP == null)
            {
                return(new { msg = "proSP is null !!" });
            }
            else if (proSP.Name == null)
            {
                return(new { msg = "proSP.Name is null !!" });
            }
            else if (proSP.Execute == null)
            {
                return(new { msg = "proSP.Execute is null !!" });
            }

            proSP.Name    = proSP.Name.Trim();
            proSP.Execute = proSP.Execute.Trim();


            Exception exception = null;
            DateTime  dNow      = DateTime.Now;

            proSP.CreatedTime = dNow;
            proSP.UpdateTime  = dNow;
            using (SQLPro db = new SQLPro())
            {
                try
                {
                    db.ProStoredProcedure.Add(proSP);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
            }

            if (exception == null)
            {
                return(new { msg = "COMMIT" });
            }
            else
            {
                return(exception);
            }
        }
        private string getAJAXparams(ProStoredProcedure proSP)
        {
            List <string> aJAX_Params = new List <string>();

            if (!string.IsNullOrWhiteSpace(proSP.Name))
            {
                aJAX_Params.Add("Name=" + proSP.Name);
            }
            if (!string.IsNullOrWhiteSpace(proSP.Execute))
            {
                if (string.IsNullOrWhiteSpace(proSP.Name))
                {
                    aJAX_Params.Add("Name=");
                }
                aJAX_Params.Add("Execute=" + proSP.Execute);
            }
            if (!string.IsNullOrWhiteSpace(proSP.Content))
            {
                if (string.IsNullOrWhiteSpace(proSP.Name))
                {
                    aJAX_Params.Add("Name=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Execute))
                {
                    aJAX_Params.Add("Execute=");
                }
                aJAX_Params.Add("Content=" + proSP.Content);
            }
            if (!string.IsNullOrWhiteSpace(proSP.Remark))
            {
                if (string.IsNullOrWhiteSpace(proSP.Name))
                {
                    aJAX_Params.Add("Name=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Execute))
                {
                    aJAX_Params.Add("Execute=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Content))
                {
                    aJAX_Params.Add("Content=");
                }
                aJAX_Params.Add("Remark=" + proSP.Remark);
            }
            if (!string.IsNullOrWhiteSpace(proSP.Tags))
            {
                if (string.IsNullOrWhiteSpace(proSP.Name))
                {
                    aJAX_Params.Add("Name=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Execute))
                {
                    aJAX_Params.Add("Execute=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Content))
                {
                    aJAX_Params.Add("Content=");
                }
                if (string.IsNullOrWhiteSpace(proSP.Remark))
                {
                    aJAX_Params.Add("Remark=");
                }
                aJAX_Params.Add("Tags=" + proSP.Tags);
            }

            if (aJAX_Params.Count > 0)
            {
                return("?" + string.Join("&", aJAX_Params));
            }
            else
            {
                return("");
            }
        }