private void ShowChildNode(TreeNode parentNode) { if (parentNode == null) { return; } parentNode.Nodes.Clear(); List <ProcessFolder> folderList = ProcessCardBLL.GetProcessFolderList(parentNode.Tag.ToString()); if (folderList == null || folderList.Count == 0) { return; } folderList.ForEach((f) => { TreeNode node = new TreeNode(); node.Text = f.FolderName; node.Tag = f.FolderId; node.Name = f.ParentFolder; node.ImageKey = "folder"; List <ProcessFolder> childFolderList = ProcessCardBLL.GetProcessFolderList(node.Tag.ToString()); if (childFolderList != null && childFolderList.Count > 0) { ShowChildNode(node); } parentNode.Nodes.Add(node); }); }
/// <summary> /// set current node new add process card /// </summary> /// <param name="processCardModuleList"></param> public void SetCurrentNodeNewAddProcessCard(List <ProcessCardModule> processCardModuleList) { TreeNode selectedNode = tvProcessProcedure.GetNodeAt(p); Guid processPlanningId = (Guid)selectedNode.Tag; ProcessCardModuleBLL processCardModuleBLL = new ProcessCardModuleBLL(); ProcessCardBLL processCardBLL = new ProcessCardBLL(); try { int i = selectedNode.Nodes.Count + 1; /// 增加卡片 foreach (var pcm in processCardModuleList) { string name = string.Format(pcm.Name + "-{0}", i); ProcessCard processCard = new ProcessCard(); processCard.ID = Guid.NewGuid(); processCard.Name = name; //Guid.NewGuid().ToString(); processCard.CardModuleId = pcm.Id; processCard.Card = processCardModuleBLL.GetCardModule(pcm.Id); processCard.CreateTime = DateTime.Now; processCard.IsCheckOut = false; processCard.IsDelete = 0; processCard.UpdateTime = DateTime.Now; Guid id = processCardBLL.InsertProcessCard(processCard); ///保存工艺规程和卡片映射 PlanningCardRelationBLL.AddProcesPlanningData( new PlanningCardRelation() { ProcessPlanningId = processPlanningId, PlanningCardRelationId = Guid.NewGuid(), ProcessCardId = id, CardSort = 0 }); TreeNode newNode = new TreeNode(); newNode.Tag = string.Format("{0}@{1}", id, pcm.Id); newNode.Name = i.ToString(); // id.ToString(); newNode.Text = name; newNode.ImageKey = "card"; newNode.Collapse(); selectedNode.Nodes.Add(newNode); i++; } } catch (Exception ex) { MessageBox.Show(ex.Message); } tvProcessProcedure.Refresh(); //tvProcessProcedure.TreeViewNodeSorter = new Kingdee.CAPP.UI.Common.NodeSorter(); }
/// <summary> /// 保存工艺规程和卡片 /// </summary> /// <param name="?"></param> /// <param name="processPlanning"></param> public void SaveProcessPlanning( List <ProcessCardModule> processCardModules, ProcessPlanning processPlanning) { ProcessCardModuleBLL processCardModuleBLL = new ProcessCardModuleBLL(); try { /// 保存工艺规程 ProcessPlanningBLL.AddProcesPlanning(processPlanning); //保存文件夹 ProcessVersion version = new ProcessVersion(); version.FolderId = tvProcessCard.SelectedNode.Tag.ToString(); version.BaseId = processPlanning.ProcessPlanningId.ToString(); version.Name = processPlanning.Name; version.CategoryId = "A9FE1F2B-730A-4DA7-8323-557C664B9734"; Kingdee.CAPP.BLL.ProcessCardBLL.InsertProcessVersion(version, null); /// 保存工艺卡片 ProcessCardBLL processCardBLL = new ProcessCardBLL(); ProcessCard = new List <Model.ProcessCard>(); int i = 1; foreach (var pcm in processCardModules) { ProcessCard processCard = new ProcessCard(); //processCard.ID = Guid.NewGuid(); processCard.Name = string.Format(processPlanning.Name + "-{0}", i); //Guid.NewGuid().ToString(); processCard.CardModuleId = pcm.Id; processCard.Card = processCardModuleBLL.GetCardModule(pcm.Id); processCard.CreateTime = DateTime.Now; processCard.IsCheckOut = false; processCard.IsDelete = 0; processCard.UpdateTime = DateTime.Now; Guid id = processCardBLL.InsertProcessCard(processCard); processCard.ID = id; ProcessCard.Add(processCard); ///保存工艺规程和卡片映射 PlanningCardRelationBLL.AddProcesPlanningData( new PlanningCardRelation() { ProcessPlanningId = processPlanning.ProcessPlanningId, PlanningCardRelationId = Guid.NewGuid(), ProcessCardId = id, CardSort = 0 }); i++; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSearch_Click(object sender, EventArgs e) { string condition = GetConditions(); if (!string.IsNullOrEmpty(condition)) { listProcessCard = ProcessCardBLL.GetProcessVersion(condition); dgvCard.DataSource = listProcessCard; } }
/// <summary> /// 获取所有已入库卡片 /// </summary> private void LoadCardData() { listProcessCard = ProcessCardBLL.GetProcessVersion(""); dgvCard.AutoGenerateColumns = false; dgvCard.DataSource = listProcessCard; DataTable dtUser = ProcessCardBLL.GetUsers(); comboCreator.DisplayMember = "UserName"; comboCreator.ValueMember = "UserId"; comboCreator.DataSource = dtUser; }
private void AddTypicalProcessCardFrm_Load(object sender, EventArgs e) { try { List <ProcessCard> processCardModuleList = ProcessCardBLL.GetDefaultProcessCardList(); this.dgvCardList.DataSource = processCardModuleList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ShowChildNode(TreeNode parentNode) { if (parentNode == null) { return; } parentNode.Nodes.Clear(); List <ProcessFolder> folderList = ProcessCardBLL.GetProcessFolderList(parentNode.Tag.ToString()); if (folderList == null || folderList.Count == 0) { return; } folderList.ForEach((f) => { TreeNode node = new TreeNode(); node.Text = f.FolderName; node.Tag = f.FolderId; node.Name = f.ParentFolder; node.ImageKey = "folder"; List <ProcessVersion> versionList = ProcessCardBLL.GetProcessCardByFolderId(f.FolderId, 2); if (versionList != null && versionList.Count > 0) { versionList.ForEach((v) => { TreeNode nd = new TreeNode(); nd.Text = v.Name; nd.Tag = v.BaseId; nd.Name = v.Name; nd.ImageKey = "planning"; ShowProcessCardByProcessPlanningId(new Guid(v.BaseId), nd); node.Nodes.Add(nd); } ); } List <ProcessFolder> childFolderList = ProcessCardBLL.GetProcessFolderList(node.Tag.ToString()); if (childFolderList != null && childFolderList.Count > 0) { ShowChildNode(node); } parentNode.Nodes.Add(node); }); }
/// <summary> /// 方法说明:根据BusinessId删除模版或文件夹 /// 作 者:jason.tang /// 完成时间:2013-07-24 /// </summary> /// <param name="Id">业务ID</param> private void RemoveTreeNode(TreeNode currentNode) { if (currentNode == null) { return; } bool result = false; if (currentNode.ImageKey == "planning") { Guid planningId = new Guid(currentNode.Tag.ToString()); result = ProcessPlanningBLL.DeletePlanningById(planningId); ProcessCardBLL.DeleteProcessVersion(planningId.ToString(), currentNode.Parent.Tag.ToString()); } else { int splitIndex = currentNode.Tag.ToString().IndexOf("@"); Guid cardid = new Guid(currentNode.Tag.ToString().Substring(0, splitIndex)); Guid planningId = new Guid(currentNode.Parent.Tag.ToString()); result = PlanningCardRelationBLL.DeleteRelationByCardId(cardid, planningId); } if (result) { if (currentNode.Parent != null && !string.IsNullOrEmpty(currentNode.Parent.ImageKey)) { tvProcessProcedure.SelectedNode = currentNode.Parent; tvProcessProcedure.SelectedImageKey = currentNode.Parent.ImageKey; } else { tvProcessProcedure.SelectedNode = tvProcessProcedure.Nodes[0]; /// 如果选中的节点为空,默认为卡片 tvProcessProcedure.SelectedImageKey = tvProcessProcedure.Nodes[0].ImageKey; } //Remove treeview tvProcessProcedure.Nodes.Remove(currentNode); tvProcessProcedure.SelectedNode.Expand(); } }
private void btnSerach_Click(object sender, EventArgs e) { string cardName = txtProcessCardName.Text.Trim(); if (string.IsNullOrEmpty(cardName)) { return; } try { List <ProcessCard> processCardModuleList = ProcessCardBLL.GetProcessCardListByCondition(cardName); this.dgvCardList.DataSource = processCardModuleList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetCard(ProcessCard _card, DataGridView datagridview) { ProcessCardBLL pcBll = new ProcessCardBLL(); ProcessCard processCard = new ProcessCard(); CardsXML cards = new CardsXML(); //DataGridView datagridview = new DataGridView(); Guid cardid = _card.ID; if (cardid != null) { processCard = pcBll.GetProcessCard(cardid); cards = processCard.Card; //if (!isNew) // this.Tag = id; } if (cards == null) { return; } datagridview.Tag = processCard.Name; int index = 0; //Panel pn = new Panel(); foreach (Card card in cards.Cards) { //pn = new Panel(); //pn.BorderStyle = BorderStyle.FixedSingle; //pn.Width = pnlPlanningCard.Width; //pn.Height = pnlPlanningCard.Height; //pn.AutoScroll = false; //pn.Name = string.Format("pnCard{0}@{1}", Guid.NewGuid().ToString(), pageCount + 1); if (index > 0) { datagridview = new DataGridView(); datagridview.Name = string.Format("dgvCard{0}", card.Id.ToString()); datagridview.RowHeadersVisible = false; datagridview.ColumnHeadersVisible = false; //datagridview.Dock = DockStyle.Top; datagridview.AllowUserToResizeColumns = false; datagridview.AllowUserToResizeRows = false; datagridview.ReadOnly = true; datagridview.ScrollBars = ScrollBars.None; datagridview.DefaultCellStyle.SelectionBackColor = datagridview.DefaultCellStyle.BackColor; datagridview.DefaultCellStyle.SelectionForeColor = Color.Black; datagridview.AutoGenerateColumns = false; pnlPlanningCard.Controls.Add(datagridview); } index++; int Width = Convert.ToInt32(card.Width); int Height = Convert.ToInt32(card.Height); int breadth = int.Parse(card.CardRange.Replace("A", "")); cardWidth = Width; cardHeight = Height; cardBreadth = breadth; //if (datagridview.Name == "dgvCard") //{ ResizeControls(Width, Height, breadth, datagridview); //} List <DataGridViewRow> listRow = new List <DataGridViewRow>(); if (card.Rows == null) { continue; } int rows = card.Rows.Length; int columns = card.Rows[0].Cells.Length; 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, datagridview); 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)datagridview.Rows[cell.PointX].Cells[cell.PointY]); cellEx.CellTag = processCard.Name; cellEx.Style.Alignment = cell.Alignment == null ? DataGridViewContentAlignment.NotSet : (DataGridViewContentAlignment)Enum.Parse(typeof(DataGridViewContentAlignment), cell.Alignment); cellEx.Style.BackColor = cell.BackGround == null || int.Parse(cell.BackGround) == 0 ? Color.Empty : Color.FromArgb(int.Parse(cell.BackGround)); cellEx.BottomBorderColor = cell.BottomBorderColor == null || int.Parse(cell.BottomBorderColor) == 0 ? Color.Empty : 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; if (!string.IsNullOrEmpty(cellEx.CellSource) && ModuleObject != null) { foreach (PropertyInfo pi in ModuleObject.GetType().GetProperties()) { if (pi.Name.ToLower() == cellEx.CellSource.ToLower()) { cellEx.Value = pi.GetValue(ModuleObject, new object[] { }); break; } } } else { 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 = cell.Alignment == null ? DataGridViewContentAlignment.NotSet : (DataGridViewContentAlignment)Enum.Parse(typeof(DataGridViewContentAlignment), cell.Alignment); cellStyle.BackColor = cell.BackGround == null || int.Parse(cell.BackGround) == 0 ? Color.Empty : Color.FromArgb(int.Parse(cell.BackGround)); if (cell.FontFamily == null || cell.ZoomFontSize == null || cell.FontStyle == null) { cellStyle.Font = preFont; } else { cellStyle.Font = new Font(cell.FontFamily, float.Parse(cell.ZoomFontSize), (FontStyle)Enum.Parse(typeof(FontStyle), cell.FontStyle)); } cellStyle.ForeColor = cell.ForeColor == null ? preColor : Color.FromArgb(int.Parse(cell.ForeColor)); preFont = cellStyle.Font; preColor = cellStyle.ForeColor; cellStyle.WrapMode = (DataGridViewTriState)Enum.Parse(typeof(DataGridViewTriState), cell.WrapMode.ToString()); if (cell.Padding == null) { listPadding.Add(0); listPadding.Add(0); listPadding.Add(0); listPadding.Add(0); } else { 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; if (cell.FontFamily == null || cell.FontSize == null || cell.FontStyle == null) { cellEx.Style.Font = preFont; } else { cellEx.Style.Font = new Font(cell.FontFamily, float.Parse(cell.FontSize), (FontStyle)Enum.Parse(typeof(FontStyle), cell.FontStyle)); } cellEx.Style.ForeColor = cell.ForeColor == null ? preColor : Color.FromArgb(int.Parse(cell.ForeColor)); preFont = cellEx.Style.Font; preColor = cellEx.Style.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; string parentName = datagridview.Parent.Name; //明细框单元格 if (cellEx.CellEditType == (ComboBoxSourceHelper.CellType)Enum.Parse(typeof(ComboBoxSourceHelper.CellType), "2")) { Rectangle rect = datagridview.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, cellEx, datagridview, dicColumns); cellEx.DetailProperty = dicColumns; } else if (cellEx.CellEditType == (ComboBoxSourceHelper.CellType)Enum.Parse(typeof(ComboBoxSourceHelper.CellType), "3")) //页码 { cellEx.Value = 1; } else if (cellEx.CellEditType == (ComboBoxSourceHelper.CellType)Enum.Parse(typeof(ComboBoxSourceHelper.CellType), "4")) //页数 { cellEx.Value = 1; } } } //读取图片 if (card.ImageObjects != null && card.ImageObjects.Length > 0) { foreach (ImageObject image in card.ImageObjects) { LoadImage(image, datagridview); } } } catch { MessageBox.Show("读取模板文件失败,无法新建卡片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } }
/// <summary> /// 方法说明:新建卡片 /// 作 者:jason.tang /// 完成时间:2013-03-05 /// </summary> private void NewCard() { using (CardModuleChooseFrm chooseFrm = new CardModuleChooseFrm()) { if (chooseFrm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ProcessCardFrm frm = new ProcessCardFrm(); frm.ProcessFolderId = chooseFrm.ProcessFolderId; if (tcDesignView.SelectedTab == tbMaterial) { frm.Name = string.Format("ProcessCardFrm-{0}-NAVG", Guid.NewGuid().ToString()); } else { frm.Name = string.Format("ProcessCardFrm-{0}-NAVP", Guid.NewGuid().ToString()); } if (!string.IsNullOrEmpty(chooseFrm.ProcessCardId)) { //frm.TabText = chooseFrm.ProcessCardName; //MainFrm.mainFrm.OpenModule(frm); //bool result = frm.OpenCard(null, chooseFrm.ProcessCardId, true); //if (!result) //{ // MainFrm.mainFrm.CloseModule(frm); //} //添加节点 ProcessCardBLL bll = new ProcessCardBLL(); ProcessCard card = bll.GetProcessCard(new Guid(chooseFrm.ProcessCardId)); string baseid = AddNodeInMaterial(card, frm.ProcessFolderId); if (string.IsNullOrEmpty(baseid)) { MessageBox.Show("该物料下已包含相同的卡片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MaterialCardRelation materialCardRelation = new MaterialCardRelation(); materialCardRelation.MaterialCardRelationId = Guid.NewGuid(); materialCardRelation.MaterialId = new Guid(baseid); materialCardRelation.ProcessCardId = card.ID; if (tcDesignView.SelectedTab == tbMaterial) { materialCardRelation.Type = 1; } else { materialCardRelation.Type = 2; } Kingdee.CAPP.BLL.MaterialCardRelationBLL.AddMaterialCardRelationData(materialCardRelation); return; } #region 设置新增卡片Tab的TabText及Name int tag = 1; int index = 1; List <int> listIndex = new List <int>(); foreach (DockContent form in this.MdiChildren) { if (form.Name.StartsWith("ProcessCardFrm") && form.TabText.StartsWith(chooseFrm.ModuleName)) { tag = int.Parse(form.TabText.Substring(form.TabText.IndexOf("-") + 1)); listIndex.Add(tag); } } listIndex.Sort(); foreach (var i in listIndex) { if (i > 1 && index == 1) { index = 1; break; } if (index > 1) { if (i - listIndex[index - 2] > 1) { index = listIndex[index - 2] + 1; break; } } index++; } frm.TabText = string.Format("{0}-{1}", chooseFrm.ModuleName, index); #endregion frm.ModuleId = chooseFrm.ModuleId; frm.ModuleName = chooseFrm.ModuleName; if (tcDesignView.SelectedTab == tbMaterial) { frm.ModuleObject = tvMaterialDesign.SelectedNode.Tag; frm.PBomID = string.Empty; } else { frm.ModuleObject = tvMaterialPBom.SelectedNode.Tag; frm.PBomID = tvMaterialPBom.SelectedNode.Name; } MainFrm.mainFrm.OpenModule(frm); } } }