lg
2024-09-22 c78ffe15080b3218671f03c7d85a5e8edd484b62
DevApp/Gs.DevApp/DevFrm/Warehouse/FrmDepot.cs
@@ -1,4 +1,5 @@
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using Gs.DevApp.Entity;
@@ -8,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Controls;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm.Warehouse
@@ -107,7 +109,7 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEscClick(object sender, EventArgs e)
        {
            UtilityHelper.ChangeTab(xtraTabControl1, 0);
            UtilityHelper.JumpToTab(xtraTabControl1, 0);
        }
        /// <summary>
        /// 删除事件
@@ -116,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;
            }
@@ -130,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);
@@ -154,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>
@@ -164,8 +166,11 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e)
        {
            String rowGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("guid"));
            string depotGuid = Convert.ToString(tlMenu.FocusedNode.GetValue("upGuid"));
            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))
@@ -182,19 +187,12 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnAddClick(object sender, EventArgs e)
        {
            UtilityHelper.ChangeTab(xtraTabControl1, 1);
            UtilityHelper.JumpToTab(xtraTabControl1, 1);
            lbGuid.Text = "";
            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValue(this.panel1.Controls, true, gridViews);
            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();
            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
            _setTable();
        }
        /// <summary>
        /// 保存事件
@@ -206,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;
            }
@@ -234,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(),//主建
@@ -243,11 +258,12 @@
                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)
                {
@@ -255,7 +271,7 @@
                    toolBarMenu1.isSetBtn = true;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gridViews.Add(gvMx1);
                    UtilityHelper.ChangeEnable(this.panel1.Controls, false, gridViews);
                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gridViews);
                }
            }
            catch (Exception ex)
@@ -275,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";
@@ -303,7 +319,7 @@
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            UtilityHelper.ChangeTab(xtraTabControl1, tabIdx);
            UtilityHelper.JumpToTab(xtraTabControl1, tabIdx);
            var _obj = new
            {
                guid = strGuid,//主建
@@ -311,7 +327,7 @@
            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;
@@ -327,9 +343,16 @@
                        array.Add(a);
                    }
                    DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
                    gridControl1.BindingContext = new BindingContext();
                    gridControl1.DataSource = dt;
                    gridControl1.ForceInitialize();
                    if (dt.Rows.Count > 0)
                    {
                        gridControl1.BindingContext = new BindingContext();
                        gridControl1.DataSource = dt;
                        gridControl1.ForceInitialize();
                    }
                    else
                    {
                        _setTable();
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -340,6 +363,17 @@
            }
        }
        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();
        }
    }
}