sync.pub.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using SQLData;
  2. using System.Data;
  3. using System.Text;
  4. namespace SiteCore.Handler
  5. {
  6. public partial class sync
  7. {
  8. public void get_zdmodel()
  9. {
  10. if (UrlPostParmsCheck("path"))
  11. {
  12. string path = GetPostString("path");
  13. string sql = "select name,con,issys from ce_columns where cpath='" + path + "'";
  14. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  15. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  16. }
  17. }
  18. public void save_zdmodel()
  19. {
  20. if (UrlPostParmsCheck("path,cdata"))
  21. {
  22. int uid = CurrentUser.UserID;
  23. string path = GetPostString("path");
  24. string cdata = GetPostString("cdata");
  25. string name = GetPostString("name");
  26. StringBuilder sql = new StringBuilder();
  27. sql.AppendFormat("if (select count(0) from ce_columns where name='{0}' and cpath='{1}')>0 begin ", name, path);
  28. sql.AppendFormat(" update ce_columns set con='{0}' where name='{1}' and cpath='{2}' ", cdata, name, path);
  29. sql.AppendFormat(" end else begin ");
  30. sql.AppendFormat(" insert into ce_columns(userid,name,cpath,con) values({0},'{1}','{2}','{3}') ", uid, name, path, cdata);
  31. sql.Append(" end ");
  32. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  33. returnSuccessMsg("保存成功");
  34. }
  35. }
  36. public void del_zdmodel()
  37. {
  38. if (UrlPostParmsCheck("name,path"))
  39. {
  40. string name = GetPostString("name");
  41. string path = GetPostString("path");
  42. string sql = string.Format("delete from ce_columns where name='{0}' and cpath='{1}' and issys=0 ;", name, path);
  43. int c = DbHelper.DbConn.ExecuteNonQuery(sql);
  44. if (c > 0) returnSuccessMsg("删除成功");
  45. else returnSuccessMsg("无法删除");
  46. }
  47. }
  48. }
  49. }