123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.OAShopManagement
- {
- /// <summary>
- /// 微信接口列表数据
- /// </summary>
- public partial class frmMicroLetterPlatformList : LYFZ.Software.UI.OAShopManagement.frmMicroLetterPlatformList
- {
- BLL.BLL_ErpMicroInterface microInterfaceBll = new BLL.BLL_ErpMicroInterface();
- LYFZ.BLL.BLL_MicroInterface bllMIF = new BLL.BLL_MicroInterface();
- public override void InitData()
- {
- BindListViewData();
- BindConfigData();
- this.Shown += frmMicroLetterPlatformList_Shown;
- this.btn_Update.Click += btn_Update_Click;
-
- this.dataGridViewEx1.CellContentDoubleClick += dataGridViewEx1_CellContentDoubleClick;
- this.dataGridViewEx1.CellContentClick += dataGridViewEx1_CellContentClick;
- }
- void frmMicroLetterPlatformList_Shown(object sender, EventArgs e)
- {
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
- VersionControl.VersionFunctionEnum.App和微信公众号微信公众平台绑定自助服务);
- if (!b)
- {
- this.Close();
- }
- }
- void dataGridViewEx1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0)
- {
- if (e.ColumnIndex == 4)
- {
- //编辑
- DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
- frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
- frmInterface.CompayList = this.CompayList;
- frmInterface.PrimitiveID = row["PrimitiveID"].ToString();
- frmInterface.ShowDialog();
- BindListViewData();
- }
- else if (e.ColumnIndex == 5)
- {
- DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
- //删除
- microInterfaceBll.Delete(Convert.ToInt32(row["id"].ToString()));
- BindListViewData();
- }
- }
- }
- void dataGridViewEx1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- if (e.ColumnIndex != 5)
- {
- DataRow row = (DataRow)this.dataGridViewEx1.Rows[e.RowIndex].Tag;
- frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
- frmInterface.CompayList = this.CompayList;
- frmInterface.PrimitiveID = row["PrimitiveID"].ToString();
- frmInterface.ShowDialog();
- BindListViewData();
- }
- }
- }
- void BindConfigData()
- {
- LYFZ.BLL.BLL_ErpSystemConfigure config = new BLL.BLL_ErpSystemConfigure();
- DataSet ds = config.GetSystemConfigure("*", "AppInterface");
- if (ds.Tables[0].Rows.Count > 0)
- {
- LYFZ.Model.Model_ErpSystemConfigure model = config.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["ID"]));
- try
- {
- Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(model.Sconfig_Value);
- tb_AppUrlPath.Text = jobject.GetValue("AppUrlPath").ToString();
- tb_AppEnId.Text = jobject.GetValue("AppEnId").ToString();
- }
- catch
- {
- }
- }
- }
- void btn_Update_Click(object sender, EventArgs e)
- {
- frmMicroLetterPlatformConfig configDia = new frmMicroLetterPlatformConfig();
- configDia.ShowDialog();
- BindConfigData();
- }
- List<LYFZ.Model.Model_ErpCompanyInfo> _compayList = new List<Model.Model_ErpCompanyInfo>();
- public List<LYFZ.Model.Model_ErpCompanyInfo> CompayList
- {
- get {
- if (_compayList.Count <= 0)
- {
- _compayList = new LYFZ.BLL.BLL_ErpCompanyInfo().GetModelList("1=1");
- }
- return _compayList;
- }
- set { _compayList = value; }
- }
- string GetComIDToName(string comID)
- {
- string retName = "";
- foreach (LYFZ.Model.Model_ErpCompanyInfo com in CompayList)
- {
- if (comID.ToLower() == com.Company_DividedShop.ToString().ToLower())
- {
- retName = com.Company_Name;
- break;
- }
- }
- return retName;
- }
- void BindListViewData()
- {
-
- this.dataGridViewEx1.Rows.Clear();
- Model.Model_MicroInterface modMIF = bllMIF.Model;
- DataTable dt = microInterfaceBll.GetAllList();
- if (!String.IsNullOrEmpty(modMIF.AppID.Trim()))
- {
- DataRow[] drList = dt.Select("AppID ='" + modMIF.AppID + "' ");
- if (drList.Length == 0)
- {
- try
- {
- Model.Model_ErpMicroInterface miicroInterface = BindMicroDataInfo(modMIF);
- LYFZ.Model.Model_ErpSystemConfigure configure = bllMIF.GetCustommenuModel();
- miicroInterface.MenuData = configure.Sconfig_Value;
- miicroInterface.PrimitiveID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID;
- microInterfaceBll.Add(miicroInterface);
- modMIF.AppID = "";
- bllMIF.UpdateMicroInterfaceSet(modMIF);
- dt = microInterfaceBll.GetAllList();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(this.dataGridViewEx1);
- row.Cells[0].Value = dt.Rows[i]["MicroName"].ToString();
- row.Cells[1].Value = dt.Rows[i]["MicroNumber"].ToString();
- row.Cells[2].Value = dt.Rows[i]["AppID"].ToString();
- row.Cells[3].Value = GetComIDToName(dt.Rows[i]["PrimitiveID"].ToString());
- row.Cells[4].Value = "编辑";
- row.Cells[5].Value = "删除";
- row.Tag = dt.Rows[i];
- this.dataGridViewEx1.Rows.Add(row);
- }
- }
- LYFZ.Model.Model_ErpMicroInterface BindMicroDataInfo(LYFZ.Model.Model_MicroInterface modFace)
- {
- LYFZ.Model.Model_ErpMicroInterface modelMIF = new Model.Model_ErpMicroInterface();
-
- modelMIF.APPEnterpriseID = modFace.APPEnterpriseID;
- modelMIF.AppID = modFace.AppID;
- modelMIF.AppSecret = modFace.AppSecret;
- modelMIF.EncodingAESKey = modFace.EncodingAESKey;
- modelMIF.InterfaceUrl = modFace.InterfaceUrl;
- modelMIF.MicroName = modFace.MicroName;
- modelMIF.MicroNumber = modFace.MicroNumber;
- modelMIF.PrimitiveID = modFace.PrimitiveID;
- modelMIF.ThirdPartyPlatformURL = modFace.ThirdPartyPlatformURL;
- modelMIF.Token = modFace.Token;
- modelMIF.VisitDomainName = modFace.VisitDomainName;
- return modelMIF;
- }
- public override void btn_Add_Click(object sender, EventArgs e)
- {
- frmMicroLetterPlatformInterface frmInterface = new frmMicroLetterPlatformInterface();
- frmInterface.CompayList = this.CompayList;
- frmInterface.PrimitiveID ="";
- frmInterface.ShowDialog();
- BindListViewData();
-
- //base.btn_Add_Click(sender, e);
- }
-
-
- }
-
- }
|