lu
2025-04-05 d70880a3d9ae6c9f99ec380ccd16f5524bb622e6
DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_MesShouTui.cs
@@ -13,10 +13,10 @@
{
    public partial class Frm_MesShouTui : DevExpress.XtraEditors.XtraForm
    {
        string _webServiceName = "MesCgthSqManager/";
        string _webServiceName = "MesShouTuiManager/";
        List<FilterEntity> _filterList = new List<FilterEntity>();
        string _ucCk = "";//发料仓库
        string _ucGys = "";//供应商
        string _ucKh = "";//客户
        public Frm_MesShouTui()
        {
            InitializeComponent();
@@ -32,7 +32,7 @@
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            this.toolBarMenu1.getXmlConfig();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "status", "", (value) =>
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "isCheck", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            });
@@ -42,49 +42,67 @@
            }, (value) =>
            {
                getPageList(this.pageBar1.CurrentPage);
            });
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            //选择库存组织(仓库和供应商)
            txt_thOrgId.EditChanged += (s, e) =>
            txt_fStockOrgId.EditChanged += (s, e) =>
            {
                var orgId = txt_thOrgId.GetId();
                var orgId = txt_fStockOrgId.GetId();
                if (string.IsNullOrEmpty(orgId))
                    return;
                txt_suppId.getSuppler(orgId, _ucGys);
                txt_depotId.getSuppler(orgId, _ucCk);
                txt_fCustId.getSuppler(orgId, _ucKh);
                txt_fStockId.getSuppler(orgId, _ucCk);
            };
            //选择需要的明细
            btnSelect.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(this.txt_suppId.GetId()))
                if (string.IsNullOrEmpty(this.txt_fStockOrgId.GetId()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择供应商!");
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择组织!");
                    this.txt_fStockOrgId.Focus();
                    return;
                }
                var frm = new SelectMesCgthSq(this.txt_suppId.GetId(), this.txt_thOrgId.GetId(), (txt_isOut.Checked == true ? 1 : 0).ToString());
                if (string.IsNullOrEmpty(this.txt_fCustId.GetId()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择客户!");
                    this.txt_fCustId.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(this.txt_fStockId.GetId()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择仓库!");
                    this.txt_fStockId.Focus();
                    return;
                }
                var frm = new SelectShuoTuiSq(this.txt_fCustId.GetId(), txt_fStockOrgId.GetId(), txt_fStockId.GetId(),  txt_fIsLink.SelectedIndex.ToString());
                //赋值给明细表
                frm.UpdateParent += (ss, ee) =>
                {
                    try
                    {
                        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++)
                        var lst = ee.DynamicList;
                        DataTable _Table = (DataTable)gcMx1.DataSource;
                        foreach (dynamic dym in lst)
                        {
                            _oldTable.ImportRow(sourceRows[i]);
                            DataRow _row = _Table.NewRow();
                            _row["aboutGuid"] = dym.rkmxGuid;
                            _row["rkNo"] = dym.invBillNo;
                            _row["wlbm"] = dym.itemNo;
                            _row["wlmc"] = dym.itemName;
                            _row["wlgg"] = dym.itemModel;
                            _row["dwName"] = dym.dwName;
                            _row["fQty"] = dym.kt;
                            _row["sQty"] = 0;
                            _row["itemId"] = dym.itemId;
                            _Table.Rows.Add(_row);
                        }
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = _oldTable;
                        gcMx1.DataSource = _Table;
                        gcMx1.ForceInitialize();
                        gvMx1.CloseEditor();
                        gvMx1.PostEditor();
                        gvMx1.UpdateCurrentRow();
                    }
                    catch (Exception ex)
                    {
@@ -132,7 +150,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();
        }
@@ -294,52 +312,49 @@
        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();
            var _ckId = txt_fStockId.GetId();
            var _khId = txt_fCustId.GetId();
            string _orgId = txt_fStockOrgId.GetId();
            int _fIsLink= txt_fIsLink.SelectedIndex==0?1:0;
            if (string.IsNullOrEmpty(_orgId))
            {
                MsgHelper.Warning("请选择组织!");
                txt_thOrgId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_gysId))
            {
                MsgHelper.Warning("请选择供应商!");
                txt_suppId.Focus();
                txt_fStockOrgId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_ckId))
            {
                MsgHelper.Warning("请选择仓库!");
                txt_depotId.Focus();
                txt_fStockId.Focus();
                return;
            }
            if (txt_returnMethod.SelectedIndex <= 0)
            if (string.IsNullOrEmpty(_khId))
            {
                MsgHelper.Warning("请选择客户!");
                txt_fCustId.Focus();
                return;
            }
            if (txt_fReturnStyle.SelectedIndex <= 0)
            {
                MsgHelper.Warning("请选择退料方式!");
                txt_returnMethod.Focus();
                return;
            }
            if (txt_returnType.SelectedIndex <= 0)
            {
                MsgHelper.Warning("请选择退料原因!");
                txt_returnType.Focus();
                txt_fReturnStyle.Focus();
                return;
            }
            var _obj = new
            {
                Guid = Gs.DevApp.ToolBox.UtilityHelper.ToGuid(lbGuid.Text.Trim()), //到货单主键
                KcZz = _orgId,
                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,//退料原因
                CusId = int.Parse(_khId),
                DepotId = int.Parse(_ckId),
                FIsLink = _fIsLink,//有无源单
                FReturnStyle = txt_fReturnStyle.Text,//退料方式
                list = new List<dynamic>(),
            };
            }; gvMx1.PostEditor();
            gvMx1.CloseEditor();
            gvMx1.UpdateCurrentRow();
            if (gvMx1.DataRowCount <= 0)
            {
                MsgHelper.ShowError("明细不能为空,请选择你的收料明细!");
@@ -350,19 +365,26 @@
                var row = gvMx1.GetDataRow(i);
                if (row != null)
                {
                    Guid _guid = UtilityHelper.ToGuid(row["id"].ToString());
                    string _msl = row["sqNum"].ToString();
                    Guid _guid = UtilityHelper.ToGuid(row["guid"].ToString());
                    string _msl = row["fQty"].ToString();
                    if (string.IsNullOrEmpty(_msl))
                    {
                        MsgHelper.ShowError("申请数量不能为空!");
                        return;
                    }
                    if (string.IsNullOrEmpty(row["fStockStatusId"].ToString()) || row["fStockStatusId"].ToString()=="请选择")
                    {
                        MsgHelper.ShowError("请选择库存状态!");
                        return;
                    }
                    _obj.list.Add(new
                    {
                        Guid = _guid,
                        AboutGuid = UtilityHelper.ToGuid(row["rkmxGuid"].ToString()),
                        Quantity = decimal.Parse(row["sqNum"].ToString()),
                        AboutGuid = UtilityHelper.ToGuid(row["aboutGuid"].ToString()),
                        Quantity = decimal.Parse(row["fQty"].ToString()),
                        Bz = row["remark"].ToString(),
                        ItemId = row["itemId"].ToString(),
                        FStockStatusId = row["fStockStatusId"].ToString(),
                    });
                }
            }
@@ -382,6 +404,7 @@
                    gvList.Add(gvMx1);
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gvList);
                    toolBarMenu1.currentAction = "";
                    Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                }
            }
            catch (Exception ex)
@@ -413,7 +436,7 @@
                    {
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
@@ -453,13 +476,13 @@
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    _ucGys = dy.suppId;
                    _ucCk = dy.depotId;
                    _ucKh = dy.fCustId;
                    _ucCk = dy.fStockId;
                    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);
                    _ucGys = "";
                    _ucKh = "";
                    _ucCk = "";
                    JObject _job = JObject.Parse(strJson);
                    JArray array = new JArray();
@@ -534,7 +557,7 @@
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    UtilityHelper.SetCheckIco(gridView1, "status", "checkUser", "checkDate", picCheckBox, this, _inFieldValue.ToString());
                    UtilityHelper.SetCheckIco(gridView1, "isCheck", "checkBy", "checkDate", picCheckBox, this, _inFieldValue.ToString());
                }
            }
            catch (Exception ex)
@@ -545,6 +568,7 @@
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
@@ -552,7 +576,7 @@
            if (e.Button.Index == 0)
            {
                var dr = gvMx1.GetDataRow(rowhandle);
                var mxGuid = dr["id"].ToString();
                var mxGuid = dr["guid"].ToString();
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                if (string.IsNullOrEmpty(mxGuid))