Beispiel #1
0
 public override void ShowEntity()
 {
     currentOrganizeEntity = organizeService.GetEntity(base.UserInfo, this.EntityId);
     if (currentOrganizeEntity == null || currentOrganizeEntity.FullName.Trim().Length <= 0)
     {
         return;
     }
     if (!string.IsNullOrEmpty(currentOrganizeEntity.ParentId))
     {
         txtParentId.Text          = organizeService.GetEntity(base.UserInfo, currentOrganizeEntity.ParentId.ToString()).FullName;
         txtParentId.SelectedValue = currentOrganizeEntity.ParentId;
     }
     txtFullName.Text          = currentOrganizeEntity.FullName;
     txtShortName.Text         = currentOrganizeEntity.ShortName;
     txtCode.Text              = currentOrganizeEntity.Code;
     cboCategory.SelectedValue = currentOrganizeEntity.Category;
     txtManager.Text           = currentOrganizeEntity.Manager;
     txtAssistantManager.Text  = currentOrganizeEntity.AssistantManager;
     txtOuterPhone.Text        = currentOrganizeEntity.OuterPhone;
     txtInnerPhone.Text        = currentOrganizeEntity.InnerPhone;
     txtFax.Text                = currentOrganizeEntity.Fax;
     txtPostalcode.Text         = currentOrganizeEntity.Postalcode;
     txtWeb.Text                = currentOrganizeEntity.Web;
     txtAddress.Text            = currentOrganizeEntity.Address;
     chkEnabled.Checked         = BusinessLogic.ConvertIntToBoolean(currentOrganizeEntity.Enabled);
     chkIsInnerOrganize.Checked = BusinessLogic.ConvertIntToBoolean(currentOrganizeEntity.IsInnerOrganize);
     txtDescription.Text        = currentOrganizeEntity.Description;
 }
Beispiel #2
0
        private bool SaveData()
        {
            organizeEntity = null;
            organizeEntity = new PiOrganizeEntity
            {
                ParentId           = BusinessLogic.ConvertToString(txtParentId.SelectedValue),
                Code               = txtCode.Text.Trim(),
                ShortName          = txtShortName.Text.Trim(),
                FullName           = txtFullName.Text.Trim(),
                Category           = cboCategory.SelectedValue.ToString(),
                OuterPhone         = txtOuterPhone.Text.Trim(),
                InnerPhone         = txtInnerPhone.Text.Trim(),
                Fax                = txtFax.Text.Trim(),
                Postalcode         = txtPostalcode.Text.Trim(),
                Address            = txtAddress.Text.Trim(),
                Web                = txtWeb.Text.Trim(),
                ManagerId          = txtManager.AccessibleDescription,
                Manager            = txtManager.Text.Trim(),
                AssistantManagerId = txtAssistantManager.AccessibleDescription,
                AssistantManager   = txtAssistantManager.Text.Trim(),
                IsInnerOrganize    = chkIsInnerOrganize.Checked ? 1 : 0,
                Enabled            = chkEnabled.Checked ? 1 : 0,
                DeleteMark         = 0,
                Description        = txtDescription.Text.Trim()
            };

            if (base.UserInfo != null)
            {
                organizeEntity.CreateBy     = UserInfo.RealName;
                organizeEntity.CreateUserId = UserInfo.Id;
            }

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

            try
            {
                this.EntityId = organizeService.Add(base.UserInfo, organizeEntity, out statusCode, out statusMessage);
                this.FullName = organizeEntity.FullName;
                this.ParentId = txtParentId.SelectedValue.ToString();
                if (statusCode == StatusCode.OKAdd.ToString())
                {
                    if (SystemInfo.ShowSuccessMsg)
                    {
                        MessageBoxHelper.ShowSuccessMsg(RDIFrameworkMessage.MSG0011);
                    }
                    return(true);
                }
                else
                {
                    MessageBoxHelper.ShowWarningMsg(statusMessage);
                    if (statusCode == StatusCode.ErrorNameExist.ToString())
                    {
                        this.txtFullName.SelectAll();
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                base.ProcessException(ex);
                return(false);
            }
        }
        private void SubmitForm(HttpContext context)
        {
            try
            {
                int    IsOk    = 1;
                var    key     = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("key"));
                var    json    = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("json"));
                string Message = key == "" ? "新增成功。" : "修改成功。";
                RDIFramework.Utilities.UserInfo curUser = Utils.UserInfo;
                PiOrganizeEntity entity = JsonHelper.JSONToObject <PiOrganizeEntity>(json);
                if (string.IsNullOrEmpty(key))
                {
                    //增加
                    if (!string.IsNullOrEmpty(entity.ManagerId))
                    {
                        entity.Manager = RDIFrameworkService.Instance.UserService.GetEntity(curUser, entity.ManagerId).RealName;
                    }
                    if (!string.IsNullOrEmpty(entity.AssistantManagerId))
                    {
                        entity.AssistantManager = RDIFrameworkService.Instance.UserService.GetEntity(curUser, entity.AssistantManagerId).RealName;
                    }
                    entity.CreateBy     = curUser.RealName;
                    entity.CreateUserId = curUser.Id;
                    string statusCode, statusMessage, returnKey;
                    returnKey = RDIFrameworkService.Instance.OrganizeService.Add(curUser, entity, out statusCode, out statusMessage);
                    context.Response.Write(statusCode == RDIFramework.Utilities.StatusCode.OKAdd.ToString()
                        ? new JsonMessage {
                        Success = true, Data = returnKey, Message = statusMessage
                    }.ToString()
                        : new JsonMessage {
                        Success = false, Data = "0", Message = statusMessage
                    }.ToString());
                }
                else
                {
                    var updateEntity = RDIFrameworkService.Instance.OrganizeService.GetEntity(curUser, key);
                    if (updateEntity != null)
                    {
                        updateEntity.ParentId           = entity.ParentId;
                        updateEntity.FullName           = entity.FullName;
                        updateEntity.ShortName          = entity.ShortName;
                        updateEntity.Code               = entity.Code;
                        updateEntity.Category           = entity.Category;
                        updateEntity.ManagerId          = entity.ManagerId;
                        updateEntity.AssistantManagerId = entity.AssistantManagerId;
                        if (!string.IsNullOrEmpty(updateEntity.ManagerId))
                        {
                            updateEntity.Manager = RDIFrameworkService.Instance.UserService.GetEntity(curUser, updateEntity.ManagerId).RealName;
                        }
                        if (!string.IsNullOrEmpty(updateEntity.AssistantManagerId))
                        {
                            updateEntity.AssistantManager = RDIFrameworkService.Instance.UserService.GetEntity(curUser, updateEntity.AssistantManagerId).RealName;
                        }
                        updateEntity.OuterPhone      = entity.OuterPhone;
                        updateEntity.InnerPhone      = entity.InnerPhone;
                        updateEntity.Fax             = entity.Fax;
                        updateEntity.Postalcode      = entity.Postalcode;
                        updateEntity.Web             = entity.Web;
                        updateEntity.Address         = entity.Address;
                        updateEntity.Enabled         = entity.Enabled;
                        updateEntity.IsInnerOrganize = entity.IsInnerOrganize;
                        updateEntity.Description     = entity.Description;
                    }

                    if (curUser != null)
                    {
                        updateEntity.ModifiedBy     = curUser.RealName;
                        updateEntity.ModifiedUserId = curUser.Id;
                    }
                    string statusCode;
                    string statusMessage;
                    var    returnValue = RDIFrameworkService.Instance.OrganizeService.Update(curUser, updateEntity, out statusMessage);
                    context.Response.Write(returnValue > 0
                        ? new JsonMessage {
                        Success = true, Data = IsOk.ToString(), Message = statusMessage
                    }.ToString()
                        : new JsonMessage {
                        Success = false, Data = "0", Message = statusMessage
                    }.ToString());
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(new JsonMessage {
                    Success = false, Data = "0", Message = "操作失败:" + ex.Message
                }.ToString());
            }
        }
Beispiel #4
0
        /// <summary>
        /// 加载树型结构的主键
        /// </summary>
        /// <param name="dataTable">数据表</param>
        /// <param name="fieldId">主键</param>
        /// <param name="fieldParentId">上级字段</param>
        /// <param name="fieldFullName">全称</param>
        /// <param name="treeNode">当前树结点</param>
        private void LoadTreeNodes(DataTable dataTable, string fieldId, string fieldParentId, string fieldFullName, TreeView treeView, TreeNode treeNode, bool loadTree = true)
        {
            var organizeEntity = new PiOrganizeEntity();

            // 查找 ParentId 字段的值是否在 Id字段 里
            // 一般情况是简单的数据过滤,就没必要进行严格的检查了,进行了严格的检查,反而降低运行效率
            DataRow[] dataRows = null;
            if (treeNode.Tag == null)
            {
                if (dataTable.Columns[fieldId].DataType == typeof(int) ||
                    (dataTable.Columns[fieldId].DataType == typeof(Int16)) ||
                    (dataTable.Columns[fieldId].DataType == typeof(Int32)) ||
                    (dataTable.Columns[fieldId].DataType == typeof(Int64)) ||
                    dataTable.Columns[fieldId].DataType == typeof(decimal))
                {
                    dataRows = dataTable.Select(fieldParentId + " IS NULL OR " + fieldParentId + " = 0");
                }
                else
                {
                    dataRows = dataTable.Select(fieldParentId + " IS NULL OR " + fieldParentId + " = ''");
                }
            }
            else
            {
                dataRows = dataTable.Select(fieldParentId + "='" + ((PiOrganizeEntity)treeNode.Tag).Id + "'");
            }

            foreach (var dataRow in dataRows)
            {
                // 节点不为空,并且是当前节点的子节点
                if ((treeNode.Tag != null) && !(((PiOrganizeEntity)treeNode.Tag).Id.ToString().Equals(dataRow[fieldParentId].ToString())))
                {
                    continue;
                }
                // 当前节点的子节点, 加载根节点
                if (dataRow.IsNull(fieldParentId) ||
                    (dataRow[fieldParentId].ToString() == "0") ||
                    (dataRow[fieldParentId].ToString().Length == 0) ||
                    ((treeNode.Tag != null) && (((PiOrganizeEntity)treeNode.Tag).Id.ToString().Equals(dataRow[fieldParentId].ToString()))))
                {
                    var newTreeNode = new TreeNode
                    {
                        Text = dataRow[fieldFullName].ToString(),
                        Tag  = BaseEntity.Create <PiOrganizeEntity>(dataRow)
                    };
                    if ((treeNode.Tag == null))
                    {
                        // 树的根节点加载
                        treeView.Nodes.Add(newTreeNode);
                    }
                    else
                    {
                        // 节点的子节点加载,第一层节点需要展开
                        treeNode.Nodes.Add(newTreeNode);
                    }
                    if (loadTree)
                    {
                        // 递归调用本函数
                        LoadTreeNodes(dataTable, fieldId, fieldParentId, fieldFullName, treeView, newTreeNode, loadTree);
                    }
                }
            }
        }