Esempio n. 1
0
        /// <summary>
        /// 检查删除选择项的有效性
        /// </summary>
        /// <returns>有效</returns>
        private bool CheckInputBatchDelete()
        {
            bool returnValue = false;
            BaseModuleEntity moduleEntity = new BaseModuleEntity();

            foreach (DataGridViewRow dgvRow in grdModule.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;
                        MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, moduleEntity.FullName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return returnValue;
                    }
                    else
                    {
                        returnValue = true;
                        // 是否有子节点
                        string id = dataRow[BaseModuleEntity.FieldId].ToString();
                        BaseInterfaceLogic.FindTreeNode(this.tvModule, BaseModuleEntity.FieldId, id);
                        if (BaseInterfaceLogic.TargetNode != null)
                        {
                            if (!BaseInterfaceLogic.NodeAllowDelete(BaseInterfaceLogic.TargetNode))
                            {
                                MessageBox.Show(AppMessage.Format(AppMessage.MSG0035, BaseInterfaceLogic.TargetNode.Text), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                returnValue = false;
                            }
                        }
                        return returnValue;
                    }
                }
            }

            //foreach (DataRow dataRow in this.DTModuleList.Rows)
            //{
            //    if (dataRow.RowState == DataRowState.Deleted)
            //    {
            //        continue;
            //    }
            //    if (dataRow["colSelected"].ToString() == true.ToString())
            //    {
            //        // 是否允许删除
            //        moduleEntity.GetFrom(dataRow);
            //        if (moduleEntity.AllowDelete == 0)
            //        {
            //            returnValue = false;
            //            MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, moduleEntity.FullName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //            return returnValue;
            //        }
            //        else
            //        {
            //            returnValue = true;
            //            // 是否有子节点
            //            string id = dataRow[BaseModuleEntity.FieldId].ToString();
            //            BaseInterfaceLogic.FindTreeNode(this.tvModule, id);
            //            if (BaseInterfaceLogic.TargetNode != null)
            //            {
            //                if (!BaseInterfaceLogic.NodeAllowDelete(BaseInterfaceLogic.TargetNode))
            //                {
            //                    MessageBox.Show(AppMessage.Format(AppMessage.MSG0035, BaseInterfaceLogic.TargetNode.Text), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //                    returnValue = false;
            //                }
            //            }
            //            return returnValue;
            //        }
            //    }
            //}
            if (!returnValue)
            {
                MessageBox.Show(AppMessage.MSGC023, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return returnValue;
        }
Esempio n. 2
0
 /// <summary>
 /// 检查批量输入的有效性
 /// </summary>
 /// <returns>有效</returns>
 private bool CheckInputBatchSave()
 {
     int selectedCount = 0;
     bool returnValue = false;
     BaseModuleEntity moduleEntity = new BaseModuleEntity();
     foreach (DataRow dataRow in this.DTModuleList.Rows)
     {
         // 这里判断数据的各种状态
         if (dataRow.RowState == DataRowState.Modified)
         {
             // 是否允许编辑
             moduleEntity.GetFrom(dataRow);
             if (moduleEntity.AllowEdit == 0)
             {
                 if ((dataRow[BaseModuleEntity.FieldFullName, DataRowVersion.Original] != dataRow[BaseModuleEntity.FieldFullName, DataRowVersion.Current]) || (dataRow[BaseModuleEntity.FieldDescription, DataRowVersion.Original] != dataRow[BaseModuleEntity.FieldDescription, DataRowVersion.Current]))
                 {
                     returnValue = false;
                     MessageBox.Show(AppMessage.Format(AppMessage.MSG0020, AppMessage.MSG9978), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                     // 这里需要直接返回了,不再进行输入交验了。
                     return returnValue;
                 }
             }
             selectedCount++;
         }
         if (dataRow.RowState == DataRowState.Deleted)
         {
             selectedCount++;
         }
     }
     // 有记录被选中了
     returnValue = selectedCount > 0;
     if (!returnValue)
     {
         MessageBox.Show(AppMessage.MSG0004, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return returnValue;
 }
Esempio n. 3
0
 /// <summary>
 /// 批量进行保存
 /// </summary>
 /// <param name="dataTable">数据表</param>
 /// <returns>影响行数</returns>
 public override int BatchSave(DataTable dataTable)
 {
     int returnValue = 0;
     BaseModuleEntity moduleEntity = new BaseModuleEntity();
     foreach (DataRow dataRow in dataTable.Rows)
     {
         // 删除状态
         if (dataRow.RowState == DataRowState.Deleted)
         {
             string id = dataRow[BaseModuleEntity.FieldId, DataRowVersion.Original].ToString();
             if (id.Length > 0)
             {
                 if (dataRow[BaseModuleEntity.FieldAllowDelete, DataRowVersion.Original].ToString().Equals("1"))
                 {
                     returnValue += this.DeleteEntity(id);
                 }
             }
         }
         // 被修改过
         if (dataRow.RowState == DataRowState.Modified)
         {
             string id = dataRow[BaseModuleEntity.FieldId, DataRowVersion.Original].ToString();
             if (id.Length > 0)
             {
                 moduleEntity.GetFrom(dataRow);
                 // 判断是否允许编辑
                 if (moduleEntity.AllowEdit == 1)
                 {
                     returnValue += this.UpdateEntity(moduleEntity);
                 }
             }
         }
         // 添加状态
         if (dataRow.RowState == DataRowState.Added)
         {
             moduleEntity.GetFrom(dataRow);
             returnValue += this.AddEntity(moduleEntity).Length > 0 ? 1 : 0;
         }
         if (dataRow.RowState == DataRowState.Unchanged)
         {
             continue;
         }
         if (dataRow.RowState == DataRowState.Detached)
         {
             continue;
         }
     }
     this.ReturnStatusCode = StatusCode.OK.ToString();
     return returnValue;
 }