iqc
lu
2025-04-21 c3ebc2116abc274eb2220e7a24c4ca03acad3a1d
DevApp/Gs.DevApp/DevFrm/QC/Jyxm.cs
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
@@ -11,6 +6,11 @@
using MES.Service.Modes;
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.QC
@@ -19,12 +19,12 @@
    {
        private List<FilterEntity> _filterList = new List<FilterEntity>();
        private readonly string _webServiceName = "MesQmCheckitemManager/";
        public string strType = "";
        public string strType = "";//iqc type
        public decimal dfValue = 1;  //iqc的样品数量默认5,否则1
        public Jyxm(string _strType)
        {
            InitializeComponent();
            strType = _strType;
        }
        protected override void OnCreateControl()
        {
@@ -38,53 +38,48 @@
            toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick;
            toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick;
            toolBarMenu1.btnChkClick += ToolBarMenu1_btnChkClick;
            toolBarMenu1.btnPiZhunClick += ToolBarMenu1_btnPiZhunClick;
          this.toolBarMenu1.getXmlConfig();
            toolBarMenu1.btnFChkClick += ToolBarMenu1_btnFChkClick;
            txt_ftype.Text = strType;
            if (strType == "iqc")
                dfValue = 5;
            this.gvMx1.InitNewRow += (s, e) =>
            {
                this.gvMx1.SetRowCellValue(e.RowHandle, "ypsl", dfValue);
                int newIndex = gvMx1.DataRowCount + 1;
                this.gvMx1.SetRowCellValue(e.RowHandle, "forder", newIndex);
            };
            this.toolBarMenu1.getXmlConfig();
            Form parentForm = this.FindForm();
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, picCheckBox, parentForm, "foneChecked", "", (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;
            _setIno();
            btnSelect.Click += (s, e) =>
            btnCopy.Click += (s, e) =>
            {
                var frm = new SelectCheckDt("jyxm");
                frm.UpdateParent += (ss, ee) =>
                if ((lbGuid.Text.Trim().Length < 10))
                {
                    var lst = ee.DynamicList;
                    var json = JsonConvert.SerializeObject(lst);
                    DataTable _newTable = (DataTable)JsonConvert.DeserializeObject(json, (typeof(DataTable)));
                    DataTable _oldTable = (DataTable)gridControl2.DataSource;
                    DataRow[] sourceRows = _newTable.Select();
                    for (int i = 0; i < sourceRows.Length; i++)
                    {
                        _oldTable.ImportRow(sourceRows[i]);
                    }
                    gridControl2.BindingContext = new BindingContext();
                    gridControl2.DataSource = _oldTable;
                    gridControl2.ForceInitialize();
                };
                    Gs.DevApp.ToolBox.MsgHelper.ShowInformation("请先保存当前信息!");
                    return;
                }
                JyxmShow frm = new JyxmShow(lbGuid.Text.Trim(), strType);
                frm.ShowDialog();
            };
            btnSave.Click += BtnSave_Click;
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
            Task.Delay(100);
            getPageList(1);
        }
@@ -106,10 +101,15 @@
        /// <param name="e"></param>
        private void ToolBarMenu1_btnQueryClick(object sender, EventArgs e)
        {
            Form parentForm;
            if (this.Parent is Form)
                parentForm = this.Parent as Form;
            else
                parentForm = this.Parent.Parent as Form;
            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, parentForm.GetType().FullName);
            frm.UpdateParent += Frm_UpdateParent;
            frm.ShowDialog();
        }
@@ -124,14 +124,16 @@
            _filterList = e.FilterList;
            getPageList(1);
        }
        /// <summary>
        /// 批准
        /// 反审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolBarMenu1_btnPiZhunClick(object sender, EventArgs e)
        /// <exception cref="NotImplementedException"></exception>
        private void ToolBarMenu1_btnFChkClick(object sender, EventArgs e)
        {
            _toolCk(2);
            _toolCk(0);
        }
        /// <summary>
@@ -209,7 +211,6 @@
            {
                List<DevExpress.XtraGrid.Views.Grid.GridView> gvList = new List<DevExpress.XtraGrid.Views.Grid.GridView>();
                gvList.Add(gvMx1);
                gvList.Add(gridView2);
                UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, true, gvList);
            }
        }
@@ -225,10 +226,8 @@
            Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 4);
            var gridViews = new List<GridView>();
            gridViews.Add(gvMx1);
            gridViews.Add(gridView2);
            UtilityHelper.CleanValueByControl(this.layoutMx1.Controls, true, gridViews);
            UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
            xtraTabPageCopy.PageEnabled = false;
        }
        /// <summary>
@@ -292,13 +291,17 @@
                            MsgHelper.ShowError("接受水平不能为空!");
                            return;
                        }
                        if (string.IsNullOrEmpty(row["ypsl"].ToString()))
                        {
                            MsgHelper.ShowError("样品数量平不能为空!");
                            return;
                        }
                        string _Fstand = row["Fstand"].ToString();
                        string _FupAllow = row["FupAllow"].ToString();
                        string _FdownAllow = row["FdownAllow"].ToString();
                        //假如三个都为空通过
                        if (string.IsNullOrEmpty(_Fstand) && string.IsNullOrEmpty(_FupAllow) && string.IsNullOrEmpty(_FdownAllow))
                        {
                        }
                        else
                        {
@@ -334,7 +337,7 @@
                            Memo = row["memo"].ToString(),
                            FupAllow = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(row["FupAllow"].ToString()),
                            FdownAllow = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(row["FdownAllow"].ToString()),
                            FqaType = this.strType,
                            ypsl = Gs.DevApp.ToolBox.UtilityHelper.GetDecimal(row["ypsl"].ToString()),
                        });
                    }
                }
@@ -344,8 +347,8 @@
                    ItemId = long.Parse(_ItemId),
                    Memo = txt_memo.Text.Trim(),
                    ItemNo = txt_itemNo.Text.Trim(),
                    Ftype = "1",
                    Fversion = Gs.DevApp.ToolBox.UtilityHelper.ToLong(txt_fversion.Text.Trim()),
                    Ftype = this.strType,
                    Fversion = 0,
                    list = lst
                };
                try
@@ -362,8 +365,9 @@
                        toolBarMenu1.isSetBtn = true;
                        var gridViews = new List<GridView>();
                        gridViews.Add(gvMx1);
                        gridViews.Add(gridView2);
                        UtilityHelper.ChangeEnableByControl(this.layoutMx1.Controls, false, gridViews);
                        toolBarMenu1.currentAction = "";
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 6);
                    }
                }
                catch (Exception ex)
@@ -375,7 +379,6 @@
            {
                MsgHelper.ShowError("提示:" + ex.Message);
            }
        }
        /// <summary>
@@ -384,8 +387,9 @@
        /// <param name="pageSize">每页几条</param>
        private void getPageList(int curPage)
        {
            var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            gcMain1.DataSource = null; var _sbSqlWhere = UtilityHelper.GetSearchWhere(_filterList);
            _sbSqlWhere += " and b.guid is not null";
            _sbSqlWhere += " and a.FTYPE='" + this.strType + "'";
            var pgq = new PageQueryModel(curPage, this.pageBar1.RowsCount,
                "org.FNumber asc ,b.item_no asc,a.FVERSION desc", "", "", _sbSqlWhere.ToString());
            var json = JsonConvert.SerializeObject(pgq);
@@ -405,7 +409,7 @@
                    {
                        gcMain1.DataSource = dt;
                        gcMain1.ForceInitialize();
                        gridView1.BestFitColumns();
                        gridView1.BestFitColumns(); Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gridView1);
                    }
                    else
                        UtilityHelper.SetDefaultTable(gcMain1, gridView1);
@@ -435,7 +439,6 @@
                MsgHelper.Warning("请先选择你要操作的行!");
                return;
            }
            xtraTabPageCopy.PageEnabled = !isEdit;
            var _obj = new
            {
                guid = strGuid //主建
@@ -470,7 +473,6 @@
                    {
                        UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    UtilityHelper.SetDefaultTable(gridControl2, gridView2);
                }
                else
                {
@@ -494,6 +496,9 @@
            {
                case -1:
                    strMsg = "删除";
                    break;
                case 0:
                    strMsg = "反审核";
                    break;
                case 1:
                    strMsg = "审核";
@@ -523,23 +528,28 @@
                    _webServiceName + "EditModelSubmit",
                    JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
                if (_inFieldValue < 0 && _rtn.rtnCode > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 0)
                    {
                        getPageList(this.pageBar1.CurrentPage);
                    }
                    else
                        Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 2);
                }
                if (_rtn.rtnCode > 0 && _rtn.rtnData.outSum * 1 > 0)
                {
                    if (xtraTabControl1.SelectedTabPageIndex == 1)
                    {
                        getModel(lbGuid.Text.Trim());
                        Form parentForm = this.FindForm();
                        UtilityHelper.SetCheckIco(gridView1, "foneChecked", "foneCheckor", "foneCheckdate", picCheckBox, parentForm, _inFieldValue > 0 ? "1" : "0");
                    }
                    else
                    {
                        //注意,这里和其它页面有点不一样
                        getPageList(this.pageBar1.CurrentPage);
                        int rowHandle = gridView1.LocateByValue("guid", rowGuid);
                        gridView1.FocusedRowHandle = rowHandle;
                    }
                    int rowHandle = gridView1.LocateByValue(1, gridView1.Columns["guid"], rowGuid);
                    gridView1.FocusedRowHandle = rowHandle;
                    Form parentForm = this.FindForm();
                    UtilityHelper.SetCheckIco(gridView1, "foneChecked", "foneCheckor", "foneCheckdate", picCheckBox, parentForm, _inFieldValue.ToString());
                }
                MsgHelper.Warning(_rtn.rtnData.outMsg.ToString());
            }
            catch (Exception ex)
            {
@@ -737,72 +747,5 @@
            }
        }
        #endregion
        /// <summary>
        /// 删除复制项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            gridView2.CloseEditor();
            gridView2.UpdateCurrentRow();
            var rowhandle = gridView2.FocusedRowHandle;
            if (rowhandle < 0)
                return;
            if (e.Button.Index == 0)
            {
                var dr = gridView2.GetDataRow(rowhandle);
                if (!MsgHelper.AskQuestion("你选择了1条数据,确定删除吗?"))
                    return;
                gridView2.DeleteRow(rowhandle);
                return;
            }
        }
        /// <summary>
        /// 提交物料复制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="NotImplementedException"></exception>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            int _rows = gridView2.RowCount;
            if (_rows <= 0)
            {
                MsgHelper.ShowInformation("请选择你需要复制的物料!");
                return;
            }
            if (!MsgHelper.AskQuestion("你选择了" + _rows.ToString() + "条数据,确定保存吗?"))
                return;
            System.Text.StringBuilder _sbGuids = new System.Text.StringBuilder();
            for (var i = 0; i < gridView2.DataRowCount; i++)
            {
                var row = gridView2.GetDataRow(i);
                if (_sbGuids.Length > 0)
                    _sbGuids.Append(",");
                Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString());
                _sbGuids.Append(_guid.ToString());
            }
            var _obj = new
            {
                sourceGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()),
                itemGuids = _sbGuids.ToString()
            };
            try
            {
                var strJson = UtilityHelper.HttpPost("", _webServiceName + "ItemsComyMx", JsonConvert.SerializeObject(_obj));
                var _rtn = UtilityHelper.ReturnToDynamic(strJson);
                MsgHelper.Warning("提示:" + _rtn.rtnMsg);
                if (_rtn.rtnCode > 0)
                {
                    UtilityHelper.SetDefaultTable(gridControl2, gridView2);
                }
            }
            catch (Exception ex)
            {
                MsgHelper.Warning("提示:" + ex.Message);
            }
        }
    }
}