frmMicroLetterPlatformList.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.OAShopManagement
  10. {
  11. /// <summary>
  12. /// 微信接口列表数据
  13. /// </summary>
  14. public partial class frmMicroLetterPlatformList : LYFZ.Software.UI.OAShopManagement.frmMicroLetterPlatformList
  15. {
  16. BLL.BLL_ErpMicroInterface microInterfaceBll = new BLL.BLL_ErpMicroInterface();
  17. LYFZ.BLL.BLL_MicroInterface bllMIF = new BLL.BLL_MicroInterface();
  18. public override void InitData()
  19. {
  20. BindListViewData();
  21. BindConfigData();
  22. this.Shown += frmMicroLetterPlatformList_Shown;
  23. this.btn_Update.Click += btn_Update_Click;
  24. this.dataGridViewEx1.CellContentDoubleClick += dataGridViewEx1_CellContentDoubleClick;
  25. this.dataGridViewEx1.CellContentClick += dataGridViewEx1_CellContentClick;
  26. }
  27. void frmMicroLetterPlatformList_Shown(object sender, EventArgs e)
  28. {
  29. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  30. VersionControl.VersionFunctionEnum.App和微信公众号微信公众平台绑定自助服务);
  31. if (!b)
  32. {
  33. this.Close();
  34. }
  35. }
  36. void dataGridViewEx1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  37. {
  38. if (e.RowIndex >= 0)
  39. {
  40. if (e.ColumnIndex == 4)
  41. {
  42. //编辑
  43. DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
  44. frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
  45. frmInterface.CompayList = this.CompayList;
  46. frmInterface.PrimitiveID = row["PrimitiveID"].ToString();
  47. frmInterface.ShowDialog();
  48. BindListViewData();
  49. }
  50. else if (e.ColumnIndex == 5)
  51. {
  52. DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
  53. //删除
  54. microInterfaceBll.Delete(Convert.ToInt32(row["id"].ToString()));
  55. BindListViewData();
  56. }
  57. }
  58. }
  59. void dataGridViewEx1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
  60. {
  61. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  62. {
  63. if (e.ColumnIndex != 5)
  64. {
  65. DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
  66. frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
  67. frmInterface.CompayList = this.CompayList;
  68. frmInterface.PrimitiveID = row["PrimitiveID"].ToString();
  69. frmInterface.ShowDialog();
  70. BindListViewData();
  71. }
  72. }
  73. }
  74. void BindConfigData()
  75. {
  76. LYFZ.BLL.BLL_ErpSystemConfigure config = new BLL.BLL_ErpSystemConfigure();
  77. DataSet ds = config.GetSystemConfigure("*", "AppInterface");
  78. if (ds.Tables[0].Rows.Count > 0)
  79. {
  80. LYFZ.Model.Model_ErpSystemConfigure model = config.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]));
  81. try
  82. {
  83. Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(model.Sconfig_Value);
  84. tb_AppUrlPath.Text = jobject.GetValue("AppUrlPath").ToString();
  85. tb_AppEnId.Text = jobject.GetValue("AppEnId").ToString();
  86. }
  87. catch
  88. {
  89. }
  90. }
  91. }
  92. void btn_Update_Click(object sender, EventArgs e)
  93. {
  94. frmMicroLetterPlatformConfig configDia = new frmMicroLetterPlatformConfig();
  95. configDia.ShowDialog();
  96. BindConfigData();
  97. }
  98. List<LYFZ.Model.Model_ErpCompanyInfo> _compayList = new List<Model.Model_ErpCompanyInfo>();
  99. public List<LYFZ.Model.Model_ErpCompanyInfo> CompayList
  100. {
  101. get {
  102. if (_compayList.Count <= 0)
  103. {
  104. _compayList = new LYFZ.BLL.BLL_ErpCompanyInfo().GetModelList("1=1");
  105. }
  106. return _compayList;
  107. }
  108. set { _compayList = value; }
  109. }
  110. string GetComIDToName(string comID)
  111. {
  112. string retName = "";
  113. foreach (LYFZ.Model.Model_ErpCompanyInfo com in CompayList)
  114. {
  115. if (comID.ToLower() == com.Company_DividedShop.ToString().ToLower())
  116. {
  117. retName = com.Company_Name;
  118. break;
  119. }
  120. }
  121. return retName;
  122. }
  123. void BindListViewData()
  124. {
  125. this.dataGridViewEx1.Rows.Clear();
  126. Model.Model_MicroInterface modMIF = bllMIF.Model;
  127. DataTable dt = microInterfaceBll.GetAllList();
  128. if (!String.IsNullOrEmpty(modMIF.AppID.Trim()))
  129. {
  130. DataRow[] drList = dt.Select("AppID ='" + modMIF.AppID + "' ");
  131. if (drList.Length == 0)
  132. {
  133. try
  134. {
  135. Model.Model_ErpMicroInterface miicroInterface = BindMicroDataInfo(modMIF);
  136. LYFZ.Model.Model_ErpSystemConfigure configure = bllMIF.GetCustommenuModel();
  137. miicroInterface.MenuData = configure.Sconfig_Value;
  138. miicroInterface.PrimitiveID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID;
  139. microInterfaceBll.Add(miicroInterface);
  140. modMIF.AppID = "";
  141. bllMIF.UpdateMicroInterfaceSet(modMIF);
  142. dt = microInterfaceBll.GetAllList();
  143. }
  144. catch (Exception ex)
  145. {
  146. MessageBoxCustom.Show(ex.Message);
  147. }
  148. }
  149. }
  150. for (int i = 0; i < dt.Rows.Count; i++)
  151. {
  152. DataGridViewRow row = new DataGridViewRow();
  153. row.CreateCells(this.dataGridViewEx1);
  154. row.Cells[0].Value = dt.Rows[i]["MicroName"].ToString();
  155. row.Cells[1].Value = dt.Rows[i]["MicroNumber"].ToString();
  156. row.Cells[2].Value = dt.Rows[i]["AppID"].ToString();
  157. row.Cells[3].Value = GetComIDToName(dt.Rows[i]["PrimitiveID"].ToString());
  158. row.Cells[4].Value = "编辑";
  159. row.Cells[5].Value = "删除";
  160. row.Tag = dt.Rows[i];
  161. this.dataGridViewEx1.Rows.Add(row);
  162. }
  163. }
  164. LYFZ.Model.Model_ErpMicroInterface BindMicroDataInfo(LYFZ.Model.Model_MicroInterface modFace)
  165. {
  166. LYFZ.Model.Model_ErpMicroInterface modelMIF = new Model.Model_ErpMicroInterface();
  167. modelMIF.APPEnterpriseID = modFace.APPEnterpriseID;
  168. modelMIF.AppID = modFace.AppID;
  169. modelMIF.AppSecret = modFace.AppSecret;
  170. modelMIF.EncodingAESKey = modFace.EncodingAESKey;
  171. modelMIF.InterfaceUrl = modFace.InterfaceUrl;
  172. modelMIF.MicroName = modFace.MicroName;
  173. modelMIF.MicroNumber = modFace.MicroNumber;
  174. modelMIF.PrimitiveID = modFace.PrimitiveID;
  175. modelMIF.ThirdPartyPlatformURL = modFace.ThirdPartyPlatformURL;
  176. modelMIF.Token = modFace.Token;
  177. modelMIF.VisitDomainName = modFace.VisitDomainName;
  178. return modelMIF;
  179. }
  180. public override void btn_Add_Click(object sender, EventArgs e)
  181. {
  182. frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
  183. frmInterface.CompayList = this.CompayList;
  184. frmInterface.PrimitiveID ="";
  185. frmInterface.ShowDialog();
  186. BindListViewData();
  187. //base.btn_Add_Click(sender, e);
  188. }
  189. }
  190. }