public HttpResponseMessage GetValues() // IEnumerable(Of String)
        {
            List <Roles> objRoles = new List <Roles>();
            DataSet      Ds       = SqlHelper.ExecuteDataset(strConn, CommandType.StoredProcedure, "Sp_getRoles");
            DataTable    Dt       = Ds.Tables[0];

            if (Dt.Rows.Count > 0)
            {
                // Dim objtran As New Roles

                foreach (DataRow obj in Dt.Rows)
                {
                    Roles Lis = new Roles();

                    Lis.RoleId = obj["RoleId"].ToString();

                    Lis.RoleName    = obj["RoleName"].ToString();
                    Lis.Description = obj["Description"].ToString();
                    objRoles.Add(Lis);
                }



                return(Request.CreateResponse(HttpStatusCode.OK, objRoles));
            }
            else
            {
                ResponceMessage objErr = new ResponceMessage();
                objErr.code    = "1";
                objErr.message = "ไม่มีข้อมูล";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objErr));
            }
        }
Example #2
0
        public HttpResponseMessage AddReportPermission()
        {
            try
            {
                SqlConnection objConn = new SqlConnection(strConn);
                if (objConn.State != ConnectionState.Open)
                {
                    objConn.Open();
                }

                ReportPermission objPReport = new ReportPermission();
                objPReport.ReportId = System.Web.HttpContext.Current.Request.Form["ReportId"].ToString();
                objPReport.RoleId   = System.Web.HttpContext.Current.Request.Form["RoleId"].ToString();



                SqlParameter[] adparam = new SqlParameter[2];
                adparam[0] = new SqlParameter("@ReportId", objPReport.ReportId);
                adparam[1] = new SqlParameter("@RoleId", objPReport.RoleId);


                SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "SP_Insert_ReportPermission", adparam);

                return(Request.CreateResponse(HttpStatusCode.OK, objPReport));
            }
            catch (Exception ex)
            {
                ResponceMessage objErr = new ResponceMessage();
                objErr.code    = "1";
                objErr.message = "ไม่มีข้อมูล";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objErr));
            }
        }
        public HttpResponseMessage GetDisplayOnAppValues()  // IEnumerable(Of String)
        {
            List <DisplayOnApp> objOnApp = new List <DisplayOnApp>();
            DataSet             Ds       = SqlHelper.ExecuteDataset(strConn, CommandType.StoredProcedure, "SP_LoadDisplayOnAppAll");
            DataTable           Dt       = Ds.Tables[0];

            if (Dt.Rows.Count > 0)
            {
                foreach (DataRow obj in Dt.Rows)
                {
                    DisplayOnApp Lis = new DisplayOnApp();

                    Lis.DisplayOnAppId = obj["DisplayOnAppId"].ToString();

                    Lis.DisplayOnAppName = obj["DisplayOnAppName"].ToString();

                    objOnApp.Add(Lis);
                }



                return(Request.CreateResponse(HttpStatusCode.OK, objOnApp));
            }
            else
            {
                ResponceMessage objErr = new ResponceMessage();
                objErr.code    = "1";
                objErr.message = "ไม่มีข้อมูล";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objErr));
            }
        }
Example #4
0
        public HttpResponseMessage GetReportCategoryAllValues()  // IEnumerable(Of String)
        {
            List <ReportCategories> objCat = new List <ReportCategories>();
            DataSet   Ds = SqlHelper.ExecuteDataset(strConn, CommandType.StoredProcedure, "SP_LoadReportCategoriesAll");
            DataTable Dt = Ds.Tables[0];

            if (Dt.Rows.Count > 0)
            {
                // Dim objtran As New Roles

                foreach (DataRow obj in Dt.Rows)
                {
                    ReportCategories Lis = new ReportCategories();

                    Lis.CategoryId = obj["CategoryId"].ToString();

                    Lis.CategoryName = obj["CategoryName"].ToString();
                    //  Lis.CategoryParent = obj["CategoryParent"].ToString();
                    objCat.Add(Lis);
                }



                return(Request.CreateResponse(HttpStatusCode.OK, objCat));
            }
            else
            {
                ResponceMessage objErr = new ResponceMessage();
                objErr.code    = "1";
                objErr.message = "ไม่มีข้อมูล";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objErr));
            }
        }
Example #5
0
        public HttpResponseMessage AddpublishReport()
        {
            try
            {
                SqlConnection objConn = new SqlConnection(strConn);
                if (objConn.State != ConnectionState.Open)
                {
                    objConn.Open();
                }

                PublishReport objPReport = new PublishReport();
                objPReport.ReportName        = HttpContext.Current.Request.Form["ReportName"].ToString();
                objPReport.ReportDescription = HttpContext.Current.Request.Form["ReportDescription"].ToString();
                objPReport.ReportData        = HttpContext.Current.Request.Form["ReportData"].ToString();
                objPReport.PublishByUsername = HttpContext.Current.Request.Form["PublishByUsername"].ToString();
                objPReport.IsPublish         = Convert.ToBoolean(HttpContext.Current.Request.Form["IsPublish"]);
                objPReport.ReportId          = HttpContext.Current.Request.Form["ReportId"];
                objPReport.CategoryId        = HttpContext.Current.Request.Form["CategoryId"];
                objPReport.DisplayOnAppId    = HttpContext.Current.Request.Form["DisplayOnAppId"];

                SqlParameter[] adparam = new SqlParameter[8];
                adparam[0] = new SqlParameter("@ReportName", objPReport.ReportName);
                adparam[1] = new SqlParameter("@ReportDescription", objPReport.ReportDescription);
                adparam[2] = new SqlParameter("@ReportData", objPReport.ReportData);
                adparam[4] = new SqlParameter("@PublishByUsername", objPReport.PublishByUsername);
                adparam[5] = new SqlParameter("@IsPublish", objPReport.IsPublish);
                adparam[6] = new SqlParameter("@CategoryId", objPReport.CategoryId);
                adparam[7] = new SqlParameter("@DisplayOnAppId", objPReport.DisplayOnAppId);

                var getRoleId = SqlHelper.ExecuteScalar(strConn, CommandType.StoredProcedure, "SP_Insert_Reports", adparam);
                objPReport.ReportId = getRoleId.ToString();

                return(Request.CreateResponse(HttpStatusCode.OK, objPReport));
            }
            catch (Exception ex)
            {
                ResponceMessage objErr = new ResponceMessage();
                objErr.code    = "1";
                objErr.message = "ไม่มีข้อมูล";
                return(Request.CreateResponse(HttpStatusCode.BadRequest, objErr));
            }
        }