bug
lu
3 天以前 8f01d83e693ee01e8013ac77874ecd3fa385be16
DevApp/Gs.DevApp/DevFrm/Ck/Frm_MesItemQt.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -18,9 +19,9 @@
        List<FilterEntity> _filterList = new List<FilterEntity>();
        string _ucKh = "";//领料客户
        string _ucBm = "";//领料部门
        string _ucCk = "";//发料仓库
        string _ucHzlx = "";//货主类型
        string _ucHz = "";//货主
        string _ucGys = "";//供应商
        public Frm_MesItemQt()
        {
            InitializeComponent();
@@ -40,7 +41,7 @@
            toolBarMenu1.btnCaiGouFchkClick += ToolBarMenu1_btnCaiGouFchkClick;
            toolBarMenu1.btnCaiWuChkClick += ToolBarMenu1_btnCaiWuChkClick;
            toolBarMenu1.btnCaiWuFchkClick += ToolBarMenu1_btnCaiWuFchkClick;
            this.toolBarMenu1.getXmlConfig();
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "isChk", "", (value) =>
           {
@@ -64,7 +65,6 @@
                ucLookHuoZhu1.OrgId = _orgId;
                ucLookHuoZhu1.HzId = _ucHz;
                ucLookHuoZhu1.SetHzLx(_ucHzlx);
                txt_qt008.getSuppler(_orgId, _ucCk);
                System.Text.StringBuilder sbWhere = new System.Text.StringBuilder();
                sbWhere.Append(" and a.FSubsidiary ='" + _orgId + "'");
                var _obj = new PageQueryModel(1, 999999, "item_no", "asc", "", sbWhere.ToString(), "");
@@ -75,10 +75,12 @@
                    var rtn = UtilityHelper.ReturnToTablePage(strReturn);
                    var dt = rtn.rtnData.list;
                    this.repositoryItemSearchLookUpEdit1.DataSource = dt;
                    // repositoryItemSearchLookUpEdit1.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
                    //repositoryItemSearchLookUpEdit1.PopupFormSize = new System.Drawing.Size(500, 300);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            };
            //选择领用组织
@@ -89,8 +91,96 @@
                    return;
                txt_qt013.getSuppler(_orgId, _ucKh);
                txt_qt009.getSuppler(_orgId, _ucBm);
                txt_wwgys.getSuppler(_orgId, _ucGys);
            };
            //选择来源单号
            txt_qt035.ButtonClick += (s, e) =>
            {
                string strSrmNo = "";
                SelectDaa frm = new SelectDaa();
                frm.UpdateParent += (ss, ee) =>
                {
                    var lst = new List<dynamic>();
                    lst = ee.DynamicList;
                    strSrmNo = lst[0].guid;
                    txt_qt035.Text = strSrmNo;
                };
                frm.ShowDialog();
            };
            #region 2025-08-27 复制beg
            btnCopyXls.Click += (s, e) =>
            {
                string kcZz = txt_qt023.GetId();
                if (string.IsNullOrEmpty(kcZz))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择库存组织后才能使用复制功能!");
                    txt_qt023.Focus();
                    return;
                }
                string filePath = AppContext.BaseDirectory + "xlsCopy.xls";
                if (File.Exists(filePath))
                {
                    var frm = new CopyXls(kcZz, lbGuid.Text.Trim(), OrderType.其它出库.ToString());
                    frm.UpdateParent += (ss, ee) =>
                    {
                        try
                        {
                            var lst = ee.DynamicList;
                            DataTable _Table = (DataTable)gcMx1.DataSource;
                            foreach (dynamic dym in lst)
                            {
                                DataRow _row = _Table.NewRow();
                                _row["qd002"] = dym.itemNo;
                                _row["qd003"] = dym.itemName;
                                _row["qd004"] = dym.itemModel;
                                _row["qd009dw"] = dym.dwName;
                                _row["itemId"] = dym.itemId;
                                _row["qd007"] = dym.sl;
                                _row["qd010"] = dym.bz;
                                //默认仓库和仓库数量
                                _row["depotName"] = dym.depotName;
                                _row["depotId"] = dym.depotId;
                                _row["kcQty"] = dym.kcQty;
                                _Table.Rows.Add(_row);
                            }
                            gcMx1.BindingContext = new BindingContext();
                            gcMx1.DataSource = _Table;
                            gcMx1.ForceInitialize();
                            gvMx1.CloseEditor();
                            gvMx1.PostEditor();
                            gvMx1.UpdateCurrentRow();
                            gvMx1.BestFitColumns();
                        }
                        catch (Exception ex)
                        {
                            Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
                        }
                    };
                    frm.ShowDialog();
                }
                else
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("找不到xlsCopy.xls文件,请联系管理员!");
                }
            };
            #endregion
            #region 2025-08-27 增加委外供应商
            txt_qtlx.SelectedIndexChanged += (s, e) =>
            {
                int idx = txt_qtlx.SelectedIndex;
                if (idx == 7)
                {
                    layItemWwgys.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }
                else
                {
                    layItemWwgys.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    txt_wwgys.SetIdOrCode("");
                }
            };
            #endregion
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
@@ -167,7 +257,7 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_qtck, gridView1, "qtck");
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定删除吗?"))
@@ -185,17 +275,19 @@
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    if (xtraTabControl1.SelectedTabPageIndex == 0)
                    { }
                    else
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
                    getPageList(this.pageBar1.CurrentPage);
                }
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                else
                    MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -232,7 +324,7 @@
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_qtck, gridView1, "qtck");
            if (string.IsNullOrEmpty(rowGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 3);
@@ -247,6 +339,10 @@
                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
                ucLookHuoZhu1.Enabled = true;
            }
            //2025/07/12加上修改状态下不能修改
            txt_qt023.IsReadly = true;
            txt_qt024.IsReadly = true;
            ucLookHuoZhu1.Enabled = false;
        }
        /// <summary>
        /// 新增事件
@@ -262,6 +358,9 @@
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gridViews);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            ucLookHuoZhu1.Enabled = true;
            //增加时,默认组织
            string deftOrg = UtilityHelper.GetFirstOrg(txt_qt023);
            string deftOrg2 = UtilityHelper.GetFirstOrg(txt_qt024);
        }
        /// <summary>
        /// 保存事件
@@ -280,51 +379,63 @@
            string inLyCus = txt_qt013.GetId();//领用客户
            string inLyDepart = txt_qt009.GetId();//领用部门
            string inKcfx = txt_qt020.Text.Trim();//库存方向
            string inFlck = txt_qt008.GetId();//发料仓库
            string qtlx = txt_qtlx.Text.Trim();//后来增加的类型
            string wwgys = txt_wwgys.GetId();
            if (string.IsNullOrEmpty(inOrgId))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择库存组织!");
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择库存组织!");
                txt_qt023.Focus();
                return;
            }
            if (string.IsNullOrEmpty(inHzlx))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择货主类型!");
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择货主类型!");
                return;
            }
            if (string.IsNullOrEmpty(inHz))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择货主!");
                return;
            }
            if (txt_qt019.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择单据类型!");
                txt_qt019.Focus();
                return;
            }
            if (string.IsNullOrEmpty(inFlck))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择发料仓库!");
                txt_qt008.Focus();
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择货主!");
                return;
            }
            if (string.IsNullOrEmpty(inLyOrg))
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择领用组织!");
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择领用组织!");
                txt_qt024.Focus();
                return;
            }
            if (string.IsNullOrEmpty(inLyCus) && string.IsNullOrEmpty(inLyDepart))
            if (txt_qtlx.SelectedIndex <= 0)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("客户或部门必选一个!");
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择出库类型!");
                txt_qtlx.Focus();
                return;
            }
            if (txt_qt020.SelectedIndex <= 0)
            //这是非委外的防呆
            if (txt_qtlx.SelectedIndex != 7)
            {
                Gs.DevApp.ToolBox.MsgHelper.Warning("请选择库存方向!");
                txt_qt020.Focus();
                return;
                if (string.IsNullOrEmpty(inLyCus) && string.IsNullOrEmpty(inLyDepart))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("客户或部门必选一个!");
                    return;
                }
                if (!string.IsNullOrEmpty(wwgys))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("出库类型不为【7:无源单委外退料】,请不要选择委外供应商!");
                    return;
                }
            }
            //这是委外的防呆
            if (txt_qtlx.SelectedIndex == 7)
            {
                if (string.IsNullOrEmpty(wwgys))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("出库类型为【7:无源单委外退料】,请选择委外供应商!");
                    return;
                }
                if (!string.IsNullOrEmpty(inLyCus))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("出库类型为【7:无源单委外退料】,不用选择客户!");
                    return;
                }
            }
            var _obj = new
            {
@@ -338,7 +449,9 @@
                inLyCus = inLyCus,//领用客户
                inLyDepart = inLyDepart,//领用部门
                inKcfx = inKcfx,//库存方向
                inFlck = inFlck,//发料仓库
                inSource = txt_qt035.EditValue,//工单号
                qtlx = qtlx,
                wwgys = wwgys,
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
@@ -361,12 +474,19 @@
                        MsgHelper.ShowError("数量不能为空!");
                        return;
                    }
                    string _depotId = row["depotId"].ToString();
                    if (string.IsNullOrEmpty(_depotId))
                    {
                        MsgHelper.ShowError("仓库不能为空!");
                        return;
                    }
                    _obj.list.Add(new
                    {
                        Guid = _guid,
                        ItemId = (row["itemId"].ToString()),
                        Sqsl = (row["qd007"].ToString()),
                        Bz = (row["qd010"].ToString()),
                        DepotId = row["depotId"].ToString(),
                    });
                }
            }
@@ -374,9 +494,9 @@
            {
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    ToolBox.MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    lbGuid.Text = _rtn.rtnData.outGuid;
                    txt_qtck.Text = _rtn.rtnData.outNo;
                    toolBarMenu1.isSetBtn = true;
@@ -387,10 +507,12 @@
                    toolBarMenu1.currentAction = "";
                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                }
                else
                    ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -401,7 +523,11 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null;
            System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder();
            _sbSqlWhere.Append(" and a.qt023  in");
            _sbSqlWhere.Append(ToolBox.UtilityHelper.GetOrgWhere());
            _sbSqlWhere.Append(UtilityHelper.GetSearchWhere(_filterList));
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
@@ -417,7 +543,8 @@
                    {
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                        gridView1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
@@ -437,7 +564,7 @@
            }
        }
        /// <summary>
        /// 读取
        /// </summary>
@@ -449,7 +576,7 @@
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -465,18 +592,18 @@
                    dynamic dy = _rtn.rtnData;
                    _ucKh = dy.qt013;
                    _ucBm = dy.qt009;
                    _ucCk = dy.qt008;
                    _ucHzlx = dy.qt025;
                    _ucHz = dy.qt018;
                    _ucGys = dy.wwgys;//委外供应商
                    lbGuid.Text = strGuid;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    _ucKh = "";
                    _ucBm = "";
                    _ucCk = "";
                    _ucHzlx = "";
                    _ucHz = "";
                    _ucGys = "";
                    ucLookHuoZhu1.Enabled = isEdit;
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
@@ -499,11 +626,11 @@
                    }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                    ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
@@ -590,7 +717,7 @@
        {
            _toolCk(41);
        }
        /// <summary>
        /// 工具条事件
        /// </summary>
@@ -624,13 +751,14 @@
                case 41:
                    strMsg = "采购反审核";
                    break;
            };
            }
            ;
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_qtck, gridView1, "qtck");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定" + strMsg + "吗?"))
@@ -646,21 +774,31 @@
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    MsgHelper.ShowInformation(_rtn.rtnData.outMsg.ToString());
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim());
                        int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                        gridView1.FocusedRowHandle = rowHandle;
                        UtilityHelper.SetCheckIco(gridView1, "isChk", "qt016", "qt002", picCheckBox, this, _inFieldValue.ToString());
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    UtilityHelper.SetCheckIco(gridView1, "isChk", "qt016", "qt002", picCheckBox, this, _inFieldValue.ToString());
                    else
                    {
                        //注意,这里和其它页面有点不一样
                        getPageList(this.pageBar1.CurrentPage);
                        int rowHandle = gridView1.LocateByValue("guid", rowGuid);
                        gridView1.FocusedRowHandle = rowHandle;
                    }
                }
                else
                    MsgHelper.ShowError(_rtn.rtnData.outMsg.ToString());
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        private void repositoryItemSearchLookUpEdit1_EditValueChanged(object sender, EventArgs e)
@@ -670,8 +808,18 @@
            gvMx1.SetFocusedRowCellValue("qd002", SelectedDataRow["itemNo"]);
            gvMx1.SetFocusedRowCellValue("qd003", SelectedDataRow["itemName"]);
            gvMx1.SetFocusedRowCellValue("qd004", SelectedDataRow["itemModel"]);
            gvMx1.SetFocusedRowCellValue("qd009", SelectedDataRow["dwName"]);
            gvMx1.SetFocusedRowCellValue("qd009dw", SelectedDataRow["dwName"]);
            gvMx1.SetFocusedRowCellValue("itemId", SelectedDataRow["id"]);
            gvMx1.SetFocusedRowCellValue("depotName", SelectedDataRow["depotName"]);
            gvMx1.SetFocusedRowCellValue("depotId", SelectedDataRow["depotId"]);
            gvMx1.SetFocusedRowCellValue("kcQty", SelectedDataRow["kcQty"]);
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            gvMx1.BestFitColumns();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
        }
        /// <summary>
        /// 删除明细
@@ -707,15 +855,53 @@
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        if (_rtn.rtnCode > 0) getModel(lbGuid.Text);
                        getModel(lbGuid.Text);
                    }
                    MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                    else
                        MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 查找仓库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptCk_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            var dr = gvMx1.GetDataRow(rowhandle);
            var strItemId = dr["itemId"].ToString();
            if (string.IsNullOrEmpty(strItemId))
            {
                MsgHelper.ShowError("提示:请先选择物料!");
                return;
            }
            var strOrgGuid = txt_qt023.GetId();
            if (string.IsNullOrEmpty(strOrgGuid))
            {
                MsgHelper.ShowError("提示:请先选择库存组织!");
                return;
            }
            SelectCk frm = new SelectCk(strOrgGuid, strItemId);
            frm.UpdateParent += (ss, ee) =>
            {
                var lst = new List<dynamic>();
                lst = ee.DynamicList;
                gvMx1.SetFocusedRowCellValue("depotName", lst[0].name);
                gvMx1.SetFocusedRowCellValue("depotId", lst[0].guid);
                gvMx1.SetFocusedRowCellValue("kcQty", lst[0].kcQty);
                gvMx1.BestFitColumns();
            };
            frm.ShowDialog();
        }
    }
}