コード例 #1
0
ファイル: SPReportRoleNew.cs プロジェクト: sun2dar/MKCRMApi
        public KeyValuePair <int, String> ReportRoleNew_Insert(ReportRoleNew model)
        {
            var param = new SqlParameter[] {
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ID
                },
                new SqlParameter("@ReportID", SqlDbType.UniqueIdentifier)
                {
                    Value = model.ReportID
                },
                new SqlParameter("@SecurityRoleId", SqlDbType.UniqueIdentifier)
                {
                    Value = model.SecurityRoleId
                },
                new SqlParameter("@RetVal", SqlDbType.Int)
                {
                    Direction = ParameterDirection.Output
                },
                new SqlParameter("@Message", SqlDbType.NVarChar, 100)
                {
                    Direction = ParameterDirection.Output
                }
            };

            int rc = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreCommand("exec [rpt].[ReportRole_Insert] @ID, @ReportID, @SecurityRoleId, @RetVal OUTPUT, @Message OUTPUT", param);

            int    retVal   = (int)param[3].Value;
            string valueRes = param[4].Value.ToString();

            return(new KeyValuePair <int, string>(retVal, valueRes));
        }
コード例 #2
0
        public ActionResult Delete()
        {
            ReportRoleNew model    = new ReportRoleNew();
            string        ReportID = Request["reportid"];

            model.ReportID = new Guid(ReportID);
            model.ID       = new Guid(Request["ID"]);

            return(formSubmit(model, "Delete"));
        }
コード例 #3
0
        public ActionResult Execute(ReportRoleNew model, string action)
        {
            KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, "");
            string message = Resources.ReportRole.ReportRoleSuccess;

            if (action == "Create")
            {
                if (db.reportRoleNew.Where(x => x.SecurityRoleId == model.SecurityRoleId).Where(x => x.ReportID == model.ReportID).Count() > 0)
                {
                    var jsonData = new { flag = false, Message = Resources.ReportRole.ReportRoleSame };
                    return(Json(jsonData));
                }
            }

            if (action == "Delete")
            {
                message = Resources.NotifResource.PrivilegeExceptionDelSuccess;
            }

            switch (action)
            {
            case "Delete":
                results = db.ReportRoleNew_Delete(model);
                break;

            case "Create":
                model.ID = Guid.NewGuid();
                results  = db.ReportRoleNew_Insert(model);
                break;
            }

            if (results.Key == 0 || results.Key == 16 || results.Key == 6)
            {
                var jsonData = new { flag = true, Message = message };
                return(Json(jsonData));
            }
            else
            {
                var jsonData = new { flag = false, Message = results.Value.ToString() };
                return(Json(jsonData));
            }
        }
コード例 #4
0
        public ActionResult Create()
        {
            ReportRoleNew model    = new ReportRoleNew();
            string        ReportID = Request["reportid"];
            string        id       = Request["ID"];

            model.ReportID       = new Guid(ReportID);
            model.SecurityRoleId = new Guid(id);

            var check = db.reportRoleView
                        .Where(x => x.ReportID == model.ReportID)
                        .Where(x => x.SecurityRoleId == model.SecurityRoleId);

            if (check.Count() > 0)
            {
                var jsonData = new { flag = false, Message = "Report sudah mendapatkan akses untuk Report ini." };
                return(Json(jsonData));
            }

            return(formSubmit(model, "Create"));
        }
コード例 #5
0
        public ActionResult formSubmit(ReportRoleNew model, string actionType)
        {
            List <string> errorMessage   = new List <string>();
            string        successMessage = Resources.NotifResource.DataSuccess;

            SessionForSP sessionParam = new SessionForSP();

            sessionParam.CurrentUserID = new Guid(Session["CurrentUserID"].ToString());

            if (ModelState.IsValid)
            {
                KeyValuePair <int, string> results = new KeyValuePair <int, string>(1, "");
                // model.ModifiedBy = new Guid(Session["CurrentUserID"].ToString());
                var jsonData = new { flag = false, Message = "" };

                if (actionType == "Create")
                {
                    model.ID = Guid.NewGuid();
                    jsonData = new { flag = true, Message = "Role berhasil ditambahkan" };
                    results  = db.ReportRoleNew_Insert(model);
                }
                else if (actionType == "Delete")
                {
                    jsonData = new { flag = true, Message = "Role berhasil dihapus" };
                    results  = db.ReportRoleNew_Delete(model);
                }

                //Update report
                ReportView reportModel = new ReportView();
                reportModel            = db.reportView.Where(x => x.ID == model.ReportID).FirstOrDefault();
                reportModel.ModifiedBy = new Guid(Session["CurrentUserID"].ToString());
                results = db.Report_Update(reportModel);

                if (results.Key == 0 || results.Key == 16 || results.Key == 6)
                {
                    UrlHelper u = new UrlHelper(this.ControllerContext.RequestContext);
                    //string urlNew = u.Action("Edit?id="+model.ReportID+"&success="+results.Value, "MasterReport");
                    string urlNew = u.Action("Edit", "MasterReport", new { id = model.ReportID, success = results.Value });
                    return(Json(jsonData));
                }
                else
                {
                    jsonData = new { flag = false, Message = "Swap Column Gagal" };
                    return(Json(jsonData));
                }
            }
            else
            {
                foreach (var key in ModelState.Keys)
                {
                    var error = ModelState[key].Errors.FirstOrDefault();
                    if (error != null)
                    {
                        errorMessage.Add(error.ErrorMessage);
                    }
                }
                var jsonData = new { flag = false, Message = errorMessage.First() };

                return(Json(jsonData));
            }
        }