lg
2024-09-22 c78ffe15080b3218671f03c7d85a5e8edd484b62
DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs
@@ -1,15 +1,15 @@
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Controls;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.Warehouse
@@ -64,6 +64,9 @@
                if (clickedNode.FirstNode == null)
                {
                    string rowGuid = clickedNode.GetValue("guid").ToString();
                    string depotGuid = clickedNode.GetValue("upGuid").ToString();
                    if (!string.IsNullOrEmpty(depotGuid))
                        rowGuid = depotGuid;
                    getModel(rowGuid, false, 999);
                }
            }
@@ -106,7 +109,7 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
        {
            UtilityHelper.ChangeTab(xtraTabControl1, 0);
            UtilityHelper.JumpToTab(xtraTabControl1, 0);
        }
        /// <summary>
        /// 删除事件
@@ -115,13 +118,14 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e)
        {
            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu);
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要删除的行!");
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + tlMenu.FocusedNode.GetValue("name") + "】,确定删除吗?"))
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
            {
                return;
            }
@@ -129,14 +133,13 @@
            {
                guidList = rowGuid,//主建
            };
            string strJson = "";
            try
            {
                strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
                string strJson = UtilityHelper.HttpPost("", "Depot/DeleteModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    UtilityHelper.ChangeTab(xtraTabControl1, 0);
                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
                    getPageList(1, UtilityHelper.GetPageSize());
                }
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -153,7 +156,7 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e)
        {
            UtilityHelper.ChangeTab(xtraTabControl1, 0);
            UtilityHelper.JumpToTab(xtraTabControl1, 0);
            getPageList(1, UtilityHelper.GetPageSize());
        }
        /// <summary>
@@ -163,7 +166,13 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_name, tlMenu);
            string depotGuid = "";
            if (tlMenu.FocusedNode != null)
                depotGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("upGuid"));
            if (!string.IsNullOrEmpty(depotGuid))
                rowGuid = depotGuid;
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
@@ -178,9 +187,12 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
        {
            UtilityHelper.ChangeTab(xtraTabControl1, 1);
            UtilityHelper.JumpToTab(xtraTabControl1, 1);
            lbGuid.Text = "";
            UtilityHelper.CleanValue(this.panel1.Controls, true);
            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
            _setTable();
        }
        /// <summary>
        /// 保存事件
@@ -192,7 +204,7 @@
            toolBarMenu1.isSetBtn = false;
            if (string.IsNullOrEmpty(txt_itemNo.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("编号号不能为空!");
                Gs.DevApp.ToolBox.MsgHelper.Warning("编号不能为空!");
                txt_itemNo.Focus();
                return;
            }
@@ -220,6 +232,23 @@
                txt_isStatus.Focus();
                return;
            }
            gvMx1.UpdateCurrentRow();
            List<dynamic> lst = new List<dynamic>();
            for (int i = 0; i < gvMx1.DataRowCount; i++)
            {
                DataRow row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    lst.Add(new
                    {
                        guid = row["guid"].ToString(),
                        sectionCode = row["sectionCode"].ToString(),
                        sectionName = row["sectionName"].ToString(),
                        remark = row["remark"].ToString(),
                        isStatus = row["isStatusTxt"].ToString(),
                    });
                }
            }
            var _obj = new
            {
                guid = lbGuid.Text.Trim(),//主建
@@ -229,17 +258,20 @@
                category = txt_category.SelectedIndex,
                isWy = txt_isWy.SelectedIndex,
                isStatus = txt_isStatus.SelectedIndex,
                list = lst
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", "Depot/EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    lbGuid.Text = _rtn.rtnData;
                    toolBarMenu1.isSetBtn = true;
                    UtilityHelper.ChangeEnable(this.panel1.Controls, false);
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gridViews.Add(gvMx1);
                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gridViews);
                }
            }
            catch (Exception ex)
@@ -259,7 +291,7 @@
            try
            {
                string strReturn = UtilityHelper.HttpPost("", "Depot/GetListPage", json);
                ReturnModel<PageListModel> dd = UtilityHelper.GetTableByJson(strReturn);
                ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn);
                DataTable dt = dd.rtnData.list;
                this.tlMenu.DataSource = dt;
                this.tlMenu.KeyFieldName = "guid";
@@ -287,7 +319,7 @@
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
            var _obj = new
            {
                guid = strGuid,//主建
@@ -295,12 +327,32 @@
            try
            {
                string strJson = UtilityHelper.HttpPost("", "Depot/GetModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.GetDataByJson(strJson);
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    lbGuid.Text = strGuid;
                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit);
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gridViews.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gridViews);
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    var d = _job["rtnData"]["list"];
                    foreach (var a in d)
                    {
                        array.Add(a);
                    }
                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
                    if (dt.Rows.Count > 0)
                    {
                        gridControl1.BindingContext = new BindingContext();
                        gridControl1.DataSource = dt;
                        gridControl1.ForceInitialize();
                    }
                    else
                    {
                        _setTable();
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -310,6 +362,18 @@
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
            }
        }
        private void _setTable()
        {
            DataTable dt = new DataTable();
            foreach (GridColumn col in gvMx1.Columns)
            {
                dt.Columns.Add(col.FieldName, typeof(string));
            }
            gridControl1.BindingContext = new BindingContext();
            gridControl1.DataSource = dt;
            gridControl1.ForceInitialize();
        }
    }
}