}       //	prepare

        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message (clear text)</returns>
        protected override String DoIt()
        {
            int To_C_Project_ID = GetRecord_ID();

            log.Info("doIt - From C_Project_ID=" + _C_Project_ID + " to " + To_C_Project_ID);
            if (To_C_Project_ID == 0)
            {
                throw new ArgumentException("Target C_Project_ID == 0");
            }
            if (_C_Project_ID == 0)
            {
                throw new ArgumentException("Source C_Project_ID == 0");
            }
            VAdvantage.Model.MProject from = new VAdvantage.Model.MProject(GetCtx(), _C_Project_ID, Get_Trx());
            VAdvantage.Model.MProject to   = new VAdvantage.Model.MProject(GetCtx(), To_C_Project_ID, Get_Trx());
            //
            int no = to.CopyDetailsFrom(from);

            return("@Copied@=" + no);
        } //	doIt
Beispiel #2
0
        }   //	prepare

        /// <summary>
        /// Perrform Process.
        /// </summary>
        /// <returns>Message (clear text)</returns>
        protected override String DoIt()
        {
            int To_C_Project_ID = GetRecord_ID();

            log.Info("doIt - From C_Project_ID=" + _C_Project_ID + " to " + To_C_Project_ID);
            if (To_C_Project_ID == 0)
            {
                throw new ArgumentException("Target C_Project_ID == 0");
            }
            if (_C_Project_ID == 0)
            {
                throw new ArgumentException("Source C_Project_ID == 0");
            }
            VAdvantage.Model.MProject from = new VAdvantage.Model.MProject(GetCtx(), _C_Project_ID, Get_Trx());
            VAdvantage.Model.MProject to   = new VAdvantage.Model.MProject(GetCtx(), To_C_Project_ID, Get_Trx());
            //comented because that was not working with project line level
            //int no = to.CopyDetailsFrom (from);
            // New function created it will work with project Line Level and copy lines in  New Project
            int no = to.CopyDetailsFrom(from, to);

            return("@Copied@=" + no);
        } //	doIt
Beispiel #3
0
        protected override string DoIt()
        {
            // Int32 value = 0;
            string msg = "";

            log.Info("C_Project_ID=" + _C_Project_ID);
            if (_C_Project_ID == 0)
            {
                throw new ArgumentException("C_Project_ID == 0");
            }

            VAdvantage.Model.MProject fromProject = new VAdvantage.Model.MProject(GetCtx(), _C_Project_ID, null);

            if (fromProject.GetGenerate_Quotation() == null)
            {
                throw new ArgumentException("No Generate Quotation found on Project.");
            }
            if (fromProject.GetGenerate_Quotation().Trim() == "Y")
            {
                throw new ArgumentException("Sales Quotation already generated");
            }
            VAdvantage.Model.MOrder order = new VAdvantage.Model.MOrder(GetCtx(), 0, null);
            C_Bpartner_id          = fromProject.GetC_BPartner_ID();
            C_Bpartner_Location_id = fromProject.GetC_BPartner_Location_ID();
            C_BPartnerSR_ID        = fromProject.GetC_BPartnerSR_ID();
            //MBPartner bp = new MBPartner(GetCtx(), C_Bpartner_id, null);
            VAdvantage.Model.MBPartnerLocation bpartnerloc = new VAdvantage.Model.MBPartnerLocation(GetCtx(), C_Bpartner_Location_id, null);
            String currentdate = DateTime.Now.ToString();
            String sqlprjln    = " select c_projectline_id from c_projectline where c_project_id=" + _C_Project_ID + "";

            C_ProjectLine_ID = VAdvantage.Utility.Util.GetValueOfInt(DB.ExecuteScalar(sqlprjln));
            if (C_ProjectLine_ID != 0)
            {
                order.SetDateOrdered(Convert.ToDateTime(currentdate));
                order.SetDatePromised(Convert.ToDateTime(currentdate));
                if (C_Bpartner_id != 0)
                {
                    order.SetC_BPartner_ID(fromProject.GetC_BPartner_ID());
                    if (bpartnerloc.IsShipTo() == true)
                    {
                        order.SetC_BPartner_Location_ID(fromProject.GetC_BPartner_Location_ID());
                        order.SetAD_User_ID(fromProject.GetAD_User_ID());
                    }
                    if (bpartnerloc.IsBillTo() == true)
                    {
                        order.SetBill_Location_ID(fromProject.GetC_BPartner_Location_ID());
                        order.SetBill_User_ID(fromProject.GetAD_User_ID());
                    }
                }
                if (C_BPartnerSR_ID != 0)
                {
                    //String sqlcust = "update c_bpartner set iscustomer='Y', isprospect='N' where c_bpartner_id=" + C_BPartnerSR_ID + "";
                    //value = DB.ExecuteQuery(sqlcust, null, null);
                    //if (value == -1)
                    //{

                    //}
                    //bp.SetIsCustomer(true);
                    //bp.SetIsProspect(false);

                    order.SetC_BPartner_ID(fromProject.GetC_BPartnerSR_ID());
                    if (bpartnerloc.IsShipTo() == true)
                    {
                        order.SetC_BPartner_Location_ID(fromProject.GetC_BPartner_Location_ID());
                        order.SetAD_User_ID(fromProject.GetAD_User_ID());
                    }
                    if (bpartnerloc.IsBillTo() == true)
                    {
                        order.SetBill_Location_ID(fromProject.GetC_BPartner_Location_ID());
                        order.SetBill_User_ID(fromProject.GetAD_User_ID());
                    }
                }
                // String sql = "select c_doctype_id from c_doctype where docbasetype= 'SOO' and  = 'Sales Quotation'";
                String sql           = "select c_doctype_id from c_doctype where docbasetype = 'SOO' and docsubtypeso = 'ON' and isreturntrx = 'N' and ad_client_id = " + GetCtx().GetAD_Client_ID();
                int    Doctype_id    = VAdvantage.Utility.Util.GetValueOfInt(DB.ExecuteScalar(sql));
                int    MPriceList_id = Util.GetValueOfInt(fromProject.GetM_PriceList_ID());
                order.SetM_PriceList_ID(MPriceList_id);
                ////String sqlmpricelist = "select m_pricelist_id from m_pricelist where name='Export'";
                ////int MPriceList_id = VAdvantage.Utility.Util.GetValueOfInt(DB.ExecuteScalar(sqlmpricelist));
                //if (MPriceList_id == order.GetM_PriceList_ID())
                //{
                //    String sqlconversiontype = "select c_conversiontype_id from c_conversiontype where value = 'C'";
                //    int C_ConversionType_id = VAdvantage.Utility.Util.GetValueOfInt(DB.ExecuteScalar(sqlconversiontype));
                //    order.SetC_ConversionType_ID(C_ConversionType_id);
                //}
                order.SetC_Project_ID(GetRecord_ID());
                if (fromProject.GetSalesRep_ID() > 0)
                {
                    order.SetSalesRep_ID(fromProject.GetSalesRep_ID());
                }
                order.SetC_Currency_ID(fromProject.GetC_Currency_ID());
                if (C_Bpartner_id != 0)
                {
                    VAdvantage.Model.MBPartner bp = new VAdvantage.Model.MBPartner(GetCtx(), C_Bpartner_id, null);
                    if (bp.GetC_Campaign_ID() == 0 && fromProject.GetC_Campaign_ID() > 0)
                    {
                        bp.SetC_Campaign_ID(fromProject.GetC_Campaign_ID());
                    }
                    bp.SetAD_Client_ID(fromProject.GetAD_Client_ID());
                    bp.SetAD_Org_ID(fromProject.GetAD_Org_ID());
                    if (bp.GetC_PaymentTerm_ID() != 0)
                    {
                        order.SetPaymentMethod(bp.GetPaymentRule());
                        order.SetC_PaymentTerm_ID(bp.GetC_PaymentTerm_ID());
                    }

                    if (!bp.Save())
                    {
                        log.SaveError("CampaignIDNotSaved", "");
                        return(Msg.GetMsg(GetCtx(), "CampaignIDtNotSaved"));
                    }
                }
                else
                {
                    VAdvantage.Model.MBPartner bp = new VAdvantage.Model.MBPartner(GetCtx(), C_BPartnerSR_ID, null);
                    if (bp.GetC_Campaign_ID() == 0 && fromProject.GetC_Campaign_ID() > 0)
                    {
                        bp.SetC_Campaign_ID(fromProject.GetC_Campaign_ID());
                    }
                    bp.SetAD_Client_ID(fromProject.GetAD_Client_ID());
                    bp.SetAD_Org_ID(fromProject.GetAD_Org_ID());
                    if (bp.GetC_PaymentTerm_ID() != 0)
                    {
                        order.SetPaymentMethod(bp.GetPaymentRule());
                        order.SetC_PaymentTerm_ID(bp.GetC_PaymentTerm_ID());
                    }

                    if (!bp.Save())
                    {
                        log.SaveError("CampaignIDtNotSaved", "");
                        return(Msg.GetMsg(GetCtx(), "CampaignIDtNotSaved"));
                    }
                }
                //if (bp.GetC_PaymentTerm_ID() != 0)
                //{
                //    order.SetPaymentMethod(bp.GetPaymentRule());
                //    order.SetC_PaymentTerm_ID(bp.GetC_PaymentTerm_ID());

                //}
                order.SetFreightCostRule("I");
                if (order.GetC_Campaign_ID() == 0 && fromProject.GetC_Campaign_ID() > 0)
                {
                    order.SetC_Campaign_ID(fromProject.GetC_Campaign_ID());
                }
                order.SetDocStatus("IP");
                order.SetC_DocType_ID(Doctype_id);
                order.SetC_DocTypeTarget_ID(Doctype_id);
                order.SetIsSOTrx(true);
                if (!order.Save())
                {
                    log.SaveError("SaleOrdertNotSaved", "");
                    return(Msg.GetMsg(GetCtx(), "SaleOrdertNotSaved"));
                }
                //Order Lines
                int count = 0;
                VAdvantage.Model.MProjectLine[] lines = fromProject.GetLines();
                for (int i = 0; i < lines.Length; i++)
                {
                    VAdvantage.Model.MOrderLine ol = new VAdvantage.Model.MOrderLine(order);
                    ol.SetLine(lines[i].GetLine());
                    ol.SetDescription(lines[i].GetDescription());
                    ol.SetM_Product_ID(lines[i].GetM_Product_ID(), true);
                    ol.SetQtyEntered(lines[i].GetPlannedQty());
                    ol.SetQtyOrdered(lines[i].GetPlannedQty());
                    ol.SetPriceEntered(lines[i].GetPlannedPrice());
                    ol.SetPriceActual(lines[i].GetPlannedPrice());
                    ol.SetPriceList(lines[i].GetPriceList());
                    if (ol.Save())
                    {
                        count++;
                    }
                }

                fromProject.SetRef_Order_ID(order.GetC_Order_ID());
                fromProject.SetGenerate_Quotation("Y");
                if (!fromProject.Save())
                {
                    log.SaveError("ProjectNotSaved", "");
                    return(Msg.GetMsg(GetCtx(), "ProjectNotSaved"));;
                }
                msg = Msg.GetMsg(GetCtx(), "QuotationGenerated");
            }
            else
            {
                msg = Msg.GetMsg(GetCtx(), "No Lines");
            }
            return(msg);
        }
Beispiel #4
0
        }       //	prepare

        protected override String DoIt()
        {
            //String msg = "";
            _C_Campaign_ID = GetRecord_ID();
            VAdvantage.Model.MCampaign Campaign = new VAdvantage.Model.MCampaign(GetCtx(), _C_Campaign_ID, Get_TrxName());
            //C_ProjectType_ID = Campaign.GetC_ProjectType_ID();
            C_CampaignType_ID = Campaign.GetC_CampaignType_ID();
            VAdvantage.Model.MCampaignType CampaignType = new VAdvantage.Model.MCampaignType(GetCtx(), C_CampaignType_ID, Get_TrxName());
            //MProjectType type = new MProjectType(GetCtx(), C_ProjectType_ID, Get_TrxName());
            VAdvantage.Model.MProject       Project       = new VAdvantage.Model.MProject(GetCtx(), 0, Get_TrxName());
            VAdvantage.Model.MCampaignPhase CampaignPhase = new VAdvantage.Model.MCampaignPhase(GetCtx(), 0, Get_TrxName());


            // MPhase Phase = new MPhase(GetCtx(), 0, Get_TrxName());
            VAdvantage.Model.MProjectTypeTask task = new VAdvantage.Model.MProjectTypeTask(GetCtx(), 0, Get_TrxName());

            Project.SetName(CampaignType.GetName());
            Project.SetC_Campaign_ID(GetRecord_ID());
            Project.SetSalesRep_ID(GetAD_User_ID());
            Project.SetDateContract(Campaign.GetStartDate());
            Project.SetDateFinish(Campaign.GetEndDate());
            Project.SetSalesRep_ID(Campaign.GetSalesRep_ID());
            Project.SetAD_Client_ID(CampaignType.GetAD_Client_ID());
            Project.SetAD_Org_ID(CampaignType.GetAD_Org_ID());
            Project.SetIsCampaign(true);

            if (!Project.Save(Get_TrxName()))
            {
                return(GetRetrievedError(Project, "CampaignNotSaved"));
                //log.SaveError("CampaignNotSaved", "");
                //return Msg.GetMsg(GetCtx(), "CampaignNotSaved");
            }
            int[] allids = VAdvantage.Model.X_C_CampaignPhase.GetAllIDs("C_CampaignPhase", "C_CampaignType_ID=" + C_CampaignType_ID + " and AD_Client_ID = " + GetAD_Client_ID() + " Order By SEQNO ", Get_TrxName());
            //int[] allids = X_C_Phase.GetAllIDs("C_Phase", "C_ProjectType_ID=" + C_ProjectType_ID, Get_TrxName());
            for (int i = 0; i < allids.Length; i++)
            {
                VAdvantage.Model.X_C_CampaignPhase CampPhase = new VAdvantage.Model.X_C_CampaignPhase(GetCtx(), allids[i], Get_TrxName());
                //X_C_Phase Phase1 = new X_C_Phase(GetCtx(), allids[i], Get_TrxName());
                int C_CampaignPhase_ID = CampPhase.GetC_CampaignPhase_ID();
                //  int C_Phase_ID = Phase1.GetC_Phase_ID();
                if (C_CampaignPhase_ID != 0)
                {
                    VAdvantage.Model.MProjectPhase ProjectPhase = new VAdvantage.Model.MProjectPhase(GetCtx(), 0, Get_TrxName());
                    //ProjectPhase.SetAD_Client_ID(Phase1.GetAD_Client_ID());
                    ProjectPhase.SetAD_Client_ID(CampPhase.GetAD_Client_ID());
                    //ProjectPhase.SetAD_Org_ID(Phase1.GetAD_Org_ID());
                    ProjectPhase.SetAD_Org_ID(CampPhase.GetAD_Org_ID());
                    ProjectPhase.SetC_Project_ID(Project.GetC_Project_ID());
                    //ProjectPhase.SetName(Phase1.GetName());
                    ProjectPhase.SetName(CampPhase.GetName());
                    // ProjectPhase.SetM_Product_ID(Phase1.GetM_Product_ID());
                    //ProjectPhase.SetM_Product_ID(CampPhase.GetM_Product_ID());
                    // ProjectPhase.SetQty(Phase1.GetStandardQty());
                    //ProjectPhase.SetQty(CampPhase.GetStandardQty());
                    //ProjectPhase.SetC_Phase_ID(Phase1.GetC_Phase_ID());
                    //ProjectPhase.SetC_Phase_ID(CampPhase.GetC_CampaignPhase_ID());
                    ProjectPhase.SetC_Project_ID(Project.GetC_Project_ID());
                    if (!ProjectPhase.Save(Get_TrxName()))
                    {
                        return(GetRetrievedError(ProjectPhase, "CampaignPhasetNotSaved"));
                        //log.SaveError("CampaignPhasetNotSaved", "");
                        //return Msg.GetMsg(GetCtx(), "CampaignPhasetNotSaved");
                    }
                    int[] allids1 = VAdvantage.Model.X_C_CampaignTask.GetAllIDs("C_CampaignTask", "C_CampaignPhase_ID=" + C_CampaignPhase_ID + " and AD_Client_ID = " + GetAD_Client_ID() + " Order By SEQNO ", Get_TrxName());
                    //int[] allids1 = X_C_Task.GetAllIDs("C_Task", "C_Phase_ID=" + C_Phase_ID, Get_TrxName());
                    for (int j = 0; j < allids1.Length; j++)
                    {
                        VAdvantage.Model.X_C_CampaignTask CampaignTask = new VAdvantage.Model.X_C_CampaignTask(GetCtx(), allids1[j], Get_TrxName());
                        //X_C_Task task1 = new X_C_Task(GetCtx(), allids1[j], Get_TrxName());
                        int C_CampaignTask_ID = CampaignTask.GetC_CampaignTask_ID();
                        //int C_Task_ID = task1.GetC_Task_ID();
                        if (C_CampaignTask_ID != 0)
                        {
                            VAdvantage.Model.MProjectTask ProjectTask = new VAdvantage.Model.MProjectTask(GetCtx(), 0, Get_TrxName());
                            //ProjectTask.SetAD_Client_ID(task1.GetAD_Client_ID());
                            //  ProjectTask.SetAD_Client_ID(CampaignTask.GetAD_Client_ID());
                            // ProjectTask.SetAD_Client_ID(task1.GetAD_Client_ID());
                            //  ProjectTask.SetAD_Org_ID(CampaignTask.GetAD_Client_ID());
                            ProjectTask.SetC_ProjectPhase_ID(ProjectPhase.GetC_ProjectPhase_ID());
                            //ProjectTask.SetName(task1.GetName());
                            ProjectTask.SetName(CampaignTask.GetName());
                            // ProjectTask.SetM_Product_ID(task1.GetM_Product_ID());
                            //ProjectTask.SetM_Product_ID(CampaignTask.GetM_Product_ID());
                            // ProjectTask.SetQty(task1.GetStandardQty());
                            //ProjectTask.SetQty(CampaignTask.GetStandardQty());
                            //ProjectTask.SetC_Task_ID(task1.GetC_Task_ID());
                            ProjectTask.SetC_ProjectTask_ID(ProjectPhase.GetC_ProjectPhase_ID());
                            //ProjectTask.SetC_Task_ID(ProjectPhase.GetC_ProjectPhase_ID());
                            // ProjectTask.SetC_Task_ID(CampaignTask.GetC_CampaignTask_ID());
                            string SQL   = "SELECT COALESCE(MAX(SeqNo),0)+10 AS DefaultValue FROM C_ProjectTask WHERE C_ProjectPhase_ID=" + ProjectPhase.GetC_ProjectPhase_ID();
                            object SeqNo = DB.ExecuteScalar(SQL, null, Get_TrxName());
                            ProjectTask.SetSeqNo(Util.GetValueOfInt(SeqNo));
                            if (!ProjectTask.Save(Get_TrxName()))
                            {
                                return(GetRetrievedError(ProjectTask, "CampaignTasktNotSaved"));

                                //log.SaveError("CampaignTasktNotSaved", "");
                                //return Msg.GetMsg(GetCtx(), "CampaignTasktNotSaved");
                            }
                        }
                    }
                }
            }
            Campaign.SetGenerateProject("Y");
            if (!Campaign.Save(Get_TrxName()))
            {
                return(GetRetrievedError(Campaign, "CampaignNotSaved"));
                //log.SaveError("CampaignNotSaved", "");
                //return Msg.GetMsg(GetCtx(), "CampaignNotSaved");
            }

            return(Msg.GetMsg(GetCtx(), "PlanningGenerationDone"));
        }