bug
lu
8 天以前 d1104a30df234dc5e28703ea2d9ea57717005442
DevApp/Gs.DevApp/DevFrm/Ck/Frm_MesCgthSq.cs
@@ -15,8 +15,8 @@
    {
        string _webServiceName = "MesCgthSqManager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        string _ucCk = "";//发料仓库
        string _ucGys = "";//供应商
        string _ucBm = "";//部门
        public Frm_MesCgthSq()
        {
            InitializeComponent();
@@ -30,21 +30,19 @@
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gvList.Add(gridView1);
            Gs.DevApp.ToolBox.UtilityHelper.getGridViewConfig(this.GetType().FullName, gvList);
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "status", "", (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;
            //选择库存组织(仓库和供应商)
@@ -54,7 +52,8 @@
                if (string.IsNullOrEmpty(orgId))
                    return;
                txt_suppId.getSuppler(orgId, _ucGys);
                txt_depotId.getSuppler(orgId, _ucCk);
                txt_fPurchaseDeptId.getSuppler(orgId, _ucBm);
                // txt_fPurchaserId.getSuppler();
            };
            //选择需要的明细
            btnSelect.Click += (s, e) =>
@@ -64,36 +63,99 @@
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择供应商!");
                    return;
                }
                var frm = new SelectMesCgthSq(this.txt_suppId.GetId(), this.txt_thOrgId.GetId(), (txt_isOut.Checked == true ? 1 : 0).ToString());
                //赋值给明细表
                frm.UpdateParent += (ss, ee) =>
                if (txt_fHasLinkRad.SelectedIndex == 0)
                {
                    try
                    var frm = new SelectMesCgthSq(this.txt_suppId.GetId(), this.txt_thOrgId.GetId());
                    //赋值给明细表
                    frm.UpdateParent += (ss, ee) =>
                    {
                        var lst = new List<string>();
                        lst = ee.StringList;
                        var _obj = lst;
                        var strReturn = UtilityHelper.HttpPost("",
                            _webServiceName + "SelectFormTo",
                            JsonConvert.SerializeObject(_obj));
                        var dt = UtilityHelper.ReturnToList(strReturn);
                        DataTable _newTable = dt.rtnData;
                        DataTable _oldTable = (DataTable)gcMx1.DataSource;
                        DataRow[] sourceRows = _newTable.Select();
                        for (int i = 0; i < sourceRows.Length; i++)
                        try
                        {
                            _oldTable.ImportRow(sourceRows[i]);
                            var lst = new List<string>();
                            lst = ee.StringList;
                            var _obj = lst;
                            var strReturn = UtilityHelper.HttpPost("",
                                _webServiceName + "SelectFormTo",
                                JsonConvert.SerializeObject(_obj));
                            var dt = UtilityHelper.ReturnToList(strReturn);
                            DataTable _newTable = dt.rtnData;
                            DataTable _oldTable = (DataTable)gcMx1.DataSource;
                            DataRow[] sourceRows = _newTable.Select();
                            for (int i = 0; i < sourceRows.Length; i++)
                            {
                                _oldTable.ImportRow(sourceRows[i]);
                            }
                            gcMx1.BindingContext = new BindingContext();
                            gcMx1.DataSource = _oldTable;
                            gcMx1.ForceInitialize();
                            gvMx1.BestFitColumns();
                            Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                        }
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = _oldTable;
                        gcMx1.ForceInitialize();
                    }
                    catch (Exception ex)
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    };
                    frm.ShowDialog();
                    return;
                }
                if (txt_fHasLinkRad.SelectedIndex == 1)
                {
                    var frm2 = new SelectMesCgthSqLink(this.txt_thOrgId.GetId());
                    frm2.UpdateParent += (ss, ee) =>
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
                        try
                        {
                            var lst = ee.DynamicList;
                            DataTable _Table = (DataTable)gcMx1.DataSource;
                            foreach (dynamic dym in lst)
                            {
                                DataRow _row = _Table.NewRow();
                                _row["id"] = dym.id;
                                _row["mid"] = dym.mid;
                                _row["rkmxGuid"] = dym.rkmxGuid;//入库明细表guid
                                _row["cgdh"] = dym.cgdh;//采购单号
                                _row["invWorkLine"] = dym.invWorkLine;//行号,
                                _row["wlbm"] = dym.wlbm; //物料编号,
                                _row["wlmc"] = dym.wlmc;  //物料名称,
                                _row["wlgg"] = dym.wlgg;//规格型号,
                                _row["rksl"] = dym.rksl;  //入库数量,
                                _row["dwName"] = dym.dwName;
                                _row["eid"] = dym.eid;
                                _row["erpid"] = dym.erpid;
                                _row["itemId"] = dym.itemId;  //物料id,
                                _row["ysNum"] = dym.ysNum;//已扫数量
                                _row["remark"] = dym.remark;
                                _row["orderNo"] = dym.orderNo; //序号
                                _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)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    };
                    frm2.ShowDialog();
                    return;
                }
            };
            //源单事件
            txt_fHasLinkRad.SelectedIndex = 0;
            layItem1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            layItem4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            txt_fHasLinkRad.SelectedIndexChanged += (s, e) =>
            {
                setSrm();
            };
        }
        private async void GridView1_ColumnFilterChanged(object sender, EventArgs e)
@@ -134,7 +196,7 @@
            gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
            gridView1.ActiveFilter.Clear();
            gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
            var frm = new ShowFilter(gridView1.Columns, _filterList);
            var frm = new ShowFilter(gridView1.Columns, _filterList, this.GetType().FullName);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -271,8 +333,17 @@
            {
                List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                gvList.Add(gvMx1);
                UtilityHelper.ChangeEnableByControl(panel1.Controls, true, gvList);
                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
            }
            //2025/07/12加上修改状态下不能修改
            setSrm();
            txt_thOrgId.IsReadly = true;
            txt_suppId.IsReadly = true;
            txt_fHasLinkRad.ReadOnly = true;
            txt_fRequireOrgId.IsReadly = true;
            txt_fOwnerIdHead.IsReadly = true;
            txt_fPurchaseDeptId.IsReadly = true;
            txt_fPurchaserId.IsReadly = true;
        }
        /// <summary>
        /// 新增事件
@@ -285,8 +356,13 @@
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
            List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
            gridViews.Add(gvMx1);
            UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews);
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gridViews);
            Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            //增加时,默认组织
            string deftOrg = UtilityHelper.GetFirstOrg(txt_thOrgId);
            string deftXqOrg = UtilityHelper.GetFirstOrg(txt_fRequireOrgId);
            string deftHzOrg = UtilityHelper.GetFirstOrg(txt_fOwnerIdHead);
            setSrm();
        }
        /// <summary>
        /// 保存事件
@@ -296,51 +372,82 @@
        private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e)
        {
            toolBarMenu1.isSetBtn = false;
            var _ckId = txt_depotId.GetId(); //仓库编号 depots_code
            var _gysId = txt_suppId.GetId(); //供应商编号
            string _orgId = txt_thOrgId.GetId();
            string _orgId = txt_thOrgId.GetId();//退货组织
            string _xqzz = txt_fRequireOrgId.GetId();//需求组织
            string _hz = txt_fOwnerIdHead.GetId();//货主
            string _bm = txt_fPurchaseDeptId.GetId();//部门
            string _ygbh = txt_fPurchaserId.GetId();//员工
            if (string.IsNullOrEmpty(_orgId))
            {
                MsgHelper.Warning("请选择组织!");
                MsgHelper.ShowError("请选择组织!");
                txt_thOrgId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_gysId))
            {
                MsgHelper.Warning("请选择供应商!");
                MsgHelper.ShowError("请选择供应商!");
                txt_suppId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_ckId))
            {
                MsgHelper.Warning("请选择仓库!");
                txt_depotId.Focus();
                return;
            }
            if (txt_returnMethod.SelectedIndex <= 0)
            {
                MsgHelper.Warning("请选择退料方式!");
                MsgHelper.ShowError("请选择退料方式!");
                txt_returnMethod.Focus();
                return;
            }
            if (txt_returnType.SelectedIndex <= 0)
            {
                MsgHelper.Warning("请选择退料原因!");
                MsgHelper.ShowError("请选择退料原因!");
                txt_returnType.Focus();
                return;
            }
            //无源单要加上条件
            if (txt_fHasLinkRad.SelectedIndex == 1)
            {
                if (string.IsNullOrEmpty(_xqzz))
                {
                    MsgHelper.ShowError("请选择需求组织!");
                    txt_fRequireOrgId.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(_hz))
                {
                    MsgHelper.ShowError("请选择货主!");
                    txt_fOwnerIdHead.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(_bm))
                {
                    MsgHelper.ShowError("请选择部门!");
                    txt_fPurchaseDeptId.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(_ygbh))
                {
                    MsgHelper.ShowError("请选择员工!");
                    txt_fPurchaserId.Focus();
                    return;
                }
            }
            var _obj = new
            {
                Guid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(lbGuid.Text.Trim()), //到货单主键
                Remark = txt_remark.Text.Trim(), //备注
                SuppId = int.Parse(_gysId), //供应商
                DepotId = int.Parse(_ckId),//仓库
                FType = txt_isOut.Checked == true ? 1 : 0,  //0=采购,1=委外
                Fmrmode = txt_returnMethod.Text,//退料方式
                Reason = txt_returnType.Text,//退料原因
                thOrgId = _orgId,
                fHasLink = txt_fHasLinkRad.SelectedIndex,
                fRequireOrgId = _xqzz,
                fPurchaseDeptId = _bm,
                fPurchaserId = _ygbh,
                fOwnerIdHead = _hz,
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            if (gvMx1.DataRowCount <= 0)
            {
@@ -359,12 +466,20 @@
                        MsgHelper.ShowError("申请数量不能为空!");
                        return;
                    }
                    string _depotId = row["depotId"].ToString();
                    if (string.IsNullOrEmpty(_depotId))
                    {
                        MsgHelper.ShowError("仓库不能为空!");
                        return;
                    }
                    _obj.list.Add(new
                    {
                        Guid = _guid,
                        AboutGuid = UtilityHelper.ToGuid(row["rkmxGuid"].ToString()),
                        Quantity = decimal.Parse(row["sqNum"].ToString()),
                        Bz = row["remark"].ToString(),
                        DepotId = row["depotId"].ToString(),
                        ItemId = row["itemId"].ToString(),
                    });
                }
            }
@@ -374,21 +489,24 @@
                    _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.outGuid;
                    txt_billNo.Text = _rtn.rtnData.outNo;
                    toolBarMenu1.isSetBtn = true;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.ChangeEnableByControl(this.panel1.Controls, false, gvList);
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList);
                    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);
            }
        }
@@ -399,7 +517,7 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            PageQueryModel pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "BILL_NO", "asc", "", _sbSqlWhere.ToString());
            string json = JsonConvert.SerializeObject(pgq);
            try
@@ -409,16 +527,16 @@
                if (dd.rtnCode > 0)
                {
                    DataTable dt = dd.rtnData.list;
                    gcMain.BindingContext = new BindingContext();
                    gcMain1.BindingContext = new BindingContext();
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    if (dt.Rows.Count > 0)
                    {
                        gcMain.DataSource = dt;
                        gcMain.ForceInitialize();
                        gridView1.BestFitColumns();
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain, gridView1);
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                    pageBar1.TotalPages = dd.rtnData.pages;//总页
                    pageBar1.CurrentPage = curPage;//当前页
@@ -434,6 +552,10 @@
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 读取实体
        /// </summary>
        /// <param name="strGuid"></param>
        private void getModel(string strGuid)
        {
            bool isEdit = false;
@@ -441,7 +563,7 @@
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
            if (string.IsNullOrEmpty(strGuid))
            {
                ToolBox.MsgHelper.Warning("请先选择你要操作的行!");
                ToolBox.MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            var _obj = new
@@ -456,13 +578,13 @@
                {
                    dynamic dy = _rtn.rtnData;
                    _ucGys = dy.suppId;
                    _ucCk = dy.depotId;
                    _ucBm = dy.fPurchaseDeptId;
                    lbGuid.Text = strGuid;
                    List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    _ucGys = "";
                    _ucCk = "";
                    _ucBm = "";
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
                    foreach (var a in _job["rtnData"]["list"])
@@ -476,18 +598,20 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    setSrm();
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                    ToolBox.MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
            }
            catch (Exception ex)
            {
                ToolBox.MsgHelper.Warning("提示:" + ex.Message);
                ToolBox.MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -505,13 +629,14 @@
                case 0:
                    strMsg = "反审核";
                    break;
            };
            }
            ;
            toolBarMenu1.guidKey = "";
            string rowGuid, rowName;
            (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1, "billNo");
            if (string.IsNullOrEmpty(rowGuid))
            {
                MsgHelper.Warning("请先选择你要操作的行!");
                MsgHelper.ShowError("请先选择你要操作的行!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了【" + rowName + "】,确定" + strMsg + "吗?"))
@@ -527,9 +652,9 @@
                    _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());
@@ -538,15 +663,24 @@
                    gridView1.FocusedRowHandle = rowHandle;
                    UtilityHelper.SetCheckIco(gridView1, "status", "checkUser", "checkDate", picCheckBox, this, _inFieldValue.ToString());
                }
                else
                    MsgHelper.ShowError(_rtn.rtnData.outMsg.ToString());
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
        /// 删除明细
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
@@ -575,15 +709,66 @@
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        if (_rtn.rtnCode > 0) getModel(lbGuid.Text);
                        getModel(lbGuid.Text);
                        MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    }
                    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 strOrgGuid = txt_thOrgId.GetId();
            if (string.IsNullOrEmpty(strOrgGuid))
            {
                MsgHelper.ShowError("提示:请先选择调出组织!");
                return;
            }
            ;
            SelectCk frm = new SelectCk(strOrgGuid);
            frm.UpdateParent += (ss, ee) =>
            {
                var lst = new List<dynamic>();
                lst = ee.DynamicList;
                gvMx1.SetFocusedRowCellValue("depotName", lst[0].name);
                gvMx1.SetFocusedRowCellValue("depotId", lst[0].guid);
            };
            frm.ShowDialog();
        }
        private void setSrm()
        {
            int ddd = txt_fHasLinkRad.SelectedIndex;
            if (ddd == 0)
            {
                layItem1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                layItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                layItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                layItem4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            }
            else
            {
                layItem1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                layItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                layItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                layItem4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }
        }
    }
}