Exemplo n.º 1
0
        /// <summary>
        /// Copy Tasks from other Phase
        /// </summary>
        /// <param name="fromPhase">from phase</param>
        /// <returns>number of tasks copied</returns>
        public int CopyTasksFrom(MProjectTypePhase fromPhase)
        {
            if (fromPhase == null)
            {
                return(0);
            }
            int count         = 0;
            int tasklinecount = 0;

            //	Copy Type Tasks
            MProjectTypeTask[] fromTasks = fromPhase.GetTasks();
            for (int i = 0; i < fromTasks.Length; i++)
            {
                MProjectTask toTask = new MProjectTask(this, fromTasks[i]);
                if (toTask.Save())
                {
                    // check if table exists then only it will copy the task lines
                    if (PO.Get_Table_ID("C_TaskLine") > 0)
                    {
                        tasklinecount = CopyMTaskLines(fromTasks[i].GetC_Task_ID(), toTask.GetC_ProjectTask_ID());
                    }
                    count++;
                }
            }
            log.Fine("#" + count + " - " + fromPhase + ", #" + tasklinecount);
            if (fromTasks.Length != count)
            {
                log.Log(Level.SEVERE, "Count difference - TypePhase=" + fromTasks.Length + " <> Saved=" + count);
            }

            return(count);
        }
Exemplo n.º 2
0
        /// <summary>
        /// To copy the task lines from project template Standard Task lines tab
        /// </summary>
        /// <param name="Task_ID">ID of tasks</param>
        /// <param name="C_ProjectTask_ID">Project task ID</param>
        /// <returns>No of lines created</returns>
        public int CopyMTaskLinesFromProjectTask(MProjectTask fromTask, MProjectTask toTask, int To_Project_ID)
        {
            ValueNamePair pp            = null;
            int           tasklinecount = 0;
            StringBuilder msg           = new StringBuilder();

            try
            {
                MProjectLine[]      fromLines = null;
                List <MProjectLine> list      = new List <MProjectLine>();

                DataSet projDs = DB.ExecuteDataset(" SELECT C_ProjectLine_ID FROM C_ProjectLine WHERE " +
                                                   " C_ProjectPhase_ID =" + fromTask.GetC_ProjectPhase_ID() + " AND C_ProjectTask_ID =" + fromTask.GetC_ProjectTask_ID() +
                                                   " AND IsActive='Y' ORDER BY Line ");

                if (projDs != null && projDs.Tables[0].Rows.Count > 0)
                {
                    for (int k = 0; k < projDs.Tables[0].Rows.Count; k++)
                    {
                        list.Add(new MProjectLine(GetCtx(), Util.GetValueOfInt(projDs.Tables[0].Rows[k]["C_ProjectLine_ID"]), Get_TrxName()));
                    }
                    fromLines = new MProjectLine[list.Count];
                    fromLines = list.ToArray();
                }

                if (fromLines != null && fromLines.Length > 0)
                {
                    for (int j = 0; j < fromLines.Length; j++)
                    {
                        MProjectLine line = new MProjectLine(GetCtx(), 0, Get_TrxName());
                        PO.CopyValues(fromLines[j], line, GetAD_Client_ID(), GetAD_Org_ID());
                        line.SetC_Project_ID(To_Project_ID);
                        line.SetC_ProjectTask_ID(toTask.GetC_ProjectTask_ID());
                        line.SetC_ProjectPhase_ID(toTask.GetC_ProjectPhase_ID());
                        line.SetInvoicedAmt(Env.ZERO);
                        line.SetInvoicedQty(Env.ZERO);
                        line.SetC_OrderPO_ID(0);
                        line.SetC_Order_ID(0);
                        line.SetProcessed(false);
                        if (line.Save())
                        {
                            tasklinecount++;
                        }
                        else
                        {
                            pp = VLogger.RetrieveError();
                            if (pp != null)
                            {
                                msg.Append(pp.GetName());
                                //if GetName is Empty then it will check GetValue
                                if (string.IsNullOrEmpty(msg.ToString()))
                                {
                                    msg.Append(Msg.GetMsg("", pp.GetValue()));
                                }
                            }
                            if (string.IsNullOrEmpty(msg.ToString()))
                            {
                                msg.Append(Msg.GetMsg(GetCtx(), "VIS_LineNotSaved"));
                            }
                            else
                            {
                                msg.Append(Msg.GetMsg(GetCtx(), "VIS_LineNotSaved") + "," + msg.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log(Level.SEVERE, "", ex);
            }
            //
            return(tasklinecount);
        }