Ejemplo n.º 1
0
        /// <summary>
        /// Add process card to process planning tree
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnConfirm_Click(object sender, EventArgs e)
        {
            if (tvProcessCard.SelectedNode == null || tvProcessCard.SelectedNode.Parent == null)
            {
                MessageBox.Show("请选择工艺文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            int count = cklProcessCardModuleNames.Items.Count;

            ///这节代码是为了--方便后面扩展
            List <object> objList = new List <object>();

            for (int i = 0; i < count; i++)
            {
                if (cklProcessCardModuleNames.GetItemChecked(i))
                {
                    if (!objList.Contains(cklProcessCardModuleNames.Items[i]))
                    {
                        objList.Add(cklProcessCardModuleNames.Items[i]);
                    }
                }
            }

            if (string.IsNullOrEmpty(txtProcessPlanningName.Text.Trim()))
            {
                MessageBox.Show(GlobalResource.HAVENOTFILLPROCESSPLANNINGNAME);
                txtProcessPlanningName.Focus();
                return;
            }

            if (objList.Count <= 0)
            {
                MessageBox.Show(GlobalResource.HAVENOTSELECTEDCARDMODULE);
                return;
            }
            else
            {
                ProcessPlanning processPlanning = new ProcessPlanning();
                processPlanning.ProcessPlanningId = Guid.NewGuid();
                processPlanning.Name = txtProcessPlanningName.Text.Trim();

                /// 保存工艺规程和卡片
                SaveProcessPlanning(ProcessCardModules, processPlanning);

                ProcessPlanningTreeFrm processProcedureTree = ProcessPlanningTreeFrm.GetInstance();
                processProcedureTree.ShowProcessPlanningTreeFromNew(ProcessCard, processPlanning, tvProcessCard.SelectedNode.Tag.ToString());


                if (processProcedureTree != null && !processProcedureTree.IsDisposed)
                {
                    processProcedureTree.Show(LefttDockPanel, DockState.DockLeft);
                }

                ///关闭当前窗口
                Close();
            }
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// add process planning module
 /// </summary>
 /// <returns></returns>
 public static Guid AddProcesPlanning(ProcessPlanning processPlanning)
 {
     try
     {
         Guid id = ProcessPlanningDAL.AddProcesPlanningData(processPlanning);
         return(id);
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// get process card list by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Guid AddProcesPlanningData(ProcessPlanning processPlanning)
        {
            try
            {
                string strsql = @"
                                INSERT INTO [dbo].[ProcessPlanning]
                                   ([ProcessPlanningId]
                                   ,[Name]
                                   ,[CreateTime]
                                   ,[CreateBy]
                                   ,[UpdateTime]
                                   ,[IsDelete]
                                   ,[IsCheckOut])
                             VALUES
                                   (@ProcessPlanningId
                                   ,@Name
                                   ,@CreateTime
                                   ,@CreateBy
                                   ,@UpdateTime
                                   ,@IsDelete
                                   ,@IsCheckOut);";

                using (DbCommand cmd = db.GetSqlStringCommand(strsql))
                {
                    db.AddInParameter(cmd, "@ProcessPlanningId", DbType.Guid, processPlanning.ProcessPlanningId);
                    db.AddInParameter(cmd, "@Name", DbType.String, processPlanning.Name);
                    db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, DateTime.Now);
                    db.AddInParameter(cmd, "@CreateBy", DbType.String, processPlanning.CreateBy);
                    db.AddInParameter(cmd, "@UpdateTime", DbType.DateTime, DateTime.Now);
                    db.AddInParameter(cmd, "@IsDelete", DbType.Int16, 0);
                    db.AddInParameter(cmd, "@IsCheckOut", DbType.Boolean, false);

                    db.ExecuteScalar(cmd);
                    return(processPlanning.ProcessPlanningId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 新增时调用, 显示工艺规程和卡片模版树
        /// </summary>
        /// <param name="processCard"></param>
        public void ShowProcessPlanningTreeFromNew(
            List <ProcessCard> processCard,
            ProcessPlanning ProcessPlanning,
            string folderid)
        {
            TreeNode planningNode = new TreeNode();

            planningNode.Text     = ProcessPlanning.Name;
            planningNode.Tag      = ProcessPlanning.ProcessPlanningId;
            planningNode.ImageKey = "planning";
            planningNode.Name     = ProcessPlanning.Sort.ToString(); //ProcessPlanning.ProcessPlanningId.ToString();
            planningNode.Expand();


            TreeNode[] nodes = tvProcessProcedure.Nodes.Find(folderid, false);

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

            //tvProcessProcedure.Nodes.Add(planningNode);
            nodes[0].Nodes.Add(planningNode);

            int i = 0;

            processCard.ForEach((o) =>
            {
                TreeNode node = new TreeNode();
                node.Text     = string.Format(ProcessPlanning.Name + "-{0}", planningNode.Nodes.Count + 1);
                node.Tag      = o.ID;
                node.ImageKey = "card";
                node.Name     = o.CardSort.ToString(); //o.ID.ToString();
                planningNode.Nodes.Add(node);

                i++;
            });
        }