Beispiel #1
0
        protected override String DoIt()
        {
            string      Sql = "Select C_Lead_ID From C_Lead where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID();
            IDataReader dr  = DB.ExecuteReader(Sql);

            try
            {
                while (dr.Read())
                {
                    VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), null);
                    lead.SetSalesRep_ID(ToSalesRep_ID);
                    lead.Save();
                    {
                    }
                }

                dr.Close();

                Sql = "Select C_Project_ID From C_Project where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID();
                dr  = DB.ExecuteReader(Sql);
                while (dr.Read())
                {
                    VAdvantage.Model.X_C_Project Project = new VAdvantage.Model.X_C_Project(GetCtx(), Util.GetValueOfInt(dr[0]), null);
                    Project.SetSalesRep_ID(ToSalesRep_ID);
                    Project.Save();
                    {
                    }
                }
                dr.Close();

                Sql = "Select C_BPartner_ID From C_BPartner where SalesRep_ID=" + FromSalesRep_ID + " and isactive='Y' and Ad_Org_id=" + GetCtx().GetAD_Org_ID();
                dr  = DB.ExecuteReader(Sql);
                while (dr.Read())
                {
                    VAdvantage.Model.X_C_BPartner BP = new VAdvantage.Model.X_C_BPartner(GetCtx(), Util.GetValueOfInt(dr[0]), null);
                    BP.SetSalesRep_ID(ToSalesRep_ID);
                    BP.Save();
                    {
                    }
                }
                dr.Close();
                return(Msg.GetMsg(GetCtx(), "RecordsTransferedSuccessfully"));;
            }
            catch
            {
                if (dr != null)
                {
                    dr.Close();
                }
                return(Msg.GetMsg(GetCtx(), "RecordsnotTransfered"));;
            }
        }
Beispiel #2
0
        protected override String DoIt()
        {
            string sql          = "Select ad_table_id from ad_table where tablename='C_Lead'";
            int    leadTable_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql));

            sql = "Select ad_table_id from ad_table where tablename='C_BPartner'";
            int BPartnerTable_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql));

            VAdvantage.Model.X_C_TargetList TList = new VAdvantage.Model.X_C_TargetList(GetCtx(), 0, null);

            if (Table_id == leadTable_ID)// C_Lead
            {
                VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Record_ID, null);

                TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id);
                // TList.SetC_MasterTargetList_ID(Campaign_id);
                TList.SetC_Lead_ID(Record_ID);
                TList.SetAddress1(lead.GetAddress1());
                TList.SetAddress2(lead.GetAddress2());
                TList.SetC_City_ID(lead.GetC_City_ID());
                TList.SetCity(lead.GetCity());
                TList.SetC_Region_ID(lead.GetC_Region_ID());
                TList.SetRegionName(lead.GetRegionName());
                TList.SetC_Country_ID(lead.GetC_Country_ID());
                TList.SetPostal(lead.GetPostal());


                if (TList.Save())
                {
                    return(Msg.GetMsg(GetCtx(), "TargetListCreate"));
                }
                return(Msg.GetMsg(GetCtx(), "TargetListNotCreate"));
            }

            if (Table_id == BPartnerTable_ID) // C_BPartner
            {
                string Query = "select isprospect from c_bpartner where c_bpartner_id=" + Record_ID;
                string P     = Util.GetValueOfString(DB.ExecuteScalar(Query));
                if (P == "Y")
                {
                    // TList.SetC_MasterTargetList_ID(Campaign_id);
                    TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id);
                    TList.SetRef_BPartner_ID(Record_ID);
                    sql = "Select C_Location_id from c_bpartner_Location where c_bpartner_id=" + Record_ID;
                    object locID = DB.ExecuteScalar(sql);
                    TList.SetC_Location_ID(Util.GetValueOfInt(locID));
                }
                else
                {
                    Query = "select iscustomer from c_bpartner where c_bpartner_id=" + Record_ID;
                    P     = Util.GetValueOfString(DB.ExecuteScalar(Query));
                    if (P == "Y")
                    {
                        //TList.SetC_MasterTargetList_ID(Campaign_id);
                        TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id);
                        TList.SetC_BPartner_ID(Record_ID);
                        sql = "Select C_Location_id from c_bpartner_Location where c_bpartner_id=" + Record_ID;
                        object locID = DB.ExecuteScalar(sql);
                        TList.SetC_Location_ID(Util.GetValueOfInt(locID));
                    }
                    else
                    {
                        return(Msg.GetMsg(GetCtx(), "TargetListNotCreate"));
                    }
                }
                if (TList.Save())
                {
                    return(Msg.GetMsg(GetCtx(), "TargetListCreate"));
                }

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


            return(Msg.GetMsg(GetCtx(), "TargetListCreate"));
        }
Beispiel #3
0
        protected override String DoIt()
        {
            VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_Trx());
            if (!(R_InterestArea_ID > 0))
            {
                return(Msg.GetMsg(GetCtx(), "NoInterestAreaIsSelected"));
            }

            if (lead.GetC_BPartner_ID() != 0)
            {
                VAdvantage.Model.X_R_ContactInterest customer = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx());
                customer.SetR_InterestArea_ID(R_InterestArea_ID);
                customer.SetC_BPartner_ID(lead.GetC_BPartner_ID());
                String query  = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetC_BPartner_ID();
                int    UserId = Util.GetValueOfInt(DB.ExecuteScalar(query));
                customer.SetAD_User_ID(UserId);
                query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetC_BPartner_ID();

                int Id = Util.GetValueOfInt(DB.ExecuteScalar(query));
                VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx());
                customer.SetC_BPartner_Location_ID(Id);
                customer.SetPhone(loc.GetPhone());
                customer.SetFax(loc.GetFax());

                VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx());
                customer.SetC_Job_ID(us.GetC_Job_ID());
                customer.SetSubscribeDate(DateTime.Today);
                query = "Select Email from ad_user where ad_user_id= " + UserId;
                String mail = Util.GetValueOfString(DB.ExecuteScalar(query));
                customer.SetEMail(mail);
                if (!customer.Save())
                {
                    return(Msg.GetMsg(GetCtx(), "NotSubscribed"));
                }
                lead.SetR_InterestArea_ID(customer.GetR_InterestArea_ID());
                if (lead.Save())
                {
                }
                return(Msg.GetMsg(GetCtx(), "SubscribedDone"));
            }
            else if (lead.GetRef_BPartner_ID() != 0)
            {
                VAdvantage.Model.X_R_ContactInterest Prospect = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx());
                Prospect.SetR_InterestArea_ID(R_InterestArea_ID);
                Prospect.SetC_BPartner_ID(lead.GetRef_BPartner_ID());
                String query  = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetRef_BPartner_ID();
                int    UserId = Util.GetValueOfInt(DB.ExecuteScalar(query));
                Prospect.SetAD_User_ID(UserId);
                query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetRef_BPartner_ID();

                int Id = Util.GetValueOfInt(DB.ExecuteScalar(query));
                VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx());
                Prospect.SetC_BPartner_Location_ID(Id);
                Prospect.SetPhone(loc.GetPhone());
                Prospect.SetFax(loc.GetFax());

                VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx());
                Prospect.SetC_Job_ID(us.GetC_Job_ID());
                Prospect.SetSubscribeDate(DateTime.Today);
                query = "Select Email from ad_user where ad_user_id= " + UserId;
                String mail = Util.GetValueOfString(DB.ExecuteScalar(query));
                Prospect.SetEMail(mail);
                if (!Prospect.Save())
                {
                    return(Msg.GetMsg(GetCtx(), "NotSubscribed"));
                }
                lead.SetR_InterestArea_ID(Prospect.GetR_InterestArea_ID());
                if (lead.Save())
                {
                }
                return(Msg.GetMsg(GetCtx(), "SubscribedDone"));
            }
            else
            {
                VAdvantage.Model.X_vss_lead_interestarea Ilead = new VAdvantage.Model.X_vss_lead_interestarea(GetCtx(), 0, Get_Trx());
                Ilead.SetC_Lead_ID(lead.GetC_Lead_ID());
                Ilead.SetR_InterestArea_ID(R_InterestArea_ID);
                Ilead.SetAD_User_ID(lead.GetAD_User_ID());
                Ilead.SetBPName(lead.GetBPName());
                Ilead.SetEMail(lead.GetEMail());
                Ilead.SetPhone(lead.GetPhone());
                Ilead.SetFax(lead.GetFax());
                Ilead.SetAddress1(lead.GetAddress1());
                Ilead.SetAddress2(lead.GetAddress2());
                Ilead.SetC_City_ID(lead.GetC_City_ID());
                Ilead.SetCity(lead.GetCity());
                Ilead.SetC_Region_ID(lead.GetC_Region_ID());
                Ilead.SetRegionName(lead.GetRegionName());
                Ilead.SetC_Country_ID(lead.GetC_Country_ID());
                Ilead.SetPostal(lead.GetPostal());
                Ilead.SetSubscribeDate(DateTime.Today);
                if (!Ilead.Save())
                {
                    return(Msg.GetMsg(GetCtx(), "NotSubscribed"));
                }
                lead.SetR_InterestArea_ID(Ilead.GetR_InterestArea_ID());
                if (lead.Save())
                {
                }
                return(Msg.GetMsg(GetCtx(), "SubscribedDone"));
            }
        }
Beispiel #4
0
        protected override String DoIt()
        {
            string      query  = "Select C_CampaignTargetList_id from C_CampaignTargetList where C_Campaign_id=" + GetRecord_ID() + " and ad_client_id = " + GetCtx().GetAD_Client_ID();
            IDataReader MainDr = DB.ExecuteReader(query, null, Get_Trx());
            IDataReader dr     = null;

            try
            {
                query = "Delete From C_InviteeList  where C_Campaign_id=" + GetRecord_ID();
                int value = DB.ExecuteQuery(query);

                while (MainDr.Read())
                {
                    query = "Delete From C_InviteeList where   ";

                    int id = Util.GetValueOfInt(MainDr[0]);
                    VAdvantage.Model.X_C_CampaignTargetList MCapTarget = new VAdvantage.Model.X_C_CampaignTargetList(GetCtx(), id, null);

                    if (MCapTarget.GetC_MasterTargetList_ID() != 0)
                    {
                        query = "Select C_BPartner_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and C_BPartner_ID is not null";
                        dr    = DB.ExecuteReader(query, null, Get_Trx());
                        while (dr.Read())
                        {
                            invitee(Util.GetValueOfInt(dr[0]));
                        }
                        dr.Close();

                        query = "Select Ref_BPartner_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and Ref_BPartner_ID is not null";
                        dr    = DB.ExecuteReader(query, null, Get_Trx());
                        while (dr.Read())
                        {
                            invitee(Util.GetValueOfInt(dr[0]));
                        }
                        dr.Close();

                        query = "Select C_Lead_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and C_Lead_ID is not null";
                        dr    = DB.ExecuteReader(query, null, Get_Trx());
                        while (dr.Read())
                        {
                            string sql    = "Select C_InviteeList_id from C_InviteeList where C_Lead_id=" + Util.GetValueOfInt(dr[0]);
                            object Leadid = DB.ExecuteScalar(sql, null, Get_Trx());
                            if (Util.GetValueOfInt(Leadid) == 0)
                            {
                                VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), Get_Trx());
                                if (lead.GetC_BPartner_ID() != 0)
                                {
                                    invitee(lead.GetC_BPartner_ID());
                                }
                                else if (lead.GetRef_BPartner_ID() != 0)
                                {
                                    invitee(lead.GetRef_BPartner_ID());
                                }

                                else if (lead.GetContactName() != null)
                                {
                                    VAdvantage.Model.X_C_InviteeList Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), 0, Get_Trx());
                                    //Invt.SetC_TargetList_ID(Util.GetValueOfInt(dr[0]));
                                    Invt.SetC_Campaign_ID(GetRecord_ID());

                                    Invt.SetName(lead.GetContactName());
                                    Invt.SetEMail(lead.GetEMail());
                                    Invt.SetPhone(lead.GetPhone());
                                    Invt.SetC_Lead_ID(lead.GetC_Lead_ID());
                                    Invt.SetAddress1(lead.GetAddress1());
                                    Invt.SetAddress1(lead.GetAddress2());
                                    Invt.SetC_City_ID(lead.GetC_City_ID());
                                    Invt.SetCity(lead.GetCity());
                                    Invt.SetC_Region_ID(lead.GetC_Region_ID());
                                    Invt.SetRegionName(lead.GetRegionName());
                                    Invt.SetC_Country_ID(lead.GetC_Country_ID());
                                    Invt.SetPostal(lead.GetPostal());
                                    // Invt.SetURL(url);
                                    if (!Invt.Save())
                                    {
                                        Msg.GetMsg(GetCtx(), "InviteeCteationNotDone");
                                    }

                                    string ID       = Invt.GetC_InviteeList_ID().ToString();
                                    string encrypt  = FormsAuthentication.HashPasswordForStoringInConfigFile(ID, "SHA1");
                                    string urlFinal = "";
                                    urlFinal = url + "?" + encrypt;
                                    sql      = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID();
                                    int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx()));

                                    //Random rand = new Random();
                                    //String s = "";
                                    //for (int i = 0; i < 9; i++)
                                    //    s = String.Concat(s, rand.Next(10).ToString());
                                    //string urlFinal = "";
                                    //// urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString();
                                    //urlFinal = url + "?" + s;
                                    ////string urlFinal = "";
                                    ////urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString();
                                    //Invt.SetURL(urlFinal);
                                    //if (!Invt.Save(Get_Trx()))
                                    //{
                                    //    Msg.GetMsg(GetCtx(), "InviteeCteationNotDone");
                                    //}
                                }
                            }
                        }
                        dr.Close();
                    }

                    if (MCapTarget.GetR_InterestArea_ID() != 0)
                    {
                        query = "Select C_BPartner_ID from R_ContactInterest where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID() + " and C_BPartner_ID is not null";
                        dr    = DB.ExecuteReader(query, null, Get_Trx());
                        while (dr.Read())
                        {
                            invitee(Util.GetValueOfInt(dr[0]));
                        }
                        dr.Close();

                        //query = "Select C_BPartner_ID from C_TargetList where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID();
                        //dr = DB.ExecuteReader(query);
                        //while (dr.Read())
                        //{
                        //    invitee(Util.GetValueOfInt(dr[0]));

                        //}
                        //dr.Close();

                        query = "Select C_Lead_ID from vss_lead_interestarea where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID() + " and C_Lead_ID is not null";
                        dr    = DB.ExecuteReader(query, null, Get_Trx());
                        while (dr.Read())
                        {
                            string sql    = "Select C_InviteeList_id from C_InviteeList where C_Lead_id=" + Util.GetValueOfInt(dr[0]);
                            object Leadid = DB.ExecuteScalar(sql, null, Get_Trx());
                            if (Util.GetValueOfInt(Leadid) == 0)
                            {
                                VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), Get_Trx());
                                if (lead.GetC_BPartner_ID() != 0)
                                {
                                    invitee(lead.GetC_BPartner_ID());
                                }
                                else if (lead.GetRef_BPartner_ID() != 0)
                                {
                                    invitee(lead.GetRef_BPartner_ID());
                                }

                                else if (lead.GetContactName() != null)
                                {
                                    VAdvantage.Model.X_C_InviteeList Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), 0, Get_Trx());
                                    //Invt.SetC_TargetList_ID(Util.GetValueOfInt(dr[0]));
                                    Invt.SetC_Campaign_ID(GetRecord_ID());
                                    Invt.SetName(lead.GetContactName());
                                    Invt.SetEMail(lead.GetEMail());
                                    Invt.SetPhone(lead.GetPhone());
                                    Invt.SetC_Lead_ID(lead.GetC_Lead_ID());
                                    Invt.SetAddress1(lead.GetAddress1());
                                    Invt.SetAddress1(lead.GetAddress2());
                                    Invt.SetC_City_ID(lead.GetC_City_ID());
                                    Invt.SetCity(lead.GetCity());
                                    Invt.SetC_Region_ID(lead.GetC_Region_ID());
                                    Invt.SetRegionName(lead.GetRegionName());
                                    Invt.SetC_Country_ID(lead.GetC_Country_ID());
                                    Invt.SetPostal(lead.GetPostal());
                                    //Invt.SetURL(url);
                                    if (!Invt.Save(Get_Trx()))
                                    {
                                        Msg.GetMsg(GetCtx(), "InviteeCteationNotDone");
                                    }

                                    string ID       = Invt.GetC_InviteeList_ID().ToString();
                                    string encrypt  = FormsAuthentication.HashPasswordForStoringInConfigFile(ID, "SHA1");
                                    string urlFinal = "";
                                    urlFinal = url + "?" + encrypt;
                                    sql      = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID();
                                    int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx()));


                                    //Random rand = new Random();
                                    //String s = "";
                                    //for (int i = 0; i < 9; i++)
                                    //    s = String.Concat(s, rand.Next(10).ToString());
                                    //string urlFinal = "";
                                    //urlFinal = url + "?" + s;
                                    ////string urlFinal = "";
                                    ////urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString();
                                    //Invt.SetURL(urlFinal);
                                    //if (!Invt.Save(Get_Trx()))
                                    //{
                                    //    Msg.GetMsg(GetCtx(), "InviteeCteationNotDone");
                                    //}
                                }
                            }
                        }
                        dr.Close();
                    }
                }
                MainDr.Close();
            }
            catch
            {
                if (MainDr != null)
                {
                    MainDr.Close();
                    MainDr = null;
                }
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
            }
            return(Msg.GetMsg(GetCtx(), "InviteeCteationDone"));
        }
Beispiel #5
0
        protected override String DoIt()
        {
            VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName());
            //  lead.GetRef_BPartner_ID()))
            int ExCustomer = lead.GetC_BPartner_ID();
            int Pospect    = lead.GetRef_BPartner_ID();



            if (ExCustomer != 0)
            {
                VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                opp.SetC_BPartner_ID(lead.GetC_BPartner_ID());
                opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                opp.SetDateContract(DateTime.Today);
                opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                //opp.SetR_Source_ID (lead.GetR_Source_ID());
                // opp.SetOpportunityStatus("N");
                opp.SetAD_User_ID(lead.GetAD_User_ID());
                VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName());
                //VAdvantage.Model.X_C_BPartner_Location loc=new VAdvantage.Model.X_C_BPartner_Location (GetCtx(),ExCustomer,Get_TrxName());

                opp.SetName(bp.GetName());;
                opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                opp.SetIsOpportunity(true);

                if (opp.Save())
                {
                    lead.SetC_Project_ID(opp.GetC_Project_ID());
                    lead.Save();
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"));
                }
                else
                {
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"));
                }
            }
            if (Pospect != 0)
            {
                VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID());
                opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                opp.SetDateContract(DateTime.Today);
                opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                // opp.SetR_Source_ID (lead.GetR_Source_ID());
                //opp.SetOpportunityStatus ("N");
                // opp.SetAD_Client_ID(GetAD_Client_ID());
                opp.SetAD_User_ID(lead.GetAD_User_ID());
                VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName());
                //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName());

                opp.SetName(bp.GetName());
                opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                opp.SetIsOpportunity(true);

                if (opp.Save())
                {
                    lead.SetC_Project_ID(opp.GetC_Project_ID());
                    lead.Save();
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"));
                }
                else
                {
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"));
                }
            }
            if (ExCustomer == 0 && Pospect == 0)
            {
                //CallProcess(_C_Lead_ID);
                if (lead.GetBPName() == null)
                {
                    return(Msg.GetMsg(GetCtx(), "Company Name, Prospect or Bpartner is Mandatory to fill"));
                }
                callprospect();
                return(DoIt());
            }

            return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"));
        }
        protected override String DoIt()
        {
            VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName());
            //  lead.GetRef_BPartner_ID()))
            int ExCustomer = lead.GetC_BPartner_ID();
            int Pospect    = lead.GetRef_BPartner_ID();



            if (ExCustomer != 0)
            {
                VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                opp.SetAD_Client_ID(lead.GetAD_Client_ID());
                opp.SetAD_Org_ID(lead.GetAD_Org_ID());
                opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                opp.SetC_BPartner_ID(lead.GetC_BPartner_ID());

                // Addde by Bharat on 19 Feb 2018 to set Ref Partner/Prospect
                if (opp.Get_ColumnIndex("Ref_BPartner_ID") > 0)
                {
                    opp.SetRef_BPartner_ID(lead.GetC_BPartner_ID());
                }
                opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                opp.SetDateContract(DateTime.Today);
                opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                //opp.SetR_Source_ID (lead.GetR_Source_ID());
                // opp.SetOpportunityStatus("N");
                opp.SetAD_User_ID(lead.GetAD_User_ID());
                VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName());
                //VAdvantage.Model.X_C_BPartner_Location loc=new VAdvantage.Model.X_C_BPartner_Location (GetCtx(),ExCustomer,Get_TrxName());

                opp.SetName(bp.GetName());;
                opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                opp.SetIsOpportunity(true);
                /*Vivek*/
                opp.SetC_EnquiryRdate(lead.GetC_EnquiryRdate());
                if (lead.GetC_ProposalDdate() != null)
                {
                    opp.SetC_ProposalDdate(Convert.ToDateTime(lead.GetC_ProposalDdate()).ToLocalTime());
                }
                else
                {
                    opp.SetC_ProposalDdate(lead.GetC_ProposalDdate());
                }
                if (opp.Save())
                {
                    lead.SetC_Project_ID(opp.GetC_Project_ID());
                    lead.Save();
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"));
                }
                else
                {
                    return(GetRetrievedError(opp, "OpprtunityGenerateNotDone"));
                    //return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone");
                }
            }
            if (Pospect != 0)
            {
                VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                opp.SetAD_Client_ID(lead.GetAD_Client_ID());
                opp.SetAD_Org_ID(lead.GetAD_Org_ID());
                opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID());
                // Addde by Bharat on 19 Feb 2018 to set Ref Partner/Prospect
                if (opp.Get_ColumnIndex("Ref_BPartner_ID") > 0)
                {
                    opp.SetRef_BPartner_ID(lead.GetRef_BPartner_ID());
                }
                opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                opp.SetDateContract(DateTime.Today);
                opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                // opp.SetR_Source_ID (lead.GetR_Source_ID());
                //opp.SetOpportunityStatus ("N");
                // opp.SetAD_Client_ID(GetAD_Client_ID());
                opp.SetAD_User_ID(lead.GetAD_User_ID());
                VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName());
                //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName());

                opp.SetName(bp.GetName());
                opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                opp.SetIsOpportunity(true);
                /*Vivek*/
                opp.SetC_EnquiryRdate(lead.GetC_EnquiryRdate());
                if (lead.GetC_ProposalDdate() != null)
                {
                    opp.SetC_ProposalDdate(Convert.ToDateTime(lead.GetC_ProposalDdate()).ToLocalTime());
                }
                else
                {
                    opp.SetC_ProposalDdate(lead.GetC_ProposalDdate());
                }
                if (opp.Save())
                {
                    lead.SetC_Project_ID(opp.GetC_Project_ID());
                    lead.Save();
                    return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"));
                }
                else
                {
                    return(GetRetrievedError(opp, "OpprtunityGenerateNotDone"));
                    //return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone");
                }
            }
            if (ExCustomer == 0 && Pospect == 0)
            {
                //CallProcess(_C_Lead_ID);
                if (lead.GetBPName() == null)
                {
                    return(Msg.GetMsg(GetCtx(), "Company Name, Prospect or Bpartner is Mandatory to fill"));
                }
                callprospect();
                return(DoIt());
            }

            return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"));
        }
Beispiel #7
0
        protected override string DoIt()
        {
            VAdvantage.Model.X_C_BPartner partner = new VAdvantage.Model.X_C_BPartner(GetCtx(), GetRecord_ID(), null);

            string _BPName = partner.GetName();

            string  _sql = "Select C_Lead_ID From C_Lead Where BPName='" + _BPName + "'  AND IsActive = 'Y' AND AD_Client_ID = " + GetAD_Client_ID();
            DataSet ds   = new DataSet();

            ds = DB.ExecuteDataset(_sql.ToString());
            if (ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    _C_Lead_ID = Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Lead_ID"]);
                    VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_TrxName());
                    //  lead.GetRef_BPartner_ID()))
                    //int ExCustomer = lead.GetC_BPartner_ID();
                    int Pospect = lead.GetRef_BPartner_ID();


                    if (Pospect != 0)
                    {
                        VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                        opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                        opp.SetC_BPartnerSR_ID(lead.GetRef_BPartner_ID());
                        opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                        opp.SetDateContract(DateTime.Today);
                        opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                        // opp.SetR_Source_ID (lead.GetR_Source_ID());
                        //opp.SetOpportunityStatus ("N");
                        // opp.SetAD_Client_ID(GetAD_Client_ID());
                        opp.SetAD_User_ID(lead.GetAD_User_ID());
                        VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), Pospect, Get_TrxName());
                        //X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Pospect, Get_TrxName());

                        opp.SetName(bp.GetName());
                        opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                        opp.SetIsOpportunity(true);


                        if (opp.Save())
                        {
                            lead.SetC_Project_ID(opp.GetC_Project_ID());
                            lead.Save();

                            bp.SetCreateProject("Y");
                            if (bp.Save())
                            {
                            }

                            return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone"));
                        }
                        else
                        {
                            return(Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone"));
                        }
                    }
                    //if (ExCustomer != 0)
                    //{
                    //    VAdvantage.Model.X_C_Project opp = new VAdvantage.Model.X_C_Project(GetCtx(), 0, Get_TrxName());
                    //    opp.SetC_Lead_ID(lead.GetC_Lead_ID());
                    //    opp.SetC_BPartner_ID(lead.GetC_BPartner_ID());
                    //    opp.SetSalesRep_ID(lead.GetSalesRep_ID());
                    //    opp.SetDateContract(DateTime.Today);
                    //    opp.SetC_Campaign_ID(lead.GetC_Campaign_ID());
                    //    opp.SetR_Source_ID(lead.GetR_Source_ID());
                    //    opp.SetOpportunityStatus("N");
                    //    opp.SetAD_User_ID(lead.GetAD_User_ID());
                    //    VAdvantage.Model.X_C_BPartner bp = new VAdvantage.Model.X_C_BPartner(GetCtx(), ExCustomer, Get_TrxName());
                    //    VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), ExCustomer, Get_TrxName());

                    //    opp.SetName(bp.GetName()); ;
                    //    opp.SetC_BPartner_Location_ID(lead.GetC_BPartner_Location_ID());
                    //    opp.SetIsOpportunity(true);

                    //    if (opp.Save())
                    //    {
                    //        lead.SetC_Project_ID(opp.GetC_Project_ID());
                    //        lead.Save();
                    //        return Msg.GetMsg(GetCtx(), "OpprtunityGenerateDone");

                    //    }
                    //    else
                    //    {
                    //        return Msg.GetMsg(GetCtx(), "OpprtunityGenerateNotDone");

                    //    }
                    //}
                }
            }
            return("");
        }