From a8ed3d24ba97b9ee93de0f15fb15b46a9850b2fc Mon Sep 17 00:00:00 2001
From: lg <999544862qq.com>
Date: 星期二, 17 九月 2024 16:58:39 +0800
Subject: [PATCH] 基础资料

---
 DevApp/Gs.DevApp/DevFrm/User/Organization.cs |  235 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 191 insertions(+), 44 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/User/Organization.cs b/DevApp/Gs.DevApp/DevFrm/User/Organization.cs
index 28336c2..ec5df29 100644
--- a/DevApp/Gs.DevApp/DevFrm/User/Organization.cs
+++ b/DevApp/Gs.DevApp/DevFrm/User/Organization.cs
@@ -1,12 +1,8 @@
-锘縰sing DevExpress.XtraEditors;
-using Gs.DevApp.Models;
+锘縰sing Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
 using System.Data;
-using System.Threading.Tasks;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.User
@@ -16,53 +12,174 @@
         public Organization()
         {
             InitializeComponent();
+            this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
+            this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
             this.toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
+            this.toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
+            this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
+            this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
+            tlMenu.DoubleClick += TlMenu_DoubleClick;
             getTree();
-            UtilityHelper.SetFont(panel1);
         }
-        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
+
+        private void TlMenu_DoubleClick(object sender, EventArgs e)
         {
-            if (string.IsNullOrEmpty(txtName.Text.Trim()))
+            TreeNode clickedNode = tlMenu.SelectedNode;
+            if (clickedNode.FirstNode == null)
             {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("鍚嶇О涓嶈兘涓虹┖锛�");
-                txtName.Focus();
+                string rowGuid = clickedNode.Name.ToString();
+                getModel(rowGuid, false, 999);
+            }
+        }
+        /// <summary>
+        /// 鍙栨秷浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
+        {
+            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+        }
+
+        /// <summary>
+        /// 鍒犻櫎浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
+        {
+            TreeNode clickedNode = tlMenu.SelectedNode;
+            if (clickedNode.FirstNode != null)
+                return;
+            string rowGuid = clickedNode.Name.ToString();
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鍒犻櫎鐨勮锛�");
                 return;
             }
-            if (string.IsNullOrEmpty(txtConPeople.Text.Trim()))
+            if (!MsgHelper.AskQuestion("浣犻�夋嫨浜嗐��" + clickedNode.Text + "銆戯紝纭畾鍒犻櫎鍚楋紵"))
             {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("鑱旂郴浜轰笉鑳戒负绌猴紒");
-                txtConPeople.Focus();
                 return;
             }
-            if (string.IsNullOrEmpty(txtConPeople.Text.Trim()))
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("鑱旂郴鐢佃瘽涓嶈兘涓虹┖锛�");
-                txtConPeople.Focus();
-                return;
-            }
-            if (string.IsNullOrEmpty(txtConTel.Text.Trim()))
-            {
-                Gs.DevApp.ToolBox.MsgHelper.Warning("鐘舵�佷笉鑳戒负绌猴紒");
-                txtConTel.Focus();
-                return;
-            }
-            string _upGuid = comUp.Text.Trim().Length > 0 ? comUp.SelectedValue.ToString() : "";
             var _obj = new
             {
-                guid = lbGuid.Text.Trim(),//涓诲缓
-                upGuid = _upGuid,//涓婄骇鐨勪富寤�
-                name = txtName.Text.Trim(),//鍚嶇О
-                conPeople = txtConPeople.Text,//鑱旂郴浜�
-                conTel = txtConPeople.Text,//鑱旂郴鐢佃瘽
-                status = txtStatus.SelectedIndex,//鐘舵��
+                guid = rowGuid,//涓诲缓
             };
             string strJson = "";
             try
             {
-                strJson = UtilityHelper.HttpPost("", "Organization/EditModel", JsonConvert.SerializeObject(_obj));
+                strJson = UtilityHelper.HttpPost("", "Organization/DeleteModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                if (_rtn.rtnCode > 0) { getTree(); }
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 鍒锋柊浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
+        {
+            UtilityHelper.ChangeTab(xtraTabControl1, 0);
+            getTree();
+        }
+
+
+        /// <summary>
+        /// 淇敼浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
+        {
+            TreeNode clickedNode = tlMenu.SelectedNode;
+            //if (clickedNode.FirstNode != null)
+            //    return;
+            string rowGuid = clickedNode.Name.ToString();
+            if (string.IsNullOrEmpty(rowGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            getModel(rowGuid, true, 1);
+        }
+        /// <summary>
+        /// 鏂板浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
+        {
+            UtilityHelper.ChangeTab(xtraTabControl1, 1);
+            lbGuid.Text = "";
+            UtilityHelper.CleanValue(this.panel1.Controls, true);
+        }
+        /// <summary>
+        /// 淇濆瓨浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
+        {
+             toolBarMenu1.isSetBtn = false;
+            if (string.IsNullOrEmpty(txt_factory.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鍚嶇О涓嶈兘涓虹┖锛�");
+                txt_factory.Focus();
+                return;
+            }
+            if (string.IsNullOrEmpty(txt_name.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鍚嶇О涓嶈兘涓虹┖锛�");
+                txt_name.Focus();
+                return;
+            }
+            if (string.IsNullOrEmpty(txt_conPeople.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鑱旂郴浜轰笉鑳戒负绌猴紒");
+                txt_conPeople.Focus();
+                return;
+            }
+            if (string.IsNullOrEmpty(txt_conTel.Text.Trim()))
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鑱旂郴鐢佃瘽涓嶈兘涓虹┖锛�");
+                txt_conTel.Focus();
+                return;
+            }
+            if (txt_isStatus.SelectedIndex <= 0)
+            {
+                Gs.DevApp.ToolBox.MsgHelper.Warning("鐘舵�佷笉鑳戒负绌猴紒");
+                txt_isStatus.Focus();
+                return;
+            }
+            string _upGuid = txt_upGuid.Text.Trim().Length > 0 ? txt_upGuid.SelectedValue.ToString() : "";
+            var _obj = new
+            {
+                guid = lbGuid.Text.Trim(),//涓诲缓
+                upGuid = _upGuid,//涓婄骇鐨勪富寤�
+                name = txt_name.Text.Trim(),//鍚嶇О
+                conPeople = txt_conPeople.Text,//鑱旂郴浜�
+                conTel = txt_conPeople.Text,//鑱旂郴鐢佃瘽
+                isStatus = txt_isStatus.SelectedIndex,//鐘舵��
+                factory = txt_factory.Text,//缁勭粐缂栧彿
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", "Organization/EditModel", JsonConvert.SerializeObject(_obj));
                 ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
                 ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
-                if (_rtn.rtnCode > 0) { getTree(); }
+                if (_rtn.rtnCode > 0)
+                {
+                    lbGuid.Text = _rtn.rtnData;
+                    toolBarMenu1.isSetBtn = true;
+                    UtilityHelper.ChangeEnable(this.panel1.Controls, false);
+                }
             }
             catch (Exception ex)
             {
@@ -72,20 +189,19 @@
 
         private void getTree()
         {
-            trv.Nodes.Clear();
+            tlMenu.Nodes.Clear();
             ImageList imageList = new ImageList();
             imageList.Images.Add("icon1", Properties.Resources.publicfix_32x32);
             imageList.Images.Add("icon2", Properties.Resources.user_16x16);
-            trv.ImageList = imageList;
-            Models.PageQueryModel pgq = new Models.PageQueryModel(1, 999999, "name", "desc", "", "");
+            tlMenu.ImageList = imageList;
+            PageQueryModel pgq = new PageQueryModel(1, 999999, "name", "desc", "", "");
             string json = JsonConvert.SerializeObject(pgq);
-            string strReturn = "";
             try
             {
-                strReturn = UtilityHelper.HttpPost("", "Organization/GetListPage", json);
+                string strReturn = UtilityHelper.HttpPost("", "Organization/GetListPage", json);
                 ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
                 DataTable dt = dd.rtnData.list;
-                DataRow[] drGrp = dt.Select("upGuid=''");
+                DataRow[] drGrp = dt.Select("upGuid='' or upguid is null");
                 DataTable dtComList = new DataTable();
                 dtComList.Columns.Add("guid", typeof(string));
                 dtComList.Columns.Add("name", typeof(string));
@@ -106,11 +222,42 @@
                         node.Nodes.Add(node22);
                     }
                     node.ExpandAll();
-                    trv.Nodes.Add(node);
+                    tlMenu.Nodes.Add(node);
                 }
-                comUp.DataSource = dtComList;
-                comUp.DisplayMember = "name";
-                comUp.ValueMember = "guid";
+                txt_upGuid.DataSource = dtComList;
+                txt_upGuid.DisplayMember = "name";
+                txt_upGuid.ValueMember = "guid";
+            }
+            catch (Exception ex)
+            {
+                ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message);
+            }
+        }
+
+        private void getModel(string strGuid, bool isEdit, int tabIdx)
+        {
+            if (string.IsNullOrEmpty(strGuid))
+            {
+                ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�");
+                return;
+            }
+            UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
+            var _obj = new
+            {
+                guid = strGuid,//涓诲缓
+            };
+            try
+            {
+                string strJson = UtilityHelper.HttpPost("", "Organization/GetModel", JsonConvert.SerializeObject(_obj));
+                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
+                if (_rtn.rtnCode > 0)
+                {
+                    dynamic dy = _rtn.rtnData;
+                    lbGuid.Text = strGuid;
+                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
+                }
+                else
+                    ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg);
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3