Esempio n. 1
0
        /// <summary>
        /// 检查批量输入的有效性
        /// </summary>
        /// <returns>有效</returns>
        private bool CheckInputBatchSave()
        {
            var selectedCount = 0;
            var returnValue   = false;
            var moduleEntity  = new PiModuleEntity();

            foreach (DataRow dataRow in this.DTModuleList.Rows)
            {
                // 这里判断数据的各种状态
                if (dataRow.RowState == DataRowState.Modified)
                {
                    // 是否允许编辑
                    moduleEntity.GetFrom(dataRow);
                    if (moduleEntity.AllowEdit == 0)
                    {
                        if ((dataRow[PiModuleTable.FieldFullName, DataRowVersion.Original] != dataRow[PiModuleTable.FieldFullName, DataRowVersion.Current]) || (dataRow[PiModuleTable.FieldDescription, DataRowVersion.Original] != dataRow[PiModuleTable.FieldDescription, DataRowVersion.Current]))
                        {
                            returnValue = false;
                            MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.Format(RDIFrameworkMessage.MSG0020, RDIFrameworkMessage.MSG9978));
                            // 这里需要直接返回了,不再进行输入交验了。
                            return(returnValue);
                        }
                    }
                    selectedCount++;
                }
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    selectedCount++;
                }
            }
            // 有记录被选中了
            returnValue = selectedCount > 0;
            if (!returnValue)
            {
                MessageBoxHelper.ShowInformationMsg(RDIFrameworkMessage.MSG0004);
            }
            return(returnValue);
        }
Esempio n. 2
0
        /// <summary>
        /// 检查删除选择项的有效性
        /// </summary>
        /// <returns>有效</returns>
        private bool CheckInputBatchDelete()
        {
            var returnValue  = false;
            var moduleEntity = new PiModuleEntity();

            foreach (DataRow dataRow in from DataGridViewRow dgvRow
                     in dgvInfo.Rows let dataRow = (dgvRow.DataBoundItem as DataRowView).Row
                                                   where dataRow.RowState != DataRowState.Deleted
                                                   where (System.Boolean)(dgvRow.Cells["colSelected"].Value ?? false) select dataRow)
            {
                // 是否允许删除
                moduleEntity.GetFrom(dataRow);
                if (moduleEntity.AllowDelete == 0)
                {
                    returnValue = false;
                    MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.Format(RDIFrameworkMessage.MSG0018, moduleEntity.FullName));
                    return(returnValue);
                }
                else
                {
                    returnValue = true;
                    // 是否有子节点
                    string id = dataRow[PiModuleTable.FieldId].ToString();
                    BasePageLogic.FindTreeNode(this.tvModule, id);
                    if (BasePageLogic.TargetNode != null)
                    {
                        if (!BasePageLogic.NodeAllowDelete(BasePageLogic.TargetNode))
                        {
                            MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.Format(RDIFrameworkMessage.MSG0035, BasePageLogic.TargetNode.Text));
                            returnValue = false;
                        }
                    }
                    return(returnValue);
                }
            }

            //优化前代码
            //foreach (DataGridViewRow dgvRow in dgvInfo.Rows)
            //{
            //    DataRow dataRow = (dgvRow.DataBoundItem as DataRowView).Row;
            //    if (dataRow.RowState == DataRowState.Deleted)
            //    {
            //        continue;
            //    }
            //    if ((System.Boolean)(dgvRow.Cells["colSelected"].Value ?? false))
            //    {
            //        // 是否允许删除
            //        moduleEntity.GetFrom(dataRow);
            //        if (moduleEntity.AllowDelete == 0)
            //        {
            //            returnValue = false;
            //            MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.Format(RDIFrameworkMessage.MSG0018, moduleEntity.FullName));
            //            return returnValue;
            //        }
            //        else
            //        {
            //            returnValue = true;
            //            // 是否有子节点
            //            string id = dataRow[PiModuleTable.FieldId].ToString();
            //            BasePageLogic.FindTreeNode(this.tvModule, id);
            //            if (BasePageLogic.TargetNode != null)
            //            {
            //                if (!BasePageLogic.NodeAllowDelete(BasePageLogic.TargetNode))
            //                {
            //                    MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.Format(RDIFrameworkMessage.MSG0035, BasePageLogic.TargetNode.Text));
            //                    returnValue = false;
            //                }
            //            }
            //            return returnValue;
            //        }
            //    }
            //}
            if (!returnValue)
            {
                MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.MSGC023);
            }
            return(returnValue);
        }