啊鑫
9 天以前 abac1dadf2ba8674a24bb0b91c75de5c7881df72
DevApp/Gs.DevApp/DevFrm/BasicData/Frm_MesDepot.cs
@@ -1,7 +1,6 @@
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.Grid;
using Gs.DevApp.DevFrm.Rpt;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
@@ -21,73 +20,6 @@
        private List<FilterEntity> _filterList = new List<FilterEntity>();
        private readonly string _webServiceName = "MesDepotsManager/";
        private DevExpress.XtraEditors.ComboBoxEdit txt_DepotModel;
        private string _kwModel;
        /*  public Frm_MesDepot()
          {
              InitializeComponent();
              toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
              toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
              toolBarMenu1.btnLoadClick += ToolBarMenu1_btnLoadClick;
              toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
              toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
              this.toolBarMenu1.getXmlConfig();
              Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
              Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, null, "", (value) =>
             {
                 Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
             }, tips);
              Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
              {
                  getModel(value);
              }, (value) =>
              {
                  getPageList(this.pageBar1.CurrentPage);
              }, lbGuid);
              getPageList(1);
              pageBar1.PagerEvent += PageBar1_PagerEvent;
              //打印批量操作事件
              this.ucBtnPrint1.btnAllClick += (s, e) =>
              {
                  string rowGuid = lbGuid.Text.Trim();
                  SelectDeleteBar frm = new SelectDeleteBar(rowGuid, "仓位码");
                  string strCodeList = "";
                  frm.UpdateParent += (ss, ee) =>
                  {
                      strCodeList = ee.StringSingle;
                  };
                  frm.ShowDialog();
                  if (string.IsNullOrEmpty(strCodeList))
                      return;
                  try
                  {
                      string rptParameter = "rpt_KW1{"
                      + "100"//重打都是传100,
                      + "," + ""
                      + "," + ""
                      + "," + ""
                      + "," + ""
                      + "," + strCodeList
                      + "}";
                      using (Form rpt = new RptPreview(rowGuid, rptParameter))
                      {
                          rpt.ShowDialog();
                      }
                      frm.Close();
                  }
                  catch (Exception ex)
                  {
                      MsgHelper.ShowError(ex.Message);
                  }
              };
              this.ucBtnPrint1.SetPrintButton(false);
          }
       */
        /*******库位条码模板切换*****/
        public Frm_MesDepot()
        {
            InitializeComponent();
@@ -111,110 +43,6 @@
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            // 初始化txt_DepotModel控件
            InitDepotModelControl();
            //打印批量操作事件
            this.ucBtnPrint1.btnAllClick += (s, e) =>
            {
                string rowGuid = lbGuid.Text.Trim();
                SelectDeleteBar frm = new SelectDeleteBar(rowGuid, "仓位码");
                string strCodeList = "";
                frm.UpdateParent += (ss, ee) =>
                {
                    strCodeList = ee.StringSingle;
                };
                frm.ShowDialog();
                if (string.IsNullOrEmpty(strCodeList))
                    return;
                try
                {
                    // 根据选择的值设置报表模型
                    SetKwModelBySelectedValue();
                    // 验证模型是否有效
                    if (string.IsNullOrEmpty(_kwModel))
                    {
                        MsgHelper.Warning("请选择有效的库位模型类型");
                        return;
                    }
                    // 使用动态模型名称构建参数
                    string rptParameter = $"{_kwModel}{{"
                        + "100" // 重打都是传100
                        + "," + ""
                        + "," + ""
                        + "," + ""
                        + "," + ""
                        + "," + strCodeList
                        + "}";
                    using (Form rpt = new RptPreview(rowGuid, rptParameter))
                    {
                        rpt.ShowDialog();
                    }
                    frm.Close();
                }
                catch (Exception ex)
                {
                    MsgHelper.ShowError(ex.Message);
                }
            };
            this.ucBtnPrint1.SetPrintButton(false);
        }
        /// <summary>
        /// 初始化txt_DepotModel控件(查找并赋值)
        /// </summary>
        private void InitDepotModelControl()
        {
            // 递归查找窗体中所有控件(包括子容器)
            Control[] foundControls = this.Controls.Find("txt_DepotModel", true);
            if (foundControls != null && foundControls.Length > 0 && foundControls[0] is DevExpress.XtraEditors.ComboBoxEdit)
            {
                txt_DepotModel = (DevExpress.XtraEditors.ComboBoxEdit)foundControls[0];
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("警告:未找到txt_DepotModel控件,请检查控件Name是否正确");
            }
        }
        /// <summary>
        /// 根据txt_DepotModel选择的值设置_kwModel
        /// </summary>
        private void SetKwModelBySelectedValue()
        {
            // 重置模型值
            _kwModel = string.Empty;
            // 检查控件是否存在
            if (txt_DepotModel == null)
            {
                MsgHelper.ShowError("未找到库位模型选择控件");
                return;
            }
            // 获取选择的值
            string selectedValue = txt_DepotModel.EditValue?.ToString().Trim() ?? string.Empty;
            string selectedText = txt_DepotModel.Text?.Trim() ?? string.Empty;
            // 判断选择的值并设置对应的模型
            // 这里同时判断EditValue和Text,确保兼容性(根据实际数据绑定情况调整)
            if (selectedValue == "库位码(小)" || selectedText == "库位码(小)")
            {
                _kwModel = "rpt_KW";
            }
            else if (selectedValue == "库位码(大)" || selectedText == "库位码(大)")
            {
                _kwModel = "rpt_KW1";
            }
            else
            {
                MsgHelper.Warning("请选择有效的库位码类型(小/大)");
            }
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
@@ -331,14 +159,14 @@
            toolBarMenu1.isSetBtn = false;
            if (string.IsNullOrEmpty(txt_depotCode.Text.Trim()))
            {
                MsgHelper.Warning("仓库编码不能为空!");
                MsgHelper.ShowError("仓库编码不能为空!");
                txt_depotCode.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_depotName.Text.Trim()))
            {
                MsgHelper.Warning("仓库名称不能为空!");
                MsgHelper.ShowError("仓库名称不能为空!");
                txt_depotName.Focus();
                return;
            }
@@ -355,11 +183,11 @@
                        MsgHelper.ShowError("编码不能为空!");
                        return;
                    }
                    if (string.IsNullOrEmpty(row["DepotSectionName"].ToString()))
                    {
                        MsgHelper.ShowError("名称不能为空!");
                        return;
                    }
                    //if (string.IsNullOrEmpty(row["DepotSectionName"].ToString()))
                    //{
                    //    MsgHelper.ShowError("名称不能为空!");
                    //    return;
                    //}
                    lst.Add(new MesDepotSections
                    {
                        Guid = UtilityHelper.ToGuid(row["guid"].ToString()),
@@ -375,18 +203,18 @@
                DepotCode = txt_depotCode.Text,
                DepotName = txt_depotName.Text,
                Description = txt_description.Text,
                Remark5=txt_remark5.TextTxt.Trim(),
                list = lst
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("",
                    _webServiceName + "EditModel",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    lbGuid.Text = _rtn.rtnData;
                    toolBarMenu1.isSetBtn = true;
                    var gridViews = new List<GridView>();
@@ -395,10 +223,12 @@
                    toolBarMenu1.currentAction = "";
                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                }
                else
                    MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -408,10 +238,12 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null;var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            var pgq = new PageQueryModel(curPage,
                this.pageBar1.RowsCount,
                "org.FNumber asc ,a.depot_code", "asc",
            gcMain1.DataSource = null;
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            _sbSqlWhere.Append(" and a.FSubsidiary in");
            _sbSqlWhere.Append(ToolBox.UtilityHelper.GetOrgWhere());
            _sbSqlWhere.Append(UtilityHelper.GetSearchWhere(_filterList));
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "org.FNumber asc ,a.depot_code", "asc",
                "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
            try