市长热线演示版

entityedit.aspx.cs 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace HySoft.BaseCallCenter.Web.formmanage
  8. {
  9. public partial class entityedit : System.Web.UI.Page
  10. {
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. }
  14. protected void btnSubmit_Click(object sender, EventArgs e)
  15. {
  16. string res = "";
  17. string name = txtF_Name.Text.Trim();
  18. string tablename = txtF_DBTableName.Value.Trim();
  19. string tablepre = txtF_DBTableNamePre.Value.Trim();
  20. try
  21. {
  22. DateTime dat = DateTime.Now;
  23. if (string.IsNullOrEmpty(name.Trim()))
  24. {
  25. res= "实体名称不能为空";
  26. }
  27. if (string.IsNullOrEmpty(tablename.Trim()))
  28. {
  29. res= "实体数据表名不能为空";
  30. }
  31. Model.T_Form_EntityInfo model = new Model.T_Form_EntityInfo();
  32. model.F_Name = name.Trim();
  33. model.F_DBTableName = tablepre.Trim() + tablename.Trim();
  34. model.F_IsActivity = 1;
  35. model.F_Des = txtF_Remark.Text.Trim();
  36. model.F_CreateSQL = "";
  37. model.F_CreateOn = dat;
  38. model.F_LastModifyOn = dat;
  39. model.F_ModifySQL = "";
  40. model.EntityAttributeItems= null;
  41. Model.T_Form_EntityAttribute[] arrmodel = new Model.T_Form_EntityAttribute[1];
  42. Model.T_Form_EntityAttribute attributemodel = new Model.T_Form_EntityAttribute();
  43. #region 主键
  44. attributemodel.F_TypeId = 2;
  45. attributemodel.F_DBTypeName = "int";
  46. attributemodel.F_Name = name.Trim() + "主键ID";
  47. attributemodel.F_DBFieldlName = "F_" + tablename.Trim() + "Id";
  48. attributemodel.F_DBTableName = model.F_DBTableName;
  49. attributemodel.F_Length = null;
  50. attributemodel.F_IsNullable = false;
  51. attributemodel.F_EntityId = model.F_EntityId;
  52. attributemodel.F_DefaultValue = null;
  53. attributemodel.F_ColumnNumber = 0;
  54. attributemodel.F_ValidForUpdateAPI = false;
  55. attributemodel.F_ValidForReadAPI = true;
  56. attributemodel.F_ValidForCreateAPI = false;
  57. attributemodel.F_VisibleToPlatform = false;
  58. attributemodel.F_IsPKAttribute = true;
  59. attributemodel.F_IsCustomField = false;
  60. attributemodel.F_DisplayMask = 0;
  61. attributemodel.F_IsSortAttribute = true;
  62. attributemodel.F_PrecisionValue = null;
  63. attributemodel.F_IsIdentity = true;
  64. attributemodel.F_AppDefaultValue = null;
  65. attributemodel.F_Locked = false;
  66. attributemodel.F_MaxLength = null;
  67. attributemodel.F_MinValue = null;
  68. attributemodel.F_MaxValue = null;
  69. attributemodel.F_LookupStyle = null;
  70. attributemodel.F_Des = name.Trim() + "主键ID";
  71. #endregion
  72. arrmodel[0] = attributemodel;
  73. model.EntityAttributeItems = arrmodel;
  74. int r = new BLL.T_Form_EntityInfo().AddTran(model);
  75. if (r == 0)
  76. {
  77. res = "success";
  78. }
  79. else
  80. {
  81. if (r == -2)
  82. {
  83. res = "创建实体失败:实体数据表名称已存在";
  84. }
  85. else if (r == -1)
  86. {
  87. res = "创建实体失败-1";
  88. }
  89. else
  90. {
  91. res = "创建实体失败" + r.ToString();
  92. }
  93. }
  94. }
  95. catch
  96. {
  97. res = "创建实体异常";
  98. }
  99. }
  100. }
  101. }