/// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="project">parent</param>
 public MProjectLine(MProject project)
     : this(project.GetCtx(), 0, project.Get_TrxName())
 {
     SetClientOrg(project);
     SetC_Project_ID(project.GetC_Project_ID()); // Parent
     SetLine();
 }
        /**
         *  Copy Lines From other Project
         *	@param project project
         *	@return number of lines copied
         */
        public int CopyLinesFrom(MProject project)
        {
            if (IsProcessed() || project == null)
            {
                return(0);
            }
            int count = 0;

            MProjectLine[] fromLines = project.GetLines();
            for (int i = 0; i < fromLines.Length; i++)
            {
                MProjectLine line = new MProjectLine(GetCtx(), 0, project.Get_TrxName());
                PO.CopyValues(fromLines[i], line, GetAD_Client_ID(), GetAD_Org_ID());
                line.SetC_Project_ID(GetC_Project_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())
                {
                    count++;
                }
            }
            if (fromLines.Length != count)
            {
                log.Log(Level.SEVERE, "Lines difference - Project=" + fromLines.Length + " <> Saved=" + count);
            }

            return(count);
        }
예제 #3
0
        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override bool AfterSave(bool newRecord, bool success)
        {
            if (newRecord & success)
            {
                Insert_Accounting("C_Project_Acct", "C_AcctSchema_Default", null);
            }

            //	Value/Name change
            MProject prjph = null;

            if (success && !newRecord &&
                (Is_ValueChanged("Value") || Is_ValueChanged("Name")))
            {
                MAccount.UpdateValueDescription(GetCtx(), "C_Project_ID=" + GetC_Project_ID(), Get_TrxName());
            }
            if (GetC_Campaign_ID() != 0)
            {
                MCampaign cam    = new MCampaign(GetCtx(), GetC_Campaign_ID(), null);
                decimal   plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_Project pl WHERE pl.IsActive = 'Y' AND pl.C_Campaign_ID = " + GetC_Campaign_ID()));
                cam.SetCosts(plnAmt);
                cam.Save();
            }
            else
            {
                prjph = new MProject(GetCtx(), GetC_Project_ID(), Get_Trx());
                decimal plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(PlannedAmt),0) FROM C_ProjectPhase WHERE IsActive= 'Y' AND C_Project_ID= " + GetC_Project_ID()));
                DB.ExecuteQuery("UPDATE C_Project SET PlannedAmt=" + plnAmt + " WHERE C_Project_ID=" + GetC_Project_ID(), null, Get_Trx());
            }
            return(success);
        }
        /**
         *  Copy Phases/Tasks from other Project
         *	@param fromProject project
         *	@return number of items copied
         */
        public int CopyPhasesFrom(MProject fromProject)
        {
            if (IsProcessed() || fromProject == null)
            {
                return(0);
            }
            int count     = 0;
            int taskCount = 0;

            //	Get Phases
            MProjectPhase[] myPhases   = GetPhases();
            MProjectPhase[] fromPhases = fromProject.GetPhases();
            //	Copy Phases
            for (int i = 0; i < fromPhases.Length; i++)
            {
                //	Check if Phase already exists
                int  C_Phase_ID = fromPhases[i].GetC_Phase_ID();
                bool exists     = false;
                if (C_Phase_ID == 0)
                {
                    exists = false;
                }
                else
                {
                    for (int ii = 0; ii < myPhases.Length; ii++)
                    {
                        if (myPhases[ii].GetC_Phase_ID() == C_Phase_ID)
                        {
                            exists = true;
                            break;
                        }
                    }
                }
                //	Phase exist
                if (exists)
                {
                    log.Info("Phase already exists here, ignored - " + fromPhases[i]);
                }
                else
                {
                    MProjectPhase toPhase = new MProjectPhase(GetCtx(), 0, Get_TrxName());
                    PO.CopyValues(fromPhases[i], toPhase, GetAD_Client_ID(), GetAD_Org_ID());
                    toPhase.SetC_Project_ID(GetC_Project_ID());
                    toPhase.SetC_Order_ID(0);
                    toPhase.SetIsComplete(false);
                    if (toPhase.Save())
                    {
                        count++;
                        taskCount += toPhase.CopyTasksFrom(fromPhases[i]);
                    }
                }
            }
            if (fromPhases.Length != count)
            {
                log.Warning("Count difference - Project=" + fromPhases.Length + " <> Saved=" + count);
            }

            return(count + taskCount);
        }
예제 #5
0
 /// <summary>
 /// Get Parent
 /// </summary>
 /// <returns>project</returns>
 public MProject GetParent()
 {
     if (_parent == null && GetC_Project_ID() != 0)
     {
         _parent = new MProject(GetCtx(), GetC_Project_ID(), Get_TrxName());
     }
     return(_parent);
 }
 /// <summary>
 /// Get Project
 /// </summary>
 /// <returns>parent</returns>
 public MProject GetProject()
 {
     if (_parent == null && GetC_Project_ID() != 0)
     {
         _parent = new MProject(GetCtx(), GetC_Project_ID(), Get_TrxName());
         if (Get_TrxName() != null)
             _parent.Load(Get_TrxName());
     }
     return _parent;
 }
예제 #7
0
        }       //	toString

        /// <summary>
        /// Execute Run.
        /// </summary>
        /// <returns>clear text info</returns>
        public String ExecuteRun()
        {
            DateTime?dateDoc = GetDateNextRun();

            if (!CalculateRuns())
            {
                throw new Exception("No Runs Left");
            }
            //	log
            MRecurringRun run = new MRecurringRun(GetCtx(), this);
            String        msg = "@Created@ ";


            //	Copy
            if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order))
            {
                MOrder from  = new MOrder(GetCtx(), GetC_Order_ID(), Get_TrxName());
                MOrder order = MOrder.CopyFrom(from, dateDoc,
                                               from.GetC_DocType_ID(), false, false, Get_TrxName());
                run.SetC_Order_ID(order.GetC_Order_ID());
                msg += order.GetDocumentNo();
            }
            else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice))
            {
                MInvoice from    = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName());
                MInvoice invoice = MInvoice.CopyFrom(from, dateDoc,
                                                     from.GetC_DocType_ID(), false, Get_TrxName(), false);
                run.SetC_Invoice_ID(invoice.GetC_Invoice_ID());
                msg += invoice.GetDocumentNo();
            }
            else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project))
            {
                MProject project = MProject.CopyFrom(GetCtx(), GetC_Project_ID(), dateDoc, Get_TrxName());
                run.SetC_Project_ID(project.GetC_Project_ID());
                msg += project.GetValue();
            }
            else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal))
            {
                MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), GetGL_JournalBatch_ID(), dateDoc, Get_TrxName());
                run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID());
                msg += journal.GetDocumentNo();
            }
            else
            {
                return("Invalid @RecurringType@ = " + GetRecurringType());
            }
            run.Save(Get_TrxName());

            //
            SetDateLastRun(run.GetUpdated());
            SetRunsRemaining(GetRunsRemaining() - 1);
            SetDateNextRun();
            Save(Get_TrxName());
            return(msg);
        }       //	execureRun
        /**
         *  Copy Lines/Phase/Task from other Project
         *	@param project project
         *	@return number of total lines copied
         */
        public int CopyDetailsFrom(MProject project)
        {
            if (IsProcessed() || project == null)
            {
                return(0);
            }
            int count = CopyLinesFrom(project)
                        + CopyPhasesFrom(project);

            return(count);
        }
예제 #9
0
 /**
  *  Get Project
  *	@return project or null
  */
 public MProject GetProject()
 {
     if (GetC_Project_ID() == 0)
     {
         _project = null;
     }
     else if (_project == null ||
              _project.GetC_Project_ID() != GetC_Project_ID())
     {
         _project = new MProject(GetCtx(), GetC_Project_ID(), Get_TrxName());
     }
     return(_project);
 }
예제 #10
0
        protected override bool AfterSave(bool newRecord, bool success)
        {
            //Used transaction object because total was not updating on header
            string isCam = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsCampaign FROM C_Project WHERE C_Project_ID = " + GetC_Project_ID(), null, Get_TrxName()));
            string isOpp = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsOpportunity FROM C_Project WHERE C_Project_ID = " + GetC_Project_ID(), null, Get_TrxName()));

            if (isOpp.Equals("N") && isCam.Equals("N"))
            {
                // set sum of total amount of phase tab to project tab, similalary Commitment amount
                MProject project = new MProject(GetCtx(), GetC_Project_ID(), Get_TrxName());
                project.SetPlannedAmt(Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_Projectphase pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID(), null, Get_TrxName())));
                project.SetCommittedAmt(Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.CommittedAmt),0)  FROM C_Projectphase pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID(), null, Get_TrxName())));
                if (!project.Save())
                {
                }

                // set sum of planned margin from task line to project tab
                string  Sql = @"SELECT SUM(pl.PlannedMarginAmt) ,  SUM(pl.PlannedQty)
                          FROM c_Project p INNER JOIN c_projectphase pp ON p.c_project_id = pp.c_project_id
                          INNER JOIN c_projecttask pt ON pp.c_projectphase_id = pt.c_projectphase_id INNER JOIN c_projectline pl ON pl.c_projecttask_id = pt.c_projecttask_id
                          WHERE p.c_project_id   = " + project.GetC_Project_ID();
                DataSet ds  = new DataSet();
                ds = DB.ExecuteDataset(Sql, null, Get_TrxName());
                if (ds != null)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        project.SetPlannedMarginAmt(Util.GetValueOfDecimal(ds.Tables[0].Rows[0][0]));
                        project.SetPlannedQty(Util.GetValueOfDecimal(ds.Tables[0].Rows[0][1]));
                        project.Save();
                    }
                }
                ds.Dispose();

                //Set Total Amount Of Phase Line on Phase Tab
                MProjectPhase prjph = null;
                if (GetC_Project_ID() != 0)
                {
                    isCam = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsCampaign FROM C_Project WHERE C_Project_ID = " + GetC_Project_ID(), null, Get_TrxName()));
                }
                if (isCam.Equals("N"))                             // Project Window
                {
                    //Used transaction object because total was not updating on header
                    prjph = new MProjectPhase(GetCtx(), GetC_ProjectPhase_ID(), Get_TrxName());
                    decimal plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(PlannedAmt),0) FROM C_ProjectLine WHERE IsActive= 'Y' AND C_ProjectPhase_ID= " + GetC_ProjectPhase_ID(), null, Get_TrxName()));
                    DB.ExecuteQuery("UPDATE C_ProjectPhase SET PlannedAmt=" + plnAmt + " WHERE C_ProjectPhase_ID=" + GetC_ProjectPhase_ID(), null, Get_TrxName());
                }
            }
            return(true);
        }
예제 #11
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="project">parent</param>
 /// <param name="phase">copy</param>
 public MProjectPhase(MProject project, MProjectTypePhase phase)
     : this(project)
 {
     //
     SetC_Phase_ID(phase.GetC_Phase_ID());                       //	FK
     SetName(phase.GetName());
     SetSeqNo(phase.GetSeqNo());
     SetDescription(phase.GetDescription());
     SetHelp(phase.GetHelp());
     if (phase.GetM_Product_ID() != 0)
     {
         SetM_Product_ID(phase.GetM_Product_ID());
     }
     SetQty(phase.GetStandardQty());
 }
예제 #12
0
 /// <summary>
 /// New Parent Constructor
 /// </summary>
 /// <param name="project">parent</param>
 public MProjectIssue(MProject project)
     : this(project.GetCtx(), 0, project.Get_TrxName())
 {
     SetClientOrg(project.GetAD_Client_ID(), project.GetAD_Org_ID());
     SetC_Project_ID(project.GetC_Project_ID()); //	Parent
     SetLine(GetNextLine());
     _parent = project;
     //
     //	setM_Locator_ID (0);
     //	setM_Product_ID (0);
     //
     SetMovementDate(DateTime.Now);
     SetMovementQty(Env.ZERO);
     SetPosted(false);
     SetProcessed(false);
 }
예제 #13
0
        /**
         *  Create Project from Lead
         *	@return error message
         */
        public String CreateProject(int C_ProjectType_ID)
        {
            if (GetC_Project_ID() != 0)
            {
                return("@AlreadyExists@: @C_Project_ID@ (ID=" + GetC_Project_ID() + ")");
            }
            if (GetC_BPartner_ID() == 0)
            {
                String retValue = CreateBP();
                if (retValue != null)
                {
                    return(retValue);
                }
            }
            _project = new MProject(GetCtx(), 0, Get_TrxName());
            _project.SetAD_Org_ID(GetAD_Org_ID());
            _project.SetProjectLineLevel(MProject.PROJECTLINELEVEL_Project);
            _project.SetName(GetName());
            _project.SetDescription(GetDescription());
            _project.SetNote(GetHelp());
            //
            _project.SetC_BPartner_ID(GetC_BPartner_ID());
            _project.SetC_BPartner_Location_ID(GetC_BPartner_Location_ID());
            _project.SetAD_User_ID(GetAD_User_ID());
            _project.SetC_BPartnerSR_ID(GetC_BPartnerSR_ID());
            _project.SetC_Campaign_ID(GetC_Campaign_ID());

            _project.SetC_ProjectType_ID(C_ProjectType_ID);
            _project.SetSalesRep_ID(GetSalesRep_ID());
            _project.SetC_SalesRegion_ID(GetC_SalesRegion_ID());
            if (!_project.Save())
            {
                return("@SaveError@");
            }
            //
            if (GetRequest() != null)
            {
                _request.SetC_Project_ID(_project.GetC_Project_ID());
                _request.Save();
            }
            //
            SetC_Project_ID(_project.GetC_Project_ID());
            return(null);
        }
        /**
         *  Create new Project by copying
         *  @param ctx context
         *	@param C_Project_ID project
         *  @param dateDoc date of the document date
         *	@param trxName transaction
         *	@return Project
         */
        public static MProject CopyFrom(Ctx ctx, int C_Project_ID, DateTime?dateDoc, Trx trxName)
        {
            MProject from = new MProject(ctx, C_Project_ID, trxName);

            if (from.GetC_Project_ID() == 0)
            {
                throw new ArgumentException("From Project not found C_Project_ID=" + C_Project_ID);
            }
            //
            MProject to = new MProject(ctx, 0, trxName);

            PO.CopyValues(from, to, from.GetAD_Client_ID(), from.GetAD_Org_ID());
            to.Set_ValueNoCheck("C_Project_ID", I_ZERO);
            //	Set Value with Time
            String Value  = to.GetValue() + " ";
            String Time   = dateDoc.ToString();
            int    length = Value.Length + Time.Length;

            if (length <= 40)
            {
                Value += Time;
            }
            else
            {
                Value += Time.Substring(length - 40 - 1);
            }
            to.SetValue(Value);
            to.SetInvoicedAmt(Env.ZERO);
            to.SetProjectBalanceAmt(Env.ZERO);
            to.SetProcessed(false);
            //
            if (!to.Save())
            {
                throw new Exception("Could not create Project");
            }

            if (to.CopyDetailsFrom(from) == 0)
            {
                throw new Exception("Could not create Project Details");
            }

            return(to);
        }
        private void UpdateHeader()
        {
            int    projID = 0;
            string isCam  = "";
            string isOpp  = "";
            string Sql    = "SELECT C_Project_ID FROM C_ProjectPhase WHERE C_ProjectPhase_ID in(select C_ProjectPhase_ID FROM" +
                            " C_ProjectTask WHERE C_ProjectTask_ID =" + GetC_ProjectTask_ID() + ")";

            //Used transaction object because total was not updating on header
            projID = Util.GetValueOfInt(DB.ExecuteScalar(Sql, null, Get_TrxName()));

            if (projID != 0)
            {
                //Used transaction object because total was not updating on header
                isOpp = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsOpportunity FROM C_Project WHERE C_Project_ID = " + projID, null, Get_TrxName()));
                isCam = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsCampaign FROM C_Project WHERE C_Project_ID = " + projID, null, Get_TrxName()));
            }
            if (isCam.Equals("Y"))                             // Campaign Window
            {
                //Used transaction object because total was not updating on header
                MProject prj    = new MProject(GetCtx(), projID, null);
                decimal  plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(PlannedAmt),0)  FROM C_ProjectTask WHERE IsActive = 'Y' AND " +
                                                                          "C_ProjectPhase_ID in (SELECT C_ProjectPhase_ID FROM C_ProjectPhase WHERE C_Project_ID = " + projID + ")", null, Get_TrxName()));
                prj.SetPlannedAmt(plnAmt);
                prj.Save();
            }
            //Amit
            else if (isOpp.Equals("N") && isCam.Equals("N"))
            {
                // set sum of total amount of task tab to phase tab, similalary Commitment amount
                MProjectPhase phase = new MProjectPhase(GetCtx(), GetC_ProjectPhase_ID(), Get_TrxName());
                phase.SetPlannedAmt(Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectTask pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectPhase_ID = " + GetC_ProjectPhase_ID(), null, Get_TrxName())));
                phase.SetCommittedAmt(Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.CommittedAmt),0)  FROM C_ProjectTask pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectPhase_ID = " + GetC_ProjectPhase_ID(), null, Get_TrxName())));
                if (!phase.Save())
                {
                }
            }
            //Amit
        }
예제 #16
0
 /// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="project">parent</param>
 public MProjectPhase(MProject project)
     : this(project.GetCtx(), 0, project.Get_TrxName())
 {
     SetClientOrg(project);
     SetC_Project_ID(project.GetC_Project_ID());
 }
예제 #17
0
        }       //	toString

        /// <summary>
        /// Execute Run.
        /// </summary>
        /// <returns>clear text info</returns>
        public String ExecuteRun()
        {
            DateTime?dateDoc = GetDateNextRun();

            if (!CalculateRuns())
            {
                throw new Exception("No Runs Left");
            }
            //	log
            MRecurringRun run = new MRecurringRun(GetCtx(), this);
            String        msg = "@Created@ ";

            //Checked if the Next Date Run is less then the date pressent Arpit on 15th Dec,2016
            if (GetDateNextRun() == DateTime.Now.Date || GetDateNextRun() == null)
            {
                //	Copy
                if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order))
                {
                    MOrder from  = new MOrder(GetCtx(), GetC_Order_ID(), Get_TrxName());
                    MOrder order = MOrder.CopyFrom(from, dateDoc,
                                                   from.GetC_DocType_ID(), false, false, Get_TrxName());
                    run.SetC_Order_ID(order.GetC_Order_ID());
                    msg += order.GetDocumentNo();
                }
                else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice))
                {
                    MInvoice from    = new MInvoice(GetCtx(), GetC_Invoice_ID(), Get_TrxName());
                    MInvoice invoice = MInvoice.CopyFrom(from, dateDoc,
                                                         from.GetC_DocType_ID(), false, Get_TrxName(), false);
                    run.SetC_Invoice_ID(invoice.GetC_Invoice_ID());
                    //Set Invoice Refrence and Description from Orignal to Recurring
                    invoice.Set_Value("InvoiceReference", from.GetDocumentNo() + "_" + (GetRunsMax() - GetRunsRemaining() + 1));
                    invoice.AddDescription(Msg.GetMsg(from.GetCtx(), "RecurringDocument") + from.GetDocumentNo());
                    if (!invoice.Save(Get_TrxName()))
                    {
                        ValueNamePair pp = VLogger.RetrieveError();
                        if (pp != null)
                        {
                            from.SetProcessMsg(Msg.GetMsg(from.GetCtx(), "CouldNotCreateInvoice") + pp.GetName());
                        }
                        else
                        {
                            from.SetProcessMsg(Msg.GetMsg(from.GetCtx(), "CouldNotCreateInvoice"));
                        }
                        throw new Exception(Msg.GetMsg(from.GetCtx(), "CouldNotCreateInvoice") + (pp != null ? pp.GetName() : ""));
                    }
                    msg += invoice.GetDocumentNo();
                }
                else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project))
                {
                    MProject project = MProject.CopyFrom(GetCtx(), GetC_Project_ID(), dateDoc, Get_TrxName());
                    run.SetC_Project_ID(project.GetC_Project_ID());
                    msg += project.GetValue();
                }
                else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournalBatch)) //Changes to GL Journal Batch by Arpit
                {
                    MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), GetGL_JournalBatch_ID(), dateDoc, Get_TrxName());
                    run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID());
                    msg += journal.GetDocumentNo();
                }
                //Added by Arpit on 14th, Dec,2016
                else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal))
                {
                    MJournal Journal = MJournal.CopyFrom(GetCtx(), GetGL_Journal_ID(), dateDoc, Get_TrxName());
                    run.SetGL_Journal_ID(Journal.GetGL_Journal_ID());
                    msg += Journal.GetDocumentNo();
                }

                //End here
                else if (GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Payment))
                {
                    MPayment from    = new MPayment(GetCtx(), GetC_Payment_ID(), Get_TrxName());
                    MPayment payment = MPayment.CopyFrom(from, dateDoc,
                                                         from.GetC_DocType_ID(), Get_TrxName());
                    run.SetC_Payment_ID(payment.GetC_Payment_ID());
                    msg += payment.GetDocumentNo();
                }
                else
                {
                    return("Invalid @RecurringType@ = " + GetRecurringType());
                }
                run.Save(Get_TrxName());

                //
                SetDateLastRun(run.GetUpdated());
                SetRunsRemaining(GetRunsRemaining() - 1);
                SetDateNextRun();
                Save(Get_TrxName());
                return(msg);
            }
            else
            {
                return(Msg.GetMsg(GetCtx(), "RecurringNotCompleted") + String.Format("{0:dd/M/yyyy}", Convert.ToDateTime(GetDateNextRun())));
            }
        }       //	execureRun
        /// <summary>
        /// Update Header
        /// </summary>
        private void UpdateHeader()
        {
            int id     = GetC_ProjectTask_ID();
            int projID = 0;

            if (id == 0)
            {
                projID = GetC_Project_ID();                    // Marketing Campaign Window
            }
            else
            {
                //Used transaction because total was not updating on header
                string Sql = "SELECT C_Project_ID FROM C_ProjectPhase WHERE C_ProjectPhase_ID in(select C_ProjectPhase_ID FROM" +
                             " C_ProjectTask WHERE C_ProjectTask_ID =" + id + ")";
                projID = Util.GetValueOfInt(DB.ExecuteScalar(Sql, null, Get_TrxName()));
            }
            //Used transaction because total was not updating on header
            string sql   = "SELECT IsOpportunity FROM C_Project WHERE C_Project_ID = " + projID;
            string isOpp = Util.GetValueOfString(DB.ExecuteScalar(sql, null, Get_TrxName()));
            //Amit
            string isCam = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsCampaign FROM C_Project WHERE C_Project_ID = " + projID, null, Get_TrxName()));

            if (isOpp.Equals("N") && isCam.Equals("N") && id != 0)
            {
                // set sum of planned Amount from task line to task
                MProjectTask tsk = new MProjectTask(GetCtx(), id, Get_Trx());
                //Used transaction because total was not updating on header
                decimal plannedAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectTask_ID = " + id, null, Get_TrxName()));
                tsk.SetPlannedAmt(plannedAmt);
                tsk.Save();
            }
            //Amit
            else if (isOpp.Equals("N") && isCam.Equals("N") && id == 0 && GetC_ProjectPhase_ID() != 0)
            {
                //Used transaction because total was not updating on header
                MProjectPhase projectPhase = new MProjectPhase(GetCtx(), GetC_ProjectPhase_ID(), Get_TrxName());
                decimal       plnAmt       = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectPhase_ID = " + GetC_ProjectPhase_ID() + " AND pl.C_Project_ID = " + projID, null, Get_TrxName()));
                projectPhase.SetPlannedAmt(plnAmt);
                projectPhase.Save();
            }
            else if (isOpp.Equals("Y"))                             // Opportunity Window
            {
                //Used transaction because total was not updating on header
                MProject prj    = new MProject(GetCtx(), projID, Get_TrxName());
                decimal  plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + projID, null, Get_TrxName()));
                prj.SetPlannedAmt(plnAmt);
                prj.Save();

                if (VAdvantage.Utility.Env.IsModuleInstalled("VA077_"))
                {
                    sql = @"UPDATE C_Project SET VA077_TotalMarginAmt=(SELECT ROUND(Sum(VA077_MarginAmt),2) FROM C_ProjectLine 
                            WHERE C_PROJECT_ID=" + projID + @" AND IsActive='Y'),
                            VA077_TotalPurchaseAmt=(SELECT ROUND(Sum(VA077_PurchaseAmt),2) FROM C_ProjectLine 
                            WHERE C_PROJECT_ID=" + projID + @" AND IsActive='Y'),
                            VA077_MarginPercent=(SELECT CASE WHEN Sum(PlannedAmt) > 0 Then 
                                                 ROUND(((Sum(PlannedAmt)- Sum(NVL(VA077_PurchaseAmt,0)))/Sum(PlannedAmt)*100),2) ELSE 0  END 
                                                 FROM C_ProjectLine WHERE C_PROJECT_ID=" + projID + @" AND IsActive='Y') 
                            WHERE C_Project_ID=" + projID;

                    int no = DB.ExecuteQuery(sql, null, Get_TrxName());
                    if (no != 1)
                    {
                        log.Log(Level.SEVERE, "updateHeader - #" + no);
                    }
                }
            }
            else if (id != 0)
            {
                MProjectTask tsk = new MProjectTask(GetCtx(), id, Get_TrxName());
                //Used transaction because total was not updating on header
                decimal plannedAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectTask_ID = " + id, null, Get_TrxName()));
                tsk.SetPlannedAmt(plannedAmt);
                tsk.Save();
            }
            else
            {
                sql = "UPDATE C_Project p SET " +
                      "PlannedAmt=(SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",PlannedQty=(SELECT COALESCE(SUM(pl.PlannedQty),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",PlannedMarginAmt=(SELECT COALESCE(SUM(pl.PlannedMarginAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",CommittedAmt=(SELECT COALESCE(SUM(pl.CommittedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",CommittedQty=(SELECT COALESCE(SUM(pl.CommittedQty),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",InvoicedAmt=(SELECT COALESCE(SUM(pl.InvoicedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ", InvoicedQty =(SELECT COALESCE(SUM(pl.InvoicedQty),0) FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      " WHERE p.C_Project_ID=" + GetC_Project_ID();
                int no = DB.ExecuteQuery(sql, null, Get_TrxName());

                if (no != 1)
                {
                    log.Log(Level.SEVERE, "updateHeader - #" + no);
                }
            }
        }
        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override bool AfterSave(bool newRecord, bool success)
        {
            PO            project    = null;
            int           _client_ID = 0;
            StringBuilder _sql       = new StringBuilder();

            //_sql.Append("Select count(*) from  ad_table where tablename like 'FRPT_Project_Acct'");
            //_sql.Append("SELECT count(*) FROM all_objects WHERE object_type IN ('TABLE') AND (object_name)  = UPPER('FRPT_Project_Acct')  AND OWNER LIKE '" + DB.GetSchema() + "'");
            _sql.Append(DBFunctionCollection.CheckTableExistence(DB.GetSchema(), "FRPT_Project_Acct"));
            int count = Util.GetValueOfInt(DB.ExecuteScalar(_sql.ToString()));

            if (count > 0)
            {
                _sql.Clear();
                _sql.Append("Select L.Value From Ad_Ref_List L inner join AD_Reference r on R.AD_REFERENCE_ID=L.AD_REFERENCE_ID where r.name='FRPT_RelatedTo' and l.name='Project'");
                var relatedtoProject = Convert.ToString(DB.ExecuteScalar(_sql.ToString()));
                _client_ID = GetAD_Client_ID();
                _sql.Clear();
                _sql.Append("select C_AcctSchema_ID from C_AcctSchema where AD_CLIENT_ID=" + _client_ID);
                DataSet ds3 = new DataSet();
                ds3 = DB.ExecuteDataset(_sql.ToString(), null);
                if (ds3 != null && ds3.Tables[0].Rows.Count > 0)
                {
                    for (int k = 0; k < ds3.Tables[0].Rows.Count; k++)
                    {
                        int _AcctSchema_ID = Util.GetValueOfInt(ds3.Tables[0].Rows[k]["C_AcctSchema_ID"]);
                        _sql.Clear();
                        _sql.Append("Select Frpt_Acctdefault_Id,C_Validcombination_Id,Frpt_Relatedto From Frpt_Acctschema_Default Where ISACTIVE='Y' AND AD_CLIENT_ID=" + _client_ID + "AND C_Acctschema_Id=" + _AcctSchema_ID);
                        DataSet ds = DB.ExecuteDataset(_sql.ToString(), null);
                        if (ds != null && ds.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                string _relatedTo = ds.Tables[0].Rows[i]["Frpt_Relatedto"].ToString();
                                if (_relatedTo != "" && (_relatedTo == relatedtoProject))
                                {
                                    _sql.Clear();
                                    _sql.Append("Select COUNT(*) From C_Project Bp Left Join FRPT_Project_Acct ca On Bp.C_Project_ID=ca.C_Project_ID And ca.Frpt_Acctdefault_Id=" + ds.Tables[0].Rows[i]["FRPT_AcctDefault_ID"] + " WHERE Bp.IsActive='Y' AND Bp.AD_Client_ID=" + _client_ID + " AND ca.C_Validcombination_Id = " + Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Validcombination_Id"]) + " AND Bp.C_Project_ID = " + GetC_Project_ID());
                                    int recordFound = Convert.ToInt32(DB.ExecuteScalar(_sql.ToString(), null, Get_Trx()));
                                    if (recordFound == 0)
                                    {
                                        project = MTable.GetPO(GetCtx(), "FRPT_Project_Acct", 0, null);
                                        project.Set_ValueNoCheck("AD_Org_ID", 0);
                                        project.Set_ValueNoCheck("C_Project_ID", Util.GetValueOfInt(GetC_Project_ID()));
                                        project.Set_ValueNoCheck("FRPT_AcctDefault_ID", Util.GetValueOfInt(ds.Tables[0].Rows[i]["FRPT_AcctDefault_ID"]));
                                        project.Set_ValueNoCheck("C_ValidCombination_ID", Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Validcombination_Id"]));
                                        project.Set_ValueNoCheck("C_AcctSchema_ID", _AcctSchema_ID);
                                        if (!project.Save())
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (newRecord & success && (String.IsNullOrEmpty(GetCtx().GetContext("#DEFAULT_ACCOUNTING_APPLICABLE")) || Util.GetValueOfString(GetCtx().GetContext("#DEFAULT_ACCOUNTING_APPLICABLE")) == "Y"))
            {
                bool sucs = Insert_Accounting("C_Project_Acct", "C_AcctSchema_Default", null);
                //Karan. work done to show message if data not saved in accounting tab. but will save data in current tab.
                // Before this, data was being saved but giving message "record not saved".
                if (!sucs)
                {
                    log.SaveWarning("AcctNotSaved", "");
                }
            }

            //	Value/Name change
            MProject prjph = null;

            if (success && !newRecord &&
                (Is_ValueChanged("Value") || Is_ValueChanged("Name")))
            {
                MAccount.UpdateValueDescription(GetCtx(), "C_Project_ID=" + GetC_Project_ID(), Get_TrxName());
            }
            if (GetC_Campaign_ID() != 0)
            {
                //Used transaction because total was not updating on header
                MCampaign cam    = new MCampaign(GetCtx(), GetC_Campaign_ID(), Get_TrxName());
                decimal   plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_Project pl WHERE pl.IsActive = 'Y' AND pl.C_Campaign_ID = " + GetC_Campaign_ID(), null, Get_TrxName()));
                cam.SetCosts(plnAmt);
                cam.Save();
            }
            else
            {
                //Used transaction because total was not updating on header
                prjph = new MProject(GetCtx(), GetC_Project_ID(), Get_TrxName());
                if (!prjph.IsOpportunity())
                {
                    //Used transaction because total was not updating on header
                    decimal plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(PlannedAmt),0) FROM C_ProjectPhase WHERE IsActive= 'Y' AND C_Project_ID= " + GetC_Project_ID(), null, Get_TrxName()));
                    DB.ExecuteQuery("UPDATE C_Project SET PlannedAmt=" + plnAmt + " WHERE C_Project_ID=" + GetC_Project_ID(), null, Get_TrxName());
                }
            }
            return(success);
        }
예제 #20
0
        /// <summary>
        /// Update Header
        /// </summary>
        private void UpdateHeader()
        {
            int id     = GetC_ProjectTask_ID();
            int projID = 0;

            if (id == 0)
            {
                projID = GetC_Project_ID();                    // Marketing Campaign Window
            }
            else
            {
                string Sql = "SELECT C_Project_ID FROM C_ProjectPhase WHERE C_ProjectPhase_ID in(select C_ProjectPhase_ID FROM" +
                             " C_ProjectTask WHERE C_ProjectTask_ID =" + id + ")";
                projID = Util.GetValueOfInt(DB.ExecuteScalar(Sql, null, null));
            }
            string sql   = "SELECT IsOpportunity FROM C_Project WHERE C_Project_ID = " + projID;
            string isOpp = Util.GetValueOfString(DB.ExecuteScalar(sql, null, null));
            //Amit
            string isCam = Util.GetValueOfString(DB.ExecuteScalar("SELECT IsCampaign FROM C_Project WHERE C_Project_ID = " + projID));

            if (isOpp.Equals("N") && isCam.Equals("N") && id != 0)
            {
                // set sum of planned Amount from task line to task
                MProjectTask tsk        = new MProjectTask(GetCtx(), id, Get_Trx());
                decimal      plannedAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectTask_ID = " + id));
                tsk.SetPlannedAmt(plannedAmt);
                tsk.Save();
            }
            //Amit
            else if (isOpp.Equals("N") && isCam.Equals("N") && id == 0 && GetC_ProjectPhase_ID() != 0)
            {
                MProjectPhase projectPhase = new MProjectPhase(GetCtx(), GetC_ProjectPhase_ID(), null);
                decimal       plnAmt       = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectPhase_ID = " + GetC_ProjectPhase_ID() + " AND pl.C_Project_ID = " + projID));
                projectPhase.SetPlannedAmt(plnAmt);
                projectPhase.Save();
            }
            else if (isOpp.Equals("Y"))                             // Opportunity Window
            {
                MProject prj    = new MProject(GetCtx(), projID, Get_TrxName());
                decimal  plnAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + projID));
                prj.SetPlannedAmt(plnAmt);
                prj.Save();
            }
            else if (id != 0)
            {
                MProjectTask tsk        = new MProjectTask(GetCtx(), id, Get_TrxName());
                decimal      plannedAmt = Util.GetValueOfDecimal(DB.ExecuteScalar("SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_ProjectTask_ID = " + id));
                tsk.SetPlannedAmt(plannedAmt);
                tsk.Save();
            }
            else
            {
                sql = "UPDATE C_Project p SET " +
                      "PlannedAmt=(SELECT COALESCE(SUM(pl.PlannedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",PlannedQty=(SELECT COALESCE(SUM(pl.PlannedQty),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",PlannedMarginAmt=(SELECT COALESCE(SUM(pl.PlannedMarginAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",CommittedAmt=(SELECT COALESCE(SUM(pl.CommittedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",CommittedQty=(SELECT COALESCE(SUM(pl.CommittedQty),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ",InvoicedAmt=(SELECT COALESCE(SUM(pl.InvoicedAmt),0)  FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      ", InvoicedQty =(SELECT COALESCE(SUM(pl.InvoicedQty),0) FROM C_ProjectLine pl WHERE pl.IsActive = 'Y' AND pl.C_Project_ID = " + GetC_Project_ID() + ")" +
                      " WHERE p.C_Project_ID=" + GetC_Project_ID();
                int no = DB.ExecuteQuery(sql, null, Get_TrxName());

                if (no != 1)
                {
                    log.Log(Level.SEVERE, "updateHeader - #" + no);
                }
            }
        }
        /// <summary>
        /// To copy details from one project to another
        /// </summary>
        /// <param name="fromProject">From Project</param>
        /// <param name="toProject">To Project</param>
        /// <returns>No Of Lines copied</returns>
        public int CopyDetailsFrom(MProject fromProject, MProject toProject)
        {
            if (IsProcessed() || fromProject == null || toProject == null)
            {
                return(0);
            }
            int count = 0; ValueNamePair pp = null; StringBuilder msg = new StringBuilder();

            #region create lines for project
            if (toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_Project))
            {
                MProjectLine[] fromLines = fromProject.GetLines();
                MProjectLine   line      = null;
                for (int i = 0; i < fromLines.Length; i++)
                {
                    line = new MProjectLine(GetCtx(), 0, fromProject.Get_TrxName());
                    PO.CopyValues(fromLines[i], line, GetAD_Client_ID(), GetAD_Org_ID());
                    line.SetC_Project_ID(toProject.GetC_Project_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())
                    {
                        count++;
                    }
                    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());
                        }
                    }
                }
            }
            #endregion

            if (toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_Phase) || toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_Task) ||
                toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_TaskLine))
            {
                #region if project line level is Project then create lines for phase only
                MProjectPhase[]     myPhases = GetPhases();
                MProjectPhase[]     fromPhases = fromProject.GetPhases();
                int                 C_Phase_ID = 0; bool exists = false;
                MProjectPhase       toPhase   = null;
                MProjectLine[]      fromLines = null;
                List <MProjectLine> list      = null;
                //	Copy Phases
                for (int i = 0; i < fromPhases.Length; i++)
                {
                    //	Check if Phase already exists
                    C_Phase_ID = fromPhases[i].GetC_Phase_ID();
                    exists     = false;
                    if (C_Phase_ID == 0)
                    {
                        exists = false;
                    }
                    else
                    {
                        for (int ii = 0; ii < myPhases.Length; ii++)
                        {
                            if (myPhases[ii].GetC_Phase_ID() == C_Phase_ID)
                            {
                                exists = true;
                                break;
                            }
                        }
                    }
                    //	Phase exist
                    if (exists)
                    {
                        log.Info("Phase already exists here, ignored - " + fromPhases[i]);
                    }
                    else
                    {
                        toPhase = new MProjectPhase(GetCtx(), 0, Get_TrxName());
                        PO.CopyValues(fromPhases[i], toPhase, GetAD_Client_ID(), GetAD_Org_ID());
                        toPhase.SetC_Project_ID(toProject.GetC_Project_ID());
                        toPhase.SetC_Order_ID(0);
                        toPhase.SetIsComplete(false);
                        if (toPhase.Save())
                        {
                            count++;
                            if (toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_Task) || toProject.GetProjectLineLevel().Equals(PROJECTLINELEVEL_TaskLine))
                            {
                                toPhase.CopyTasksFrom(fromPhases[i], toPhase);
                            }
                            else
                            {
                                DataSet projDs = DB.ExecuteDataset(" SELECT C_ProjectLine_ID FROM C_ProjectLine WHERE " +
                                                                   " C_ProjectPhase_ID=" + fromPhases[i].GetC_ProjectPhase_ID() + " AND " +
                                                                   " C_Project_ID = " + fromPhases[i].GetC_Project_ID() + " ORDER BY Line ");

                                if (projDs != null && projDs.Tables[0].Rows.Count > 0)
                                {
                                    list = new List <MProjectLine>();
                                    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)
                                {
                                    MProjectLine line = null;
                                    for (int j = 0; j < fromLines.Length; j++)
                                    {
                                        line = new MProjectLine(GetCtx(), 0, fromProject.Get_TrxName());
                                        PO.CopyValues(fromLines[j], line, GetAD_Client_ID(), GetAD_Org_ID());
                                        line.SetC_Project_ID(toProject.GetC_Project_ID());
                                        line.SetC_ProjectPhase_ID(toPhase.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())
                                        {
                                            count++;
                                        }
                                        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());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        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());
                            }
                        }
                    }
                }
                #endregion
            }



            //    count = CopyLinesFrom(fromProject)
            //+ CopyPhasesFrom(fromProject);
            return(count);
        }