bug
lu
3 天以前 5c26ea4c8c813ea85acf68fa07e180a12c748f33
DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01Input.cs
@@ -12,15 +12,26 @@
    {
        string _webServiceName = "MesQaItemsDetect01Manager/";
        private string dt01Guid = "";
        public Frm_MesQaItemsDetect01Input(string _dt01Guid)
        bool isEdit = false;
        string strBhg = "×";
        /// <summary>
        ///
        /// </summary>
        /// <param name="_dt01Guid">MES_QA_ITEMS_DETECT_01表GUidance</param>
        /// <param name="_blEdit">是否可编辑</param>
        public Frm_MesQaItemsDetect01Input(string _dt01Guid, bool _blEdit)
        {
            InitializeComponent();
            this.dt01Guid = _dt01Guid;
            this.isEdit = _blEdit;
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1);
            getModel();
            //编辑事件
            gvMx1.CellValueChanged += GvMx1_CellValueChanged;
            //取消不符合条件的编辑
            gvMx1.ShowingEditor += GvMx1_ShowingEditor;
            //禁用样本数之外的单元格且改变颜色
            gvMx1.CustomDrawCell += GvMx1_CustomDrawCell;
            getModel();
        }
        /// <summary>
@@ -36,6 +47,10 @@
                return false;
            if (_FieldName == "样本数")
                return true;
            if (_FieldName.Contains("jg"))
                return false;
            if (string.IsNullOrEmpty(_maxYbs))
                return false;
            string _seqYb = _FieldName.Replace("样本", "");
@@ -44,48 +59,68 @@
            return true;
        }
        /// <summary>
        /// 禁用样本数之外的单元格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GvMx1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            // 获取单元格的值
            string _maxYbs = (gvMx1.GetRowCellValue(e.RowHandle, "样本数").ToString());
            bool _bl = ckCol(e.Column.FieldName, _maxYbs);
            if (_bl)
            {
                e.Appearance.BackColor = Color.Azure;
                e.Appearance.BackColor = Color.LightBlue;
                e.Appearance.ForeColor = Color.Blue;
                e.Column.MinWidth = 50;
            }
            else
            {
                e.Appearance.BackColor = Color.LightGray;
            }
            e.Column.OptionsColumn.ReadOnly = !isEdit;
            if (e.Column.Name.Contains("样本") && e.Column.Name != "样本数")
            {
                object value = gvMx1.GetRowCellValue(e.RowHandle, e.Column + "jg");
                if (value != null && value.ToString() == strBhg)
                {
                    e.Appearance.BackColor = Color.Red;
                    e.Appearance.ForeColor = Color.White;
                };
            }
        }
        private void GvMx1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            // 获取行句柄
            int rowHandle = e.RowHandle;
            // 获取列
            //  GridColumn col = gvMx1.Columns[e.Column.Name];
            // 获取新值
            object newValue = e.Value;
            // 获取旧值
            //   object oldValue = gvMx1.GetRowCellValue(rowHandle, col);
            //   MessageBox.Show(newValue.ToString());
            //  getModel();
            // 在这里执行你的逻辑,例如:
            //  MessageBox.Show($"行 {rowHandle},列 {col.FieldName} 的值已从 {oldValue} 改为 {newValue}");
            string dt05Guid = gvMx1.GetRowCellValue(e.RowHandle, "guid").ToString();
            string dtCol = e.Column.FieldName;
            gvMx1.CloseEditor();
            gvMx1.PostEditor();
            gvMx1.UpdateCurrentRow();
            var _obj = new
            {
                dt05Guid = dt05Guid,
                fSeq = dtCol,
                fVal = newValue,
            };
            if (e.Column.FieldName.Contains("jg"))
                return;
            try
            {
                // 获取行句柄
                int rowHandle = e.RowHandle;
                // 获取列
                //  GridColumn col = gvMx1.Columns[e.Column.Name];
                // 获取新值
                object newValue = e.Value;
                if (newValue == null || string.IsNullOrEmpty(newValue.ToString())) { return; }
                // 获取旧值
                //   object oldValue = gvMx1.GetRowCellValue(rowHandle, col);
                //   MessageBox.Show(newValue.ToString());
                //  getModel();
                // 在这里执行你的逻辑,例如:
                //  MessageBox.Show($"行 {rowHandle},列 {col.FieldName} 的值已从 {oldValue} 改为 {newValue}");
                string dt05Guid = gvMx1.GetRowCellValue(e.RowHandle, "guid").ToString();
                string dtCol = e.Column.FieldName;
                gvMx1.CloseEditor();
                gvMx1.PostEditor();
                gvMx1.UpdateCurrentRow();
                var _obj = new
                {
                    dt05Guid = dt05Guid,
                    fSeq = dtCol,
                    fVal = newValue,
                };
                string strJson = UtilityHelper.HttpPost("", _webServiceName + "EditYangLi", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode > 0)
@@ -94,14 +129,20 @@
                    string _outMsg = _rtn.rtnData.outMsg;
                    string _outSum = _rtn.rtnData.outSum;
                    if (string.IsNullOrEmpty(_outSum)) _outSum = "-1";
                    if (int.Parse(_outSum) < 0) {
                        MessageBox.Show(_outMsg);
                    if (int.Parse(_outSum) < 0)
                    {
                        Gs.DevApp.ToolBox.MsgHelper.ShowError(_outMsg);
                        gvMx1.SetRowCellValue(rowHandle, dtCol, "");
                    }
                    else
                    {
                        //如果不合格,存进去
                        string _outFstand = _rtn.rtnData.outFstand;
                        gvMx1.SetRowCellValue(rowHandle, dtCol + "jg", _outFstand);
                    }
                    //如果是样本数,要重新刷新
                    if (_strYbNo == "样本数")
                        getModel();
                    //lbGuid.Text = _rtn.rtnData.outGuid;
                    //txt_hNo.Text = _rtn.rtnData.outNo;
                    //toolBarMenu1.isSetBtn = true;
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
@@ -142,13 +183,21 @@
                        gcMx1.DataSource = dt;
                        gcMx1.ForceInitialize();
                        gvMx1.BestFitColumns();
                        // 隐藏不必要的列,同时把不合格的存进去
                        foreach (DataColumn col in dt.Columns)
                        {
                            if (col.ColumnName.Contains("jg"))
                            {
                                gvMx1.Columns[col.ColumnName].Visible = false;
                            }
                        }
                        gvMx1.Columns["guid"].Visible = false;
                        gvMx1.Columns["parentGuid"].Visible = false;
                    }
                    else
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    gvMx1.Columns["guid"].Visible = false;
                    gvMx1.Columns["parentGuid"].Visible = false;
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);