bug
lu
7 天以前 ccbe3fad6c7ebb9c1e936163c7f04cb469ff32fc
DevApp/Gs.DevApp/DevFrm/Rk/Frm_MesInvItemArn.cs
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.RichEdit.Export;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.Grid;
using Gs.DevApp.DevFrm.Rk;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Gs.DevApp.UserControl;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gs.DevApp.DevFrm
{
@@ -19,10 +19,11 @@
    {
        private List<FilterEntity> _filterList = new List<FilterEntity>();
        private readonly string _webServiceName = "MesInvItemArnManager/";
        string _ucCk = "";//仓库
        string _ucGys = "";//供应商
        public Frm_MesInvItemArn()
        {
            InitializeComponent();
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick;
            toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick;
            toolBarMenu1.btnSaveClick += ToolBarMenu1_btnSaveClick;
@@ -30,25 +31,23 @@
            toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1;
            toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick;
            toolBarMenu1.btnFjianYanClick += ToolBarMenu1_btnFjianYanClick;
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick;
            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);
            });
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, this, "fstatus", "", (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);
            //以下两行有影响性能,但目前没好方案
            txt_suppId.getSuppler("");
            txt_depotsId.getSuppler("");
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            //设置组织
            this.txt_receiveOrgId.EditChanged += (s, e) =>
@@ -56,13 +55,7 @@
                string _orgId = txt_receiveOrgId.GetId();
                if (string.IsNullOrEmpty(_orgId))
                    return;
                txt_suppId.getSuppler(_orgId);
                txt_depotsId.getSuppler(_orgId);
            };
            //设置仓库选择
            this.txt_depotsId.EditChanged += (s, e) =>
            {
                txtDepotsCode.Text = this.txt_depotsId.GetCode();
                txt_suppId.getSuppler(_orgId, _ucGys);
            };
            //设置供应商选择
            this.txt_suppId.EditChanged += (s, e) =>
@@ -72,6 +65,12 @@
            //选择需要入库的明细
            btnSelect.Click += (s, e) =>
            {
                if (string.IsNullOrEmpty(this.txt_receiveOrgId.GetId()))
                {
                    MsgHelper.Warning("请选择收料组织!");
                    txt_receiveOrgId.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(this.txt_suppId.GetId()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请先选择供应商,才能选择来料明细!");
@@ -98,21 +97,58 @@
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = _oldTable;
                        gcMx1.ForceInitialize();
                        gvMx1.PostEditor();
                        gvMx1.UpdateCurrentRow();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                };
                frm.ShowDialog();
            };
            //选择srm明细
            txt_paperBillNo.ButtonClick += (s, e) =>
            {
                string strSrmNo = "";
                SelectSrm frm = new SelectSrm();
                frm.UpdateParent += (ss, ee) =>
                {
                    var lst = new List<dynamic>();
                    lst = ee.DynamicList;
                    strSrmNo = lst[0].guid;
                    txt_paperBillNo.Text = strSrmNo;
                    txt_receiveOrgId.SetIdOrCode(lst[0].receiveOrgId);
                    txt_suppId.SetIdOrCode(lst[0].suppId);
                    var _obj = new
                    {
                        inShdh = strSrmNo,
                        inP1 = "",
                        inP2 = ""
                    };
                    var strReturn = UtilityHelper.HttpPost("", _webServiceName + "SelectSrmTo", 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.PostEditor();
                    gvMx1.UpdateCurrentRow();
                };
                frm.ShowDialog();
            };
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns);
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            Task.Delay(100);
            getPageList(1);
        }
@@ -137,7 +173,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();
        }
@@ -166,24 +202,13 @@
            toolBarMenu1.guidKey = rowGuid;
        }
        /// <summary>
        ///  反检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnFjianYanClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmitF");
        }
        /// <summary>
        /// 检验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnJianYanClick(object sender, EventArgs e)
        private void ToolBarMenu1_btnChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmit");
        }
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk("EditModelSubmitF");
        }
        /// <summary>
        ///     取消事件
@@ -224,8 +249,11 @@
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
                {
                    UtilityHelper.JumpToTab(xtraTabControl1, 0);
                    getPageList(1);
                    if (xtraTabControl1.SelectedTabPageIndex == 0)
                    { }
                    else
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
                    getPageList(this.pageBar1.CurrentPage);
                }
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
@@ -246,14 +274,15 @@
                getModel(lbGuid.Text.Trim());
            else
            {
                _filterList.Clear();
                if (gridView1.ActiveFilter.Count > 0)
                {
                    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                    gridView1.ActiveFilter.Clear();
                    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                }
                getPageList(1);
                //_filterList.Clear();
                //if (gridView1.ActiveFilter.Count > 0)
                //{
                //    gridView1.ColumnFilterChanged -= GridView1_ColumnFilterChanged;
                //    gridView1.ActiveFilter.Clear();
                //    gridView1.ColumnFilterChanged += GridView1_ColumnFilterChanged;
                //}
                //getPageList(1);
                getPageList(this.pageBar1.CurrentPage);
            }
        }
@@ -281,7 +310,7 @@
            {
                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);
            }
        }
@@ -296,8 +325,10 @@
            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_receiveOrgId);
        }
        /// <summary>
@@ -309,24 +340,17 @@
        {
            toolBarMenu1.isSetBtn = false;
            string _orgId = txt_receiveOrgId.GetId();
            string _ckId = txt_depotsId.GetId(); //仓库编号 depots_code
            string _gysId = txt_suppId.GetId(); //供应商编号
            if (string.IsNullOrEmpty(_orgId))
            {
                MsgHelper.Warning("请选择收料组织!");
                MsgHelper.ShowError("请选择收料组织!");
                txt_receiveOrgId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_gysId))
            {
                MsgHelper.Warning("请选择供应商!");
                MsgHelper.ShowError("请选择供应商!");
                txt_suppId.Focus();
                return;
            }
            if (string.IsNullOrEmpty(_ckId))
            {
                MsgHelper.Warning("请选择仓库!");
                txt_depotsId.Focus();
                return;
            }
            var _obj = new
@@ -335,12 +359,11 @@
                PaperBillNo = txt_paperBillNo.Text.Trim(), //送货单号;
                Remark = txt_remark.Text.Trim(), //备注
                SuppId = _gysId, //供应商
                DepotsId = _ckId,//仓库
                FType = txt_fType.Checked ? 1 : 0,//0=采购,1=委外
                OrgId = _orgId,
                list = new List<dynamic>(),
            };
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            if (gvMx1.DataRowCount <= 0)
            {
@@ -366,6 +389,7 @@
                        ItemId = int.Parse(row["itemId"].ToString()),
                        Quantity = decimal.Parse(row["quantity"].ToString()),
                        UrgentFlag = Gs.DevApp.ToolBox.UtilityHelper.ToBit(row["urgentFlag"].ToString()),
                        Remark = row["memo"].ToString(),
                    });
                }
            }
@@ -375,19 +399,24 @@
                    _webServiceName + "EditModel",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    lbGuid.Text = _rtn.rtnData;
                    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(panel1.Controls, false);
                    UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false);
                    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);
            }
        }
@@ -397,7 +426,7 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount, "create_date",
                "asc", "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
@@ -409,15 +438,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();
                        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;//当前页
@@ -457,10 +487,14 @@
                if (_rtn.rtnCode > 0)
                {
                    var dy = _rtn.rtnData;
                    _ucGys = dy.suppId;
                    _ucCk = dy.depotsId;
                    lbGuid.Text = strGuid;
                    var gvList = new List<GridView>();
                    gvList.Add(gvMx1);
                    UtilityHelper.SetValueByObj(panel1.Controls, dy, isEdit, gvList);
                    UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList);
                    _ucGys = "";
                    _ucCk = "";
                    var _job = JObject.Parse(strJson);
                    var array = new JArray();
                    foreach (var a in _job["rtnData"]["list"]) array.Add(a);
@@ -472,6 +506,8 @@
                        gcMx1.BindingContext = new BindingContext();
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
                    }
                    else
                    {
@@ -557,7 +593,6 @@
                }
                var lst = new List<string>();
                lst.Add(mxGuid);
                var _obj = lst;
                try
                {
@@ -567,18 +602,17 @@
                    var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                    if (_rtn.rtnCode > 0)
                    {
                        MsgHelper.ShowInformation("提示:" + _rtn.rtnMsg);
                    }
                    MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
                    else
                        MsgHelper.ShowError("提示:" + _rtn.rtnMsg);
                }
                catch (Exception ex)
                {
                    MsgHelper.Warning("提示:" + ex.Message);
                    MsgHelper.ShowError("提示:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 检验和反检验
@@ -606,12 +640,16 @@
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnData.outMsg);
                if (_rtn.rtnCode > 0)
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim());
                    else
                        getPageList(this.pageBar1.CurrentPage);
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    int _inFieldValue = (_meth == "EditModelSubmit" ? 1 : -1);
                    UtilityHelper.SetCheckIco(gridView1, "fstatus", "checkUser", "checkDate", picCheckBox, this, _inFieldValue.ToString());
                }
            }
            catch (Exception ex)
@@ -620,5 +658,21 @@
            }
        }
        /// <summary>
        /// 查看到货记录,根据采购明细guid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rptHistory_ButtonClick(object sender, ButtonPressedEventArgs e)
        {
            var rowhandle = gvMx1.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            var dr = gvMx1.GetDataRow(rowhandle);
            var mxGuid = dr["aboutGuid"].ToString();
            HistoryDhmxcs frm = new HistoryDhmxcs(mxGuid);
            frm.ShowDialog();
        }
    }
}