sync.inst.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace SiteCore.Handler
  9. {
  10. public partial class sync
  11. {
  12. //save_inst
  13. public void get_inst()
  14. {
  15. DataStruct dStruct = GetStruct();
  16. List<string> lw = new List<string>();
  17. string key = GetPostString("key");
  18. if (key.Length > 0) lw.Add(string.Format("name like '%{0}%'", key));
  19. dStruct.Order = "id desc";
  20. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  21. DataTable dt = WebCache.GetData("s_inst", dStruct);
  22. writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  23. }
  24. public void del_inst()
  25. {
  26. if (UrlParmsCheck("eid"))
  27. {
  28. int eid = GetInt("eid");
  29. SInst.Del(eid);
  30. returnSuccessMsg("删除成功");
  31. }
  32. }
  33. public void save_inst()
  34. {
  35. if (UrlPostParmsCheck("name"))
  36. {
  37. //,address,phone,contex
  38. int eid = GetPostInt("eid");
  39. string name = GetPostString("name");
  40. int num = GetPostInt("num");
  41. string imgs = GetPostString("imgs");
  42. string address = GetPostString("address");
  43. string phone = GetPostString("phone");
  44. string contex = GetPostString("contex");
  45. string teacher = GetPostString("teacher");
  46. string intro = GetPostString("intro");
  47. string tags = GetPostString("tags");
  48. double stars = GetPostDouble("stars");
  49. string lnglat = GetPostString("lnglat");
  50. string blnglat = GetPostString("blnglat");
  51. SInst entity = null;
  52. if (eid > 0) entity = SInst.Get(eid);
  53. else entity = new SInst();
  54. entity.Name = name;
  55. if (imgs.Length > 0)
  56. {
  57. string[] sArr = imgs.Split(',');
  58. if (num > 0)
  59. {
  60. if (sArr.Length >= num) entity.CoverImg = sArr[num - 1];
  61. }
  62. else
  63. {
  64. entity.CoverImg = sArr[0];
  65. }
  66. }
  67. entity.Imgs = imgs;
  68. entity.Address = address;
  69. entity.Phone = phone;
  70. entity.Contex = getFormartBr(contex);
  71. entity.TeacherRes = getFormartBr(teacher);
  72. if (lnglat != "")
  73. {
  74. string[] lArr = lnglat.Split(',');
  75. entity.Lng = lArr[0];
  76. entity.Lat = lArr[1];
  77. }
  78. if(blnglat!="")
  79. {
  80. string[] lArr = blnglat.Split(',');
  81. entity.bLng = lArr[0];
  82. entity.bLat = lArr[1];
  83. }
  84. entity.Stars = stars;
  85. entity.Tags = tags;
  86. entity.Traffic = getFormartBr(intro);
  87. //entity.Con = intro;
  88. if (eid > 0) entity.Update();
  89. else entity.Create();
  90. returnSuccessMsg("保存成功!");
  91. }
  92. }
  93. public string getFormartBr(string con)
  94. {
  95. con = con.Replace("\r\n", "<br>").Replace("\n", "<br>");
  96. //con = con.Replace(" ", "&nbsp;");
  97. return con;
  98. }
  99. }
  100. }