Guest User

Untitled

a guest
Oct 20th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. [Error Shown on image][1]
  2.  
  3. public ActionResult Index()
  4. {
  5. MemberData();
  6. return View();
  7. }
  8.  
  9. [HttpPost]
  10. public JsonResult MemberData()
  11. {
  12. List<float> percentage = new List<float>();
  13.  
  14. SqlConnection con = new SqlConnection(constr);
  15. SqlCommand cmd = new SqlCommand("select COUNT(IsActive) as Total from MemberMaster where IsActive=1", con);
  16. cmd.CommandType = CommandType.Text;
  17. cmd.Connection = con;
  18. con.Open();
  19.  
  20. DataTable mDT = new DataTable();
  21. SqlDataAdapter da = new SqlDataAdapter(cmd);
  22.  
  23. da.Fill(mDT);
  24.  
  25. ChartjsViewModel objModel = new ChartjsViewModel();
  26.  
  27. TempData["vper"] = objModel.mPer = new List<int>();
  28.  
  29. for (int i = 0; i < mDT.Rows.Count; i++)
  30. {
  31.  
  32. objModel.mPer.Add(int.Parse(mDT.Rows[i]["Total"].ToString()));
  33. }
  34. con.Close();
  35. return Json(new { objModel.mPer});
  36. }
  37.  
  38. <script type="text/javascript">
  39. var myData = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(TempData["vper"]));
  40. $(function () {
  41. var n = myData;
  42. setInterval(function () {
  43. if (n > 11) {
  44. $.ajax({
  45. type: "Post",
  46. url: "/Testing/MemberData",
  47. data: "{'Index':'" + n + "'}",
  48. contentType: "application/json; charset=utf-8",
  49. dataType: "json",
  50. success: function (data) {
  51. var value = data.d;
  52. //alert(value);
  53. $(".progress-bar").attr("aria-valuenow", value);
  54. $(".progress-bar").attr("style", "width:" + value + "%");
  55. $(".progress-bar").text(value + "%");
  56. },
  57. error: function (err) {
  58. alert(err);
  59. }
  60. });
  61. n++;
  62. }
  63. }, 2000);
  64. })
  65. </script>
Add Comment
Please, Sign In to add comment