private PiModuleEntity GetPageModuleEntity(PiModuleEntity entity)
 {
     entity.Code       = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Code"));
     entity.FullName   = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("FullName"));
     entity.Category   = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vcategory"));
     entity.ModuleType = BusinessLogic.ConvertToNullableInt(WebCommon.StringHelper.GetRequestObject("vmoduletype")) ?? 6;
     entity.ParentId   = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("vparentid"));
     if (string.IsNullOrEmpty(entity.ParentId))
     {
         entity.ParentId = null;
     }
     entity.NavigateUrl    = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("NavigateUrl"));
     entity.MvcNavigateUrl = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("MvcNavigateUrl"));
     entity.IconCss        = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("IconCss"));
     entity.IconUrl        = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("IconUrl"));
     entity.AssemblyName   = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("AssemblyName"));
     entity.FormName       = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("FormName"));
     entity.Enabled        = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Enabled")) == "on" ? 1 : 0;
     entity.IsPublic       = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("IsPublic")) == "on" ? 1 : 0;
     entity.Expand         = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Expand")) == "on" ? 1 : 0;
     entity.AllowEdit      = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("AllowEdit")) == "on" ? 1 : 0;
     entity.AllowDelete    = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("AllowDelete")) == "on" ? 1 : 0;
     entity.IsMenu         = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("IsMenu")) == "on" ? 1 : 0;
     entity.Description    = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("Description"));
     if (string.IsNullOrEmpty(entity.NavigateUrl))
     {
         entity.NavigateUrl = @"#";
     }
     return(entity);
 }
        /// <summary>
        /// 增加模块(菜单)
        /// </summary>
        /// <param name="ctx">http请求信息</param>
        private void AddModule(HttpContext ctx)
        {
            var entity = new PiModuleEntity {
                DeleteMark = 0
            };
            var vUser = Utils.UserInfo;

            entity = GetPageModuleEntity(entity);
            if (vUser != null)
            {
                entity.CreateBy     = vUser.RealName;
                entity.CreateUserId = vUser.Id;
            }
            var statusCode    = string.Empty;
            var statusMessage = string.Empty;

            try
            {
                string keyId = RDIFrameworkService.Instance.ModuleService.Add(vUser, entity, out statusCode, out statusMessage);

                ctx.Response.Write(statusCode == StatusCode.OKAdd.ToString()
                    ? new JsonMessage {
                    Success = true, Data = keyId, Message = statusMessage
                }.ToString()
                    : new JsonMessage {
                    Success = false, Data = "0", Message = statusMessage
                }.ToString());
            }
            catch (Exception ex)
            {
                ctx.Response.Write(new JsonMessage {
                    Success = false, Data = "0", Message = statusMessage + ex.Message
                }.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 显示内容
        /// </summary>
        public override void ShowEntity()
        {
            currentModuleEntity         = BaseEntity.Create <PiModuleEntity>(this.DTModule);
            this.ParentId               = BusinessLogic.ConvertToString(currentModuleEntity.ParentId);
            this.txtCode.Text           = currentModuleEntity.Code;
            this.txtFullName.Text       = currentModuleEntity.FullName;
            this.txtNavigateUrl.Text    = currentModuleEntity.NavigateUrl;
            this.txtMvcNavigateUrl.Text = currentModuleEntity.MvcNavigateUrl;
            this.txtFormName.Text       = currentModuleEntity.FormName;
            this.txtAssemblyName.Text   = currentModuleEntity.AssemblyName;
            this.txtIconUrl.Text        = currentModuleEntity.IconUrl;
            this.txtIconCss.Text        = currentModuleEntity.IconCss;
            this.txtTarget.Text         = currentModuleEntity.Target;
            switch (currentModuleEntity.ModuleType)
            {
            case 1:
                rbModuleType1.Checked = true;
                break;

            case 2:
                rbModuleType2.Checked = true;
                break;

            case 3:
                rbModuleType3.Checked = true;
                break;
            }

            this.chkEnabled.Checked     = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.Enabled);
            this.chkIsPublic.Checked    = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.IsPublic);
            this.chkExpand.Checked      = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.Expand);
            this.chkAllowEdit.Checked   = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.AllowEdit);
            this.chkAllowDelete.Checked = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.AllowDelete);
            this.chkIsMenu.Checked      = BusinessLogic.ConvertIntToBoolean(currentModuleEntity.IsMenu);
            this.txtDescription.Text    = currentModuleEntity.Description;
            if (!string.IsNullOrEmpty(currentModuleEntity.ImageIndex) && currentModuleEntity.ImageIndex.Trim().Length > 0)
            {
                var buffer = RDIFrameworkService.Instance.FileService.Download(this.UserInfo, currentModuleEntity.ImageIndex);
                if (buffer != null && buffer.Length > 0)
                {
                    pictureModulePic.Image = BusinessLogic.byteArrayToImage(buffer);
                }
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 保存新增的数据
        /// </summary>
        /// <param name="close">增加成功是否关闭窗体</param>
        private void SaveAddData(bool close)
        {
            if (!BasePageLogic.ControlValueIsEmpty(gbMain))
            {
                return;
            }
            // 设置鼠标繁忙状态,并保留原先的状态
            var holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            var moduleEntity = new PiModuleEntity
            {
                ParentId       = BusinessLogic.ConvertToString(txtParentId.SelectedValue),
                FullName       = txtFullName.Text.Trim(),
                Code           = txtCode.Text.Trim(),
                Target         = txtTarget.Text.Trim(),
                NavigateUrl    = txtNavigateUrl.Text.Trim(),
                MvcNavigateUrl = txtMvcNavigateUrl.Text.Trim(),
                ImageIndex     = SelectedFileId,
                IconUrl        = txtIconUrl.Text.Trim(),
                IconCss        = txtIconCss.Text.Trim(),
                FormName       = txtFormName.Text.Trim(),
                AssemblyName   = txtAssemblyName.Text.Trim(),
                ModuleType     = 3
            };

            if (rbModuleType1.Checked)
            {
                moduleEntity.ModuleType = 1;
            }

            if (rbModuleType2.Checked)
            {
                moduleEntity.ModuleType = 2;
            }

            if (rbModuleType3.Checked)
            {
                moduleEntity.ModuleType = 3;
            }

            if (string.IsNullOrEmpty(moduleEntity.NavigateUrl))
            {
                moduleEntity.NavigateUrl = @"#";
            }
            if (moduleEntity.ModuleType != null && moduleEntity.ModuleType == 2)
            {
                moduleEntity.IconCss = "icon-note";
            }

            moduleEntity.PermissionItemCode = "Resource.AccessPermission";
            moduleEntity.Enabled            = chkEnabled.Checked ? 1 : 0;
            moduleEntity.IsPublic           = chkIsPublic.Checked ? 1 : 0;
            moduleEntity.Expand             = chkExpand.Checked ? 1 : 0;
            moduleEntity.Description        = txtDescription.Text.Trim();
            moduleEntity.AllowDelete        = chkAllowDelete.Checked ? 1 : 0;
            moduleEntity.AllowEdit          = chkAllowEdit.Checked ? 1 : 0;
            moduleEntity.IsMenu             = chkIsMenu.Checked ? 1 : 0;
            moduleEntity.DeleteMark         = 0;

            string statusCode    = string.Empty;
            string statusMessage = string.Empty;

            this.EntityId = moduleService.Add(UserInfo, moduleEntity, out statusCode, out statusMessage);
            this.FullName = moduleEntity.FullName;
            this.ParentId = BusinessLogic.ConvertToString(moduleEntity.ParentId);
            if (statusCode == StatusCode.OKAdd.ToString())
            {
                this.Changed = true;

                if (SystemInfo.ShowInformation)
                {
                    // 添加成功,进行提示
                    MessageBoxHelper.ShowSuccessMsg(statusMessage);
                }
                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    BasePageLogic.EmptyControlValue(gbMain);
                    this.chkEnabled.Checked     = true;
                    this.chkAllowEdit.Checked   = true;
                    this.chkAllowDelete.Checked = true;
                    txtFullName.Focus();
                }
            }
            else
            {
                MessageBoxHelper.ShowWarningMsg(statusMessage);
                // 是否编号重复了,提高友善性
                if (statusCode == StatusCode.ErrorCodeExist.ToString())
                {
                    this.txtCode.SelectAll();
                    this.txtCode.Focus();
                }
            }
            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;

            if (this.Changed && close)
            {
                this.Close();
            }
        }