Пример #1
0
        public ActionResult Edit_DB_Link()
        {
            this.Response.ContentType = "text/plain";

            NModel.DB_Link model = new NModel.DB_Link();
            BLL.DB_Link    dal   = new BLL.DB_Link();

            String JsonStr = "";

            bool isGet = Tool.NStr.PostForSetVal <NModel.DB_Link>(ref model, ref JsonStr, "");

            // 下面代码编写
            if (isGet && !string.IsNullOrEmpty(model.Link_Name) &&
                !string.IsNullOrEmpty(model.Link_Num)

                && !string.IsNullOrEmpty(model.Link_Url) &&
                model.Link_AddTime != null

                )
            {
                //取默认值

                model.Link_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));

                bool isEdit = dal.Edit(model) > 0 ? true : false;

                string msg = dal.ErrorMsg;
                if (!string.IsNullOrEmpty(msg))
                {
                    msg = "原因:" + msg;
                }

                if (isEdit)
                {
                    this.Response.Write(Tool.NMsg.SetMsg("修改成功", "1"));
                    this.Response.End();
                }
                else
                {
                    this.Response.Write(Tool.NMsg.SetMsg("修改失败" + msg, "0"));
                    this.Response.End();
                }

                dal.Close();
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("提交失败", "0"));
                this.Response.End();
            }

            return(View());
        }
Пример #2
0
        public ActionResult Add_DB_Link()
        {
            this.Response.ContentType = "text/plain";
            NModel.DB_Link model = new NModel.DB_Link();
            BLL.DB_Link    dal   = new BLL.DB_Link();

            String JsonStr = "";

            bool isGet = Tool.NStr.PostForSetVal <NModel.DB_Link>(ref model, ref JsonStr, "");

            // 下面代码编写
            if (isGet && !string.IsNullOrEmpty(model.Link_Name) &&
                !string.IsNullOrEmpty(model.Link_Num)

                && !string.IsNullOrEmpty(model.Link_Url)

                )
            {
                {
                    model.Link_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));
                    model.Link_AddTime  = DateTime.Parse(DateTime.Now.ToString("s"));
                    //
                    bool isAdd = dal.Add(model) > 0 ? true : false;

                    if (isAdd)
                    {
                        this.Response.Write(Tool.NMsg.SetMsg("增加成功", "1"));
                        this.Response.End();
                    }
                    else
                    {
                        this.Response.Write(Tool.NMsg.SetMsg("增加失败" + dal.ErrorMsg, "1"));
                        this.Response.End();
                    }
                }
            }
            else
            {
                this.Response.Write(Tool.NMsg.SetMsg("提交失败", "0"));
            }

            dal.Close();

            return(View());
        }