Exemple #1
0
        public ActionResult AddModule(string ModuleCode, string ModuleName, string System, string Remark)
        {
            this.Internationalization();
            try
            {
                    TugDataEntities db = new TugDataEntities();
                    System.Linq.Expressions.Expression<Func<FunctionModule, bool>> exp = u => u.ModuleName == ModuleName;
                    FunctionModule tmpmodule = db.FunctionModule.Where(exp).FirstOrDefault();
                    if (tmpmodule!=null)
                    {
                        //Response.StatusCode = 404;
                        //return Json(new { message = ModuleName + "已存在!" });
                        throw new Exception(ModuleName + "已存在!");
                    }

                    TugDataModel.FunctionModule module = new FunctionModule();
                    module.ModuleCode = ModuleCode;
                    module.ModuleName = ModuleName;
                    module.System = System;
                    module.Remark = Remark;
                    //module.UserID = Session.GetDataFromSession<int>("userid");
                    module.UserDefinedCol1 = "";
                    module.UserDefinedCol2 = "";
                    module.UserDefinedCol3 = "";
                    module.UserDefinedCol4 = "";

                    module.UserDefinedCol9 = "";
                    module.UserDefinedCol10 = "";

                    module = db.FunctionModule.Add(module);
                    db.SaveChanges();

                    var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                    return Json(ret);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public ActionResult AddEditModule()
        {
            this.Internationalization();

            #region Add

            if (Request.Form["oper"].Equals("add"))
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();
                    {
                        TugDataModel.FunctionModule userRole = new FunctionModule();

                        userRole.ModuleCode = Request.Form["ModuleCode"];
                        userRole.ModuleName = Request.Form["ModuleName"];
                        userRole.System = Request.Form["System"];
                        userRole.Remark = Request.Form["Remark"];
                        //userRole.OwnerID = -1;
                        //userRole.CreateDate = userRole.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");;
                        //userRole.UserID = Session.GetDataFromSession<int>("userid");
                        userRole.UserDefinedCol1 = Request.Form["UserDefinedCol1"];
                        userRole.UserDefinedCol2 = Request.Form["UserDefinedCol2"];
                        userRole.UserDefinedCol3 = Request.Form["UserDefinedCol3"];
                        userRole.UserDefinedCol4 = Request.Form["UserDefinedCol4"];

                        if (Request.Form["UserDefinedCol5"] != "")
                            userRole.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]);

                        if (Request.Form["UserDefinedCol6"] != "")
                            userRole.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"]);

                        if (Request.Form["UserDefinedCol7"] != "")
                            userRole.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"]);

                        if (Request.Form["UserDefinedCol8"] != "")
                            userRole.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"]);

                        userRole.UserDefinedCol9 = Request.Form["UserDefinedCol9"];
                        userRole.UserDefinedCol10 = Request.Form["UserDefinedCol10"];

                        userRole = db.FunctionModule.Add(userRole);
                        db.SaveChanges();

                        var ret = new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE };
                        //Response.Write(@Resources.Common.SUCCESS_MESSAGE);
                        return Json(ret);
                    }
                }
                catch (Exception)
                {
                    var ret = new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE };
                    //Response.Write(@Resources.Common.EXCEPTION_MESSAGE);
                    return Json(ret);
                }
            }

            #endregion Add

            #region Edit

            if (Request.Form["oper"].Equals("edit"))
            {
                try
                {
                    TugDataEntities db = new TugDataEntities();

                    int idx = Util.toint(Request.Form["IDX"]);
                    FunctionModule userRole = db.FunctionModule.Where(u => u.IDX == idx).FirstOrDefault();

                    if (userRole == null)
                    {
                        return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    else
                    {
                        userRole.ModuleCode = Request.Form["ModuleCode"];
                        userRole.ModuleName = Request.Form["ModuleName"];
                        userRole.System = Request.Form["System"];
                        userRole.Remark = Request.Form["Remark"];
                        //userRole.OwnerID = -1;
                        //userRole.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");;
                        //userRole.UserID = Session.GetDataFromSession<int>("userid");

                        userRole.UserDefinedCol1 = Request.Form["UserDefinedCol1"];
                        userRole.UserDefinedCol2 = Request.Form["UserDefinedCol2"];
                        userRole.UserDefinedCol3 = Request.Form["UserDefinedCol3"];
                        userRole.UserDefinedCol4 = Request.Form["UserDefinedCol4"];

                        if (Request.Form["UserDefinedCol5"] != "")
                            userRole.UserDefinedCol5 = Convert.ToDouble(Request.Form["UserDefinedCol5"]);

                        if (Request.Form["UserDefinedCol6"] != "")
                            userRole.UserDefinedCol6 = Util.toint(Request.Form["UserDefinedCol6"]);

                        if (Request.Form["UserDefinedCol7"] != "")
                            userRole.UserDefinedCol7 = Util.toint(Request.Form["UserDefinedCol7"]);

                        if (Request.Form["UserDefinedCol8"] != "")
                            userRole.UserDefinedCol8 = Util.toint(Request.Form["UserDefinedCol8"]);

                        userRole.UserDefinedCol9 = Request.Form["UserDefinedCol9"];
                        userRole.UserDefinedCol10 = Request.Form["UserDefinedCol10"];

                        db.Entry(userRole).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
                    }
                }
                catch (Exception exp)
                {
                    return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
                }
            }

            #endregion Edit

            return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
        }