Exemplo n.º 1
0
 /// <summary>
 /// Add 添加的主键
 /// </summary>
 /// <param name="paramobject">对象</param>
 /// <returns>主键</returns>
 public string Add(string fullName)
 {
     string statusCode = string.Empty;
     BaseModuleEntity moduleEntity = new BaseModuleEntity();
     moduleEntity.FullName = fullName;
     return this.Add(moduleEntity, out statusCode);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>返回</returns>
        public string Add(BaseModuleEntity moduleEntity, out string statusCode)
        {
            string returnValue = string.Empty;
            // 检查名称是否重复
            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldCode, moduleEntity.Code));
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldFullName, moduleEntity.FullName));
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldDeletionStateCode, 0));

            if (this.Exists(parameters))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(moduleEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return returnValue;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 转换数据
 /// </summary>
 private BaseModuleEntity GetEntity()
 {
     BaseModuleEntity entity = new BaseModuleEntity();
     if (string.IsNullOrEmpty(this.ucParent.SelectedId))
     {
         entity.ParentId = null;
     }
     else
     {
         entity.ParentId = int.Parse(this.ucParent.SelectedId);
     }
     entity.Code = this.txtCode.Text;
     entity.FullName = this.txtFullName.Text;
     entity.NavigateUrl = this.txtNavigateUrl.Text;
     entity.Target = this.txtTarget.Text;
     entity.FormName = this.txtFormName.Text;
     entity.AssemblyName = this.txtAssemblyName.Text;
     entity.Enabled = this.chkEnabled.Checked ? 1 : 0;
     entity.Expand = this.chkExpand.Checked ? 1 : 0;
     entity.IsPublic = this.chkIsPublic.Checked ? 1 : 0;
     entity.Description = this.txtDescription.Text;
     entity.DeletionStateCode = 0;
     entity.AllowDelete = 1;
     entity.AllowEdit = 1;
     return entity;
 }
Exemplo n.º 4
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;
 }
        /// <summary>
        /// 加载组织机构树的主键
        /// </summary>
        /// <param name="TreeNode">当前节点</param>
        private void LoadTreeModule(TreeNode treeNode)
        {
            BaseModuleEntity moduleEntity = null;

            DataTable permissionItemDT = null;

            string id = string.Empty;
            if ((treeNode.Tag != null))
            {
                moduleEntity = (BaseModuleEntity)treeNode.Tag;
                id = moduleEntity.Id.ToString();
            }

            foreach (DataRow dataRow in this.DTModule.Rows)
            {
                // 判断不为空的当前节点的子节点
                if ((!id.Equals(dataRow[BaseModuleEntity.FieldParentId].ToString())))
                {
                    continue;
                }
                // 当前节点的子节点, 加载根节点
                if ((dataRow.IsNull(BaseModuleEntity.FieldParentId)
                    || (dataRow[BaseModuleEntity.FieldParentId].ToString().Length == 0)
                    || (dataRow[BaseModuleEntity.FieldParentId].ToString().Equals("0"))
                    || (dataRow[BaseModuleEntity.FieldParentId].ToString().Equals(BaseSystemInfo.RootMenuCode))
                    || (id.Equals(dataRow[BaseModuleEntity.FieldParentId].ToString()))))
                {
                    moduleEntity = new BaseModuleEntity(dataRow);
                    TreeNode newTreeNode = new TreeNode();

                    #if (DEBUG)
                        // newTreeNode.Text = moduleEntity.FullName + " [" + moduleEntity.Code +"]";
                        newTreeNode.Text = moduleEntity.FullName;
                    #else
                        newTreeNode.Text = moduleEntity.FullName;
                    #endif

                    newTreeNode.Tag = moduleEntity;
                    if (!string.IsNullOrEmpty(moduleEntity.PermissionScopeTables))
                    {
                        newTreeNode.ImageIndex = 3;
                        newTreeNode.SelectedImageIndex = 3;
                    }
                    // 是否已经有这个模块访问权限
                    newTreeNode.Checked = Array.IndexOf(this.ModuleIds, moduleEntity.Id.ToString()) >= 0;

                    if ((treeNode.Tag == null) || ((treeNode.Tag as DataRow)[BaseModuleEntity.FieldId].ToString().Length == 0))
                    {
                        // 树的根节点加载
                        this.tvModulePermissionItem.Nodes.Add(newTreeNode);
                    }
                    else
                    {
                        // 节点的子节点加载
                        treeNode.Nodes.Add(newTreeNode);
                    }

                    permissionItemDT = GetPermissionItemDT(moduleEntity.Id.ToString());
                    foreach (DataRow dataRowPermissionItem in permissionItemDT.Rows)
                    {
                        TreeNode treeNodePermissionItem = new TreeNode();

                        #if (DEBUG)
                            treeNodePermissionItem.Text = dataRowPermissionItem[BasePermissionItemEntity.FieldFullName].ToString() + " [" + dataRowPermissionItem[BasePermissionItemEntity.FieldCode].ToString() +"]";
                        #else
                            treeNodePermissionItem.Text = dataRowPermissionItem[BasePermissionItemEntity.FieldFullName].ToString();
                        #endif

                        treeNodePermissionItem.Tag = dataRowPermissionItem[BasePermissionItemEntity.FieldId].ToString();
                        treeNodePermissionItem.ImageIndex = 14;
                        treeNodePermissionItem.SelectedImageIndex = 14;
                        // 是否已经有这个操作权限
                        treeNodePermissionItem.Checked = Array.IndexOf(this.PermissionItemIds, treeNodePermissionItem.Tag.ToString()) >= 0;
                        newTreeNode.Nodes.Add(treeNodePermissionItem);
                    }

                    if (treeNode.Level < 2)
                    {
                        treeNode.Expand();
                    }

                    // 递归调用本函数
                    this.LoadTreeModule(newTreeNode);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(BaseModuleEntity baseModuleEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return this.AddEntity(baseModuleEntity);
 }
Exemplo n.º 7
0
        // 这个是声明扩展方法
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseModuleEntity baseModuleEntity);
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
 /// <summary>
 /// 更新实体
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 public int UpdateEntity(BaseModuleEntity baseModuleEntity)
 {
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
     sqlBuilder.BeginUpdate(this.CurrentTableName);
     this.SetEntity(sqlBuilder, baseModuleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseModuleEntity.FieldModifiedOn);
     sqlBuilder.SetWhere(BaseModuleEntity.FieldId, baseModuleEntity.Id);
     return sqlBuilder.EndUpdate();
 }
Exemplo n.º 10
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseModuleEntity baseModuleEntity)
 {
     SetEntityExpand(sqlBuilder, baseModuleEntity);
     sqlBuilder.SetValue(BaseModuleEntity.FieldParentId, baseModuleEntity.ParentId);
     sqlBuilder.SetValue(BaseModuleEntity.FieldCode, baseModuleEntity.Code);
     sqlBuilder.SetValue(BaseModuleEntity.FieldFullName, baseModuleEntity.FullName);
     sqlBuilder.SetValue(BaseModuleEntity.FieldCategory, baseModuleEntity.Category);
     sqlBuilder.SetValue(BaseModuleEntity.FieldImageIndex, baseModuleEntity.ImageIndex);
     sqlBuilder.SetValue(BaseModuleEntity.FieldSelectedImageIndex, baseModuleEntity.SelectedImageIndex);
     sqlBuilder.SetValue(BaseModuleEntity.FieldNavigateUrl, baseModuleEntity.NavigateUrl);
     sqlBuilder.SetValue(BaseModuleEntity.FieldTarget, baseModuleEntity.Target);
     sqlBuilder.SetValue(BaseModuleEntity.FieldFormName, baseModuleEntity.FormName);
     sqlBuilder.SetValue(BaseModuleEntity.FieldAssemblyName, baseModuleEntity.AssemblyName);
     sqlBuilder.SetValue(BaseModuleEntity.FieldPermissionItemCode, baseModuleEntity.PermissionItemCode);
     sqlBuilder.SetValue(BaseModuleEntity.FieldPermissionScopeTables, baseModuleEntity.PermissionScopeTables);
     sqlBuilder.SetValue(BaseModuleEntity.FieldSortCode, baseModuleEntity.SortCode);
     sqlBuilder.SetValue(BaseModuleEntity.FieldEnabled, baseModuleEntity.Enabled);
     sqlBuilder.SetValue(BaseModuleEntity.FieldDeletionStateCode, baseModuleEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseModuleEntity.FieldIsPublic, baseModuleEntity.IsPublic);
     sqlBuilder.SetValue(BaseModuleEntity.FieldExpand, baseModuleEntity.Expand);
     sqlBuilder.SetValue(BaseModuleEntity.FieldAllowEdit, baseModuleEntity.AllowEdit);
     sqlBuilder.SetValue(BaseModuleEntity.FieldAllowDelete, baseModuleEntity.AllowDelete);
     sqlBuilder.SetValue(BaseModuleEntity.FieldDescription, baseModuleEntity.Description);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 public int Update(BaseModuleEntity baseModuleEntity)
 {
     return this.UpdateEntity(baseModuleEntity);
 }
Exemplo n.º 12
0
 public BaseModuleEntity GetEntity(int id)
 {
     BaseModuleEntity baseModuleEntity = new BaseModuleEntity(this.GetDataTable(new KeyValuePair<string, object>(BaseModuleEntity.FieldId, id)));
     return baseModuleEntity;
 }
Exemplo n.º 13
0
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 public string AddEntity(BaseModuleEntity baseModuleEntity)
 {
     string sequence = string.Empty;
     if (baseModuleEntity.SortCode == null || baseModuleEntity.SortCode == 0)
     {
         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
         sequence = sequenceManager.GetSequence(this.CurrentTableName);
         baseModuleEntity.SortCode = int.Parse(sequence);
     }
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);
     sqlBuilder.BeginInsert(this.CurrentTableName, BaseModuleEntity.FieldId);
     if (!this.Identity)
     {
         sqlBuilder.SetValue(BaseModuleEntity.FieldId, baseModuleEntity.Id);
     }
     else
     {
         if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
         {
             if (DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 sqlBuilder.SetFormula(BaseModuleEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
             }
             if (DbHelper.CurrentDbType == DbTypes.DB2)
             {
                 sqlBuilder.SetFormula(BaseModuleEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
             }
         }
         else
         {
             if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
             {
                 if (baseModuleEntity.Id == null)
                 {
                     if (string.IsNullOrEmpty(sequence))
                     {
                         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                         sequence = sequenceManager.GetSequence(this.CurrentTableName);
                     }
                     baseModuleEntity.Id = int.Parse(sequence);
                 }
                 sqlBuilder.SetValue(BaseModuleEntity.FieldId, baseModuleEntity.Id);
             }
         }
     }
     this.SetEntity(sqlBuilder, baseModuleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseModuleEntity.FieldCreateUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseModuleEntity.FieldCreateBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseModuleEntity.FieldCreateOn);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseModuleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseModuleEntity.FieldModifiedOn);
     if (this.Identity && (DbHelper.CurrentDbType == DbTypes.SqlServer || DbHelper.CurrentDbType == DbTypes.Access))
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
Exemplo n.º 14
0
 public FrmModuleAdd(BaseModuleEntity entity)
     : this()
 {
     this.moduleEntity = entity;
 }
Exemplo n.º 15
0
        /// <summary>
        /// 添加TreeView子节点
        /// </summary>
        public void AddSonNode(TreeNode parentTreeNode)
        {
            //string parentId = (parentTreeNode.Tag as DataRow)[BaseModuleEntity.FieldId].ToString();
            //string expand = (parentTreeNode.Tag as DataRow)[BaseModuleEntity.FieldExpand].ToString();

            // 改进为:保存实体类
            int? parentId = (parentTreeNode.Tag as BaseModuleEntity).Id;
            int? expand = (parentTreeNode.Tag as BaseModuleEntity).Expand;

            List<BaseModuleEntity> baseModuleEntitys = new List<BaseModuleEntity>();
            foreach (DataRow dataRow in ClientCache.Instance.DTUserMoule.Rows)
            {
                BaseModuleEntity baseModuleEntity = new BaseModuleEntity(dataRow);
                baseModuleEntitys.Add(baseModuleEntity);
            }

            //foreach (DataRow dr in ClientCache.Instance.DTUserMoule.Rows)
            foreach (BaseModuleEntity baseModuleEntity in baseModuleEntitys)
            {
                //if (dr[BaseModuleEntity.FieldParentId].ToString() != parentId)
                if (baseModuleEntity.ParentId != parentId)
                {
                    continue;
                }
                TreeNode treeNode = new TreeNode();
                //treeNode.Text = dr[BaseModuleEntity.FieldFullName].ToString();
                treeNode.Text = baseModuleEntity.FullName;

                //treeNode.Tag = dr;
                treeNode.Tag = baseModuleEntity;

                treeNode.ImageIndex = 2;
                treeNode.SelectedImageIndex = 3;
                AddSonNode(treeNode);
                parentTreeNode.Nodes.Add(treeNode);
                if (expand.Equals(1))
                {
                    parentTreeNode.Expand();
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 加载组织机构树的主键
        /// </summary>
        /// <param name="treeNode">当前节点</param>
        private void LoadTreeModule(TreeNode treeNode)
        {
            foreach (DataRow dataRow in ClientCache.Instance.DTUserMoule.Rows)
            {
                // 判断不为空的当前节点的子节点
                if ((treeNode.Tag != null) && (!((BaseModuleEntity)treeNode.Tag).Id.ToString().Equals(dataRow[BaseModuleEntity.FieldParentId].ToString())))
                {
                    continue;
                }
                // 当前节点的子节点, 加载根节点
                if ((dataRow.IsNull(BaseModuleEntity.FieldParentId) || (dataRow[BaseModuleEntity.FieldParentId].ToString().Length == 0) || (dataRow[BaseModuleEntity.FieldParentId].ToString().Equals("0")) || (dataRow[BaseModuleEntity.FieldCode].ToString().Equals(BaseSystemInfo.RootMenuCode)) || ((treeNode.Tag != null) && ((BaseModuleEntity)treeNode.Tag).Id.ToString().Equals(dataRow[BaseModuleEntity.FieldParentId].ToString()))))
                {
                    BaseModuleEntity moduleEntity = new BaseModuleEntity(dataRow);
                    TreeNode newTreeNode = new TreeNode();
                    newTreeNode.Text = moduleEntity.FullName;
                    newTreeNode.Tag = moduleEntity;
                    newTreeNode.Checked = (moduleEntity.Enabled == 1);

                    /*
                    if (newTreeNode.Level < 2 || dataRow[BaseModuleEntity.FieldExpand].ToString().Equals("1"))
                    {
                        newTreeNode.Expand();
                    }
                    else
                    {
                        newTreeNode.Collapse(true);
                    }
                    */

                    if ((treeNode.Tag == null) || ((treeNode.Tag as DataRow)[BaseModuleEntity.FieldId].ToString().Length == 0))
                    {
                        // 树的根节点加载,只加载指定的系统
                        if (dataRow[BaseModuleEntity.FieldCode].ToString().Equals(BaseSystemInfo.RootMenuCode))
                        {
                            this.tvModule.Nodes.Add(newTreeNode);
                        }
                    }
                    else
                    {
                        // 节点的子节点加载
                        treeNode.Nodes.Add(newTreeNode);
                        if (treeNode.Level < 1)
                        {
                            treeNode.Expand();
                        }
                    }
                    // 递归调用本函数
                    this.LoadTreeModule(newTreeNode);
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 加载左侧功能栏项
        /// </summary>
        public void LoadSildeBar()
        {
            // 清空左侧功能栏信息
            tvMain.Nodes.Clear();
            navigationBar.Items.Clear();

            // 这里是需要加载的跟节点主键
            int? rootMenuId = null;

            List<BaseModuleEntity> moduleEntitys = new List<BaseModuleEntity>();
            foreach (DataRow dataRow in ClientCache.Instance.DTUserMoule.Rows)
            {
                BaseModuleEntity moduleEntity = new BaseModuleEntity(dataRow);
                moduleEntitys.Add(moduleEntity);
                if (moduleEntity.Code.Equals(BaseSystemInfo.RootMenuCode))
                {
                    rootMenuId = moduleEntity.Id;
                }
            }

            int itemIndex;

            //foreach (DataRow dr in ClientCache.Instance.DTUserMoule.Rows)
            foreach (BaseModuleEntity moduleEntity in moduleEntitys)
            {
                //~这部分可以单独调优,只是为了把左侧功能栏项加载好,要新增项只需修改判断条件。
                //if (string.IsNullOrEmpty(dr[BaseModuleEntity.FieldParentId].ToString()))
                if (moduleEntity.ParentId == rootMenuId)
                {
                    // baseModuleEntity.ParentId == null
                    // itemIndex = navigationBar.Items.Add(new ButtonItem());
                    // ButtonItem bi = this.navigationBar.Items[itemIndex] as ButtonItem;
                    // bi.Name = dr[BaseModuleEntity.FieldCode].ToString();
                    // .OptionGroup = "navBar";
                    // bi.Text = dr[BaseModuleEntity.FieldFullName].ToString();
                    // .Tag = dr;
                    // bi.Image = Image.FromFile(BaseSystemInfo.StartupPath + "\\Resource\\BaseBar.png");
                    // bi.Click += new System.EventHandler(this.toolStripButton_Click);

                    // 改进为:保存实体类
                    itemIndex = navigationBar.Items.Add(new ButtonItem());
                    ButtonItem bi = this.navigationBar.Items[itemIndex] as ButtonItem;
                    bi.Name = moduleEntity.Code;
                    bi.OptionGroup = "navBar";
                    bi.Text = moduleEntity.FullName;
                    bi.Tag = moduleEntity;
                    //bi.Image = Image.FromFile(BaseSystemInfo.StartupPath + "\\Resource\\BaseBar.png");
                    bi.Click += new System.EventHandler(this.toolStripButton_Click);
                }
            }
            System.Drawing.Rectangle rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            navigationBar.Size = rect.Size;
            if (this.navigationBar.Items.Count > 0)
            {
                (this.navigationBar.Items[0] as ButtonItem).Checked = true;
                toolStripButton_Click((this.navigationBar.Items[0] as ButtonItem), System.EventArgs.Empty);
            }
        }
Exemplo n.º 18
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;
 }
Exemplo n.º 19
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="moduleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>返回</returns>
        public int Update(BaseModuleEntity moduleEntity, out string statusCode)
        {
            int returnValue = 0;
            // 检查是否已被其他人修改
            //if (DbLogic.IsModifed(DbHelper, BaseModuleEntity.TableName, moduleEntity.Id, moduleEntity.ModifiedUserId, moduleEntity.ModifiedOn))
            //{
            //    // 数据已经被修改
            //    statusCode = StatusCode.ErrorChanged.ToString();
            //}
            //else
            //{

            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldCode, moduleEntity.Code));
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldFullName, moduleEntity.FullName));
            parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldDeletionStateCode, 0));

            // 检查编号是否重复
            if ((moduleEntity.Code.Length > 0) && (this.Exists(parameters, moduleEntity.Id)))
            {
                // 编号已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.UpdateEntity(moduleEntity);
                if (returnValue == 1)
                {
                    statusCode = StatusCode.OKUpdate.ToString();
                }
                else
                {
                    statusCode = StatusCode.ErrorDeleted.ToString();
                }
            }
            //}
            return returnValue;
        }
Exemplo n.º 20
0
 /// <summary>
 /// 加载窗体
 /// </summary>
 public override void FormOnLoad()
 {
     // 权限信息
     this.moduleEntity = DotNetService.Instance.ModuleService.GetEntity(UserInfo, this.EntityId);
     // 设置用户控件状态
     this.ucParent.CheckMove = true;
     this.ucParent.OpenId = this.EntityId;
     // 显示内容
     this.ShowEntity();
     // 设置焦点
     this.ActiveControl = this.txtFullName;
     this.txtFullName.Focus();
 }
Exemplo n.º 21
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseModuleEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseModuleEntity baseModuleEntity)
 {
     return this.AddEntity(baseModuleEntity);
 }