예제 #1
0
        /// <summary>
        /// 新增小模板
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItemNewItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            try
            {
                string type       = treeList1.FocusedNode.GetValue("NODETYPE").ToString();
                string createUser = string.Empty;
                string isPerson   = string.Empty;
                string parentID   = string.Empty;
                if (type.Equals("Folder"))
                {
                    parentID   = treeList1.FocusedNode.GetValue("ID").ToString();
                    isPerson   = treeList1.FocusedNode.GetValue("ISPERSON").ToString();
                    createUser = null == treeList1.FocusedNode.GetValue("createusers") ? "" : treeList1.FocusedNode.GetValue("createusers").ToString();
                }
                else
                {
                    DataTable focusDt = m_app.SqlHelper.ExecuteDataTable("select * from emrtemplet_item_person where code='" + treeList1.FocusedNode.GetValue("ID").ToString() + "'");
                    if (null != focusDt && focusDt.Rows.Count > 0)
                    {
                        parentID   = null == focusDt.Rows[0]["parentid"] ? "" : focusDt.Rows[0]["parentid"].ToString();
                        createUser = null == treeList1.FocusedNode.ParentNode.GetValue("createusers") ? "" : treeList1.FocusedNode.ParentNode.GetValue("createusers").ToString();
                        isPerson   = null == treeList1.FocusedNode.ParentNode.GetValue("ISPERSON") ? "" : treeList1.FocusedNode.ParentNode.GetValue("ISPERSON").ToString();
                    }
                }
                //分类权限控制
                string msg = GetMsgIfNotCreateUser(parentID, createUser, 0, 2, int.Parse(isPerson));
                if (!string.IsNullOrEmpty(msg))
                {
                    m_app.CustomMessageBox.MessageShow(msg);
                    return;
                }
                //宜昌中心医院要求大分类下可以直接插模板 edit by ywk  2012年11月30日11:45:27
                //if (treeList1.FocusedNode.Level == 0)
                //{
                //    m_app.CustomMessageBox.MessageShow("大分类下不可以新增模板,请选择子分类");
                //    return;
                //}

                //if (type.Equals("Leaf"))
                //{
                //    m_app.CustomMessageBox.MessageShow("请选择分类节点");
                //    return;
                //}

                //新增时,清空上次操作里的值 add ywk
                m_ItemContent.MyItem.Content     = "";
                m_ItemContent.MyItem.ItemName    = "";
                m_ItemContent.MyItem.Code        = Guid.NewGuid().ToString();
                m_ItemContent.MyItem.ParentID    = parentID;
                m_ItemContent.MyItem.CatalogName = type.Equals("Folder") ? treeList1.FocusedNode.GetValue("ITEMNAME").ToString() : treeList1.FocusedNode.ParentNode.GetValue("ITEMNAME").ToString();
                m_ItemContent.MyItem.IsPerson    = isPerson;
                //新增的时候把当前登录人赋给创建人 add by ywk 2012年6月5日 10:28:10
                m_ItemContent.MyItem.CreateUser = m_app.User.Id;

                if (m_ItemContent.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    // 输入的科室小模板的模板内容
                    string content = m_ItemContent.MyItem.Content;
                    if (m_ItemContent.MyItem.Content.Contains("\r\n"))//存在换行,替代插入数据库中 edit by ywk
                    {
                        content = m_ItemContent.MyItem.Content.Replace("\r\n", "'||chr(10)||chr(13)||'");
                    }

                    List <OracleParameter> paraList = new List <OracleParameter>();
                    OracleParameter        param1   = new OracleParameter("code", OracleType.VarChar);
                    OracleParameter        param2   = new OracleParameter("name", OracleType.VarChar);
                    OracleParameter        param3   = new OracleParameter("item_content", OracleType.Clob);
                    OracleParameter        param4   = new OracleParameter("deptshare", OracleType.Int32);
                    OracleParameter        param5   = new OracleParameter("parentid", OracleType.VarChar);
                    OracleParameter        param6   = new OracleParameter("deptid", OracleType.VarChar);
                    OracleParameter        param7   = new OracleParameter("isperson", OracleType.VarChar);
                    OracleParameter        param8   = new OracleParameter("createusers", OracleType.VarChar);
                    param1.Value = m_ItemContent.MyItem.Code;
                    param2.Value = m_ItemContent.MyItem.ItemName;
                    param3.Value = content;
                    param4.Value = 1;
                    param5.Value = m_ItemContent.MyItem.ParentID;
                    param6.Value = m_app.User.CurrentDeptId;
                    param7.Value = m_ItemContent.MyItem.IsPerson;
                    param8.Value = m_ItemContent.MyItem.CreateUser;
                    paraList.Add(param1);
                    paraList.Add(param2);
                    paraList.Add(param3);
                    paraList.Add(param4);
                    paraList.Add(param5);
                    paraList.Add(param6);
                    paraList.Add(param7);
                    paraList.Add(param8);
                    DS_SqlService.InsertTemplete(paraList);

                    TreeListNode nd = treeList1.AppendNode(new object[] { m_ItemContent.MyItem.Code, m_ItemContent.MyItem.ItemName, "Leaf", m_ItemContent.MyItem.IsPerson, m_ItemContent.MyItem.CreateUser, m_ItemContent.MyItem.Content, m_ItemContent.MyItem.DeptID, m_ItemContent.MyItem.ParentID }, type.Equals("Folder") ? treeList1.FocusedNode : treeList1.FocusedNode.ParentNode);
                    nd.Tag = m_ItemContent.MyItem;
                    //treeList1.FocusedNode.ExpandAll();
                    m_app.CustomMessageBox.MessageShow("新增成功");
                    treeList1.FocusedNode = nd;
                }
            }
            catch (Exception ex)
            {
                m_app.CustomMessageBox.MessageShow(ex.Message);
            }
        }