Exemplo n.º 1
0
        public void GetProcessCardTest()
        {
            Guid id = new Guid("6E41805B-7A69-4A93-A16F-C1BB62C447FB"); // TODO: Initialize to an appropriate value
            ProcessCardModuleBLL cardbll = new ProcessCardModuleBLL();
            ProcessCardModule    module  = cardbll.GetProcessCardModule(id);

            Assert.IsNotNull(module);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Modified process card
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public bool UpdateProcessCardModule(ProcessCardModule card)
        {
            bool result = false;

            try
            {
                result = ProcessCardModuleDAL.UpdateProcessCardModule(card);
            }
            catch
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// add process card
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public Guid AddProcessCard(ProcessCardModule card)
        {
            Guid result;

            try
            {
                result = ProcessCardModuleDAL.AddProcessCard(card);
            }
            catch
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// New add module or folder common method
        /// </summary>
        public void AddModuleOrFolder(BusinessType type, ProcessCardModule cardModule)
        {
            TreeNode node = tvProcessCard.SelectedNode;

            ///如果整个Treeview都没有选中的话
            if (node == null)
            {
                node = tvProcessCard.Nodes[0];
            }

            /// 避免直接新建时选中卡片或其他的节点
            while (node.ImageKey != "folder" && node.ImageKey != "folder_o")
            {
                node = node.Parent;
            }

            Guid businessId = Guid.NewGuid();

            CardManager businessModule = new CardManager();

            businessModule.BType      = type;
            businessModule.ParentNode = int.Parse(node.Name);

            if (cardModule != null)
            {
                businessId = cardModule.Id;
            }
            businessModule.BusinessId = businessId;

            ///当前节点修改缓存且显示在界面上
            string     newNodeName = string.Empty;
            AddNodeFrm nodeFrm     = null;
            int        currentNode = 0;

            if (type != BusinessType.Card)
            {
                nodeFrm = new AddNodeFrm(businessModule);
                nodeFrm.ShowDialog();

                if (nodeFrm.DialogResult != DialogResult.OK)
                {
                    return;
                }
                newNodeName = nodeFrm.NewNodeName;
                currentNode = nodeFrm.CurrentNode;
            }
            else
            {
                newNodeName = cardModule.Name;
                currentNode = CardManagerBLL.AddBusiness(
                    cardModule.Name,
                    (int)type,
                    businessModule.ParentNode, cardModule.Id);
            }

            businessModule.Name = newNodeName;

            List <CardManager> cardManagerList = null;

            if (!cardManagerDic.ContainsKey(node.Name))
            {
                cardManagerList = new List <CardManager>();
                cardManagerList.Add(businessModule);
                cardManagerDic.Add(node.Name, cardManagerList);
            }
            else
            {
                cardManagerList = cardManagerDic[node.Name];

                cardManagerList.Add(new CardManager()
                {
                    BType       = type,
                    CurrentNode = currentNode,
                    BusinessId  = businessId,
                    Name        = newNodeName
                });
                cardManagerDic[node.Name] = cardManagerList;
            }

            TreeNode newNode = new TreeNode();

            newNode.Text = newNodeName;
            newNode.Name = currentNode.ToString();
            newNode.Tag  = businessId;
            switch (type)
            {
            case BusinessType.Root:
                newNode.ImageKey = "folder_o";
                break;

            case BusinessType.Card:
                newNode.ImageKey = "card";
                break;

            case BusinessType.FixTip:
                newNode.ImageKey = "detail";
                break;

            case BusinessType.Detail:
                newNode.ImageKey = "content";
                break;

            case BusinessType.Folder:
                newNode.ImageKey = "folder";
                break;

            default:
                break;
            }

            node.Nodes.Add(newNode);

            ///新增加的节点也要加入缓存
            cardManagerDic.Add(newNode.Name,
                               new List <CardManager>());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 方法说明:根据模板ID打开模板
        /// 作    者:jason.tang
        /// 完成时间:2013-01-21
        /// </summary>
        /// <param name="moduleId">模板ID</param>
        /// <param name="dgv">操作的DataGrid</param>
        private void GetTemplate(ProcessCardModule module, DataGridView dgv)
        {
            ProcessCardModuleBLL pcmDll     = new ProcessCardModuleBLL();
            CardsXML             cardmodule = new CardsXML();

            Model.ProcessCardModule pcm = new ProcessCardModule();

            string moduleId = module.Id.ToString();

            try
            {
                Guid gid = new Guid(moduleId);
                pcm        = pcmDll.GetProcessCardModule(gid);
                cardmodule = pcm.CardModule;
            }
            catch
            {
                return;
            }

            Card card = cardmodule.Cards.FirstOrDefault <Card>();

            int Width  = Convert.ToInt32(card.Width);
            int Height = Convert.ToInt32(card.Height);

            _breadth = int.Parse(card.CardRange.Replace("A", ""));
            ResizeInitGridView(Width, Height, dgv);

            List <DataGridViewRow> listRow = new List <DataGridViewRow>();


            if (card.Rows == null || card.Rows.Length == 0)
            {
                return;
            }

            int rows    = card.Rows.Length;
            int columns = card.Rows[0].Cells.Length;

            dgv.Rows.Clear();
            dgv.Columns.Clear();

            List <int> listWidth  = new List <int>();
            List <int> listHeight = new List <int>();

            foreach (Row row in card.Rows)
            {
                listHeight.Add(Convert.ToInt32(row.Height));
            }

            foreach (Cell cell in card.Rows[0].Cells)
            {
                listWidth.Add(Convert.ToInt32(cell.Width));
            }

            InitDataGridView(listHeight, listWidth, dgv);
            DataGridViewTextBoxCellEx            cellEx;
            List <DataGridViewCustomerCellStyle> listCellStyle;
            DataGridViewCustomerCellStyle        cellStyle;
            List <int> listPadding;

            try
            {
                foreach (Row row in card.Rows)
                {
                    foreach (Cell cell in row.Cells)
                    {
                        cellEx = ((DataGridViewTextBoxCellEx)dgv.Rows[cell.PointX].Cells[cell.PointY]);
                        cellEx.Style.Alignment   = (DataGridViewContentAlignment)Enum.Parse(typeof(DataGridViewContentAlignment), cell.Alignment);
                        cellEx.Style.BackColor   = int.Parse(cell.BackGround) == 0 ? Color.White : Color.FromArgb(int.Parse(cell.BackGround));
                        cellEx.BottomBorderColor = Color.FromArgb(int.Parse(cell.BottomBorderColor));
                        cellEx.BottomBorderWidth = Convert.ToInt32(cell.BottomBorderWidth);
                        cellEx.CellEditType      = (ComboBoxSourceHelper.CellType)Enum.Parse(typeof(ComboBoxSourceHelper.CellType), cell.CellType);
                        cellEx.ColumnSpan        = cell.ColSpan;
                        cellEx.Value             = cell.Content;
                        string[] spanCell = cell.SpanCell.Split(new char[] { ',' });
                        cellEx.SpanCell = new Point(int.Parse(spanCell[0]), int.Parse(spanCell[1]));

                        #region 处理CellStyle

                        listCellStyle = new List <DataGridViewCustomerCellStyle>();
                        listPadding   = new List <int>();
                        if (cellEx.CustStyle == null)
                        {
                            cellStyle           = new DataGridViewCustomerCellStyle();
                            cellStyle.Alignment = (DataGridViewContentAlignment)Enum.Parse(typeof(DataGridViewContentAlignment), cell.Alignment);
                            cellStyle.BackColor = int.Parse(cell.BackGround) == 0 ? Color.White : Color.FromArgb(int.Parse(cell.BackGround));
                            cellStyle.Font      = new Font(cell.FontFamily, float.Parse(cell.ZoomFontSize), (FontStyle)Enum.Parse(typeof(FontStyle), cell.FontStyle));
                            cellStyle.ForeColor = Color.FromArgb(int.Parse(cell.ForeColor));
                            cellStyle.WrapMode  = (DataGridViewTriState)Enum.Parse(typeof(DataGridViewTriState), cell.WrapMode.ToString());

                            string[] padding = cell.Padding.Split(new char[] { ',' });
                            foreach (string pad in padding)
                            {
                                listPadding.Add(int.Parse(pad));
                            }
                            cellStyle.Padding = new System.Windows.Forms.Padding(listPadding[0], listPadding[1], listPadding[2], listPadding[3]);
                            listCellStyle.Add(cellStyle);
                            cellEx.CustStyle = listCellStyle;
                        }

                        #endregion

                        //cell.ContentType;
                        //cell.DataSrc;
                        //cell.DetailCells;

                        cellEx.Style.Font      = new Font(cell.FontFamily, float.Parse(cell.FontSize), (FontStyle)Enum.Parse(typeof(FontStyle), cell.FontStyle));
                        cellEx.Style.ForeColor = Color.FromArgb(int.Parse(cell.ForeColor));
                        cellEx.LeftBorderColor = Color.FromArgb(int.Parse(cell.LeftBorderColor));
                        cellEx.LeftBorderWidth = Convert.ToInt32(cell.LeftBorderWidth);
                        //cell.Name;
                        cellEx.RightBorderColor = Color.FromArgb(int.Parse(cell.RightBorderColor));
                        cellEx.RightBorderWidth = Convert.ToInt32(cell.RightBorderWidth);
                        cellEx.RowSpan          = cell.RowSpan;
                        cellEx.TopBorderColor   = Color.FromArgb(int.Parse(cell.TopBorderColor));
                        cellEx.TopBorderWidth   = Convert.ToInt32(cell.TopBorderWidth);

                        cellEx.LeftTopRightBottom = cell.LeftTopRightBottom;
                        cellEx.LeftBottomRightTop = cell.LeftBottomRightTop;
                        cellEx.CellContent        = string.IsNullOrEmpty(cell.ContentType) ? (ComboBoxSourceHelper.CellContent)Enum.Parse(typeof(ComboBoxSourceHelper.CellContent), "0") :
                                                    (ComboBoxSourceHelper.CellContent)Enum.Parse(typeof(ComboBoxSourceHelper.CellContent), cell.ContentType);

                        cellEx.Style.WrapMode = (DataGridViewTriState)Enum.Parse(typeof(DataGridViewTriState), cell.WrapMode.ToString());
                        cellEx.CellSource     = cell.CellSource;

                        //明细框单元格
                        if (cellEx.CellEditType == (ComboBoxSourceHelper.CellType)Enum.Parse(typeof(ComboBoxSourceHelper.CellType), "2"))
                        {
                            Rectangle rect = dgv.GetCellDisplayRectangle(cellEx.ColumnIndex, cellEx.RowIndex, false);
                            int       top  = rect.Y - 1;
                            int       left = rect.X - 1;

                            List <DetailGridViewTextBoxColumn> dicColumns = new List <DetailGridViewTextBoxColumn>();
                            object objDetailProperty = cell.DetailCells;
                            //明细框
                            AddDetailGridView(top, left, objDetailProperty, dicColumns, dgv, cellEx);
                            cellEx.DetailProperty = dicColumns;
                        }
                    }
                }
                //读取图片
                if (card.ImageObjects != null && card.ImageObjects.Length > 0)
                {
                    foreach (ImageObject image in card.ImageObjects)
                    {
                        LoadImage(image, dgv);
                    }
                }
            }
            catch
            {
                dgv.Rows.Clear();
                dgv.Columns.Clear();
                MessageBox.Show("模板文件打开失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //dgvCardModule.Refresh();
        }